diff --git a/README.md b/README.md index 35d9ea5..17ccf60 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ ![](https://img.shields.io/github/v/release/alireza0/s-ui.svg) ![S-UI Docker pull](https://img.shields.io/docker/pulls/alireza7/s-ui.svg) -![S-UI-Singbox Docker pull](https://img.shields.io/docker/pulls/alireza7/s-ui-singbox.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/alireza0/s-ui)](https://goreportcard.com/report/github.com/alireza0/s-ui) [![Downloads](https://img.shields.io/github/downloads/alireza0/s-ui/total.svg)](https://img.shields.io/github/downloads/alireza0/s-ui/total.svg) [![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true)](https://www.gnu.org/licenses/gpl-3.0.en.html) diff --git a/config/config.go b/config/config.go index 85b2859..36cb611 100644 --- a/config/config.go +++ b/config/config.go @@ -51,7 +51,7 @@ func GetDBFolderPath() string { if dbFolderPath == "" { dir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { - dbFolderPath = "/usr/local/s-ui/db" + return "/usr/local/s-ui/db" } dbFolderPath = dir + "/db" } diff --git a/service/inbounds.go b/service/inbounds.go index c3f1dfb..84782b3 100644 --- a/service/inbounds.go +++ b/service/inbounds.go @@ -336,6 +336,9 @@ func (s *InboundService) RestartInbounds(tx *gorm.DB, ids []uint) error { return err } inboundConfig, err = s.addUsers(tx, inboundConfig, inbound.Id, inbound.Type) + if err != nil { + return err + } err = corePtr.AddInbound(inboundConfig) if err != nil { return err diff --git a/service/server.go b/service/server.go index 60cd1b9..aec10b7 100644 --- a/service/server.go +++ b/service/server.go @@ -185,7 +185,7 @@ func (s *ServerService) generateECHKeyPair(options string) []string { } func (s *ServerService) generateTLSKeyPair(serverName string) []string { - privateKeyPem, publicKeyPem, err := tls.GenerateKeyPair(time.Now, serverName, time.Now().AddDate(0, 12, 0)) + privateKeyPem, publicKeyPem, err := tls.GenerateCertificate(nil, nil, time.Now, serverName, time.Now().AddDate(0, 12, 0)) if err != nil { return []string{"Failed to generate TLS keypair: ", err.Error()} } diff --git a/service/setting.go b/service/setting.go index 7a58be7..e31e5c4 100644 --- a/service/setting.go +++ b/service/setting.go @@ -358,7 +358,7 @@ func (s *SettingService) Save(tx *gorm.DB, data json.RawMessage) error { return err } for key, obj := range settings { - // Secure file existance check + // Secure file existence check if obj != "" && (key == "webCertFile" || key == "webKeyFile" || key == "subCertFile" || diff --git a/util/outJson.go b/util/outJson.go index 39145be..0468afa 100644 --- a/util/outJson.go +++ b/util/outJson.go @@ -25,6 +25,9 @@ func FillOutJson(i *model.Inbound, hostname string) error { } inbound, err := i.MarshalFull() + if err != nil { + return err + } outJson["type"] = i.Type outJson["tag"] = i.Tag diff --git a/web/web.go b/web/web.go index 5ac72a7..dc877c3 100644 --- a/web/web.go +++ b/web/web.go @@ -24,7 +24,7 @@ import ( "github.com/gin-gonic/gin" ) -//go:embed html/* +//go:embed * var content embed.FS type Server struct {