mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
disable https for dlna and fic certs path
This commit is contained in:
@@ -236,23 +236,22 @@ func loadTorrent(path, host string) (ret []interface{}) {
|
|||||||
|
|
||||||
func getLink(host, path string) string {
|
func getLink(host, path string) string {
|
||||||
if !strings.HasPrefix(host, "http") {
|
if !strings.HasPrefix(host, "http") {
|
||||||
if settings.Ssl {
|
// if settings.Ssl {
|
||||||
host = "https://" + host
|
// host = "https://" + host
|
||||||
} else {
|
// } else {
|
||||||
host = "http://" + host
|
host = "http://" + host
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
pos := strings.LastIndex(host, ":")
|
pos := strings.LastIndex(host, ":")
|
||||||
if pos > 7 {
|
if pos > 7 {
|
||||||
host = host[:pos]
|
host = host[:pos]
|
||||||
}
|
}
|
||||||
if settings.Ssl {
|
// if settings.Ssl {
|
||||||
return host + ":" + settings.SslPort + "/" + path
|
// return host + ":" + settings.SslPort + "/" + path
|
||||||
} else {
|
// } else {
|
||||||
return host + ":" + settings.Port + "/" + path
|
return host + ":" + settings.Port + "/" + path
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getObjFromTorrent(path, parent, host string, torr *torr.Torrent, file *state.TorrentFileStat) (ret interface{}) {
|
func getObjFromTorrent(path, parent, host string, torr *torr.Torrent, file *state.TorrentFileStat) (ret interface{}) {
|
||||||
|
|||||||
@@ -12,19 +12,16 @@ import (
|
|||||||
|
|
||||||
func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA bool) {
|
func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA bool) {
|
||||||
settings.InitSets(roSets, searchWA)
|
settings.InitSets(roSets, searchWA)
|
||||||
|
// https checks
|
||||||
//// https checks
|
|
||||||
// check if ssl enabled
|
|
||||||
settings.Ssl = sslEnabled
|
|
||||||
settings.BTsets.Ssl = sslEnabled
|
|
||||||
if sslEnabled {
|
if sslEnabled {
|
||||||
// set settings ssl enabled
|
// set settings ssl enabled
|
||||||
|
settings.Ssl = sslEnabled
|
||||||
if sslport == "" {
|
if sslport == "" {
|
||||||
if settings.BTsets.SslPort == "" {
|
if settings.BTsets.SslPort != "" {
|
||||||
settings.BTsets.SslPort = "8091"
|
sslport = settings.BTsets.SslPort
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
settings.BTsets.SslPort = sslport
|
sslport = "8091"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// check if ssl cert and key files exist
|
// check if ssl cert and key files exist
|
||||||
if sslCert != "" && sslKey != "" {
|
if sslCert != "" && sslKey != "" {
|
||||||
@@ -32,17 +29,16 @@ func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA b
|
|||||||
settings.BTsets.SslCert = sslCert
|
settings.BTsets.SslCert = sslCert
|
||||||
settings.BTsets.SslKey = sslKey
|
settings.BTsets.SslKey = sslKey
|
||||||
}
|
}
|
||||||
log.TLogln("Check web ssl port", settings.BTsets.SslPort)
|
log.TLogln("Check web ssl port", sslport)
|
||||||
l, err := net.Listen("tcp", ":"+settings.BTsets.SslPort)
|
l, err := net.Listen("tcp", ":"+sslport)
|
||||||
if l != nil {
|
if l != nil {
|
||||||
l.Close()
|
l.Close()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.TLogln("Port", settings.BTsets.SslPort, "already in use! Please set different port for HTTP. Abort")
|
log.TLogln("Port", sslport, "already in use! Please set different port for HTTPS. Abort")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// http checks
|
// http checks
|
||||||
if port == "" {
|
if port == "" {
|
||||||
port = "8090"
|
port = "8090"
|
||||||
@@ -53,14 +49,14 @@ func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA b
|
|||||||
l.Close()
|
l.Close()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.TLogln("Port", port, "already in use! Please set different sslport for HTTPS. Abort")
|
log.TLogln("Port", port, "already in use! Please set different sslport for HTTP. Abort")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
// remove old disk caches
|
||||||
// set settings http and https ports. Start web server.
|
|
||||||
go cleanCache()
|
go cleanCache()
|
||||||
|
// set settings http and https ports. Start web server.
|
||||||
settings.Port = port
|
settings.Port = port
|
||||||
settings.SslPort = settings.BTsets.SslPort
|
settings.SslPort = sslport
|
||||||
web.Start()
|
web.Start()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ type BTSets struct {
|
|||||||
ConnectionsLimit int
|
ConnectionsLimit int
|
||||||
PeersListenPort int
|
PeersListenPort int
|
||||||
|
|
||||||
//Https
|
// HTTPS
|
||||||
Ssl bool
|
|
||||||
SslPort string
|
SslPort string
|
||||||
SslCert string
|
SslCert string
|
||||||
SslKey string
|
SslKey string
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ var (
|
|||||||
tdb *TDB
|
tdb *TDB
|
||||||
Path string
|
Path string
|
||||||
Port string
|
Port string
|
||||||
SslPort string
|
|
||||||
Ssl bool
|
Ssl bool
|
||||||
|
SslPort string
|
||||||
ReadOnly bool
|
ReadOnly bool
|
||||||
HttpAuth bool
|
HttpAuth bool
|
||||||
SearchWA bool
|
SearchWA bool
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"server/log"
|
"server/log"
|
||||||
|
"server/settings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ func generateSelfSignedCert(ips []string) ([]byte, []byte, error) {
|
|||||||
template := x509.Certificate{
|
template := x509.Certificate{
|
||||||
SerialNumber: serialNumber,
|
SerialNumber: serialNumber,
|
||||||
Subject: pkix.Name{
|
Subject: pkix.Name{
|
||||||
Organization: []string{"Torrserver"},
|
Organization: []string{"TorrServer"},
|
||||||
},
|
},
|
||||||
NotBefore: notBefore,
|
NotBefore: notBefore,
|
||||||
NotAfter: notAfter,
|
NotAfter: notAfter,
|
||||||
@@ -75,14 +76,14 @@ func MakeCertKeyFiles(ips []string) (string, string) {
|
|||||||
log.TLogln("Error generating certificate:", err)
|
log.TLogln("Error generating certificate:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
certFile, err := os.Create("server.pem")
|
certFile, err := os.Create(filepath.Join(settings.Path, "server.pem"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.TLogln("Error creating certificate file:", err)
|
log.TLogln("Error creating certificate file:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer certFile.Close()
|
defer certFile.Close()
|
||||||
|
|
||||||
privFile, err := os.Create("server.key")
|
privFile, err := os.Create(filepath.Join(settings.Path, "server.key"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.TLogln("Error creating private key file:", err)
|
log.TLogln("Error creating private key file:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -101,7 +102,7 @@ func MakeCertKeyFiles(ips []string) (string, string) {
|
|||||||
}
|
}
|
||||||
log.TLogln("Self-signed certificate and private key generated successfully.")
|
log.TLogln("Self-signed certificate and private key generated successfully.")
|
||||||
|
|
||||||
return getAbsPath("server.pem"), getAbsPath("server.key")
|
return getAbsPath(certFile.Name()), getAbsPath(privFile.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAbsPath(fileName string) string {
|
func getAbsPath(fileName string) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user