mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
add -m option
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ type args struct {
|
|||||||
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"`
|
||||||
SearchWA bool `arg:"-s" help:"search without auth"`
|
SearchWA bool `arg:"-s" help:"search without auth"`
|
||||||
|
MaxSize string `arg:"-m" help:"max allowed stream size"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (args) Version() string {
|
func (args) Version() string {
|
||||||
@@ -104,6 +106,13 @@ func main() {
|
|||||||
go watchTDir(params.TorrentsDir)
|
go watchTDir(params.TorrentsDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if params.MaxSize != "" {
|
||||||
|
maxSize, err := strconv.ParseInt(params.MaxSize, 10, 64)
|
||||||
|
if err == nil {
|
||||||
|
settings.MaxSize = maxSize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server.Start(params.Port, params.SslPort, params.SslCert, params.SslKey, params.Ssl, 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.TLogln(server.WaitServer())
|
||||||
log.Close()
|
log.Close()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ var (
|
|||||||
PubIPv4 string
|
PubIPv4 string
|
||||||
PubIPv6 string
|
PubIPv6 string
|
||||||
TorAddr string
|
TorAddr string
|
||||||
|
MaxSize int64
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitSets(readOnly, searchWA bool) {
|
func InitSets(readOnly, searchWA bool) {
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
|
|||||||
if file == nil {
|
if file == nil {
|
||||||
return fmt.Errorf("file with id %v not found", fileID)
|
return fmt.Errorf("file with id %v not found", fileID)
|
||||||
}
|
}
|
||||||
|
if int64(sets.MaxSize) > 0 && file.Length() > int64(sets.MaxSize) {
|
||||||
|
log.Println("file", file.DisplayPath(), "size exceeded max allowed", sets.MaxSize, "bytes")
|
||||||
|
return fmt.Errorf("file size exceeded max allowed %d bytes", sets.MaxSize)
|
||||||
|
}
|
||||||
|
|
||||||
reader := t.NewReader(file)
|
reader := t.NewReader(file)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user