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 {
|
||||
if !strings.HasPrefix(host, "http") {
|
||||
if settings.Ssl {
|
||||
host = "https://" + host
|
||||
} else {
|
||||
host = "http://" + host
|
||||
}
|
||||
|
||||
// if settings.Ssl {
|
||||
// host = "https://" + host
|
||||
// } else {
|
||||
host = "http://" + host
|
||||
// }
|
||||
|
||||
}
|
||||
pos := strings.LastIndex(host, ":")
|
||||
if pos > 7 {
|
||||
host = host[:pos]
|
||||
}
|
||||
if settings.Ssl {
|
||||
return host + ":" + settings.SslPort + "/" + path
|
||||
} else {
|
||||
return host + ":" + settings.Port + "/" + path
|
||||
}
|
||||
|
||||
// if settings.Ssl {
|
||||
// return host + ":" + settings.SslPort + "/" + path
|
||||
// } else {
|
||||
return host + ":" + settings.Port + "/" + path
|
||||
// }
|
||||
}
|
||||
|
||||
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) {
|
||||
settings.InitSets(roSets, searchWA)
|
||||
|
||||
//// https checks
|
||||
// check if ssl enabled
|
||||
settings.Ssl = sslEnabled
|
||||
settings.BTsets.Ssl = sslEnabled
|
||||
// https checks
|
||||
if sslEnabled {
|
||||
// set settings ssl enabled
|
||||
settings.Ssl = sslEnabled
|
||||
if sslport == "" {
|
||||
if settings.BTsets.SslPort == "" {
|
||||
settings.BTsets.SslPort = "8091"
|
||||
if settings.BTsets.SslPort != "" {
|
||||
sslport = settings.BTsets.SslPort
|
||||
} else {
|
||||
sslport = "8091"
|
||||
}
|
||||
} else {
|
||||
settings.BTsets.SslPort = sslport
|
||||
}
|
||||
// check if ssl cert and key files exist
|
||||
if sslCert != "" && sslKey != "" {
|
||||
@@ -32,17 +29,16 @@ func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA b
|
||||
settings.BTsets.SslCert = sslCert
|
||||
settings.BTsets.SslKey = sslKey
|
||||
}
|
||||
log.TLogln("Check web ssl port", settings.BTsets.SslPort)
|
||||
l, err := net.Listen("tcp", ":"+settings.BTsets.SslPort)
|
||||
log.TLogln("Check web ssl port", sslport)
|
||||
l, err := net.Listen("tcp", ":"+sslport)
|
||||
if l != nil {
|
||||
l.Close()
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// http checks
|
||||
if port == "" {
|
||||
port = "8090"
|
||||
@@ -53,14 +49,14 @@ func Start(port, sslport, sslCert, sslKey string, sslEnabled, roSets, searchWA b
|
||||
l.Close()
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
// set settings http and https ports. Start web server.
|
||||
// remove old disk caches
|
||||
go cleanCache()
|
||||
// set settings http and https ports. Start web server.
|
||||
settings.Port = port
|
||||
settings.SslPort = settings.BTsets.SslPort
|
||||
settings.SslPort = sslport
|
||||
web.Start()
|
||||
|
||||
}
|
||||
|
||||
@@ -47,11 +47,10 @@ type BTSets struct {
|
||||
ConnectionsLimit int
|
||||
PeersListenPort int
|
||||
|
||||
//Https
|
||||
Ssl bool
|
||||
SslPort string
|
||||
SslCert string
|
||||
SslKey string
|
||||
// HTTPS
|
||||
SslPort string
|
||||
SslCert string
|
||||
SslKey string
|
||||
}
|
||||
|
||||
func (v *BTSets) String() string {
|
||||
|
||||
@@ -11,8 +11,8 @@ var (
|
||||
tdb *TDB
|
||||
Path string
|
||||
Port string
|
||||
Ssl bool
|
||||
SslPort string
|
||||
Ssl bool
|
||||
ReadOnly bool
|
||||
HttpAuth bool
|
||||
SearchWA bool
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"server/log"
|
||||
"server/settings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -41,7 +42,7 @@ func generateSelfSignedCert(ips []string) ([]byte, []byte, error) {
|
||||
template := x509.Certificate{
|
||||
SerialNumber: serialNumber,
|
||||
Subject: pkix.Name{
|
||||
Organization: []string{"Torrserver"},
|
||||
Organization: []string{"TorrServer"},
|
||||
},
|
||||
NotBefore: notBefore,
|
||||
NotAfter: notAfter,
|
||||
@@ -72,19 +73,19 @@ func generateSelfSignedCert(ips []string) ([]byte, []byte, error) {
|
||||
func MakeCertKeyFiles(ips []string) (string, string) {
|
||||
certPEM, privPEM, err := generateSelfSignedCert(ips)
|
||||
if err != nil {
|
||||
log.TLogln("Error generating certificate:", err)
|
||||
log.TLogln("Error generating certificate:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
certFile, err := os.Create("server.pem")
|
||||
certFile, err := os.Create(filepath.Join(settings.Path, "server.pem"))
|
||||
if err != nil {
|
||||
log.TLogln("Error creating certificate file:", err)
|
||||
log.TLogln("Error creating certificate file:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer certFile.Close()
|
||||
|
||||
privFile, err := os.Create("server.key")
|
||||
privFile, err := os.Create(filepath.Join(settings.Path, "server.key"))
|
||||
if err != nil {
|
||||
log.TLogln("Error creating private key file:", err)
|
||||
log.TLogln("Error creating private key file:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer privFile.Close()
|
||||
@@ -100,8 +101,8 @@ func MakeCertKeyFiles(ips []string) (string, string) {
|
||||
os.Exit(1)
|
||||
}
|
||||
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 {
|
||||
@@ -119,16 +120,16 @@ func VerifyCertKeyFiles(certFile, keyFile, port string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Check if the certificate chain is expired
|
||||
for _, cert := range cert.Certificate {
|
||||
x509Cert, err := x509.ParseCertificate(cert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if x509Cert.NotAfter.Before(time.Now()) {
|
||||
return errors.New("certificate has expired")
|
||||
}
|
||||
}
|
||||
// Check if the certificate chain is expired
|
||||
for _, cert := range cert.Certificate {
|
||||
x509Cert, err := x509.ParseCertificate(cert)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if x509Cert.NotAfter.Before(time.Now()) {
|
||||
return errors.New("certificate has expired")
|
||||
}
|
||||
}
|
||||
// Create a TLS configuration
|
||||
config := tls.Config{
|
||||
Certificates: []tls.Certificate{cert},
|
||||
|
||||
Reference in New Issue
Block a user