nginx.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package models
  2. import "github.com/astaxie/beego"
  3. // Nginx nginx data
  4. type Nginx struct {
  5. Id int `orm:"pk;auto" json:"id"`
  6. Name string `json:"name"`
  7. Uid string `json:"uid"`
  8. VersionInfo string `json:"versionInfo"`
  9. // 是否以服务的形式进行托管
  10. IsServer bool `json:"isServer"`
  11. NginxPath string `json:"nginxPath"`
  12. // nginx的配置文件所在目录,即nginx.conf所在的目录
  13. NginxDir string `json:"nginxDir"`
  14. // 数据目录,所有的配置文件目录
  15. DataDir string `json:"dataDir"`
  16. IsLocal bool `json:"isLocal"`
  17. IpAddr string `json:"ipAddr"`
  18. Port int `json:"port"`
  19. User string `json:"user"`
  20. Password string `json:"password"`
  21. HttpData string `json:"httpData"`
  22. HttpConf string `json:"httpConf"`
  23. Remark string `json:"remark"`
  24. }
  25. // Check 检查参数,给默认值
  26. func (t *Nginx) Check() {
  27. if t.DataDir == "" {
  28. t.DataDir = beego.AppConfig.String("datadir")
  29. }
  30. if t.NginxPath == "" {
  31. t.NginxPath = beego.AppConfig.String("nginxPath")
  32. }
  33. if t.NginxDir == "" {
  34. t.NginxDir = beego.AppConfig.String("nginxDir")
  35. }
  36. }
  37. // ServerHost nginx data
  38. type ServerHost struct {
  39. Id int `orm:"pk;auto" json:"id"`
  40. Enable bool `json:"enable"`
  41. // is tcp or udp, default is false
  42. IsStream bool `json:"isStream"`
  43. NginxId int `json:"nginxId"`
  44. Name string `json:"name"`
  45. // 记录一下上一次刷新保存的名字
  46. LastName string `json:"lastName"`
  47. // 前端完整的 server_host配置数据
  48. ServerData string `json:"serverData"`
  49. // nginx server.conf content
  50. ServerConf string `json:"serverConf"`
  51. Remark string `json:"remark"`
  52. }
  53. // NginxCerts nginx证书, ServiceName域名,唯一不可重复
  54. type NginxCerts struct {
  55. Id int `orm:"pk;auto" json:"id"`
  56. ServiceName string `orm:"unique" json:"serviceName"`
  57. Key string `json:"key"`
  58. Pem string `json:"pem"`
  59. NginxId int `json:"nginxId"`
  60. ExpiresAt string `json:"expiresAt"`
  61. SubjectName string `json:"subjectName"`
  62. // 系统的提示信息
  63. HintMsg string `json:"hintMsg"`
  64. CreatedAt string `json:"createdAt"`
  65. Remark string `json:"remark"`
  66. }