mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
add TorrentAddr cmd option
This commit is contained in:
@@ -32,6 +32,7 @@ type args struct {
|
|||||||
DontKill bool `arg:"-k" help:"don't kill server on signal"`
|
DontKill bool `arg:"-k" help:"don't kill server on signal"`
|
||||||
UI bool `arg:"-u" help:"open torrserver page in browser"`
|
UI bool `arg:"-u" help:"open torrserver page in browser"`
|
||||||
TorrentsDir string `arg:"-t" help:"autoload torrents from dir"`
|
TorrentsDir string `arg:"-t" help:"autoload torrents from dir"`
|
||||||
|
TorrentAddr string `default:":32000" help:"Torrent client address"`
|
||||||
PubIPv4 string `arg:"-4" help:"set public IPv4 addr"`
|
PubIPv4 string `arg:"-4" help:"set public IPv4 addr"`
|
||||||
PubIPv6 string `arg:"-6" help:"set public IPv6 addr"`
|
PubIPv6 string `arg:"-6" help:"set public IPv6 addr"`
|
||||||
}
|
}
|
||||||
@@ -74,6 +75,10 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.TorrentAddr != "" {
|
||||||
|
settings.TorAddr = params.TorrentAddr
|
||||||
|
}
|
||||||
|
|
||||||
if params.PubIPv4 != "" {
|
if params.PubIPv4 != "" {
|
||||||
settings.PubIPv4 = params.PubIPv4
|
settings.PubIPv4 = params.PubIPv4
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ var (
|
|||||||
HttpAuth bool
|
HttpAuth bool
|
||||||
PubIPv4 string
|
PubIPv4 string
|
||||||
PubIPv6 string
|
PubIPv6 string
|
||||||
|
TorAddr string
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitSets(readOnly bool) {
|
func InitSets(readOnly bool) {
|
||||||
|
|||||||
@@ -120,24 +120,28 @@ func (bt *BTServer) configure(ctx context.Context) (err error) {
|
|||||||
if settings.BTsets.UploadRateLimit > 0 {
|
if settings.BTsets.UploadRateLimit > 0 {
|
||||||
bt.config.UploadRateLimiter = utils.Limit(settings.BTsets.UploadRateLimit * 1024)
|
bt.config.UploadRateLimiter = utils.Limit(settings.BTsets.UploadRateLimit * 1024)
|
||||||
}
|
}
|
||||||
if settings.BTsets.PeersListenPort > 0 {
|
if settings.TorAddr != "" {
|
||||||
log.Println("Set listen port", settings.BTsets.PeersListenPort)
|
bt.config.SetListenAddr(settings.TorAddr)
|
||||||
bt.config.ListenPort = settings.BTsets.PeersListenPort
|
|
||||||
} else {
|
} else {
|
||||||
upnpport := 32000
|
if settings.BTsets.PeersListenPort > 0 {
|
||||||
for {
|
log.Println("Set listen port", settings.BTsets.PeersListenPort)
|
||||||
log.Println("Check upnp port", upnpport)
|
bt.config.ListenPort = settings.BTsets.PeersListenPort
|
||||||
l, err := net.Listen("tcp", ":"+strconv.Itoa(upnpport))
|
} else {
|
||||||
if l != nil {
|
upnpport := 32000
|
||||||
l.Close()
|
for {
|
||||||
|
log.Println("Check upnp port", upnpport)
|
||||||
|
l, err := net.Listen("tcp", ":"+strconv.Itoa(upnpport))
|
||||||
|
if l != nil {
|
||||||
|
l.Close()
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
upnpport++
|
||||||
}
|
}
|
||||||
if err == nil {
|
log.Println("Set upnp port", upnpport)
|
||||||
break
|
bt.config.ListenPort = upnpport
|
||||||
}
|
|
||||||
upnpport++
|
|
||||||
}
|
}
|
||||||
log.Println("Set upnp port", upnpport)
|
|
||||||
bt.config.ListenPort = upnpport
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Client config:", settings.BTsets)
|
log.Println("Client config:", settings.BTsets)
|
||||||
|
|||||||
Reference in New Issue
Block a user