Added Https service. Fix for #188 How enable https? (#312)

* https service added on port 8091 default

* https port check

* format

* readme

* readme

* readme

* readme

---------

Co-authored-by: evfedoto <evfedoto@cisco.com>
Co-authored-by: nikk <tsynik@gmail.com>
This commit is contained in:
Evgeni
2023-11-13 00:50:11 +01:00
committed by GitHub
parent 792f87380d
commit a91e6eb11b
23 changed files with 46811 additions and 2120 deletions

View File

@@ -23,6 +23,10 @@ import (
type args struct {
Port string `arg:"-p" help:"web server port, default 8090"`
Ssl bool `help:"enables https"`
SslPort string `help:"web server ssl port, If not set, will be set to default 8091 or taken from db(if stored previously). Accepted if --ssl enabled."`
SslCert string `help:"path to ssl cert file. If not set, will be taken from db(if stored previously) or default self-signed certificate/key will be generated. Accepted if --ssl enabled."`
SslKey string `help:"path to ssl key file. If not set, will be taken from db(if stored previously) or default self-signed certificate/key will be generated. Accepted if --ssl enabled."`
Path string `arg:"-d" help:"database dir path"`
LogPath string `arg:"-l" help:"server log file path"`
WebLogPath string `arg:"-w" help:"web access log file path"`
@@ -56,6 +60,10 @@ func main() {
params.Port = "8090"
}
if params.SslPort == "" {
params.SslPort = "8091"
}
settings.Path = params.Path
settings.HttpAuth = params.HttpAuth
log.Init(params.LogPath, params.WebLogPath)
@@ -71,7 +79,11 @@ func main() {
if params.UI {
go func() {
time.Sleep(time.Second)
browser.OpenURL("http://127.0.0.1:" + params.Port)
if params.Ssl {
browser.OpenURL("https://127.0.0.1:" + params.SslPort)
} else {
browser.OpenURL("http://127.0.0.1:" + params.Port)
}
}()
}
@@ -91,7 +103,7 @@ func main() {
go watchTDir(params.TorrentsDir)
}
server.Start(params.Port, params.RDB, params.SearchWA)
server.Start(params.Port, params.SslPort, params.SslCert, params.SslKey, params.Ssl, params.RDB, params.SearchWA)
log.TLogln(server.WaitServer())
log.Close()
time.Sleep(time.Second * 3)