diff --git a/README.md b/README.md index 51db2b0..7e2c57f 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ On FreeBSD (TrueNAS/FreeNAS) you can use this plugin https://github.com/filka96/iocage-plugin-TorrServer +#### NAS releases +https://github.com/vladlenas + +Synology NAS packages repo source: https://grigi.lt + ### Build Install golang 1.16+ by instruction: https://golang.org/doc/install \ Goto dir to source\ @@ -243,9 +248,9 @@ docker run --rm -d -e TS_PORT=5665 -e TS_DONTKILL=1 -e TS_HTTPAUTH=1 -e TS_RDB=1 # ### Donate: -[PayPal](https://www.paypal.me/yourok) \ -[QIWI]((https://qiwi.com/n/YOUROK85) \ -[YooMoney](https://yoomoney.ru/to/410013733697114/200) +[QIWI](https://qiwi.com/n/YOUROK85) \ +[YooMoney](https://yoomoney.ru/to/410013733697114/200) \ +[PayPal](https://www.paypal.me/yourok) SberBank card: **5484 4000 2285 7839** @@ -255,14 +260,22 @@ YooMoney card: **4048 4150 1812 8179** # ### Thanks to everyone who tested and helped -###### **Anacrolix Matt Joiner** [github.com/anacrolix](https://github.com/anacrolix/) +###### @nacrolix **Matt Joiner** [github.com/anacrolix](https://github.com/anacrolix/) -###### **tsynik** [github.com/tsynik](https://github.com/tsynik) +###### @tsynik [github.com/tsynik](https://github.com/tsynik) -###### **dancheskus** [github.com/dancheskus](https://github.com/dancheskus) +###### @dancheskus [github.com/dancheskus](https://github.com/dancheskus) -###### **kolsys** [github.com/kolsys](https://github.com/kolsys) +###### @kolsys [github.com/kolsys](https://github.com/kolsys) -###### **Tw1cker Руслан Пахнев** [github.com/Nemiroff](https://github.com/Nemiroff) +###### @vladlenas [github.com/vladlenas](https://github.com/vladlenas) -###### **SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) +###### @Nemiroff aka **Tw1cker** [github.com/Nemiroff](https://github.com/Nemiroff) + +###### @spawnlmg **SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) + +###### @TopperBG **Dimitar Maznekov** [github.com/TopperBG](https://github.com/TopperBG) + +###### @FaintGhost **Zhang Yaowei** [github.com/FaintGhost](https://github.com/FaintGhost) + +###### @Anton111111 **Anton Potekhin** [github.com/Anton111111](https://github.com/Anton111111) diff --git a/server/torr/torrent.go b/server/torr/torrent.go index d5bc46d..548b16d 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -198,11 +198,10 @@ func (t *Torrent) updateRA() { if t.Torrent != nil && t.Torrent.Info() != nil { pieceLen := t.Torrent.Info().PieceLength adj := pieceLen * int64(t.Torrent.Stats().ActivePeers) / int64(1+t.cache.Readers()) - switch { - case adj < pieceLen: + if adj < pieceLen { adj = pieceLen - case adj > pieceLen*4: - adj = pieceLen * 4 + //} else if adj > pieceLen*4 { + // adj = pieceLen * 4 } go t.cache.AdjustRA(adj) } diff --git a/server/web/api/m3u.go b/server/web/api/m3u.go index 076e492..6952ba5 100644 --- a/server/web/api/m3u.go +++ b/server/web/api/m3u.go @@ -40,6 +40,7 @@ func allPlayList(c *gin.Context) { // http://127.0.0.1:8090/playlist?hash=... // http://127.0.0.1:8090/playlist?hash=...&fromlast +// http://127.0.0.1:8090/playlist/fname?hash=... func playList(c *gin.Context) { hash, _ := c.GetQuery("hash") _, fromlast := c.GetQuery("fromlast") @@ -65,8 +66,14 @@ func playList(c *gin.Context) { host := utils.GetScheme(c) + "://" + c.Request.Host list := getM3uList(tor.Status(), host, fromlast) list = "#EXTM3U\n" + list + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param + if name == "" { + name = tor.Name() + ".m3u" + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { + name += ".m3u" + } - sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), list) + sendM3U(c, name, tor.Hash().HexString(), list) } func sendM3U(c *gin.Context, name, hash string, m3u string) { diff --git a/server/web/api/stream.go b/server/web/api/stream.go index b33f22b..c8fcce2 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -4,6 +4,7 @@ import ( "net/http" "net/url" "strconv" + "strings" "server/torr" "server/torr/state" @@ -120,8 +121,14 @@ func stream(c *gin.Context) { } else // return m3u if query if m3u { + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param + if name == "" { + name = tor.Name() + ".m3u" + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { + name += ".m3u" + } m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast) - sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist) + sendM3U(c, name, tor.Hash().HexString(), m3ulist) return } else // return play if query @@ -200,8 +207,14 @@ func streamNoAuth(c *gin.Context) { // return m3u if query if m3u { + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param + if name == "" { + name = tor.Name() + ".m3u" + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { + name += ".m3u" + } m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast) - sendM3U(c, tor.Name()+".m3u", tor.Hash().HexString(), m3ulist) + sendM3U(c, name, tor.Hash().HexString(), m3ulist) return } else // return play if query