diff --git a/.dockerignore b/.dockerignore index ff05a67c..8d6e49cd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ .git -frontend/node_modules +app/node_modules .idea tmp diff --git a/server/api/analytic.go b/api/analytic.go similarity index 85% rename from server/api/analytic.go rename to api/analytic.go index 6b38c513..11af1b0b 100644 --- a/server/api/analytic.go +++ b/api/analytic.go @@ -2,8 +2,8 @@ package api import ( "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/analytic" - "github.com/0xJacky/Nginx-UI/server/internal/logger" + analytic2 "github.com/0xJacky/Nginx-UI/internal/analytic" + "github.com/0xJacky/Nginx-UI/internal/logger" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/load" @@ -28,8 +28,8 @@ type Stat struct { Uptime uint64 `json:"uptime"` LoadAvg *load.AvgStat `json:"loadavg"` CPU CPUStat `json:"cpu"` - Memory analytic.MemStat `json:"memory"` - Disk analytic.DiskStat `json:"disk"` + Memory analytic2.MemStat `json:"memory"` + Disk analytic2.DiskStat `json:"disk"` Network net.IOCountersStat `json:"network"` } @@ -51,7 +51,7 @@ func Analytic(c *gin.Context) { var stat Stat for { - stat.Memory, err = analytic.GetMemoryStat() + stat.Memory, err = analytic2.GetMemoryStat() if err != nil { logger.Error(err) @@ -76,7 +76,7 @@ func Analytic(c *gin.Context) { stat.LoadAvg, _ = load.Avg() - stat.Disk, err = analytic.GetDiskStat() + stat.Disk, err = analytic2.GetDiskStat() if err != nil { logger.Error(err) @@ -105,14 +105,14 @@ func Analytic(c *gin.Context) { func GetAnalyticInit(c *gin.Context) { cpuInfo, _ := cpu.Info() network, _ := net.IOCounters(false) - memory, err := analytic.GetMemoryStat() + memory, err := analytic2.GetMemoryStat() if err != nil { logger.Error(err) return } - diskStat, err := analytic.GetDiskStat() + diskStat, err := analytic2.GetDiskStat() if err != nil { logger.Error(err) @@ -138,17 +138,17 @@ func GetAnalyticInit(c *gin.Context) { "host": hostInfo, "cpu": gin.H{ "info": cpuInfo, - "user": analytic.CpuUserRecord, - "total": analytic.CpuTotalRecord, + "user": analytic2.CpuUserRecord, + "total": analytic2.CpuTotalRecord, }, "network": gin.H{ "init": _net, - "bytesRecv": analytic.NetRecvRecord, - "bytesSent": analytic.NetSentRecord, + "bytesRecv": analytic2.NetRecvRecord, + "bytesSent": analytic2.NetSentRecord, }, "disk_io": gin.H{ - "writes": analytic.DiskWriteRecord, - "reads": analytic.DiskReadRecord, + "writes": analytic2.DiskWriteRecord, + "reads": analytic2.DiskReadRecord, }, "memory": memory, "disk": diskStat, @@ -173,7 +173,7 @@ func GetNodeStat(c *gin.Context) { for { // write - err = ws.WriteJSON(analytic.GetNodeStat()) + err = ws.WriteJSON(analytic2.GetNodeStat()) if err != nil || websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseNoStatusReceived, @@ -203,7 +203,7 @@ func GetNodesAnalytic(c *gin.Context) { for { // write - err = ws.WriteJSON(analytic.NodeMap) + err = ws.WriteJSON(analytic2.NodeMap) if err != nil || websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseNoStatusReceived, diff --git a/server/api/api.go b/api/api.go similarity index 95% rename from server/api/api.go rename to api/api.go index 62026616..e730d8d9 100644 --- a/server/api/api.go +++ b/api/api.go @@ -1,7 +1,7 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/logger" "github.com/gin-gonic/gin" val "github.com/go-playground/validator/v10" "net/http" diff --git a/server/api/auth.go b/api/auth.go similarity index 97% rename from server/api/auth.go rename to api/auth.go index babe4ae9..ecf63ed1 100644 --- a/server/api/auth.go +++ b/api/auth.go @@ -2,10 +2,10 @@ package api import ( "fmt" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/settings" "net/http" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/settings" "github.com/casdoor/casdoor-go-sdk/casdoorsdk" "github.com/gin-gonic/gin" "github.com/pkg/errors" diff --git a/server/api/backup.go b/api/backup.go similarity index 90% rename from server/api/backup.go rename to api/backup.go index f27c1bde..0081649e 100644 --- a/server/api/backup.go +++ b/api/backup.go @@ -1,7 +1,7 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/model" + "github.com/0xJacky/Nginx-UI/model" "github.com/gin-gonic/gin" "github.com/unknwon/com" "net/http" diff --git a/server/api/cert.go b/api/cert.go similarity index 94% rename from server/api/cert.go rename to api/cert.go index fedc6d54..8c11c653 100644 --- a/server/api/cert.go +++ b/api/cert.go @@ -1,11 +1,11 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/cert" - "github.com/0xJacky/Nginx-UI/server/internal/cert/dns" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/model" + cert2 "github.com/0xJacky/Nginx-UI/internal/cert" + "github.com/0xJacky/Nginx-UI/internal/cert/dns" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/model" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "github.com/spf13/cast" @@ -69,7 +69,7 @@ func IssueCert(c *gin.Context) { }(ws) // read - buffer := &cert.ConfigPayload{} + buffer := &cert2.ConfigPayload{} err = ws.ReadJSON(buffer) @@ -88,13 +88,13 @@ func IssueCert(c *gin.Context) { logChan := make(chan string, 1) errChan := make(chan error, 1) - go cert.IssueCert(buffer, logChan, errChan) + go cert2.IssueCert(buffer, logChan, errChan) go handleIssueCertLogChan(ws, logChan) // block, until errChan closes for err = range errChan { - errLog := &cert.AutoCertErrorLog{} + errLog := &cert2.AutoCertErrorLog{} errLog.SetCertModel(&certModel) errLog.Exit("issue cert", err) @@ -169,7 +169,7 @@ func getCert(c *gin.Context, certModel *model.Cert) { sslCertificationBytes, _ = os.ReadFile(certModel.SSLCertificatePath) } - pubKey, err := cert.GetCertInfo(certModel.SSLCertificatePath) + pubKey, err := cert2.GetCertInfo(certModel.SSLCertificatePath) if err != nil { ErrHandler(c, err) diff --git a/server/api/config.go b/api/config.go similarity index 85% rename from server/api/config.go rename to api/config.go index 883be8c2..4960eff6 100644 --- a/server/api/config.go +++ b/api/config.go @@ -1,10 +1,10 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/config_list" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/query" + "github.com/0xJacky/Nginx-UI/internal/config_list" + "github.com/0xJacky/Nginx-UI/internal/logger" + nginx2 "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/query" "github.com/gin-gonic/gin" "github.com/sashabaranov/go-openai" "net/http" @@ -22,7 +22,7 @@ func GetConfigs(c *gin.Context) { "is_dir": "bool", } - configFiles, err := os.ReadDir(nginx.GetConfPath(dir)) + configFiles, err := os.ReadDir(nginx2.GetConfPath(dir)) if err != nil { ErrHandler(c, err) @@ -42,7 +42,7 @@ func GetConfigs(c *gin.Context) { } case mode&os.ModeSymlink != 0: // is a symbol var targetPath string - targetPath, err = os.Readlink(nginx.GetConfPath(file.Name())) + targetPath, err = os.Readlink(nginx2.GetConfPath(file.Name())) if err != nil { logger.Error("Read Symlink Error", targetPath, err) continue @@ -77,7 +77,7 @@ func GetConfigs(c *gin.Context) { func GetConfig(c *gin.Context) { name := c.Param("name") - path := nginx.GetConfPath("/", name) + path := nginx2.GetConfPath("/", name) stat, err := os.Stat(path) @@ -130,7 +130,7 @@ func AddConfig(c *gin.Context) { name := request.Name content := request.Content - path := nginx.GetConfPath("/", name) + path := nginx2.GetConfPath("/", name) if _, err = os.Stat(path); err == nil { c.JSON(http.StatusNotAcceptable, gin.H{ @@ -147,8 +147,8 @@ func AddConfig(c *gin.Context) { } } - output := nginx.Reload() - if nginx.GetLogLevel(output) >= nginx.Warn { + output := nginx2.Reload() + if nginx2.GetLogLevel(output) >= nginx2.Warn { c.JSON(http.StatusInternalServerError, gin.H{ "message": output, }) @@ -174,7 +174,7 @@ func EditConfig(c *gin.Context) { ErrHandler(c, err) return } - path := nginx.GetConfPath("/", name) + path := nginx2.GetConfPath("/", name) content := request.Content origContent, err := os.ReadFile(path) @@ -192,9 +192,9 @@ func EditConfig(c *gin.Context) { } } - output := nginx.Reload() + output := nginx2.Reload() - if nginx.GetLogLevel(output) >= nginx.Warn { + if nginx2.GetLogLevel(output) >= nginx2.Warn { c.JSON(http.StatusInternalServerError, gin.H{ "message": output, }) diff --git a/api/dns_credential.go b/api/dns_credential.go new file mode 100644 index 00000000..24599de3 --- /dev/null +++ b/api/dns_credential.go @@ -0,0 +1,130 @@ +package api + +import ( + "github.com/0xJacky/Nginx-UI/internal/cert/dns" + model2 "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" + "github.com/gin-gonic/gin" + "github.com/spf13/cast" + "net/http" +) + +func GetDnsCredential(c *gin.Context) { + id := cast.ToInt(c.Param("id")) + + d := query.DnsCredential + + dnsCredential, err := d.FirstByID(id) + if err != nil { + ErrHandler(c, err) + return + } + type apiDnsCredential struct { + model2.Model + Name string `json:"name"` + dns.Config + } + c.JSON(http.StatusOK, apiDnsCredential{ + Model: dnsCredential.Model, + Name: dnsCredential.Name, + Config: *dnsCredential.Config, + }) +} + +func GetDnsCredentialList(c *gin.Context) { + d := query.DnsCredential + provider := c.Query("provider") + var data []*model2.DnsCredential + var err error + if provider != "" { + data, err = d.Where(d.Provider.Eq(provider)).Find() + } else { + data, err = d.Find() + } + + if err != nil { + ErrHandler(c, err) + return + } + c.JSON(http.StatusOK, gin.H{ + "data": data, + }) +} + +type DnsCredentialManageJson struct { + Name string `json:"name" binding:"required"` + Provider string `json:"provider"` + dns.Config +} + +func AddDnsCredential(c *gin.Context) { + var json DnsCredentialManageJson + if !BindAndValid(c, &json) { + return + } + + json.Config.Name = json.Provider + dnsCredential := model2.DnsCredential{ + Name: json.Name, + Config: &json.Config, + Provider: json.Provider, + } + + d := query.DnsCredential + + err := d.Create(&dnsCredential) + if err != nil { + ErrHandler(c, err) + return + } + + c.JSON(http.StatusOK, dnsCredential) +} + +func EditDnsCredential(c *gin.Context) { + id := cast.ToInt(c.Param("id")) + + var json DnsCredentialManageJson + if !BindAndValid(c, &json) { + return + } + + d := query.DnsCredential + + dnsCredential, err := d.FirstByID(id) + if err != nil { + ErrHandler(c, err) + return + } + + json.Config.Name = json.Provider + _, err = d.Where(d.ID.Eq(dnsCredential.ID)).Updates(&model2.DnsCredential{ + Name: json.Name, + Config: &json.Config, + Provider: json.Provider, + }) + + if err != nil { + ErrHandler(c, err) + return + } + + GetDnsCredential(c) +} + +func DeleteDnsCredential(c *gin.Context) { + id := cast.ToInt(c.Param("id")) + d := query.DnsCredential + + dnsCredential, err := d.FirstByID(id) + if err != nil { + ErrHandler(c, err) + return + } + err = d.DeleteByID(dnsCredential.ID) + if err != nil { + ErrHandler(c, err) + return + } + c.JSON(http.StatusNoContent, nil) +} diff --git a/server/api/domain.go b/api/domain.go similarity index 79% rename from server/api/domain.go rename to api/domain.go index 07da23c4..30f5e2f0 100644 --- a/server/api/domain.go +++ b/api/domain.go @@ -1,19 +1,19 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/cert" - "github.com/0xJacky/Nginx-UI/server/internal/config_list" - "github.com/0xJacky/Nginx-UI/server/internal/helper" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/gin-gonic/gin" - "github.com/sashabaranov/go-openai" - "net/http" - "os" - "strings" - "time" + "github.com/0xJacky/Nginx-UI/internal/cert" + "github.com/0xJacky/Nginx-UI/internal/config_list" + helper2 "github.com/0xJacky/Nginx-UI/internal/helper" + "github.com/0xJacky/Nginx-UI/internal/logger" + nginx2 "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" + "github.com/gin-gonic/gin" + "github.com/sashabaranov/go-openai" + "net/http" + "os" + "strings" + "time" ) func GetDomains(c *gin.Context) { @@ -27,14 +27,14 @@ func GetDomains(c *gin.Context) { "modify": "time", } - configFiles, err := os.ReadDir(nginx.GetConfPath("sites-available")) + configFiles, err := os.ReadDir(nginx2.GetConfPath("sites-available")) if err != nil { ErrHandler(c, err) return } - enabledConfig, err := os.ReadDir(nginx.GetConfPath("sites-enabled")) + enabledConfig, err := os.ReadDir(nginx2.GetConfPath("sites-enabled")) if err != nil { ErrHandler(c, err) @@ -88,7 +88,7 @@ func GetDomain(c *gin.Context) { name = rewriteName.(string) } - path := nginx.GetConfPath("sites-available", name) + path := nginx2.GetConfPath("sites-available", name) file, err := os.Stat(path) if os.IsNotExist(err) { c.JSON(http.StatusNotFound, gin.H{ @@ -99,7 +99,7 @@ func GetDomain(c *gin.Context) { enabled := true - if _, err := os.Stat(nginx.GetConfPath("sites-enabled", name)); os.IsNotExist(err) { + if _, err := os.Stat(nginx2.GetConfPath("sites-enabled", name)); os.IsNotExist(err) { enabled = false } @@ -149,7 +149,7 @@ func GetDomain(c *gin.Context) { } c.Set("maybe_error", "nginx_config_syntax_error") - config, err := nginx.ParseNgxConfig(path) + config, err := nginx2.ParseNgxConfig(path) if err != nil { ErrHandler(c, err) @@ -218,9 +218,9 @@ func SaveDomain(c *gin.Context) { return } - path := nginx.GetConfPath("sites-available", name) + path := nginx2.GetConfPath("sites-available", name) - if !json.Overwrite && helper.FileExists(path) { + if !json.Overwrite && helper2.FileExists(path) { c.JSON(http.StatusNotAcceptable, gin.H{ "message": "File exists", }) @@ -232,24 +232,24 @@ func SaveDomain(c *gin.Context) { ErrHandler(c, err) return } - enabledConfigFilePath := nginx.GetConfPath("sites-enabled", name) + enabledConfigFilePath := nginx2.GetConfPath("sites-enabled", name) // rename the config file if needed if name != json.Name { - newPath := nginx.GetConfPath("sites-available", json.Name) + newPath := nginx2.GetConfPath("sites-available", json.Name) s := query.Site _, err = s.Where(s.Path.Eq(path)).Update(s.Path, newPath) // check if dst file exists, do not rename - if helper.FileExists(newPath) { + if helper2.FileExists(newPath) { c.JSON(http.StatusNotAcceptable, gin.H{ "message": "File exists", }) return } // recreate soft link - if helper.FileExists(enabledConfigFilePath) { + if helper2.FileExists(enabledConfigFilePath) { _ = os.Remove(enabledConfigFilePath) - enabledConfigFilePath = nginx.GetConfPath("sites-enabled", json.Name) + enabledConfigFilePath = nginx2.GetConfPath("sites-enabled", json.Name) err = os.Symlink(newPath, enabledConfigFilePath) if err != nil { @@ -268,12 +268,12 @@ func SaveDomain(c *gin.Context) { c.Set("rewriteConfigFileName", name) } - enabledConfigFilePath = nginx.GetConfPath("sites-enabled", name) - if helper.FileExists(enabledConfigFilePath) { + enabledConfigFilePath = nginx2.GetConfPath("sites-enabled", name) + if helper2.FileExists(enabledConfigFilePath) { // Test nginx configuration - output := nginx.TestConf() + output := nginx2.TestConf() - if nginx.GetLogLevel(output) > nginx.Warn { + if nginx2.GetLogLevel(output) > nginx2.Warn { c.JSON(http.StatusInternalServerError, gin.H{ "message": output, "error": "nginx_config_syntax_error", @@ -281,9 +281,9 @@ func SaveDomain(c *gin.Context) { return } - output = nginx.Reload() + output = nginx2.Reload() - if nginx.GetLogLevel(output) > nginx.Warn { + if nginx2.GetLogLevel(output) > nginx2.Warn { c.JSON(http.StatusInternalServerError, gin.H{ "message": output, }) @@ -295,8 +295,8 @@ func SaveDomain(c *gin.Context) { } func EnableDomain(c *gin.Context) { - configFilePath := nginx.GetConfPath("sites-available", c.Param("name")) - enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name")) + configFilePath := nginx2.GetConfPath("sites-available", c.Param("name")) + enabledConfigFilePath := nginx2.GetConfPath("sites-enabled", c.Param("name")) _, err := os.Stat(configFilePath) @@ -315,9 +315,9 @@ func EnableDomain(c *gin.Context) { } // Test nginx config, if not pass then disable the site. - output := nginx.TestConf() + output := nginx2.TestConf() - if nginx.GetLogLevel(output) > nginx.Warn { + if nginx2.GetLogLevel(output) > nginx2.Warn { _ = os.Remove(enabledConfigFilePath) c.JSON(http.StatusInternalServerError, gin.H{ "message": output, @@ -325,9 +325,9 @@ func EnableDomain(c *gin.Context) { return } - output = nginx.Reload() + output = nginx2.Reload() - if nginx.GetLogLevel(output) > nginx.Warn { + if nginx2.GetLogLevel(output) > nginx2.Warn { c.JSON(http.StatusInternalServerError, gin.H{ "message": output, }) @@ -340,7 +340,7 @@ func EnableDomain(c *gin.Context) { } func DisableDomain(c *gin.Context) { - enabledConfigFilePath := nginx.GetConfPath("sites-enabled", c.Param("name")) + enabledConfigFilePath := nginx2.GetConfPath("sites-enabled", c.Param("name")) _, err := os.Stat(enabledConfigFilePath) @@ -364,9 +364,9 @@ func DisableDomain(c *gin.Context) { return } - output := nginx.Reload() + output := nginx2.Reload() - if nginx.GetLogLevel(output) > nginx.Warn { + if nginx2.GetLogLevel(output) > nginx2.Warn { c.JSON(http.StatusInternalServerError, gin.H{ "message": output, }) @@ -381,8 +381,8 @@ func DisableDomain(c *gin.Context) { func DeleteDomain(c *gin.Context) { var err error name := c.Param("name") - availablePath := nginx.GetConfPath("sites-available", name) - enabledPath := nginx.GetConfPath("sites-enabled", name) + availablePath := nginx2.GetConfPath("sites-available", name) + enabledPath := nginx2.GetConfPath("sites-enabled", name) if _, err = os.Stat(availablePath); os.IsNotExist(err) { c.JSON(http.StatusNotFound, gin.H{ @@ -418,7 +418,7 @@ func AddDomainToAutoCert(c *gin.Context) { name := c.Param("name") var json struct { - model.Cert + model.Cert Domains []string `json:"domains"` } @@ -480,17 +480,17 @@ func DuplicateSite(c *gin.Context) { return } - src := nginx.GetConfPath("sites-available", name) - dst := nginx.GetConfPath("sites-available", json.Name) + src := nginx2.GetConfPath("sites-available", name) + dst := nginx2.GetConfPath("sites-available", json.Name) - if helper.FileExists(dst) { + if helper2.FileExists(dst) { c.JSON(http.StatusNotAcceptable, gin.H{ "message": "File exists", }) return } - _, err := helper.CopyFile(src, dst) + _, err := helper2.CopyFile(src, dst) if err != nil { ErrHandler(c, err) @@ -512,7 +512,7 @@ func DomainEditByAdvancedMode(c *gin.Context) { } name := c.Param("name") - path := nginx.GetConfPath("sites-available", name) + path := nginx2.GetConfPath("sites-available", name) s := query.Site diff --git a/server/api/environment.go b/api/environment.go similarity index 92% rename from server/api/environment.go rename to api/environment.go index b46891c0..064e776f 100644 --- a/server/api/environment.go +++ b/api/environment.go @@ -1,10 +1,10 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/analytic" - "github.com/0xJacky/Nginx-UI/server/internal/environment" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" + "github.com/0xJacky/Nginx-UI/internal/analytic" + "github.com/0xJacky/Nginx-UI/internal/environment" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" "github.com/gin-gonic/gin" "github.com/spf13/cast" "net/http" diff --git a/server/api/install.go b/api/install.go similarity index 88% rename from server/api/install.go rename to api/install.go index 4de5a2a2..404382df 100644 --- a/server/api/install.go +++ b/api/install.go @@ -1,10 +1,10 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/boot" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/boot" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/google/uuid" "golang.org/x/crypto/bcrypt" diff --git a/server/api/nginx_log.go b/api/nginx_log.go similarity index 94% rename from server/api/nginx_log.go rename to api/nginx_log.go index 23ca6fd3..09cf6b31 100644 --- a/server/api/nginx_log.go +++ b/api/nginx_log.go @@ -2,10 +2,10 @@ package api import ( "encoding/json" - "github.com/0xJacky/Nginx-UI/server/internal/helper" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/helper" + "github.com/0xJacky/Nginx-UI/internal/logger" + nginx2 "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "github.com/hpcloud/tail" @@ -106,9 +106,9 @@ func GetNginxLogPage(c *gin.Context) { func getLogPath(control *controlStruct) (logPath string, err error) { switch control.Type { case "site": - var config *nginx.NgxConfig - path := nginx.GetConfPath("sites-available", control.ConfName) - config, err = nginx.ParseNgxConfig(path) + var config *nginx2.NgxConfig + path := nginx2.GetConfPath("sites-available", control.ConfName) + config, err = nginx2.ParseNgxConfig(path) if err != nil { err = errors.Wrap(err, "error parsing ngx config") return diff --git a/server/api/ngx.go b/api/ngx.go similarity index 72% rename from server/api/ngx.go rename to api/ngx.go index 3399ff84..b43eb2a9 100644 --- a/server/api/ngx.go +++ b/api/ngx.go @@ -1,14 +1,14 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/gin-gonic/gin" - "net/http" - "os" + nginx2 "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/gin-gonic/gin" + "net/http" + "os" ) func BuildNginxConfig(c *gin.Context) { - var ngxConf nginx.NgxConfig + var ngxConf nginx2.NgxConfig if !BindAndValid(c, &ngxConf) { return } @@ -28,7 +28,7 @@ func TokenizeNginxConfig(c *gin.Context) { } c.Set("maybe_error", "nginx_config_syntax_error") - ngxConfig := nginx.ParseNgxConfigByContent(json.Content) + ngxConfig := nginx2.ParseNgxConfigByContent(json.Content) c.JSON(http.StatusOK, ngxConfig) @@ -45,12 +45,12 @@ func FormatNginxConfig(c *gin.Context) { c.Set("maybe_error", "nginx_config_syntax_error") c.JSON(http.StatusOK, gin.H{ - "content": nginx.FmtCode(json.Content), + "content": nginx2.FmtCode(json.Content), }) } func NginxStatus(c *gin.Context) { - pidPath := nginx.GetNginxPIDPath() + pidPath := nginx2.GetNginxPIDPath() running := true if fileInfo, err := os.Stat(pidPath); err != nil || fileInfo.Size() == 0 { // fileInfo.Size() == 0 no process id @@ -63,25 +63,25 @@ func NginxStatus(c *gin.Context) { } func ReloadNginx(c *gin.Context) { - output := nginx.Reload() + output := nginx2.Reload() c.JSON(http.StatusOK, gin.H{ "message": output, - "level": nginx.GetLogLevel(output), + "level": nginx2.GetLogLevel(output), }) } func TestNginx(c *gin.Context) { - output := nginx.TestConf() + output := nginx2.TestConf() c.JSON(http.StatusOK, gin.H{ "message": output, - "level": nginx.GetLogLevel(output), + "level": nginx2.GetLogLevel(output), }) } func RestartNginx(c *gin.Context) { - output := nginx.Restart() + output := nginx2.Restart() c.JSON(http.StatusOK, gin.H{ "message": output, - "level": nginx.GetLogLevel(output), + "level": nginx2.GetLogLevel(output), }) } diff --git a/server/api/node.go b/api/node.go similarity index 75% rename from server/api/node.go rename to api/node.go index f32f0e9b..948837f5 100644 --- a/server/api/node.go +++ b/api/node.go @@ -1,8 +1,8 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/analytic" - "github.com/0xJacky/Nginx-UI/server/internal/upgrader" + analytic2 "github.com/0xJacky/Nginx-UI/internal/analytic" + "github.com/0xJacky/Nginx-UI/internal/upgrader" "github.com/dustin/go-humanize" "github.com/gin-gonic/gin" "github.com/shirou/gopsutil/v3/cpu" @@ -24,11 +24,11 @@ func GetCurrentNode(c *gin.Context) { return } cpuInfo, _ := cpu.Info() - memory, _ := analytic.GetMemoryStat() + memory, _ := analytic2.GetMemoryStat() ver, _ := upgrader.GetCurrentVersion() diskUsage, _ := disk.Usage(".") - nodeInfo := analytic.NodeInfo{ + nodeInfo := analytic2.NodeInfo{ NodeRuntimeInfo: runtimeInfo, CPUNum: len(cpuInfo), MemoryTotal: memory.Total, @@ -36,9 +36,9 @@ func GetCurrentNode(c *gin.Context) { Version: ver.Version, } - stat := analytic.GetNodeStat() + stat := analytic2.GetNodeStat() - c.JSON(http.StatusOK, analytic.Node{ + c.JSON(http.StatusOK, analytic2.Node{ NodeInfo: nodeInfo, NodeStat: stat, }) diff --git a/server/api/openai.go b/api/openai.go similarity index 96% rename from server/api/openai.go rename to api/openai.go index a1228d77..a7b16ea7 100644 --- a/server/api/openai.go +++ b/api/openai.go @@ -3,9 +3,9 @@ package api import ( "context" "fmt" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/pkg/errors" "github.com/sashabaranov/go-openai" diff --git a/server/api/pty.go b/api/pty.go similarity index 86% rename from server/api/pty.go rename to api/pty.go index e402cf17..e2227d0c 100644 --- a/server/api/pty.go +++ b/api/pty.go @@ -1,8 +1,8 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/pty" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/pty" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "net/http" diff --git a/server/api/settings.go b/api/settings.go similarity index 96% rename from server/api/settings.go rename to api/settings.go index 4dd89c7d..f972803f 100644 --- a/server/api/settings.go +++ b/api/settings.go @@ -2,7 +2,7 @@ package api import ( "fmt" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "net/http" "net/url" diff --git a/server/api/template.go b/api/template.go similarity index 93% rename from server/api/template.go rename to api/template.go index 38c1a5e8..c2f362c0 100644 --- a/server/api/template.go +++ b/api/template.go @@ -1,8 +1,8 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/internal/template" + "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/internal/template" "github.com/gin-gonic/gin" "net/http" ) diff --git a/server/api/translation.go b/api/translation.go similarity index 58% rename from server/api/translation.go rename to api/translation.go index 955b079c..b7373e64 100644 --- a/server/api/translation.go +++ b/api/translation.go @@ -1,9 +1,9 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/translation" - "github.com/gin-gonic/gin" - "net/http" + "github.com/0xJacky/Nginx-UI/internal/translation" + "github.com/gin-gonic/gin" + "net/http" ) func GetTranslation(c *gin.Context) { diff --git a/server/api/upgrade.go b/api/upgrade.go similarity index 94% rename from server/api/upgrade.go rename to api/upgrade.go index 0059b1da..f42f27e0 100644 --- a/server/api/upgrade.go +++ b/api/upgrade.go @@ -1,9 +1,9 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/upgrader" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/upgrader" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/gorilla/websocket" "net/http" diff --git a/server/api/user.go b/api/user.go similarity index 90% rename from server/api/user.go rename to api/user.go index 183d8150..3593b3b9 100644 --- a/server/api/user.go +++ b/api/user.go @@ -1,13 +1,13 @@ package api import ( - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/0xJacky/Nginx-UI/server/settings" - "github.com/gin-gonic/gin" - "github.com/spf13/cast" - "golang.org/x/crypto/bcrypt" - "net/http" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" + "github.com/0xJacky/Nginx-UI/settings" + "github.com/gin-gonic/gin" + "github.com/spf13/cast" + "golang.org/x/crypto/bcrypt" + "net/http" ) func GetUsers(c *gin.Context) { diff --git a/frontend/.env.development b/app/.env.development similarity index 100% rename from frontend/.env.development rename to app/.env.development diff --git a/frontend/.env.production b/app/.env.production similarity index 100% rename from frontend/.env.production rename to app/.env.production diff --git a/frontend/.gitignore b/app/.gitignore similarity index 68% rename from frontend/.gitignore rename to app/.gitignore index ab27e168..3744261d 100644 --- a/frontend/.gitignore +++ b/app/.gitignore @@ -10,27 +10,15 @@ lerna-debug.log* # deps node_modules dist -dist-ssr *.local -.yarn cache # Editor directories and files .vscode/* !.vscode/extensions.json -.idea .DS_Store *.suo *.ntvs* *.njsproj *.sln *.sw? - -# Yarn -.pnp.* -.yarn/* -!.yarn/patches -!.yarn/plugins -!.yarn/releases -!.yarn/sdks -!.yarn/versions diff --git a/frontend/.vscode/extensions.json b/app/.vscode/extensions.json similarity index 100% rename from frontend/.vscode/extensions.json rename to app/.vscode/extensions.json diff --git a/frontend/README.md b/app/README.md similarity index 100% rename from frontend/README.md rename to app/README.md diff --git a/frontend/frontend.go b/app/app.go similarity index 85% rename from frontend/frontend.go rename to app/app.go index ae0808ca..2bc0b3c1 100644 --- a/frontend/frontend.go +++ b/app/app.go @@ -1,4 +1,4 @@ -package frontend +package app import ( "embed" diff --git a/frontend/auto-imports.d.ts b/app/auto-imports.d.ts similarity index 100% rename from frontend/auto-imports.d.ts rename to app/auto-imports.d.ts diff --git a/frontend/components.d.ts b/app/components.d.ts similarity index 100% rename from frontend/components.d.ts rename to app/components.d.ts diff --git a/frontend/gettext.config.js b/app/gettext.config.js similarity index 100% rename from frontend/gettext.config.js rename to app/gettext.config.js diff --git a/frontend/i18n.json b/app/i18n.json similarity index 100% rename from frontend/i18n.json rename to app/i18n.json diff --git a/frontend/index.html b/app/index.html similarity index 100% rename from frontend/index.html rename to app/index.html diff --git a/frontend/package.json b/app/package.json similarity index 100% rename from frontend/package.json rename to app/package.json diff --git a/frontend/pnpm-lock.yaml b/app/pnpm-lock.yaml similarity index 100% rename from frontend/pnpm-lock.yaml rename to app/pnpm-lock.yaml diff --git a/frontend/public/favicon.ico b/app/public/favicon.ico similarity index 100% rename from frontend/public/favicon.ico rename to app/public/favicon.ico diff --git a/frontend/src/App.vue b/app/src/App.vue similarity index 100% rename from frontend/src/App.vue rename to app/src/App.vue diff --git a/frontend/src/api/analytic.ts b/app/src/api/analytic.ts similarity index 100% rename from frontend/src/api/analytic.ts rename to app/src/api/analytic.ts diff --git a/frontend/src/api/auth.ts b/app/src/api/auth.ts similarity index 100% rename from frontend/src/api/auth.ts rename to app/src/api/auth.ts diff --git a/frontend/src/api/auto_cert.ts b/app/src/api/auto_cert.ts similarity index 100% rename from frontend/src/api/auto_cert.ts rename to app/src/api/auto_cert.ts diff --git a/frontend/src/api/cert.ts b/app/src/api/cert.ts similarity index 100% rename from frontend/src/api/cert.ts rename to app/src/api/cert.ts diff --git a/frontend/src/api/config.ts b/app/src/api/config.ts similarity index 100% rename from frontend/src/api/config.ts rename to app/src/api/config.ts diff --git a/frontend/src/api/curd.ts b/app/src/api/curd.ts similarity index 100% rename from frontend/src/api/curd.ts rename to app/src/api/curd.ts diff --git a/frontend/src/api/dns_credential.ts b/app/src/api/dns_credential.ts similarity index 100% rename from frontend/src/api/dns_credential.ts rename to app/src/api/dns_credential.ts diff --git a/frontend/src/api/domain.ts b/app/src/api/domain.ts similarity index 100% rename from frontend/src/api/domain.ts rename to app/src/api/domain.ts diff --git a/frontend/src/api/environment.ts b/app/src/api/environment.ts similarity index 100% rename from frontend/src/api/environment.ts rename to app/src/api/environment.ts diff --git a/frontend/src/api/install.ts b/app/src/api/install.ts similarity index 100% rename from frontend/src/api/install.ts rename to app/src/api/install.ts diff --git a/frontend/src/api/nginx_log.ts b/app/src/api/nginx_log.ts similarity index 100% rename from frontend/src/api/nginx_log.ts rename to app/src/api/nginx_log.ts diff --git a/frontend/src/api/ngx.ts b/app/src/api/ngx.ts similarity index 100% rename from frontend/src/api/ngx.ts rename to app/src/api/ngx.ts diff --git a/frontend/src/api/openai.ts b/app/src/api/openai.ts similarity index 100% rename from frontend/src/api/openai.ts rename to app/src/api/openai.ts diff --git a/frontend/src/api/settings.ts b/app/src/api/settings.ts similarity index 100% rename from frontend/src/api/settings.ts rename to app/src/api/settings.ts diff --git a/frontend/src/api/template.ts b/app/src/api/template.ts similarity index 100% rename from frontend/src/api/template.ts rename to app/src/api/template.ts diff --git a/frontend/src/api/upgrade.ts b/app/src/api/upgrade.ts similarity index 100% rename from frontend/src/api/upgrade.ts rename to app/src/api/upgrade.ts diff --git a/frontend/src/api/user.ts b/app/src/api/user.ts similarity index 100% rename from frontend/src/api/user.ts rename to app/src/api/user.ts diff --git a/frontend/src/assets/img/logo.png b/app/src/assets/img/logo.png similarity index 100% rename from frontend/src/assets/img/logo.png rename to app/src/assets/img/logo.png diff --git a/frontend/src/assets/svg/ChatGPT_logo.svg b/app/src/assets/svg/ChatGPT_logo.svg similarity index 100% rename from frontend/src/assets/svg/ChatGPT_logo.svg rename to app/src/assets/svg/ChatGPT_logo.svg diff --git a/frontend/src/assets/svg/cpu.svg b/app/src/assets/svg/cpu.svg similarity index 100% rename from frontend/src/assets/svg/cpu.svg rename to app/src/assets/svg/cpu.svg diff --git a/frontend/src/assets/svg/memory.svg b/app/src/assets/svg/memory.svg similarity index 100% rename from frontend/src/assets/svg/memory.svg rename to app/src/assets/svg/memory.svg diff --git a/frontend/src/assets/svg/pulse.svg b/app/src/assets/svg/pulse.svg similarity index 100% rename from frontend/src/assets/svg/pulse.svg rename to app/src/assets/svg/pulse.svg diff --git a/frontend/src/components/Breadcrumb/Breadcrumb.vue b/app/src/components/Breadcrumb/Breadcrumb.vue similarity index 100% rename from frontend/src/components/Breadcrumb/Breadcrumb.vue rename to app/src/components/Breadcrumb/Breadcrumb.vue diff --git a/frontend/src/components/Chart/AreaChart.vue b/app/src/components/Chart/AreaChart.vue similarity index 100% rename from frontend/src/components/Chart/AreaChart.vue rename to app/src/components/Chart/AreaChart.vue diff --git a/frontend/src/components/Chart/RadialBarChart.vue b/app/src/components/Chart/RadialBarChart.vue similarity index 100% rename from frontend/src/components/Chart/RadialBarChart.vue rename to app/src/components/Chart/RadialBarChart.vue diff --git a/frontend/src/components/Chart/UsageProgressLine.vue b/app/src/components/Chart/UsageProgressLine.vue similarity index 100% rename from frontend/src/components/Chart/UsageProgressLine.vue rename to app/src/components/Chart/UsageProgressLine.vue diff --git a/frontend/src/components/ChatGPT/ChatGPT.vue b/app/src/components/ChatGPT/ChatGPT.vue similarity index 100% rename from frontend/src/components/ChatGPT/ChatGPT.vue rename to app/src/components/ChatGPT/ChatGPT.vue diff --git a/frontend/src/components/CodeEditor/CodeEditor.vue b/app/src/components/CodeEditor/CodeEditor.vue similarity index 100% rename from frontend/src/components/CodeEditor/CodeEditor.vue rename to app/src/components/CodeEditor/CodeEditor.vue diff --git a/frontend/src/components/CodeEditor/index.ts b/app/src/components/CodeEditor/index.ts similarity index 100% rename from frontend/src/components/CodeEditor/index.ts rename to app/src/components/CodeEditor/index.ts diff --git a/frontend/src/components/EnvIndicator/EnvIndicator.vue b/app/src/components/EnvIndicator/EnvIndicator.vue similarity index 100% rename from frontend/src/components/EnvIndicator/EnvIndicator.vue rename to app/src/components/EnvIndicator/EnvIndicator.vue diff --git a/frontend/src/components/FooterToolbar/FooterToolBar.vue b/app/src/components/FooterToolbar/FooterToolBar.vue similarity index 100% rename from frontend/src/components/FooterToolbar/FooterToolBar.vue rename to app/src/components/FooterToolbar/FooterToolBar.vue diff --git a/frontend/src/components/FooterToolbar/index.ts b/app/src/components/FooterToolbar/index.ts similarity index 100% rename from frontend/src/components/FooterToolbar/index.ts rename to app/src/components/FooterToolbar/index.ts diff --git a/frontend/src/components/Logo/Logo.vue b/app/src/components/Logo/Logo.vue similarity index 100% rename from frontend/src/components/Logo/Logo.vue rename to app/src/components/Logo/Logo.vue diff --git a/frontend/src/components/NginxControl/NginxControl.vue b/app/src/components/NginxControl/NginxControl.vue similarity index 100% rename from frontend/src/components/NginxControl/NginxControl.vue rename to app/src/components/NginxControl/NginxControl.vue diff --git a/frontend/src/components/NodeSelector/NodeSelector.vue b/app/src/components/NodeSelector/NodeSelector.vue similarity index 100% rename from frontend/src/components/NodeSelector/NodeSelector.vue rename to app/src/components/NodeSelector/NodeSelector.vue diff --git a/frontend/src/components/PageHeader/PageHeader.vue b/app/src/components/PageHeader/PageHeader.vue similarity index 100% rename from frontend/src/components/PageHeader/PageHeader.vue rename to app/src/components/PageHeader/PageHeader.vue diff --git a/frontend/src/components/SetLanguage/SetLanguage.vue b/app/src/components/SetLanguage/SetLanguage.vue similarity index 100% rename from frontend/src/components/SetLanguage/SetLanguage.vue rename to app/src/components/SetLanguage/SetLanguage.vue diff --git a/frontend/src/components/StdDataDisplay/StdBatchEdit.vue b/app/src/components/StdDataDisplay/StdBatchEdit.vue similarity index 100% rename from frontend/src/components/StdDataDisplay/StdBatchEdit.vue rename to app/src/components/StdDataDisplay/StdBatchEdit.vue diff --git a/frontend/src/components/StdDataDisplay/StdCurd.vue b/app/src/components/StdDataDisplay/StdCurd.vue similarity index 100% rename from frontend/src/components/StdDataDisplay/StdCurd.vue rename to app/src/components/StdDataDisplay/StdCurd.vue diff --git a/frontend/src/components/StdDataDisplay/StdPagination.vue b/app/src/components/StdDataDisplay/StdPagination.vue similarity index 100% rename from frontend/src/components/StdDataDisplay/StdPagination.vue rename to app/src/components/StdDataDisplay/StdPagination.vue diff --git a/frontend/src/components/StdDataDisplay/StdTable.vue b/app/src/components/StdDataDisplay/StdTable.vue similarity index 100% rename from frontend/src/components/StdDataDisplay/StdTable.vue rename to app/src/components/StdDataDisplay/StdTable.vue diff --git a/frontend/src/components/StdDataDisplay/StdTableTransformer.tsx b/app/src/components/StdDataDisplay/StdTableTransformer.tsx similarity index 100% rename from frontend/src/components/StdDataDisplay/StdTableTransformer.tsx rename to app/src/components/StdDataDisplay/StdTableTransformer.tsx diff --git a/frontend/src/components/StdDataDisplay/index.ts b/app/src/components/StdDataDisplay/index.ts similarity index 100% rename from frontend/src/components/StdDataDisplay/index.ts rename to app/src/components/StdDataDisplay/index.ts diff --git a/frontend/src/components/StdDataEntry/StdDataEntry.tsx b/app/src/components/StdDataEntry/StdDataEntry.tsx similarity index 100% rename from frontend/src/components/StdDataEntry/StdDataEntry.tsx rename to app/src/components/StdDataEntry/StdDataEntry.tsx diff --git a/frontend/src/components/StdDataEntry/StdFormItem.vue b/app/src/components/StdDataEntry/StdFormItem.vue similarity index 100% rename from frontend/src/components/StdDataEntry/StdFormItem.vue rename to app/src/components/StdDataEntry/StdFormItem.vue diff --git a/frontend/src/components/StdDataEntry/components/StdPassword.vue b/app/src/components/StdDataEntry/components/StdPassword.vue similarity index 100% rename from frontend/src/components/StdDataEntry/components/StdPassword.vue rename to app/src/components/StdDataEntry/components/StdPassword.vue diff --git a/frontend/src/components/StdDataEntry/components/StdSelect.vue b/app/src/components/StdDataEntry/components/StdSelect.vue similarity index 100% rename from frontend/src/components/StdDataEntry/components/StdSelect.vue rename to app/src/components/StdDataEntry/components/StdSelect.vue diff --git a/frontend/src/components/StdDataEntry/components/StdSelector.vue b/app/src/components/StdDataEntry/components/StdSelector.vue similarity index 100% rename from frontend/src/components/StdDataEntry/components/StdSelector.vue rename to app/src/components/StdDataEntry/components/StdSelector.vue diff --git a/frontend/src/components/StdDataEntry/index.tsx b/app/src/components/StdDataEntry/index.tsx similarity index 100% rename from frontend/src/components/StdDataEntry/index.tsx rename to app/src/components/StdDataEntry/index.tsx diff --git a/frontend/src/components/StdDataEntry/style.less b/app/src/components/StdDataEntry/style.less similarity index 100% rename from frontend/src/components/StdDataEntry/style.less rename to app/src/components/StdDataEntry/style.less diff --git a/frontend/src/components/SwitchAppearance/SwitchAppearance.vue b/app/src/components/SwitchAppearance/SwitchAppearance.vue similarity index 100% rename from frontend/src/components/SwitchAppearance/SwitchAppearance.vue rename to app/src/components/SwitchAppearance/SwitchAppearance.vue diff --git a/frontend/src/components/SwitchAppearance/icons/VPIconMoon.vue b/app/src/components/SwitchAppearance/icons/VPIconMoon.vue similarity index 100% rename from frontend/src/components/SwitchAppearance/icons/VPIconMoon.vue rename to app/src/components/SwitchAppearance/icons/VPIconMoon.vue diff --git a/frontend/src/components/SwitchAppearance/icons/VPIconSun.vue b/app/src/components/SwitchAppearance/icons/VPIconSun.vue similarity index 100% rename from frontend/src/components/SwitchAppearance/icons/VPIconSun.vue rename to app/src/components/SwitchAppearance/icons/VPIconSun.vue diff --git a/frontend/src/components/VPSwitch/VPSwitch.vue b/app/src/components/VPSwitch/VPSwitch.vue similarity index 100% rename from frontend/src/components/VPSwitch/VPSwitch.vue rename to app/src/components/VPSwitch/VPSwitch.vue diff --git a/frontend/src/gettext.ts b/app/src/gettext.ts similarity index 100% rename from frontend/src/gettext.ts rename to app/src/gettext.ts diff --git a/frontend/src/language/LINGUAS b/app/src/language/LINGUAS similarity index 100% rename from frontend/src/language/LINGUAS rename to app/src/language/LINGUAS diff --git a/frontend/src/language/constants.ts b/app/src/language/constants.ts similarity index 100% rename from frontend/src/language/constants.ts rename to app/src/language/constants.ts diff --git a/frontend/src/language/en/app.po b/app/src/language/en/app.po similarity index 100% rename from frontend/src/language/en/app.po rename to app/src/language/en/app.po diff --git a/frontend/src/language/es/app.mo b/app/src/language/es/app.mo similarity index 100% rename from frontend/src/language/es/app.mo rename to app/src/language/es/app.mo diff --git a/frontend/src/language/es/app.po b/app/src/language/es/app.po similarity index 100% rename from frontend/src/language/es/app.po rename to app/src/language/es/app.po diff --git a/frontend/src/language/fr_FR/app.mo b/app/src/language/fr_FR/app.mo similarity index 100% rename from frontend/src/language/fr_FR/app.mo rename to app/src/language/fr_FR/app.mo diff --git a/frontend/src/language/fr_FR/app.po b/app/src/language/fr_FR/app.po similarity index 100% rename from frontend/src/language/fr_FR/app.po rename to app/src/language/fr_FR/app.po diff --git a/frontend/src/language/messages.pot b/app/src/language/messages.pot similarity index 100% rename from frontend/src/language/messages.pot rename to app/src/language/messages.pot diff --git a/frontend/src/language/ru_RU/app.po b/app/src/language/ru_RU/app.po similarity index 100% rename from frontend/src/language/ru_RU/app.po rename to app/src/language/ru_RU/app.po diff --git a/frontend/src/language/zh_CN/app.mo b/app/src/language/zh_CN/app.mo similarity index 100% rename from frontend/src/language/zh_CN/app.mo rename to app/src/language/zh_CN/app.mo diff --git a/frontend/src/language/zh_CN/app.po b/app/src/language/zh_CN/app.po similarity index 100% rename from frontend/src/language/zh_CN/app.po rename to app/src/language/zh_CN/app.po diff --git a/frontend/src/language/zh_TW/app.mo b/app/src/language/zh_TW/app.mo similarity index 100% rename from frontend/src/language/zh_TW/app.mo rename to app/src/language/zh_TW/app.mo diff --git a/frontend/src/language/zh_TW/app.po b/app/src/language/zh_TW/app.po similarity index 100% rename from frontend/src/language/zh_TW/app.po rename to app/src/language/zh_TW/app.po diff --git a/frontend/src/layouts/BaseLayout.vue b/app/src/layouts/BaseLayout.vue similarity index 100% rename from frontend/src/layouts/BaseLayout.vue rename to app/src/layouts/BaseLayout.vue diff --git a/frontend/src/layouts/BaseRouterView.vue b/app/src/layouts/BaseRouterView.vue similarity index 100% rename from frontend/src/layouts/BaseRouterView.vue rename to app/src/layouts/BaseRouterView.vue diff --git a/frontend/src/layouts/FooterLayout.vue b/app/src/layouts/FooterLayout.vue similarity index 100% rename from frontend/src/layouts/FooterLayout.vue rename to app/src/layouts/FooterLayout.vue diff --git a/frontend/src/layouts/HeaderLayout.vue b/app/src/layouts/HeaderLayout.vue similarity index 100% rename from frontend/src/layouts/HeaderLayout.vue rename to app/src/layouts/HeaderLayout.vue diff --git a/frontend/src/layouts/Loading.vue b/app/src/layouts/Loading.vue similarity index 100% rename from frontend/src/layouts/Loading.vue rename to app/src/layouts/Loading.vue diff --git a/frontend/src/layouts/SideBar.vue b/app/src/layouts/SideBar.vue similarity index 100% rename from frontend/src/layouts/SideBar.vue rename to app/src/layouts/SideBar.vue diff --git a/frontend/src/lib/helper/index.ts b/app/src/lib/helper/index.ts similarity index 100% rename from frontend/src/lib/helper/index.ts rename to app/src/lib/helper/index.ts diff --git a/frontend/src/lib/http/index.ts b/app/src/lib/http/index.ts similarity index 100% rename from frontend/src/lib/http/index.ts rename to app/src/lib/http/index.ts diff --git a/frontend/src/lib/websocket/index.ts b/app/src/lib/websocket/index.ts similarity index 100% rename from frontend/src/lib/websocket/index.ts rename to app/src/lib/websocket/index.ts diff --git a/frontend/src/main.ts b/app/src/main.ts similarity index 100% rename from frontend/src/main.ts rename to app/src/main.ts diff --git a/frontend/src/pinia/index.ts b/app/src/pinia/index.ts similarity index 100% rename from frontend/src/pinia/index.ts rename to app/src/pinia/index.ts diff --git a/frontend/src/pinia/moudule/settings.ts b/app/src/pinia/moudule/settings.ts similarity index 100% rename from frontend/src/pinia/moudule/settings.ts rename to app/src/pinia/moudule/settings.ts diff --git a/frontend/src/pinia/moudule/user.ts b/app/src/pinia/moudule/user.ts similarity index 100% rename from frontend/src/pinia/moudule/user.ts rename to app/src/pinia/moudule/user.ts diff --git a/frontend/src/routes/index.ts b/app/src/routes/index.ts similarity index 100% rename from frontend/src/routes/index.ts rename to app/src/routes/index.ts diff --git a/app/src/version.json b/app/src/version.json new file mode 100644 index 00000000..9080b93b --- /dev/null +++ b/app/src/version.json @@ -0,0 +1 @@ +{"version":"2.0.0-beta.4","build_id":47,"total_build":251} \ No newline at end of file diff --git a/frontend/src/views/cert/Cert.vue b/app/src/views/cert/Cert.vue similarity index 100% rename from frontend/src/views/cert/Cert.vue rename to app/src/views/cert/Cert.vue diff --git a/frontend/src/views/cert/DNSChallenge.vue b/app/src/views/cert/DNSChallenge.vue similarity index 100% rename from frontend/src/views/cert/DNSChallenge.vue rename to app/src/views/cert/DNSChallenge.vue diff --git a/frontend/src/views/cert/DNSCredential.vue b/app/src/views/cert/DNSCredential.vue similarity index 100% rename from frontend/src/views/cert/DNSCredential.vue rename to app/src/views/cert/DNSCredential.vue diff --git a/frontend/src/views/config/Config.vue b/app/src/views/config/Config.vue similarity index 100% rename from frontend/src/views/config/Config.vue rename to app/src/views/config/Config.vue diff --git a/frontend/src/views/config/ConfigEdit.vue b/app/src/views/config/ConfigEdit.vue similarity index 100% rename from frontend/src/views/config/ConfigEdit.vue rename to app/src/views/config/ConfigEdit.vue diff --git a/frontend/src/views/config/InspectConfig.vue b/app/src/views/config/InspectConfig.vue similarity index 100% rename from frontend/src/views/config/InspectConfig.vue rename to app/src/views/config/InspectConfig.vue diff --git a/frontend/src/views/config/config.ts b/app/src/views/config/config.ts similarity index 100% rename from frontend/src/views/config/config.ts rename to app/src/views/config/config.ts diff --git a/frontend/src/views/config/constants.ts b/app/src/views/config/constants.ts similarity index 100% rename from frontend/src/views/config/constants.ts rename to app/src/views/config/constants.ts diff --git a/frontend/src/views/dashboard/DashBoard.vue b/app/src/views/dashboard/DashBoard.vue similarity index 100% rename from frontend/src/views/dashboard/DashBoard.vue rename to app/src/views/dashboard/DashBoard.vue diff --git a/frontend/src/views/dashboard/Environments.vue b/app/src/views/dashboard/Environments.vue similarity index 100% rename from frontend/src/views/dashboard/Environments.vue rename to app/src/views/dashboard/Environments.vue diff --git a/frontend/src/views/dashboard/ServerAnalytic.vue b/app/src/views/dashboard/ServerAnalytic.vue similarity index 100% rename from frontend/src/views/dashboard/ServerAnalytic.vue rename to app/src/views/dashboard/ServerAnalytic.vue diff --git a/frontend/src/views/dashboard/components/NodeAnalyticItem.vue b/app/src/views/dashboard/components/NodeAnalyticItem.vue similarity index 100% rename from frontend/src/views/dashboard/components/NodeAnalyticItem.vue rename to app/src/views/dashboard/components/NodeAnalyticItem.vue diff --git a/frontend/src/views/domain/DomainAdd.vue b/app/src/views/domain/DomainAdd.vue similarity index 100% rename from frontend/src/views/domain/DomainAdd.vue rename to app/src/views/domain/DomainAdd.vue diff --git a/frontend/src/views/domain/DomainEdit.vue b/app/src/views/domain/DomainEdit.vue similarity index 100% rename from frontend/src/views/domain/DomainEdit.vue rename to app/src/views/domain/DomainEdit.vue diff --git a/frontend/src/views/domain/DomainList.vue b/app/src/views/domain/DomainList.vue similarity index 100% rename from frontend/src/views/domain/DomainList.vue rename to app/src/views/domain/DomainList.vue diff --git a/frontend/src/views/domain/cert/Cert.vue b/app/src/views/domain/cert/Cert.vue similarity index 100% rename from frontend/src/views/domain/cert/Cert.vue rename to app/src/views/domain/cert/Cert.vue diff --git a/frontend/src/views/domain/cert/CertInfo.vue b/app/src/views/domain/cert/CertInfo.vue similarity index 100% rename from frontend/src/views/domain/cert/CertInfo.vue rename to app/src/views/domain/cert/CertInfo.vue diff --git a/frontend/src/views/domain/cert/ChangeCert.vue b/app/src/views/domain/cert/ChangeCert.vue similarity index 100% rename from frontend/src/views/domain/cert/ChangeCert.vue rename to app/src/views/domain/cert/ChangeCert.vue diff --git a/frontend/src/views/domain/cert/IssueCert.vue b/app/src/views/domain/cert/IssueCert.vue similarity index 100% rename from frontend/src/views/domain/cert/IssueCert.vue rename to app/src/views/domain/cert/IssueCert.vue diff --git a/frontend/src/views/domain/cert/components/AutoCertStepOne.vue b/app/src/views/domain/cert/components/AutoCertStepOne.vue similarity index 100% rename from frontend/src/views/domain/cert/components/AutoCertStepOne.vue rename to app/src/views/domain/cert/components/AutoCertStepOne.vue diff --git a/frontend/src/views/domain/cert/components/DNSChallenge.vue b/app/src/views/domain/cert/components/DNSChallenge.vue similarity index 100% rename from frontend/src/views/domain/cert/components/DNSChallenge.vue rename to app/src/views/domain/cert/components/DNSChallenge.vue diff --git a/frontend/src/views/domain/cert/components/ObtainCert.vue b/app/src/views/domain/cert/components/ObtainCert.vue similarity index 100% rename from frontend/src/views/domain/cert/components/ObtainCert.vue rename to app/src/views/domain/cert/components/ObtainCert.vue diff --git a/frontend/src/views/domain/components/Deploy.vue b/app/src/views/domain/components/Deploy.vue similarity index 100% rename from frontend/src/views/domain/components/Deploy.vue rename to app/src/views/domain/components/Deploy.vue diff --git a/frontend/src/views/domain/components/RightSettings.vue b/app/src/views/domain/components/RightSettings.vue similarity index 100% rename from frontend/src/views/domain/components/RightSettings.vue rename to app/src/views/domain/components/RightSettings.vue diff --git a/frontend/src/views/domain/components/SiteDuplicate.vue b/app/src/views/domain/components/SiteDuplicate.vue similarity index 100% rename from frontend/src/views/domain/components/SiteDuplicate.vue rename to app/src/views/domain/components/SiteDuplicate.vue diff --git a/frontend/src/views/domain/ngx_conf/LocationEditor.vue b/app/src/views/domain/ngx_conf/LocationEditor.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/LocationEditor.vue rename to app/src/views/domain/ngx_conf/LocationEditor.vue diff --git a/frontend/src/views/domain/ngx_conf/LogEntry.vue b/app/src/views/domain/ngx_conf/LogEntry.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/LogEntry.vue rename to app/src/views/domain/ngx_conf/LogEntry.vue diff --git a/frontend/src/views/domain/ngx_conf/NgxConfigEditor.vue b/app/src/views/domain/ngx_conf/NgxConfigEditor.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/NgxConfigEditor.vue rename to app/src/views/domain/ngx_conf/NgxConfigEditor.vue diff --git a/frontend/src/views/domain/ngx_conf/config_template/ConfigTemplate.vue b/app/src/views/domain/ngx_conf/config_template/ConfigTemplate.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/config_template/ConfigTemplate.vue rename to app/src/views/domain/ngx_conf/config_template/ConfigTemplate.vue diff --git a/frontend/src/views/domain/ngx_conf/config_template/TemplateForm.vue b/app/src/views/domain/ngx_conf/config_template/TemplateForm.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/config_template/TemplateForm.vue rename to app/src/views/domain/ngx_conf/config_template/TemplateForm.vue diff --git a/frontend/src/views/domain/ngx_conf/config_template/TemplateFormItem.vue b/app/src/views/domain/ngx_conf/config_template/TemplateFormItem.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/config_template/TemplateFormItem.vue rename to app/src/views/domain/ngx_conf/config_template/TemplateFormItem.vue diff --git a/frontend/src/views/domain/ngx_conf/directive/DirectiveAdd.vue b/app/src/views/domain/ngx_conf/directive/DirectiveAdd.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/directive/DirectiveAdd.vue rename to app/src/views/domain/ngx_conf/directive/DirectiveAdd.vue diff --git a/frontend/src/views/domain/ngx_conf/directive/DirectiveEditor.vue b/app/src/views/domain/ngx_conf/directive/DirectiveEditor.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/directive/DirectiveEditor.vue rename to app/src/views/domain/ngx_conf/directive/DirectiveEditor.vue diff --git a/frontend/src/views/domain/ngx_conf/directive/DirectiveEditorItem.vue b/app/src/views/domain/ngx_conf/directive/DirectiveEditorItem.vue similarity index 100% rename from frontend/src/views/domain/ngx_conf/directive/DirectiveEditorItem.vue rename to app/src/views/domain/ngx_conf/directive/DirectiveEditorItem.vue diff --git a/frontend/src/views/domain/ngx_conf/index.ts b/app/src/views/domain/ngx_conf/index.ts similarity index 100% rename from frontend/src/views/domain/ngx_conf/index.ts rename to app/src/views/domain/ngx_conf/index.ts diff --git a/frontend/src/views/environment/Environment.vue b/app/src/views/environment/Environment.vue similarity index 100% rename from frontend/src/views/environment/Environment.vue rename to app/src/views/environment/Environment.vue diff --git a/frontend/src/views/nginx_log/NginxLog.vue b/app/src/views/nginx_log/NginxLog.vue similarity index 100% rename from frontend/src/views/nginx_log/NginxLog.vue rename to app/src/views/nginx_log/NginxLog.vue diff --git a/frontend/src/views/other/Error.vue b/app/src/views/other/Error.vue similarity index 100% rename from frontend/src/views/other/Error.vue rename to app/src/views/other/Error.vue diff --git a/frontend/src/views/other/Install.vue b/app/src/views/other/Install.vue similarity index 100% rename from frontend/src/views/other/Install.vue rename to app/src/views/other/Install.vue diff --git a/frontend/src/views/other/Login.vue b/app/src/views/other/Login.vue similarity index 100% rename from frontend/src/views/other/Login.vue rename to app/src/views/other/Login.vue diff --git a/frontend/src/views/preference/BasicSettings.vue b/app/src/views/preference/BasicSettings.vue similarity index 100% rename from frontend/src/views/preference/BasicSettings.vue rename to app/src/views/preference/BasicSettings.vue diff --git a/frontend/src/views/preference/NginxSettings.vue b/app/src/views/preference/NginxSettings.vue similarity index 100% rename from frontend/src/views/preference/NginxSettings.vue rename to app/src/views/preference/NginxSettings.vue diff --git a/frontend/src/views/preference/OpenAISettings.vue b/app/src/views/preference/OpenAISettings.vue similarity index 100% rename from frontend/src/views/preference/OpenAISettings.vue rename to app/src/views/preference/OpenAISettings.vue diff --git a/frontend/src/views/preference/Preference.vue b/app/src/views/preference/Preference.vue similarity index 100% rename from frontend/src/views/preference/Preference.vue rename to app/src/views/preference/Preference.vue diff --git a/frontend/src/views/preference/typedef.ts b/app/src/views/preference/typedef.ts similarity index 100% rename from frontend/src/views/preference/typedef.ts rename to app/src/views/preference/typedef.ts diff --git a/frontend/src/views/pty/Terminal.vue b/app/src/views/pty/Terminal.vue similarity index 100% rename from frontend/src/views/pty/Terminal.vue rename to app/src/views/pty/Terminal.vue diff --git a/frontend/src/views/system/About.vue b/app/src/views/system/About.vue similarity index 100% rename from frontend/src/views/system/About.vue rename to app/src/views/system/About.vue diff --git a/frontend/src/views/system/Upgrade.vue b/app/src/views/system/Upgrade.vue similarity index 100% rename from frontend/src/views/system/Upgrade.vue rename to app/src/views/system/Upgrade.vue diff --git a/frontend/src/views/user/User.vue b/app/src/views/user/User.vue similarity index 100% rename from frontend/src/views/user/User.vue rename to app/src/views/user/User.vue diff --git a/frontend/src/vite-env.d.ts b/app/src/vite-env.d.ts similarity index 100% rename from frontend/src/vite-env.d.ts rename to app/src/vite-env.d.ts diff --git a/frontend/tsconfig.json b/app/tsconfig.json similarity index 100% rename from frontend/tsconfig.json rename to app/tsconfig.json diff --git a/frontend/tsconfig.node.json b/app/tsconfig.node.json similarity index 100% rename from frontend/tsconfig.node.json rename to app/tsconfig.node.json diff --git a/app/version.json b/app/version.json new file mode 100644 index 00000000..9080b93b --- /dev/null +++ b/app/version.json @@ -0,0 +1 @@ +{"version":"2.0.0-beta.4","build_id":47,"total_build":251} \ No newline at end of file diff --git a/frontend/vite.config.ts b/app/vite.config.ts similarity index 100% rename from frontend/vite.config.ts rename to app/vite.config.ts diff --git a/build-demo.sh b/build-demo.sh deleted file mode 100755 index 5bc9e876..00000000 --- a/build-demo.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -CGO_ENABLED=1 GOOS=linux CC=x86_64-unknown-linux-gnu-gcc \ - CXX=x86_64-unknown-linux-gnu-g++ GOARCH=amd64 go build -ldflags \ - "-X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go - -docker build -f demo.Dockerfile -t nginx-ui-demo . -docker tag nginx-ui-demo uozi/nginx-ui-demo -docker push uozi/nginx-ui-demo diff --git a/build.sh b/build.sh deleted file mode 100755 index 79450485..00000000 --- a/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -CGO_ENABLED=1 GOOS=linux CC=x86_64-unknown-linux-gnu-gcc \ - CXX=x86_64-unknown-linux-gnu-g++ GOARCH=amd64 go build -ldflags \ - "-X 'github.com/0xJacky/Nginx-UI/server/settings.buildTime=$(date +%s)'" -o nginx-ui -v main.go - -# docker build -t nginx-ui . -# docker tag nginx-ui uozi/nginx-ui -# docker push uozi/nginx-ui diff --git a/cmd/generate/generate.go b/cmd/generate/generate.go index bf55c1ec..3f5f63d9 100644 --- a/cmd/generate/generate.go +++ b/cmd/generate/generate.go @@ -3,8 +3,8 @@ package main import ( "flag" "fmt" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/settings" "gorm.io/driver/sqlite" "gorm.io/gen" "gorm.io/gorm" diff --git a/frontend/src/version.json b/frontend/src/version.json deleted file mode 100644 index dced963e..00000000 --- a/frontend/src/version.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"2.0.0-beta.4","build_id":45,"total_build":249} \ No newline at end of file diff --git a/frontend/version.json b/frontend/version.json deleted file mode 100644 index dced963e..00000000 --- a/frontend/version.json +++ /dev/null @@ -1 +0,0 @@ -{"version":"2.0.0-beta.4","build_id":45,"total_build":249} \ No newline at end of file diff --git a/server/internal/analytic/analytic.go b/internal/analytic/analytic.go similarity index 95% rename from server/internal/analytic/analytic.go rename to internal/analytic/analytic.go index f44cf75a..6d3602ec 100644 --- a/server/internal/analytic/analytic.go +++ b/internal/analytic/analytic.go @@ -1,7 +1,7 @@ package analytic import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/logger" "github.com/shirou/gopsutil/v3/net" "time" ) diff --git a/server/internal/analytic/node.go b/internal/analytic/node.go similarity index 85% rename from server/internal/analytic/node.go rename to internal/analytic/node.go index 3619a11d..cf981aa9 100644 --- a/server/internal/analytic/node.go +++ b/internal/analytic/node.go @@ -1,18 +1,18 @@ package analytic import ( - "crypto/tls" - "encoding/json" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/upgrader" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/shirou/gopsutil/v3/load" - "github.com/shirou/gopsutil/v3/net" - "io" - "net/http" - "net/url" - "sync" - "time" + "crypto/tls" + "encoding/json" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/upgrader" + "github.com/0xJacky/Nginx-UI/model" + "github.com/shirou/gopsutil/v3/load" + "github.com/shirou/gopsutil/v3/net" + "io" + "net/http" + "net/url" + "sync" + "time" ) type NodeInfo struct { @@ -36,8 +36,8 @@ type NodeStat struct { type Node struct { EnvironmentID int `json:"environment_id,omitempty"` *model.Environment - NodeStat - NodeInfo + NodeStat + NodeInfo } var mutex sync.Mutex diff --git a/server/internal/analytic/node_record.go b/internal/analytic/node_record.go similarity index 93% rename from server/internal/analytic/node_record.go rename to internal/analytic/node_record.go index 78056f9b..3a7f15e5 100644 --- a/server/internal/analytic/node_record.go +++ b/internal/analytic/node_record.go @@ -3,9 +3,9 @@ package analytic import ( "context" "encoding/json" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" "github.com/gorilla/websocket" "net/http" "time" diff --git a/server/internal/analytic/node_stat.go b/internal/analytic/node_stat.go similarity index 95% rename from server/internal/analytic/node_stat.go rename to internal/analytic/node_stat.go index 4f5aba67..7a46d08e 100644 --- a/server/internal/analytic/node_stat.go +++ b/internal/analytic/node_stat.go @@ -1,7 +1,7 @@ package analytic import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/logger" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/load" "github.com/shirou/gopsutil/v3/net" diff --git a/server/internal/analytic/record.go b/internal/analytic/record.go similarity index 97% rename from server/internal/analytic/record.go rename to internal/analytic/record.go index 6b11384b..fba25958 100644 --- a/server/internal/analytic/record.go +++ b/internal/analytic/record.go @@ -1,7 +1,7 @@ package analytic import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/logger" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/net" diff --git a/server/internal/analytic/stat.go b/internal/analytic/stat.go similarity index 100% rename from server/internal/analytic/stat.go rename to internal/analytic/stat.go diff --git a/server/internal/boot/boot.go b/internal/boot/boot.go similarity index 81% rename from server/internal/boot/boot.go rename to internal/boot/boot.go index a1c32ff4..066f99ed 100644 --- a/server/internal/boot/boot.go +++ b/internal/boot/boot.go @@ -1,12 +1,12 @@ package boot import ( - "github.com/0xJacky/Nginx-UI/server/internal/analytic" - "github.com/0xJacky/Nginx-UI/server/internal/cert" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/0xJacky/Nginx-UI/server/settings" + analytic2 "github.com/0xJacky/Nginx-UI/internal/analytic" + "github.com/0xJacky/Nginx-UI/internal/cert" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/query" + "github.com/0xJacky/Nginx-UI/settings" "github.com/go-co-op/gocron" "github.com/google/uuid" "mime" @@ -24,7 +24,7 @@ func Kernel() { } syncs := []func(){ - analytic.RecordServerAnalytic, + analytic2.RecordServerAnalytic, } for _, v := range async { @@ -39,7 +39,7 @@ func Kernel() { func InitAfterDatabase() { syncs := []func(){ InitAutoObtainCert, - analytic.RetrieveNodesStatus, + analytic2.RetrieveNodesStatus, } for _, v := range syncs { diff --git a/server/internal/cert/auto_cert.go b/internal/cert/auto_cert.go similarity index 96% rename from server/internal/cert/auto_cert.go rename to internal/cert/auto_cert.go index 3e228ff6..c95e855c 100644 --- a/server/internal/cert/auto_cert.go +++ b/internal/cert/auto_cert.go @@ -2,8 +2,8 @@ package cert import ( "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/model" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/model" "github.com/pkg/errors" "time" ) diff --git a/server/internal/cert/cert.go b/internal/cert/cert.go similarity index 87% rename from server/internal/cert/cert.go rename to internal/cert/cert.go index 344fc676..c64cd651 100644 --- a/server/internal/cert/cert.go +++ b/internal/cert/cert.go @@ -1,30 +1,30 @@ package cert import ( - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/tls" - "github.com/0xJacky/Nginx-UI/server/internal/cert/dns" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/0xJacky/Nginx-UI/server/settings" - "github.com/go-acme/lego/v4/certcrypto" - "github.com/go-acme/lego/v4/certificate" - "github.com/go-acme/lego/v4/challenge/http01" - "github.com/go-acme/lego/v4/lego" - lego_log "github.com/go-acme/lego/v4/log" - dns_providers "github.com/go-acme/lego/v4/providers/dns" - "github.com/go-acme/lego/v4/registration" - "github.com/pkg/errors" - "io" - "log" - "net/http" - "os" - "path/filepath" - "strings" + "crypto" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "crypto/tls" + "github.com/0xJacky/Nginx-UI/internal/cert/dns" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/query" + "github.com/0xJacky/Nginx-UI/settings" + "github.com/go-acme/lego/v4/certcrypto" + "github.com/go-acme/lego/v4/certificate" + "github.com/go-acme/lego/v4/challenge/http01" + "github.com/go-acme/lego/v4/lego" + lego_log "github.com/go-acme/lego/v4/log" + dns_providers "github.com/go-acme/lego/v4/providers/dns" + "github.com/go-acme/lego/v4/registration" + "github.com/pkg/errors" + "io" + "log" + "net/http" + "os" + "path/filepath" + "strings" ) const ( diff --git a/server/internal/cert/cert_info.go b/internal/cert/cert_info.go similarity index 100% rename from server/internal/cert/cert_info.go rename to internal/cert/cert_info.go diff --git a/server/internal/cert/config/acmedns.toml b/internal/cert/config/acmedns.toml similarity index 100% rename from server/internal/cert/config/acmedns.toml rename to internal/cert/config/acmedns.toml diff --git a/server/internal/cert/config/alidns.toml b/internal/cert/config/alidns.toml similarity index 100% rename from server/internal/cert/config/alidns.toml rename to internal/cert/config/alidns.toml diff --git a/server/internal/cert/config/allinkl.toml b/internal/cert/config/allinkl.toml similarity index 100% rename from server/internal/cert/config/allinkl.toml rename to internal/cert/config/allinkl.toml diff --git a/server/internal/cert/config/arvancloud.toml b/internal/cert/config/arvancloud.toml similarity index 100% rename from server/internal/cert/config/arvancloud.toml rename to internal/cert/config/arvancloud.toml diff --git a/server/internal/cert/config/auroradns.toml b/internal/cert/config/auroradns.toml similarity index 100% rename from server/internal/cert/config/auroradns.toml rename to internal/cert/config/auroradns.toml diff --git a/server/internal/cert/config/autodns.toml b/internal/cert/config/autodns.toml similarity index 100% rename from server/internal/cert/config/autodns.toml rename to internal/cert/config/autodns.toml diff --git a/server/internal/cert/config/azure.toml b/internal/cert/config/azure.toml similarity index 100% rename from server/internal/cert/config/azure.toml rename to internal/cert/config/azure.toml diff --git a/server/internal/cert/config/bindman.toml b/internal/cert/config/bindman.toml similarity index 100% rename from server/internal/cert/config/bindman.toml rename to internal/cert/config/bindman.toml diff --git a/server/internal/cert/config/bluecat.toml b/internal/cert/config/bluecat.toml similarity index 100% rename from server/internal/cert/config/bluecat.toml rename to internal/cert/config/bluecat.toml diff --git a/server/internal/cert/config/brandit.toml b/internal/cert/config/brandit.toml similarity index 100% rename from server/internal/cert/config/brandit.toml rename to internal/cert/config/brandit.toml diff --git a/server/internal/cert/config/bunny.toml b/internal/cert/config/bunny.toml similarity index 100% rename from server/internal/cert/config/bunny.toml rename to internal/cert/config/bunny.toml diff --git a/server/internal/cert/config/checkdomain.toml b/internal/cert/config/checkdomain.toml similarity index 100% rename from server/internal/cert/config/checkdomain.toml rename to internal/cert/config/checkdomain.toml diff --git a/server/internal/cert/config/civo.toml b/internal/cert/config/civo.toml similarity index 100% rename from server/internal/cert/config/civo.toml rename to internal/cert/config/civo.toml diff --git a/server/internal/cert/config/clouddns.toml b/internal/cert/config/clouddns.toml similarity index 100% rename from server/internal/cert/config/clouddns.toml rename to internal/cert/config/clouddns.toml diff --git a/server/internal/cert/config/cloudflare.toml b/internal/cert/config/cloudflare.toml similarity index 100% rename from server/internal/cert/config/cloudflare.toml rename to internal/cert/config/cloudflare.toml diff --git a/server/internal/cert/config/cloudns.toml b/internal/cert/config/cloudns.toml similarity index 100% rename from server/internal/cert/config/cloudns.toml rename to internal/cert/config/cloudns.toml diff --git a/server/internal/cert/config/cloudxns.toml b/internal/cert/config/cloudxns.toml similarity index 100% rename from server/internal/cert/config/cloudxns.toml rename to internal/cert/config/cloudxns.toml diff --git a/server/internal/cert/config/config.go b/internal/cert/config/config.go similarity index 100% rename from server/internal/cert/config/config.go rename to internal/cert/config/config.go diff --git a/server/internal/cert/config/conoha.toml b/internal/cert/config/conoha.toml similarity index 100% rename from server/internal/cert/config/conoha.toml rename to internal/cert/config/conoha.toml diff --git a/server/internal/cert/config/constellix.toml b/internal/cert/config/constellix.toml similarity index 100% rename from server/internal/cert/config/constellix.toml rename to internal/cert/config/constellix.toml diff --git a/server/internal/cert/config/desec.toml b/internal/cert/config/desec.toml similarity index 100% rename from server/internal/cert/config/desec.toml rename to internal/cert/config/desec.toml diff --git a/server/internal/cert/config/designate.toml b/internal/cert/config/designate.toml similarity index 100% rename from server/internal/cert/config/designate.toml rename to internal/cert/config/designate.toml diff --git a/server/internal/cert/config/digitalocean.toml b/internal/cert/config/digitalocean.toml similarity index 100% rename from server/internal/cert/config/digitalocean.toml rename to internal/cert/config/digitalocean.toml diff --git a/server/internal/cert/config/dnshomede.toml b/internal/cert/config/dnshomede.toml similarity index 100% rename from server/internal/cert/config/dnshomede.toml rename to internal/cert/config/dnshomede.toml diff --git a/server/internal/cert/config/dnsimple.toml b/internal/cert/config/dnsimple.toml similarity index 100% rename from server/internal/cert/config/dnsimple.toml rename to internal/cert/config/dnsimple.toml diff --git a/server/internal/cert/config/dnsmadeeasy.toml b/internal/cert/config/dnsmadeeasy.toml similarity index 100% rename from server/internal/cert/config/dnsmadeeasy.toml rename to internal/cert/config/dnsmadeeasy.toml diff --git a/server/internal/cert/config/dnspod.toml b/internal/cert/config/dnspod.toml similarity index 100% rename from server/internal/cert/config/dnspod.toml rename to internal/cert/config/dnspod.toml diff --git a/server/internal/cert/config/dode.toml b/internal/cert/config/dode.toml similarity index 100% rename from server/internal/cert/config/dode.toml rename to internal/cert/config/dode.toml diff --git a/server/internal/cert/config/domeneshop.toml b/internal/cert/config/domeneshop.toml similarity index 100% rename from server/internal/cert/config/domeneshop.toml rename to internal/cert/config/domeneshop.toml diff --git a/server/internal/cert/config/dreamhost.toml b/internal/cert/config/dreamhost.toml similarity index 100% rename from server/internal/cert/config/dreamhost.toml rename to internal/cert/config/dreamhost.toml diff --git a/server/internal/cert/config/duckdns.toml b/internal/cert/config/duckdns.toml similarity index 100% rename from server/internal/cert/config/duckdns.toml rename to internal/cert/config/duckdns.toml diff --git a/server/internal/cert/config/dyn.toml b/internal/cert/config/dyn.toml similarity index 100% rename from server/internal/cert/config/dyn.toml rename to internal/cert/config/dyn.toml diff --git a/server/internal/cert/config/dynu.toml b/internal/cert/config/dynu.toml similarity index 100% rename from server/internal/cert/config/dynu.toml rename to internal/cert/config/dynu.toml diff --git a/server/internal/cert/config/easydns.toml b/internal/cert/config/easydns.toml similarity index 100% rename from server/internal/cert/config/easydns.toml rename to internal/cert/config/easydns.toml diff --git a/server/internal/cert/config/edgedns.toml b/internal/cert/config/edgedns.toml similarity index 100% rename from server/internal/cert/config/edgedns.toml rename to internal/cert/config/edgedns.toml diff --git a/server/internal/cert/config/epik.toml b/internal/cert/config/epik.toml similarity index 100% rename from server/internal/cert/config/epik.toml rename to internal/cert/config/epik.toml diff --git a/server/internal/cert/config/exec.toml b/internal/cert/config/exec.toml similarity index 100% rename from server/internal/cert/config/exec.toml rename to internal/cert/config/exec.toml diff --git a/server/internal/cert/config/exoscale.toml b/internal/cert/config/exoscale.toml similarity index 100% rename from server/internal/cert/config/exoscale.toml rename to internal/cert/config/exoscale.toml diff --git a/server/internal/cert/config/freemyip.toml b/internal/cert/config/freemyip.toml similarity index 100% rename from server/internal/cert/config/freemyip.toml rename to internal/cert/config/freemyip.toml diff --git a/server/internal/cert/config/gandi.toml b/internal/cert/config/gandi.toml similarity index 100% rename from server/internal/cert/config/gandi.toml rename to internal/cert/config/gandi.toml diff --git a/server/internal/cert/config/gandiv5.toml b/internal/cert/config/gandiv5.toml similarity index 100% rename from server/internal/cert/config/gandiv5.toml rename to internal/cert/config/gandiv5.toml diff --git a/server/internal/cert/config/gcloud.toml b/internal/cert/config/gcloud.toml similarity index 100% rename from server/internal/cert/config/gcloud.toml rename to internal/cert/config/gcloud.toml diff --git a/server/internal/cert/config/gcore.toml b/internal/cert/config/gcore.toml similarity index 100% rename from server/internal/cert/config/gcore.toml rename to internal/cert/config/gcore.toml diff --git a/server/internal/cert/config/glesys.toml b/internal/cert/config/glesys.toml similarity index 100% rename from server/internal/cert/config/glesys.toml rename to internal/cert/config/glesys.toml diff --git a/server/internal/cert/config/godaddy.toml b/internal/cert/config/godaddy.toml similarity index 100% rename from server/internal/cert/config/godaddy.toml rename to internal/cert/config/godaddy.toml diff --git a/server/internal/cert/config/googledomains.toml b/internal/cert/config/googledomains.toml similarity index 100% rename from server/internal/cert/config/googledomains.toml rename to internal/cert/config/googledomains.toml diff --git a/server/internal/cert/config/hetzner.toml b/internal/cert/config/hetzner.toml similarity index 100% rename from server/internal/cert/config/hetzner.toml rename to internal/cert/config/hetzner.toml diff --git a/server/internal/cert/config/hostingde.toml b/internal/cert/config/hostingde.toml similarity index 100% rename from server/internal/cert/config/hostingde.toml rename to internal/cert/config/hostingde.toml diff --git a/server/internal/cert/config/hosttech.toml b/internal/cert/config/hosttech.toml similarity index 100% rename from server/internal/cert/config/hosttech.toml rename to internal/cert/config/hosttech.toml diff --git a/server/internal/cert/config/httpreq.toml b/internal/cert/config/httpreq.toml similarity index 100% rename from server/internal/cert/config/httpreq.toml rename to internal/cert/config/httpreq.toml diff --git a/server/internal/cert/config/hurricane.toml b/internal/cert/config/hurricane.toml similarity index 100% rename from server/internal/cert/config/hurricane.toml rename to internal/cert/config/hurricane.toml diff --git a/server/internal/cert/config/hyperone.toml b/internal/cert/config/hyperone.toml similarity index 100% rename from server/internal/cert/config/hyperone.toml rename to internal/cert/config/hyperone.toml diff --git a/server/internal/cert/config/ibmcloud.toml b/internal/cert/config/ibmcloud.toml similarity index 100% rename from server/internal/cert/config/ibmcloud.toml rename to internal/cert/config/ibmcloud.toml diff --git a/server/internal/cert/config/iij.toml b/internal/cert/config/iij.toml similarity index 100% rename from server/internal/cert/config/iij.toml rename to internal/cert/config/iij.toml diff --git a/server/internal/cert/config/iijdpf.toml b/internal/cert/config/iijdpf.toml similarity index 100% rename from server/internal/cert/config/iijdpf.toml rename to internal/cert/config/iijdpf.toml diff --git a/server/internal/cert/config/infoblox.toml b/internal/cert/config/infoblox.toml similarity index 100% rename from server/internal/cert/config/infoblox.toml rename to internal/cert/config/infoblox.toml diff --git a/server/internal/cert/config/infomaniak.toml b/internal/cert/config/infomaniak.toml similarity index 100% rename from server/internal/cert/config/infomaniak.toml rename to internal/cert/config/infomaniak.toml diff --git a/server/internal/cert/config/internetbs.toml b/internal/cert/config/internetbs.toml similarity index 100% rename from server/internal/cert/config/internetbs.toml rename to internal/cert/config/internetbs.toml diff --git a/server/internal/cert/config/inwx.toml b/internal/cert/config/inwx.toml similarity index 100% rename from server/internal/cert/config/inwx.toml rename to internal/cert/config/inwx.toml diff --git a/server/internal/cert/config/ionos.toml b/internal/cert/config/ionos.toml similarity index 100% rename from server/internal/cert/config/ionos.toml rename to internal/cert/config/ionos.toml diff --git a/server/internal/cert/config/iwantmyname.toml b/internal/cert/config/iwantmyname.toml similarity index 100% rename from server/internal/cert/config/iwantmyname.toml rename to internal/cert/config/iwantmyname.toml diff --git a/server/internal/cert/config/joker.toml b/internal/cert/config/joker.toml similarity index 100% rename from server/internal/cert/config/joker.toml rename to internal/cert/config/joker.toml diff --git a/server/internal/cert/config/liara.toml b/internal/cert/config/liara.toml similarity index 100% rename from server/internal/cert/config/liara.toml rename to internal/cert/config/liara.toml diff --git a/server/internal/cert/config/lightsail.toml b/internal/cert/config/lightsail.toml similarity index 100% rename from server/internal/cert/config/lightsail.toml rename to internal/cert/config/lightsail.toml diff --git a/server/internal/cert/config/linode.toml b/internal/cert/config/linode.toml similarity index 100% rename from server/internal/cert/config/linode.toml rename to internal/cert/config/linode.toml diff --git a/server/internal/cert/config/liquidweb.toml b/internal/cert/config/liquidweb.toml similarity index 100% rename from server/internal/cert/config/liquidweb.toml rename to internal/cert/config/liquidweb.toml diff --git a/server/internal/cert/config/loopia.toml b/internal/cert/config/loopia.toml similarity index 100% rename from server/internal/cert/config/loopia.toml rename to internal/cert/config/loopia.toml diff --git a/server/internal/cert/config/luadns.toml b/internal/cert/config/luadns.toml similarity index 100% rename from server/internal/cert/config/luadns.toml rename to internal/cert/config/luadns.toml diff --git a/server/internal/cert/config/mydnsjp.toml b/internal/cert/config/mydnsjp.toml similarity index 100% rename from server/internal/cert/config/mydnsjp.toml rename to internal/cert/config/mydnsjp.toml diff --git a/server/internal/cert/config/mythicbeasts.toml b/internal/cert/config/mythicbeasts.toml similarity index 100% rename from server/internal/cert/config/mythicbeasts.toml rename to internal/cert/config/mythicbeasts.toml diff --git a/server/internal/cert/config/namecheap.toml b/internal/cert/config/namecheap.toml similarity index 100% rename from server/internal/cert/config/namecheap.toml rename to internal/cert/config/namecheap.toml diff --git a/server/internal/cert/config/namedotcom.toml b/internal/cert/config/namedotcom.toml similarity index 100% rename from server/internal/cert/config/namedotcom.toml rename to internal/cert/config/namedotcom.toml diff --git a/server/internal/cert/config/namesilo.toml b/internal/cert/config/namesilo.toml similarity index 100% rename from server/internal/cert/config/namesilo.toml rename to internal/cert/config/namesilo.toml diff --git a/server/internal/cert/config/nearlyfreespeech.toml b/internal/cert/config/nearlyfreespeech.toml similarity index 100% rename from server/internal/cert/config/nearlyfreespeech.toml rename to internal/cert/config/nearlyfreespeech.toml diff --git a/server/internal/cert/config/netcup.toml b/internal/cert/config/netcup.toml similarity index 100% rename from server/internal/cert/config/netcup.toml rename to internal/cert/config/netcup.toml diff --git a/server/internal/cert/config/netlify.toml b/internal/cert/config/netlify.toml similarity index 100% rename from server/internal/cert/config/netlify.toml rename to internal/cert/config/netlify.toml diff --git a/server/internal/cert/config/nicmanager.toml b/internal/cert/config/nicmanager.toml similarity index 100% rename from server/internal/cert/config/nicmanager.toml rename to internal/cert/config/nicmanager.toml diff --git a/server/internal/cert/config/nifcloud.toml b/internal/cert/config/nifcloud.toml similarity index 100% rename from server/internal/cert/config/nifcloud.toml rename to internal/cert/config/nifcloud.toml diff --git a/server/internal/cert/config/njalla.toml b/internal/cert/config/njalla.toml similarity index 100% rename from server/internal/cert/config/njalla.toml rename to internal/cert/config/njalla.toml diff --git a/server/internal/cert/config/nodion.toml b/internal/cert/config/nodion.toml similarity index 100% rename from server/internal/cert/config/nodion.toml rename to internal/cert/config/nodion.toml diff --git a/server/internal/cert/config/ns1.toml b/internal/cert/config/ns1.toml similarity index 100% rename from server/internal/cert/config/ns1.toml rename to internal/cert/config/ns1.toml diff --git a/server/internal/cert/config/oraclecloud.toml b/internal/cert/config/oraclecloud.toml similarity index 100% rename from server/internal/cert/config/oraclecloud.toml rename to internal/cert/config/oraclecloud.toml diff --git a/server/internal/cert/config/otc.toml b/internal/cert/config/otc.toml similarity index 100% rename from server/internal/cert/config/otc.toml rename to internal/cert/config/otc.toml diff --git a/server/internal/cert/config/ovh.toml b/internal/cert/config/ovh.toml similarity index 100% rename from server/internal/cert/config/ovh.toml rename to internal/cert/config/ovh.toml diff --git a/server/internal/cert/config/pdns.toml b/internal/cert/config/pdns.toml similarity index 100% rename from server/internal/cert/config/pdns.toml rename to internal/cert/config/pdns.toml diff --git a/server/internal/cert/config/plesk.toml b/internal/cert/config/plesk.toml similarity index 100% rename from server/internal/cert/config/plesk.toml rename to internal/cert/config/plesk.toml diff --git a/server/internal/cert/config/porkbun.toml b/internal/cert/config/porkbun.toml similarity index 100% rename from server/internal/cert/config/porkbun.toml rename to internal/cert/config/porkbun.toml diff --git a/server/internal/cert/config/rackspace.toml b/internal/cert/config/rackspace.toml similarity index 100% rename from server/internal/cert/config/rackspace.toml rename to internal/cert/config/rackspace.toml diff --git a/server/internal/cert/config/regru.toml b/internal/cert/config/regru.toml similarity index 100% rename from server/internal/cert/config/regru.toml rename to internal/cert/config/regru.toml diff --git a/server/internal/cert/config/rfc2136.toml b/internal/cert/config/rfc2136.toml similarity index 100% rename from server/internal/cert/config/rfc2136.toml rename to internal/cert/config/rfc2136.toml diff --git a/server/internal/cert/config/rimuhosting.toml b/internal/cert/config/rimuhosting.toml similarity index 100% rename from server/internal/cert/config/rimuhosting.toml rename to internal/cert/config/rimuhosting.toml diff --git a/server/internal/cert/config/route53.toml b/internal/cert/config/route53.toml similarity index 100% rename from server/internal/cert/config/route53.toml rename to internal/cert/config/route53.toml diff --git a/server/internal/cert/config/safedns.toml b/internal/cert/config/safedns.toml similarity index 100% rename from server/internal/cert/config/safedns.toml rename to internal/cert/config/safedns.toml diff --git a/server/internal/cert/config/sakuracloud.toml b/internal/cert/config/sakuracloud.toml similarity index 100% rename from server/internal/cert/config/sakuracloud.toml rename to internal/cert/config/sakuracloud.toml diff --git a/server/internal/cert/config/scaleway.toml b/internal/cert/config/scaleway.toml similarity index 100% rename from server/internal/cert/config/scaleway.toml rename to internal/cert/config/scaleway.toml diff --git a/server/internal/cert/config/selectel.toml b/internal/cert/config/selectel.toml similarity index 100% rename from server/internal/cert/config/selectel.toml rename to internal/cert/config/selectel.toml diff --git a/server/internal/cert/config/servercow.toml b/internal/cert/config/servercow.toml similarity index 100% rename from server/internal/cert/config/servercow.toml rename to internal/cert/config/servercow.toml diff --git a/server/internal/cert/config/simply.toml b/internal/cert/config/simply.toml similarity index 100% rename from server/internal/cert/config/simply.toml rename to internal/cert/config/simply.toml diff --git a/server/internal/cert/config/sonic.toml b/internal/cert/config/sonic.toml similarity index 100% rename from server/internal/cert/config/sonic.toml rename to internal/cert/config/sonic.toml diff --git a/server/internal/cert/config/stackpath.toml b/internal/cert/config/stackpath.toml similarity index 100% rename from server/internal/cert/config/stackpath.toml rename to internal/cert/config/stackpath.toml diff --git a/server/internal/cert/config/tencentcloud.toml b/internal/cert/config/tencentcloud.toml similarity index 100% rename from server/internal/cert/config/tencentcloud.toml rename to internal/cert/config/tencentcloud.toml diff --git a/server/internal/cert/config/transip.toml b/internal/cert/config/transip.toml similarity index 100% rename from server/internal/cert/config/transip.toml rename to internal/cert/config/transip.toml diff --git a/server/internal/cert/config/ultradns.toml b/internal/cert/config/ultradns.toml similarity index 100% rename from server/internal/cert/config/ultradns.toml rename to internal/cert/config/ultradns.toml diff --git a/server/internal/cert/config/variomedia.toml b/internal/cert/config/variomedia.toml similarity index 100% rename from server/internal/cert/config/variomedia.toml rename to internal/cert/config/variomedia.toml diff --git a/server/internal/cert/config/vegadns.toml b/internal/cert/config/vegadns.toml similarity index 100% rename from server/internal/cert/config/vegadns.toml rename to internal/cert/config/vegadns.toml diff --git a/server/internal/cert/config/vercel.toml b/internal/cert/config/vercel.toml similarity index 100% rename from server/internal/cert/config/vercel.toml rename to internal/cert/config/vercel.toml diff --git a/server/internal/cert/config/versio.toml b/internal/cert/config/versio.toml similarity index 100% rename from server/internal/cert/config/versio.toml rename to internal/cert/config/versio.toml diff --git a/server/internal/cert/config/vinyldns.toml b/internal/cert/config/vinyldns.toml similarity index 100% rename from server/internal/cert/config/vinyldns.toml rename to internal/cert/config/vinyldns.toml diff --git a/server/internal/cert/config/vkcloud.toml b/internal/cert/config/vkcloud.toml similarity index 100% rename from server/internal/cert/config/vkcloud.toml rename to internal/cert/config/vkcloud.toml diff --git a/server/internal/cert/config/vscale.toml b/internal/cert/config/vscale.toml similarity index 100% rename from server/internal/cert/config/vscale.toml rename to internal/cert/config/vscale.toml diff --git a/server/internal/cert/config/vultr.toml b/internal/cert/config/vultr.toml similarity index 100% rename from server/internal/cert/config/vultr.toml rename to internal/cert/config/vultr.toml diff --git a/server/internal/cert/config/websupport.toml b/internal/cert/config/websupport.toml similarity index 100% rename from server/internal/cert/config/websupport.toml rename to internal/cert/config/websupport.toml diff --git a/server/internal/cert/config/wedos.toml b/internal/cert/config/wedos.toml similarity index 100% rename from server/internal/cert/config/wedos.toml rename to internal/cert/config/wedos.toml diff --git a/server/internal/cert/config/yandex.toml b/internal/cert/config/yandex.toml similarity index 100% rename from server/internal/cert/config/yandex.toml rename to internal/cert/config/yandex.toml diff --git a/server/internal/cert/config/yandexcloud.toml b/internal/cert/config/yandexcloud.toml similarity index 100% rename from server/internal/cert/config/yandexcloud.toml rename to internal/cert/config/yandexcloud.toml diff --git a/server/internal/cert/config/zoneee.toml b/internal/cert/config/zoneee.toml similarity index 100% rename from server/internal/cert/config/zoneee.toml rename to internal/cert/config/zoneee.toml diff --git a/server/internal/cert/config/zonomi.toml b/internal/cert/config/zonomi.toml similarity index 100% rename from server/internal/cert/config/zonomi.toml rename to internal/cert/config/zonomi.toml diff --git a/server/internal/cert/dns/config_env.go b/internal/cert/dns/config_env.go similarity index 97% rename from server/internal/cert/dns/config_env.go rename to internal/cert/dns/config_env.go index 7b82c4bc..a008a751 100644 --- a/server/internal/cert/dns/config_env.go +++ b/internal/cert/dns/config_env.go @@ -1,7 +1,7 @@ package dns import ( - "github.com/0xJacky/Nginx-UI/server/internal/cert/config" + "github.com/0xJacky/Nginx-UI/internal/cert/config" "github.com/BurntSushi/toml" "log" "os" diff --git a/server/internal/cert/dns/config_env_test.go b/internal/cert/dns/config_env_test.go similarity index 91% rename from server/internal/cert/dns/config_env_test.go rename to internal/cert/dns/config_env_test.go index 2d77049d..25243690 100644 --- a/server/internal/cert/dns/config_env_test.go +++ b/internal/cert/dns/config_env_test.go @@ -1,7 +1,7 @@ package dns import ( - "github.com/0xJacky/Nginx-UI/server/internal/cert/config" + "github.com/0xJacky/Nginx-UI/internal/cert/config" "github.com/BurntSushi/toml" "log" "path/filepath" diff --git a/server/internal/cert/dns/tencent_cloud_dns_test.go b/internal/cert/dns/tencent_cloud_dns_test.go similarity index 96% rename from server/internal/cert/dns/tencent_cloud_dns_test.go rename to internal/cert/dns/tencent_cloud_dns_test.go index 3e3b7b3f..1d24ce79 100644 --- a/server/internal/cert/dns/tencent_cloud_dns_test.go +++ b/internal/cert/dns/tencent_cloud_dns_test.go @@ -5,8 +5,8 @@ import ( "crypto/elliptic" "crypto/rand" "crypto/tls" - "github.com/0xJacky/Nginx-UI/server/internal/cert" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/cert" + "github.com/0xJacky/Nginx-UI/settings" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/certificate" "github.com/go-acme/lego/v4/lego" diff --git a/server/internal/config_list/config_list.go b/internal/config_list/config_list.go similarity index 100% rename from server/internal/config_list/config_list.go rename to internal/config_list/config_list.go diff --git a/server/internal/environment/environment.go b/internal/environment/environment.go similarity index 74% rename from server/internal/environment/environment.go rename to internal/environment/environment.go index c7cf6ea2..abfa394b 100644 --- a/server/internal/environment/environment.go +++ b/internal/environment/environment.go @@ -1,8 +1,8 @@ package environment import ( - "github.com/0xJacky/Nginx-UI/server/internal/analytic" - "github.com/0xJacky/Nginx-UI/server/query" + "github.com/0xJacky/Nginx-UI/internal/analytic" + "github.com/0xJacky/Nginx-UI/query" ) func RetrieveEnvironmentList() (envs []*analytic.Node, err error) { diff --git a/server/internal/helper/copy.go b/internal/helper/copy.go similarity index 100% rename from server/internal/helper/copy.go rename to internal/helper/copy.go diff --git a/server/internal/helper/file.go b/internal/helper/file.go similarity index 100% rename from server/internal/helper/file.go rename to internal/helper/file.go diff --git a/server/internal/helper/hash.go b/internal/helper/hash.go similarity index 88% rename from server/internal/helper/hash.go rename to internal/helper/hash.go index 86359664..86959e6a 100644 --- a/server/internal/helper/hash.go +++ b/internal/helper/hash.go @@ -3,7 +3,7 @@ package helper import ( "crypto/sha512" "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/logger" "io" "os" ) diff --git a/server/internal/helper/tar.go b/internal/helper/tar.go similarity index 100% rename from server/internal/helper/tar.go rename to internal/helper/tar.go diff --git a/server/internal/logger/color.go b/internal/logger/color.go similarity index 100% rename from server/internal/logger/color.go rename to internal/logger/color.go diff --git a/server/internal/logger/logger.go b/internal/logger/logger.go similarity index 98% rename from server/internal/logger/logger.go rename to internal/logger/logger.go index 1111f9d2..be371af8 100644 --- a/server/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -1,7 +1,7 @@ package logger import ( - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "go.uber.org/zap" "go.uber.org/zap/zapcore" diff --git a/server/internal/nginx/build_config.go b/internal/nginx/build_config.go similarity index 100% rename from server/internal/nginx/build_config.go rename to internal/nginx/build_config.go diff --git a/server/internal/nginx/conf/nextcloud_ngx.conf b/internal/nginx/conf/nextcloud_ngx.conf similarity index 100% rename from server/internal/nginx/conf/nextcloud_ngx.conf rename to internal/nginx/conf/nextcloud_ngx.conf diff --git a/server/internal/nginx/conf/test.conf b/internal/nginx/conf/test.conf similarity index 100% rename from server/internal/nginx/conf/test.conf rename to internal/nginx/conf/test.conf diff --git a/server/internal/nginx/format_code.go b/internal/nginx/format_code.go similarity index 100% rename from server/internal/nginx/format_code.go rename to internal/nginx/format_code.go diff --git a/server/internal/nginx/log.go b/internal/nginx/log.go similarity index 100% rename from server/internal/nginx/log.go rename to internal/nginx/log.go diff --git a/internal/nginx/nginx.go b/internal/nginx/nginx.go new file mode 100644 index 00000000..8d3b8622 --- /dev/null +++ b/internal/nginx/nginx.go @@ -0,0 +1,99 @@ +package nginx + +import ( + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/settings" + "os/exec" + "path/filepath" + "regexp" +) + +func execShell(cmd string) (out string) { + bytes, err := exec.Command("/bin/sh -c", cmd).CombinedOutput() + out = string(bytes) + if err != nil { + out += " " + err.Error() + } + return +} + +func TestConf() (out string) { + if settings.NginxSettings.TestConfigCmd != "" { + out = execShell(settings.NginxSettings.TestConfigCmd) + + return + } + + out = execShell("nginx -t") + + return +} + +func Reload() (out string) { + if settings.NginxSettings.ReloadCmd != "" { + out = execShell(settings.NginxSettings.ReloadCmd) + return + } + + out = execShell("nginx -s reload") + + return +} + +func Restart() (out string) { + if settings.NginxSettings.RestartCmd != "" { + out = execShell(settings.NginxSettings.RestartCmd) + + return + } + + out = execShell("nginx -s reopen") + + return +} + +func GetConfPath(dir ...string) string { + var confPath string + + if settings.NginxSettings.ConfigDir == "" { + out, err := exec.Command("nginx", "-V").CombinedOutput() + if err != nil { + logger.Error(err) + return "" + } + r, _ := regexp.Compile("--conf-path=(.*)/(.*.conf)") + match := r.FindStringSubmatch(string(out)) + if len(match) < 1 { + logger.Error("nginx.GetConfPath len(match) < 1") + return "" + } + confPath = r.FindStringSubmatch(string(out))[1] + } else { + confPath = settings.NginxSettings.ConfigDir + } + + return filepath.Join(confPath, filepath.Join(dir...)) +} + +func GetNginxPIDPath() string { + var confPath string + + if settings.NginxSettings.PIDPath == "" { + out, err := exec.Command("nginx", "-V").CombinedOutput() + if err != nil { + logger.Error(err) + return "" + } + r, _ := regexp.Compile("--pid-path=(.*.pid)") + match := r.FindStringSubmatch(string(out)) + if len(match) < 1 { + logger.Error("nginx.GetNginxPIDPath len(match) < 1") + return "" + } + confPath = r.FindStringSubmatch(string(out))[1] + } else { + confPath = settings.NginxSettings.PIDPath + } + + return confPath +} diff --git a/server/internal/nginx/ngx_conf_parse_test.go b/internal/nginx/ngx_conf_parse_test.go similarity index 100% rename from server/internal/nginx/ngx_conf_parse_test.go rename to internal/nginx/ngx_conf_parse_test.go diff --git a/server/internal/nginx/parse.go b/internal/nginx/parse.go similarity index 100% rename from server/internal/nginx/parse.go rename to internal/nginx/parse.go diff --git a/server/internal/nginx/type.go b/internal/nginx/type.go similarity index 100% rename from server/internal/nginx/type.go rename to internal/nginx/type.go diff --git a/server/internal/pty/pipeline.go b/internal/pty/pipeline.go similarity index 97% rename from server/internal/pty/pipeline.go rename to internal/pty/pipeline.go index e9c245b4..80f821a7 100644 --- a/server/internal/pty/pipeline.go +++ b/internal/pty/pipeline.go @@ -2,8 +2,8 @@ package pty import ( "encoding/json" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/settings" "github.com/creack/pty" "github.com/gorilla/websocket" "github.com/pkg/errors" diff --git a/server/internal/pty/type.go b/internal/pty/type.go similarity index 100% rename from server/internal/pty/type.go rename to internal/pty/type.go diff --git a/server/internal/template/template.go b/internal/template/template.go similarity index 93% rename from server/internal/template/template.go rename to internal/template/template.go index b12d61df..73c1839f 100644 --- a/server/internal/template/template.go +++ b/internal/template/template.go @@ -3,9 +3,9 @@ package template import ( "bufio" "bytes" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/logger" + nginx2 "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/settings" templ "github.com/0xJacky/Nginx-UI/template" "github.com/BurntSushi/toml" "github.com/gin-gonic/gin" @@ -71,7 +71,7 @@ func GetTemplateInfo(path, name string) (configListItem ConfigInfoItem) { type ConfigDetail struct { Custom string `json:"custom"` - nginx.NgxServer + nginx2.NgxServer } func ParseTemplate(path, name string, bindData map[string]TVariable) (c ConfigDetail, err error) { @@ -160,14 +160,14 @@ func ParseTemplate(path, name string, bindData map[string]TVariable) (c ConfigDe c.Custom = custom for _, d := range config.GetDirectives() { switch d.GetName() { - case nginx.Location: - l := &nginx.NgxLocation{ + case nginx2.Location: + l := &nginx2.NgxLocation{ Path: strings.Join(d.GetParameters(), " "), } l.ParseLocation(d, 0) c.NgxServer.Locations = append(c.NgxServer.Locations, l) default: - dir := &nginx.NgxDirective{ + dir := &nginx2.NgxDirective{ Directive: d.GetName(), } dir.ParseDirective(d, 0) diff --git a/server/internal/translation/translation.go b/internal/translation/translation.go similarity index 83% rename from server/internal/translation/translation.go rename to internal/translation/translation.go index e9fd7f64..29d8c10f 100644 --- a/server/internal/translation/translation.go +++ b/internal/translation/translation.go @@ -2,7 +2,7 @@ package translation import ( "fmt" - "github.com/0xJacky/Nginx-UI/frontend" + "github.com/0xJacky/Nginx-UI/app" "github.com/0xJacky/pofile/pofile" "io" "log" @@ -21,7 +21,7 @@ func init() { } func handlePo(langCode string) { - file, err := frontend.DistFS.Open(fmt.Sprintf("src/language/%s/app.po", langCode)) + file, err := app.DistFS.Open(fmt.Sprintf("src/language/%s/app.po", langCode)) if err != nil { log.Fatalln(err) diff --git a/server/internal/upgrader/upgrade.go b/internal/upgrader/upgrade.go similarity index 94% rename from server/internal/upgrader/upgrade.go rename to internal/upgrader/upgrade.go index a461243b..74a895aa 100644 --- a/server/internal/upgrader/upgrade.go +++ b/internal/upgrader/upgrade.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" _github "github.com/0xJacky/Nginx-UI/.github" - "github.com/0xJacky/Nginx-UI/frontend" - "github.com/0xJacky/Nginx-UI/server/internal/helper" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/app" + helper2 "github.com/0xJacky/Nginx-UI/internal/helper" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/settings" "github.com/pkg/errors" "io" "net/http" @@ -154,7 +154,7 @@ type CurVersion struct { } func GetCurrentVersion() (c CurVersion, err error) { - verJson, err := frontend.DistFS.ReadFile("dist/version.json") + verJson, err := app.DistFS.ReadFile("dist/version.json") if err != nil { err = errors.Wrap(err, "service.GetCurrentVersion ReadFile err") return @@ -322,10 +322,10 @@ func (u *Upgrader) DownloadLatestRelease(progressChan chan float64) (tarName str digestFileContent := strings.TrimSpace(string(digestFileBytes)) - logger.Debug("DownloadLatestRelease tar digest", helper.DigestSHA512(tarName)) + logger.Debug("DownloadLatestRelease tar digest", helper2.DigestSHA512(tarName)) logger.Debug("DownloadLatestRelease digestFileContent", digestFileContent) - if digestFileContent != helper.DigestSHA512(tarName) { + if digestFileContent != helper2.DigestSHA512(tarName) { err = errors.Wrap(err, "digest not equal") return } @@ -335,7 +335,7 @@ func (u *Upgrader) DownloadLatestRelease(progressChan chan float64) (tarName str func (u *Upgrader) PerformCoreUpgrade(exPath string, tarPath string) (err error) { dir := filepath.Dir(exPath) - err = helper.UnTar(dir, tarPath) + err = helper2.UnTar(dir, tarPath) if err != nil { err = errors.Wrap(err, "PerformCoreUpgrade unTar error") return diff --git a/main.go b/main.go index 61bcf0ed..6e69e1a9 100644 --- a/main.go +++ b/main.go @@ -3,14 +3,36 @@ package main import ( "flag" "fmt" - "github.com/0xJacky/Nginx-UI/server" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/boot" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/nginx" + "github.com/0xJacky/Nginx-UI/internal/upgrader" + "github.com/0xJacky/Nginx-UI/router" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/jpillora/overseer" "github.com/jpillora/overseer/fetcher" "log" + "net/http" ) +func Program(state overseer.State) { + defer logger.Sync() + + logger.Infof("Nginx configuration directory: %s", nginx.GetConfPath()) + + boot.Kernel() + + if state.Listener != nil { + err := http.Serve(state.Listener, router.InitRouter()) + if err != nil { + logger.Error(err) + } + } + + logger.Info("Server exited") +} + func main() { var confPath string flag.StringVar(&confPath, "config", "app.ini", "Specify the configuration file") @@ -20,14 +42,14 @@ func main() { gin.SetMode(settings.ServerSettings.RunMode) - r, err := server.GetRuntimeInfo() + r, err := upgrader.GetRuntimeInfo() if err != nil { log.Fatalln(err) } overseer.Run(overseer.Config{ - Program: server.Program, + Program: Program, Address: fmt.Sprintf("%s:%s", settings.ServerSettings.HttpHost, settings.ServerSettings.HttpPort), Fetcher: &fetcher.File{Path: r.ExPath}, TerminateTimeout: 0, diff --git a/server/model/auth.go b/model/auth.go similarity index 97% rename from server/model/auth.go rename to model/auth.go index 405493ea..b34d36c4 100644 --- a/server/model/auth.go +++ b/model/auth.go @@ -1,7 +1,7 @@ package model import ( - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/golang-jwt/jwt" "time" diff --git a/server/model/cert.go b/model/cert.go similarity index 97% rename from server/model/cert.go rename to model/cert.go index eed9660e..b957992f 100644 --- a/server/model/cert.go +++ b/model/cert.go @@ -1,7 +1,7 @@ package model import ( - "github.com/0xJacky/Nginx-UI/server/internal/nginx" + "github.com/0xJacky/Nginx-UI/internal/nginx" "github.com/lib/pq" "os" ) diff --git a/server/model/chatgpt_log.go b/model/chatgpt_log.go similarity index 100% rename from server/model/chatgpt_log.go rename to model/chatgpt_log.go diff --git a/server/model/config_backup.go b/model/config_backup.go similarity index 94% rename from server/model/config_backup.go rename to model/config_backup.go index ea85c419..020a121e 100644 --- a/server/model/config_backup.go +++ b/model/config_backup.go @@ -1,7 +1,7 @@ package model import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/logger" "os" "path/filepath" ) diff --git a/server/model/dns_credential.go b/model/dns_credential.go similarity index 79% rename from server/model/dns_credential.go rename to model/dns_credential.go index b3918871..f5a634c1 100644 --- a/server/model/dns_credential.go +++ b/model/dns_credential.go @@ -1,7 +1,7 @@ package model import ( - "github.com/0xJacky/Nginx-UI/server/internal/cert/dns" + "github.com/0xJacky/Nginx-UI/internal/cert/dns" ) type DnsCredential struct { diff --git a/server/model/environment.go b/model/environment.go similarity index 100% rename from server/model/environment.go rename to model/environment.go diff --git a/server/model/log.go b/model/log.go similarity index 100% rename from server/model/log.go rename to model/log.go diff --git a/server/model/model.go b/model/model.go similarity index 96% rename from server/model/model.go rename to model/model.go index 1b7d706a..8e0ef1af 100644 --- a/server/model/model.go +++ b/model/model.go @@ -2,8 +2,8 @@ package model import ( "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/settings" "github.com/gin-gonic/gin" "github.com/spf13/cast" "gorm.io/driver/sqlite" diff --git a/server/model/site.go b/model/site.go similarity index 100% rename from server/model/site.go rename to model/site.go diff --git a/server/query/auth_tokens.gen.go b/query/auth_tokens.gen.go similarity index 99% rename from server/query/auth_tokens.gen.go rename to query/auth_tokens.gen.go index ed72035b..d80cd0b0 100644 --- a/server/query/auth_tokens.gen.go +++ b/query/auth_tokens.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newAuthToken(db *gorm.DB, opts ...gen.DOOption) authToken { diff --git a/server/query/auths.gen.go b/query/auths.gen.go similarity index 99% rename from server/query/auths.gen.go rename to query/auths.gen.go index 9d1c4ac0..c1419090 100644 --- a/server/query/auths.gen.go +++ b/query/auths.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newAuth(db *gorm.DB, opts ...gen.DOOption) auth { diff --git a/server/query/certs.gen.go b/query/certs.gen.go similarity index 86% rename from server/query/certs.gen.go rename to query/certs.gen.go index 9870cb79..682765da 100644 --- a/server/query/certs.gen.go +++ b/query/certs.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + model2 "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,15 +17,13 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newCert(db *gorm.DB, opts ...gen.DOOption) cert { _cert := cert{} _cert.certDo.UseDB(db, opts...) - _cert.certDo.UseModel(&model.Cert{}) + _cert.certDo.UseModel(&model2.Cert{}) tableName := _cert.certDo.TableName() _cert.ALL = field.NewAsterisk(tableName) @@ -68,8 +67,8 @@ type cert struct { AutoCert field.Int ChallengeMethod field.String DnsCredentialID field.Int - Log field.String - DnsCredential certBelongsToDnsCredential + Log field.String + DnsCredential certBelongsToDnsCredential fieldMap map[string]field.Expr } @@ -171,17 +170,17 @@ func (a certBelongsToDnsCredential) Session(session *gorm.Session) *certBelongsT return &a } -func (a certBelongsToDnsCredential) Model(m *model.Cert) *certBelongsToDnsCredentialTx { +func (a certBelongsToDnsCredential) Model(m *model2.Cert) *certBelongsToDnsCredentialTx { return &certBelongsToDnsCredentialTx{a.db.Model(m).Association(a.Name())} } type certBelongsToDnsCredentialTx struct{ tx *gorm.Association } -func (a certBelongsToDnsCredentialTx) Find() (result *model.DnsCredential, err error) { +func (a certBelongsToDnsCredentialTx) Find() (result *model2.DnsCredential, err error) { return result, a.tx.Find(&result) } -func (a certBelongsToDnsCredentialTx) Append(values ...*model.DnsCredential) (err error) { +func (a certBelongsToDnsCredentialTx) Append(values ...*model2.DnsCredential) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v @@ -189,7 +188,7 @@ func (a certBelongsToDnsCredentialTx) Append(values ...*model.DnsCredential) (er return a.tx.Append(targetValues...) } -func (a certBelongsToDnsCredentialTx) Replace(values ...*model.DnsCredential) (err error) { +func (a certBelongsToDnsCredentialTx) Replace(values ...*model2.DnsCredential) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v @@ -197,7 +196,7 @@ func (a certBelongsToDnsCredentialTx) Replace(values ...*model.DnsCredential) (e return a.tx.Replace(targetValues...) } -func (a certBelongsToDnsCredentialTx) Delete(values ...*model.DnsCredential) (err error) { +func (a certBelongsToDnsCredentialTx) Delete(values ...*model2.DnsCredential) (err error) { targetValues := make([]interface{}, len(values)) for i, v := range values { targetValues[i] = v @@ -216,7 +215,7 @@ func (a certBelongsToDnsCredentialTx) Count() int64 { type certDo struct{ gen.DO } // FirstByID Where("id=@id") -func (c certDo) FirstByID(id int) (result *model.Cert, err error) { +func (c certDo) FirstByID(id int) (result *model2.Cert, err error) { var params []interface{} var generateSQL strings.Builder @@ -341,57 +340,57 @@ func (c certDo) Unscoped() *certDo { return c.withDO(c.DO.Unscoped()) } -func (c certDo) Create(values ...*model.Cert) error { +func (c certDo) Create(values ...*model2.Cert) error { if len(values) == 0 { return nil } return c.DO.Create(values) } -func (c certDo) CreateInBatches(values []*model.Cert, batchSize int) error { +func (c certDo) CreateInBatches(values []*model2.Cert, batchSize int) error { return c.DO.CreateInBatches(values, batchSize) } // Save : !!! underlying implementation is different with GORM // The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (c certDo) Save(values ...*model.Cert) error { +func (c certDo) Save(values ...*model2.Cert) error { if len(values) == 0 { return nil } return c.DO.Save(values) } -func (c certDo) First() (*model.Cert, error) { +func (c certDo) First() (*model2.Cert, error) { if result, err := c.DO.First(); err != nil { return nil, err } else { - return result.(*model.Cert), nil + return result.(*model2.Cert), nil } } -func (c certDo) Take() (*model.Cert, error) { +func (c certDo) Take() (*model2.Cert, error) { if result, err := c.DO.Take(); err != nil { return nil, err } else { - return result.(*model.Cert), nil + return result.(*model2.Cert), nil } } -func (c certDo) Last() (*model.Cert, error) { +func (c certDo) Last() (*model2.Cert, error) { if result, err := c.DO.Last(); err != nil { return nil, err } else { - return result.(*model.Cert), nil + return result.(*model2.Cert), nil } } -func (c certDo) Find() ([]*model.Cert, error) { +func (c certDo) Find() ([]*model2.Cert, error) { result, err := c.DO.Find() - return result.([]*model.Cert), err + return result.([]*model2.Cert), err } -func (c certDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Cert, err error) { - buf := make([]*model.Cert, 0, batchSize) +func (c certDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model2.Cert, err error) { + buf := make([]*model2.Cert, 0, batchSize) err = c.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { defer func() { results = append(results, buf...) }() return fc(tx, batch) @@ -399,7 +398,7 @@ func (c certDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) return results, err } -func (c certDo) FindInBatches(result *[]*model.Cert, batchSize int, fc func(tx gen.Dao, batch int) error) error { +func (c certDo) FindInBatches(result *[]*model2.Cert, batchSize int, fc func(tx gen.Dao, batch int) error) error { return c.DO.FindInBatches(result, batchSize, fc) } @@ -425,23 +424,23 @@ func (c certDo) Preload(fields ...field.RelationField) *certDo { return &c } -func (c certDo) FirstOrInit() (*model.Cert, error) { +func (c certDo) FirstOrInit() (*model2.Cert, error) { if result, err := c.DO.FirstOrInit(); err != nil { return nil, err } else { - return result.(*model.Cert), nil + return result.(*model2.Cert), nil } } -func (c certDo) FirstOrCreate() (*model.Cert, error) { +func (c certDo) FirstOrCreate() (*model2.Cert, error) { if result, err := c.DO.FirstOrCreate(); err != nil { return nil, err } else { - return result.(*model.Cert), nil + return result.(*model2.Cert), nil } } -func (c certDo) FindByPage(offset int, limit int) (result []*model.Cert, count int64, err error) { +func (c certDo) FindByPage(offset int, limit int) (result []*model2.Cert, count int64, err error) { result, err = c.Offset(offset).Limit(limit).Find() if err != nil { return @@ -470,7 +469,7 @@ func (c certDo) Scan(result interface{}) (err error) { return c.DO.Scan(result) } -func (c certDo) Delete(models ...*model.Cert) (result gen.ResultInfo, err error) { +func (c certDo) Delete(models ...*model2.Cert) (result gen.ResultInfo, err error) { return c.DO.Delete(models) } diff --git a/server/query/chat_gpt_logs.gen.go b/query/chat_gpt_logs.gen.go similarity index 99% rename from server/query/chat_gpt_logs.gen.go rename to query/chat_gpt_logs.gen.go index 8e619c44..b7ebc914 100644 --- a/server/query/chat_gpt_logs.gen.go +++ b/query/chat_gpt_logs.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newChatGPTLog(db *gorm.DB, opts ...gen.DOOption) chatGPTLog { diff --git a/server/query/config_backups.gen.go b/query/config_backups.gen.go similarity index 99% rename from server/query/config_backups.gen.go rename to query/config_backups.gen.go index a1f195b1..5e7ee870 100644 --- a/server/query/config_backups.gen.go +++ b/query/config_backups.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newConfigBackup(db *gorm.DB, opts ...gen.DOOption) configBackup { diff --git a/server/query/dns_credentials.gen.go b/query/dns_credentials.gen.go similarity index 99% rename from server/query/dns_credentials.gen.go rename to query/dns_credentials.gen.go index b2adba4d..dccc24d4 100644 --- a/server/query/dns_credentials.gen.go +++ b/query/dns_credentials.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newDnsCredential(db *gorm.DB, opts ...gen.DOOption) dnsCredential { diff --git a/server/query/environments.gen.go b/query/environments.gen.go similarity index 99% rename from server/query/environments.gen.go rename to query/environments.gen.go index 42a8186c..a8b4500d 100644 --- a/server/query/environments.gen.go +++ b/query/environments.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newEnvironment(db *gorm.DB, opts ...gen.DOOption) environment { diff --git a/server/query/gen.go b/query/gen.go similarity index 100% rename from server/query/gen.go rename to query/gen.go diff --git a/server/query/query.go b/query/query.go similarity index 100% rename from server/query/query.go rename to query/query.go diff --git a/server/query/sites.gen.go b/query/sites.gen.go similarity index 99% rename from server/query/sites.gen.go rename to query/sites.gen.go index f31508f9..410925c5 100644 --- a/server/query/sites.gen.go +++ b/query/sites.gen.go @@ -6,6 +6,7 @@ package query import ( "context" + "github.com/0xJacky/Nginx-UI/model" "strings" "gorm.io/gorm" @@ -16,8 +17,6 @@ import ( "gorm.io/gen/field" "gorm.io/plugin/dbresolver" - - "github.com/0xJacky/Nginx-UI/server/model" ) func newSite(db *gorm.DB, opts ...gen.DOOption) site { diff --git a/resources/screenshots/dashboard_en.png b/resources/screenshots/dashboard_en.png index 6097934d..968f7fc3 100644 Binary files a/resources/screenshots/dashboard_en.png and b/resources/screenshots/dashboard_en.png differ diff --git a/server/router/middleware.go b/router/middleware.go similarity index 87% rename from server/router/middleware.go rename to router/middleware.go index 6296cbcc..dd79bc89 100644 --- a/server/router/middleware.go +++ b/router/middleware.go @@ -1,19 +1,19 @@ package router import ( - "encoding/base64" - "github.com/0xJacky/Nginx-UI/frontend" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/settings" - "github.com/gin-contrib/static" - "github.com/gin-gonic/gin" - "github.com/spf13/cast" - "io/fs" - "net/http" - "path" - "runtime" - "strings" + "encoding/base64" + "github.com/0xJacky/Nginx-UI/app" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/model" + "github.com/0xJacky/Nginx-UI/settings" + "github.com/gin-contrib/static" + "github.com/gin-gonic/gin" + "github.com/spf13/cast" + "io/fs" + "net/http" + "path" + "runtime" + "strings" ) func recovery() gin.HandlerFunc { diff --git a/server/router/operation_sync.go b/router/operation_sync.go similarity index 97% rename from server/router/operation_sync.go rename to router/operation_sync.go index b6d98565..d6133478 100644 --- a/server/router/operation_sync.go +++ b/router/operation_sync.go @@ -5,8 +5,8 @@ import ( "crypto/tls" "encoding/json" "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/analytic" - "github.com/0xJacky/Nginx-UI/server/internal/logger" + "github.com/0xJacky/Nginx-UI/internal/analytic" + "github.com/0xJacky/Nginx-UI/internal/logger" "github.com/gin-gonic/gin" "github.com/pkg/errors" "io" diff --git a/server/router/proxy.go b/router/proxy.go similarity index 94% rename from server/router/proxy.go rename to router/proxy.go index 13ad0e4b..ac2fb72a 100644 --- a/server/router/proxy.go +++ b/router/proxy.go @@ -2,8 +2,8 @@ package router import ( "crypto/tls" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/query" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/query" "github.com/gin-gonic/gin" "github.com/spf13/cast" "io" diff --git a/server/router/proxy_ws.go b/router/proxy_ws.go similarity index 90% rename from server/router/proxy_ws.go rename to router/proxy_ws.go index f3d71576..29c4efd4 100644 --- a/server/router/proxy_ws.go +++ b/router/proxy_ws.go @@ -1,8 +1,8 @@ package router import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/query" + "github.com/0xJacky/Nginx-UI/internal/logger" + "github.com/0xJacky/Nginx-UI/query" "github.com/gin-gonic/gin" "github.com/pretty66/websocketproxy" "github.com/spf13/cast" diff --git a/router/routers.go b/router/routers.go new file mode 100644 index 00000000..fb9295ef --- /dev/null +++ b/router/routers.go @@ -0,0 +1,157 @@ +package router + +import ( + api2 "github.com/0xJacky/Nginx-UI/api" + "github.com/gin-contrib/static" + "github.com/gin-gonic/gin" + "net/http" +) + +func InitRouter() *gin.Engine { + r := gin.New() + r.Use(gin.Logger()) + + r.Use(recovery()) + + r.Use(cacheJs()) + + //r.Use(OperationSync()) + + r.Use(static.Serve("/", mustFS(""))) + + r.NoRoute(func(c *gin.Context) { + c.JSON(http.StatusNotFound, gin.H{ + "message": "not found", + }) + }) + + root := r.Group("/api") + { + root.GET("install", api2.InstallLockCheck) + root.POST("install", api2.InstallNginxUI) + + root.POST("/login", api2.Login) + root.DELETE("/logout", api2.Logout) + + root.GET("/casdoor_uri", api2.GetCasdoorUri) + root.POST("/casdoor_callback", api2.CasdoorCallback) + + // translation + root.GET("translation/:code", api2.GetTranslation) + + w := root.Group("/", authRequired(), proxyWs()) + { + // Analytic + w.GET("analytic", api2.Analytic) + w.GET("analytic/intro", api2.GetNodeStat) + w.GET("analytic/nodes", api2.GetNodesAnalytic) + // pty + w.GET("pty", api2.Pty) + // Nginx log + w.GET("nginx_log", api2.NginxLog) + } + + g := root.Group("/", authRequired(), proxy()) + { + + g.GET("analytic/init", api2.GetAnalyticInit) + + g.GET("users", api2.GetUsers) + g.GET("user/:id", api2.GetUser) + g.POST("user", api2.AddUser) + g.POST("user/:id", api2.EditUser) + g.DELETE("user/:id", api2.DeleteUser) + + g.GET("domains", api2.GetDomains) + g.GET("domain/:name", api2.GetDomain) + + // Modify site configuration directly + g.POST("domain/:name", api2.SaveDomain) + + // Transform NgxConf to nginx configuration + g.POST("ngx/build_config", api2.BuildNginxConfig) + // Tokenized nginx configuration to NgxConf + g.POST("ngx/tokenize_config", api2.TokenizeNginxConfig) + // Format nginx configuration code + g.POST("ngx/format_code", api2.FormatNginxConfig) + + g.POST("nginx/reload", api2.ReloadNginx) + g.POST("nginx/restart", api2.RestartNginx) + g.POST("nginx/test", api2.TestNginx) + g.GET("nginx/status", api2.NginxStatus) + + g.POST("domain/:name/enable", api2.EnableDomain) + g.POST("domain/:name/disable", api2.DisableDomain) + g.POST("domain/:name/advance", api2.DomainEditByAdvancedMode) + + g.DELETE("domain/:name", api2.DeleteDomain) + + g.POST("domain/:name/duplicate", api2.DuplicateSite) + g.GET("domain/:name/cert", api2.IssueCert) + + g.GET("configs", api2.GetConfigs) + g.GET("config/*name", api2.GetConfig) + g.POST("config", api2.AddConfig) + g.POST("config/*name", api2.EditConfig) + + //g.GET("backups", api.GetFileBackupList) + //g.GET("backup/:id", api.GetFileBackup) + + g.GET("template", api2.GetTemplate) + g.GET("template/configs", api2.GetTemplateConfList) + g.GET("template/blocks", api2.GetTemplateBlockList) + g.GET("template/block/:name", api2.GetTemplateBlock) + g.POST("template/block/:name", api2.GetTemplateBlock) + + g.GET("certs", api2.GetCertList) + g.GET("cert/:id", api2.GetCert) + g.POST("cert", api2.AddCert) + g.POST("cert/:id", api2.ModifyCert) + g.DELETE("cert/:id", api2.RemoveCert) + + // Add domain to auto-renew cert list + g.POST("auto_cert/:name", api2.AddDomainToAutoCert) + // Delete domain from auto-renew cert list + g.DELETE("auto_cert/:name", api2.RemoveDomainFromAutoCert) + g.GET("auto_cert/dns/providers", api2.GetDNSProvidersList) + g.GET("auto_cert/dns/provider/:code", api2.GetDNSProvider) + + // DNS Credential + g.GET("dns_credentials", api2.GetDnsCredentialList) + g.GET("dns_credential/:id", api2.GetDnsCredential) + g.POST("dns_credential", api2.AddDnsCredential) + g.POST("dns_credential/:id", api2.EditDnsCredential) + g.DELETE("dns_credential/:id", api2.DeleteDnsCredential) + + g.POST("nginx_log", api2.GetNginxLogPage) + + // Settings + g.GET("settings", api2.GetSettings) + g.POST("settings", api2.SaveSettings) + + // Upgrade + g.GET("upgrade/release", api2.GetRelease) + g.GET("upgrade/current", api2.GetCurrentVersion) + g.GET("upgrade/perform", api2.PerformCoreUpgrade) + + // ChatGPT + g.POST("chat_gpt", api2.MakeChatCompletionRequest) + g.POST("chat_gpt_record", api2.StoreChatGPTRecord) + + // Environment + g.GET("environments", api2.GetEnvironmentList) + envGroup := g.Group("environment") + { + envGroup.GET("/:id", api2.GetEnvironment) + envGroup.POST("", api2.AddEnvironment) + envGroup.POST("/:id", api2.EditEnvironment) + envGroup.DELETE("/:id", api2.DeleteEnvironment) + } + + // node + g.GET("node", api2.GetCurrentNode) + } + } + + return r +} diff --git a/server/api/dns_credential.go b/server/api/dns_credential.go deleted file mode 100644 index 54725052..00000000 --- a/server/api/dns_credential.go +++ /dev/null @@ -1,130 +0,0 @@ -package api - -import ( - "github.com/0xJacky/Nginx-UI/server/internal/cert/dns" - "github.com/0xJacky/Nginx-UI/server/model" - "github.com/0xJacky/Nginx-UI/server/query" - "github.com/gin-gonic/gin" - "github.com/spf13/cast" - "net/http" -) - -func GetDnsCredential(c *gin.Context) { - id := cast.ToInt(c.Param("id")) - - d := query.DnsCredential - - dnsCredential, err := d.FirstByID(id) - if err != nil { - ErrHandler(c, err) - return - } - type apiDnsCredential struct { - model.Model - Name string `json:"name"` - dns.Config - } - c.JSON(http.StatusOK, apiDnsCredential{ - Model: dnsCredential.Model, - Name: dnsCredential.Name, - Config: *dnsCredential.Config, - }) -} - -func GetDnsCredentialList(c *gin.Context) { - d := query.DnsCredential - provider := c.Query("provider") - var data []*model.DnsCredential - var err error - if provider != "" { - data, err = d.Where(d.Provider.Eq(provider)).Find() - } else { - data, err = d.Find() - } - - if err != nil { - ErrHandler(c, err) - return - } - c.JSON(http.StatusOK, gin.H{ - "data": data, - }) -} - -type DnsCredentialManageJson struct { - Name string `json:"name" binding:"required"` - Provider string `json:"provider"` - dns.Config -} - -func AddDnsCredential(c *gin.Context) { - var json DnsCredentialManageJson - if !BindAndValid(c, &json) { - return - } - - json.Config.Name = json.Provider - dnsCredential := model.DnsCredential{ - Name: json.Name, - Config: &json.Config, - Provider: json.Provider, - } - - d := query.DnsCredential - - err := d.Create(&dnsCredential) - if err != nil { - ErrHandler(c, err) - return - } - - c.JSON(http.StatusOK, dnsCredential) -} - -func EditDnsCredential(c *gin.Context) { - id := cast.ToInt(c.Param("id")) - - var json DnsCredentialManageJson - if !BindAndValid(c, &json) { - return - } - - d := query.DnsCredential - - dnsCredential, err := d.FirstByID(id) - if err != nil { - ErrHandler(c, err) - return - } - - json.Config.Name = json.Provider - _, err = d.Where(d.ID.Eq(dnsCredential.ID)).Updates(&model.DnsCredential{ - Name: json.Name, - Config: &json.Config, - Provider: json.Provider, - }) - - if err != nil { - ErrHandler(c, err) - return - } - - GetDnsCredential(c) -} - -func DeleteDnsCredential(c *gin.Context) { - id := cast.ToInt(c.Param("id")) - d := query.DnsCredential - - dnsCredential, err := d.FirstByID(id) - if err != nil { - ErrHandler(c, err) - return - } - err = d.DeleteByID(dnsCredential.ID) - if err != nil { - ErrHandler(c, err) - return - } - c.JSON(http.StatusNoContent, nil) -} diff --git a/server/internal/nginx/nginx.go b/server/internal/nginx/nginx.go deleted file mode 100644 index 04208cb7..00000000 --- a/server/internal/nginx/nginx.go +++ /dev/null @@ -1,99 +0,0 @@ -package nginx - -import ( - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/settings" - "os/exec" - "path/filepath" - "regexp" -) - -func execShell(cmd string) (out string) { - bytes, err := exec.Command("/bin/sh -c", cmd).CombinedOutput() - out = string(bytes) - if err != nil { - out += " " + err.Error() - } - return -} - -func TestConf() (out string) { - if settings.NginxSettings.TestConfigCmd != "" { - out = execShell(settings.NginxSettings.TestConfigCmd) - - return - } - - out = execShell("nginx -t") - - return -} - -func Reload() (out string) { - if settings.NginxSettings.ReloadCmd != "" { - out = execShell(settings.NginxSettings.ReloadCmd) - return - } - - out = execShell("nginx -s reload") - - return -} - -func Restart() (out string) { - if settings.NginxSettings.RestartCmd != "" { - out = execShell(settings.NginxSettings.RestartCmd) - - return - } - - out = execShell("nginx -s reopen") - - return -} - -func GetConfPath(dir ...string) string { - var confPath string - - if settings.NginxSettings.ConfigDir == "" { - out, err := exec.Command("nginx", "-V").CombinedOutput() - if err != nil { - logger.Error(err) - return "" - } - r, _ := regexp.Compile("--conf-path=(.*)/(.*.conf)") - match := r.FindStringSubmatch(string(out)) - if len(match) < 1 { - logger.Error("nginx.GetConfPath len(match) < 1") - return "" - } - confPath = r.FindStringSubmatch(string(out))[1] - } else { - confPath = settings.NginxSettings.ConfigDir - } - - return filepath.Join(confPath, filepath.Join(dir...)) -} - -func GetNginxPIDPath() string { - var confPath string - - if settings.NginxSettings.PIDPath == "" { - out, err := exec.Command("nginx", "-V").CombinedOutput() - if err != nil { - logger.Error(err) - return "" - } - r, _ := regexp.Compile("--pid-path=(.*.pid)") - match := r.FindStringSubmatch(string(out)) - if len(match) < 1 { - logger.Error("nginx.GetNginxPIDPath len(match) < 1") - return "" - } - confPath = r.FindStringSubmatch(string(out))[1] - } else { - confPath = settings.NginxSettings.PIDPath - } - - return confPath -} diff --git a/server/router/routers.go b/server/router/routers.go deleted file mode 100644 index 8ed89f84..00000000 --- a/server/router/routers.go +++ /dev/null @@ -1,157 +0,0 @@ -package router - -import ( - "github.com/0xJacky/Nginx-UI/server/api" - "github.com/gin-contrib/static" - "github.com/gin-gonic/gin" - "net/http" -) - -func InitRouter() *gin.Engine { - r := gin.New() - r.Use(gin.Logger()) - - r.Use(recovery()) - - r.Use(cacheJs()) - - //r.Use(OperationSync()) - - r.Use(static.Serve("/", mustFS(""))) - - r.NoRoute(func(c *gin.Context) { - c.JSON(http.StatusNotFound, gin.H{ - "message": "not found", - }) - }) - - root := r.Group("/api") - { - root.GET("install", api.InstallLockCheck) - root.POST("install", api.InstallNginxUI) - - root.POST("/login", api.Login) - root.DELETE("/logout", api.Logout) - - root.GET("/casdoor_uri", api.GetCasdoorUri) - root.POST("/casdoor_callback", api.CasdoorCallback) - - // translation - root.GET("translation/:code", api.GetTranslation) - - w := root.Group("/", authRequired(), proxyWs()) - { - // Analytic - w.GET("analytic", api.Analytic) - w.GET("analytic/intro", api.GetNodeStat) - w.GET("analytic/nodes", api.GetNodesAnalytic) - // pty - w.GET("pty", api.Pty) - // Nginx log - w.GET("nginx_log", api.NginxLog) - } - - g := root.Group("/", authRequired(), proxy()) - { - - g.GET("analytic/init", api.GetAnalyticInit) - - g.GET("users", api.GetUsers) - g.GET("user/:id", api.GetUser) - g.POST("user", api.AddUser) - g.POST("user/:id", api.EditUser) - g.DELETE("user/:id", api.DeleteUser) - - g.GET("domains", api.GetDomains) - g.GET("domain/:name", api.GetDomain) - - // Modify site configuration directly - g.POST("domain/:name", api.SaveDomain) - - // Transform NgxConf to nginx configuration - g.POST("ngx/build_config", api.BuildNginxConfig) - // Tokenized nginx configuration to NgxConf - g.POST("ngx/tokenize_config", api.TokenizeNginxConfig) - // Format nginx configuration code - g.POST("ngx/format_code", api.FormatNginxConfig) - - g.POST("nginx/reload", api.ReloadNginx) - g.POST("nginx/restart", api.RestartNginx) - g.POST("nginx/test", api.TestNginx) - g.GET("nginx/status", api.NginxStatus) - - g.POST("domain/:name/enable", api.EnableDomain) - g.POST("domain/:name/disable", api.DisableDomain) - g.POST("domain/:name/advance", api.DomainEditByAdvancedMode) - - g.DELETE("domain/:name", api.DeleteDomain) - - g.POST("domain/:name/duplicate", api.DuplicateSite) - g.GET("domain/:name/cert", api.IssueCert) - - g.GET("configs", api.GetConfigs) - g.GET("config/*name", api.GetConfig) - g.POST("config", api.AddConfig) - g.POST("config/*name", api.EditConfig) - - //g.GET("backups", api.GetFileBackupList) - //g.GET("backup/:id", api.GetFileBackup) - - g.GET("template", api.GetTemplate) - g.GET("template/configs", api.GetTemplateConfList) - g.GET("template/blocks", api.GetTemplateBlockList) - g.GET("template/block/:name", api.GetTemplateBlock) - g.POST("template/block/:name", api.GetTemplateBlock) - - g.GET("certs", api.GetCertList) - g.GET("cert/:id", api.GetCert) - g.POST("cert", api.AddCert) - g.POST("cert/:id", api.ModifyCert) - g.DELETE("cert/:id", api.RemoveCert) - - // Add domain to auto-renew cert list - g.POST("auto_cert/:name", api.AddDomainToAutoCert) - // Delete domain from auto-renew cert list - g.DELETE("auto_cert/:name", api.RemoveDomainFromAutoCert) - g.GET("auto_cert/dns/providers", api.GetDNSProvidersList) - g.GET("auto_cert/dns/provider/:code", api.GetDNSProvider) - - // DNS Credential - g.GET("dns_credentials", api.GetDnsCredentialList) - g.GET("dns_credential/:id", api.GetDnsCredential) - g.POST("dns_credential", api.AddDnsCredential) - g.POST("dns_credential/:id", api.EditDnsCredential) - g.DELETE("dns_credential/:id", api.DeleteDnsCredential) - - g.POST("nginx_log", api.GetNginxLogPage) - - // Settings - g.GET("settings", api.GetSettings) - g.POST("settings", api.SaveSettings) - - // Upgrade - g.GET("upgrade/release", api.GetRelease) - g.GET("upgrade/current", api.GetCurrentVersion) - g.GET("upgrade/perform", api.PerformCoreUpgrade) - - // ChatGPT - g.POST("chat_gpt", api.MakeChatCompletionRequest) - g.POST("chat_gpt_record", api.StoreChatGPTRecord) - - // Environment - g.GET("environments", api.GetEnvironmentList) - envGroup := g.Group("environment") - { - envGroup.GET("/:id", api.GetEnvironment) - envGroup.POST("", api.AddEnvironment) - envGroup.POST("/:id", api.EditEnvironment) - envGroup.DELETE("/:id", api.DeleteEnvironment) - } - - // node - g.GET("node", api.GetCurrentNode) - } - } - - return r -} diff --git a/server/server.go b/server/server.go deleted file mode 100644 index 5bbb569c..00000000 --- a/server/server.go +++ /dev/null @@ -1,32 +0,0 @@ -package server - -import ( - "github.com/0xJacky/Nginx-UI/server/internal/boot" - "github.com/0xJacky/Nginx-UI/server/internal/logger" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" - "github.com/0xJacky/Nginx-UI/server/internal/upgrader" - "github.com/0xJacky/Nginx-UI/server/router" - "github.com/jpillora/overseer" - "net/http" -) - -func GetRuntimeInfo() (r upgrader.RuntimeInfo, err error) { - return upgrader.GetRuntimeInfo() -} - -func Program(state overseer.State) { - defer logger.Sync() - - logger.Info("Nginx config dir path: " + nginx.GetConfPath()) - - boot.Kernel() - - if state.Listener != nil { - err := http.Serve(state.Listener, router.InitRouter()) - if err != nil { - logger.Error(err) - } - } - - logger.Info("Server exiting") -} diff --git a/server/settings/settings.go b/settings/settings.go similarity index 100% rename from server/settings/settings.go rename to settings/settings.go diff --git a/server/test/acme_test.go b/test/acme_test.go similarity index 95% rename from server/test/acme_test.go rename to test/acme_test.go index 0f9ae026..8bcef900 100644 --- a/server/test/acme_test.go +++ b/test/acme_test.go @@ -2,7 +2,7 @@ package test import ( "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" + "github.com/0xJacky/Nginx-UI/internal/nginx" "io/ioutil" "log" "os" diff --git a/server/test/analytic_test.go b/test/analytic_test.go similarity index 100% rename from server/test/analytic_test.go rename to test/analytic_test.go diff --git a/server/test/cert_test.go b/test/cert_test.go similarity index 92% rename from server/test/cert_test.go rename to test/cert_test.go index 00cf3e29..1e22fab9 100644 --- a/server/test/cert_test.go +++ b/test/cert_test.go @@ -2,7 +2,7 @@ package test import ( "fmt" - "github.com/0xJacky/Nginx-UI/server/internal/nginx" + "github.com/0xJacky/Nginx-UI/internal/nginx" "log" "os" "os/exec" diff --git a/server/test/chatgpt_test.go b/test/chatgpt_test.go similarity index 95% rename from server/test/chatgpt_test.go rename to test/chatgpt_test.go index 35693eb7..d7726876 100644 --- a/server/test/chatgpt_test.go +++ b/test/chatgpt_test.go @@ -3,7 +3,7 @@ package test import ( "context" "fmt" - "github.com/0xJacky/Nginx-UI/server/settings" + "github.com/0xJacky/Nginx-UI/settings" "github.com/pkg/errors" "github.com/sashabaranov/go-openai" "io" diff --git a/server/test/lego_test.go b/test/lego_test.go similarity index 100% rename from server/test/lego_test.go rename to test/lego_test.go diff --git a/server/test/nginx_test.go b/test/nginx_test.go similarity index 100% rename from server/test/nginx_test.go rename to test/nginx_test.go