From 722265d4cfe4a3271982ff745ec9aaae39b34c51 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Fri, 13 Oct 2023 03:03:27 +0300 Subject: [PATCH 1/8] Update README.md --- README.md | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 51db2b0..5b24b1d 100644 --- a/README.md +++ b/README.md @@ -243,9 +243,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 +255,20 @@ 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) +###### **@nemiroff aka Tw1cker** [github.com/Nemiroff](https://github.com/Nemiroff) -###### **SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) +###### **@spawnlmg SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) + +###### **@TopperBG Dimitar "Topper" 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) From b6dc5822d46f01e9f0c8430e5d41e295b5dff9d1 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Fri, 13 Oct 2023 03:18:50 +0300 Subject: [PATCH 2/8] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5b24b1d..2e82129 100644 --- a/README.md +++ b/README.md @@ -255,20 +255,20 @@ YooMoney card: **4048 4150 1812 8179** # ### Thanks to everyone who tested and helped -###### **@nacrolix 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) -###### **@nemiroff aka Tw1cker** [github.com/Nemiroff](https://github.com/Nemiroff) +###### @Nemiroff aka **Tw1cker** [github.com/Nemiroff](https://github.com/Nemiroff) -###### **@spawnlmg SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) +###### @spawnlmg **SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) -###### **@TopperBG Dimitar "Topper" Maznekov** [github.com/TopperBG](https://github.com/TopperBG) +###### @TopperBG **Dimitar Maznekov** [github.com/TopperBG](https://github.com/TopperBG) -###### **@FaintGhost Zhang Yaowei** [github.com/FaintGhost](https://github.com/FaintGhost) +###### @FaintGhost **Zhang Yaowei** [github.com/FaintGhost](https://github.com/FaintGhost) -###### **@Anton111111 Anton Potekhin** [github.com/Anton111111](https://github.com/Anton111111) +###### @Anton111111 **Anton Potekhin** [github.com/Anton111111](https://github.com/Anton111111) From be15e247ea6999e9141f9502e3d774828e9d9ce0 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Fri, 13 Oct 2023 04:14:28 +0300 Subject: [PATCH 3/8] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 2e82129..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\ @@ -263,6 +268,8 @@ YooMoney card: **4048 4150 1812 8179** ###### @kolsys [github.com/kolsys](https://github.com/kolsys) +###### @vladlenas [github.com/vladlenas](https://github.com/vladlenas) + ###### @Nemiroff aka **Tw1cker** [github.com/Nemiroff](https://github.com/Nemiroff) ###### @spawnlmg **SpAwN_LMG** [github.com/spawnlmg](https://github.com/spawnlmg) From 0d413b29173abe9faf60db2383ee4a4d6585fc8a Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Fri, 13 Oct 2023 17:28:12 +0300 Subject: [PATCH 4/8] add fname handle to playlist api --- server/web/api/m3u.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/web/api/m3u.go b/server/web/api/m3u.go index 076e492..a5fc48c 100644 --- a/server/web/api/m3u.go +++ b/server/web/api/m3u.go @@ -40,7 +40,9 @@ 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) { + name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param hash, _ := c.GetQuery("hash") _, fromlast := c.GetQuery("fromlast") if hash == "" { @@ -65,8 +67,13 @@ func playList(c *gin.Context) { host := utils.GetScheme(c) + "://" + c.Request.Host list := getM3uList(tor.Status(), host, fromlast) list = "#EXTM3U\n" + list + if name == "" { + name = tor.Name() + ".m3u" + } else { + 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) { From 64ae3b8f1c211eeb39e0a5daee8d71de5fcafe90 Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Fri, 13 Oct 2023 17:38:41 +0300 Subject: [PATCH 5/8] also for stream --- server/web/api/m3u.go | 2 +- server/web/api/stream.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/server/web/api/m3u.go b/server/web/api/m3u.go index a5fc48c..22aa259 100644 --- a/server/web/api/m3u.go +++ b/server/web/api/m3u.go @@ -42,7 +42,6 @@ func allPlayList(c *gin.Context) { // http://127.0.0.1:8090/playlist?hash=...&fromlast // http://127.0.0.1:8090/playlist/fname?hash=... func playList(c *gin.Context) { - name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param hash, _ := c.GetQuery("hash") _, fromlast := c.GetQuery("fromlast") if hash == "" { @@ -67,6 +66,7 @@ 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 { diff --git a/server/web/api/stream.go b/server/web/api/stream.go index b33f22b..28eef3b 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 { + 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 From dfde29f1783fc5ce041b4f805be51c9015956abc Mon Sep 17 00:00:00 2001 From: yourok <8yourok8@mail.ru> Date: Tue, 24 Oct 2023 22:03:42 +0300 Subject: [PATCH 6/8] fix read a head --- server/torr/torrent.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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) } From c1e3b64426b1a29f2e2c94da551c85f31436e56d Mon Sep 17 00:00:00 2001 From: yourok <8yourok8@mail.ru> Date: Mon, 30 Oct 2023 10:45:58 +0300 Subject: [PATCH 7/8] fix double ext m3u --- server/web/api/stream.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/web/api/stream.go b/server/web/api/stream.go index 28eef3b..575a93b 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -124,7 +124,7 @@ func stream(c *gin.Context) { name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param if name == "" { name = tor.Name() + ".m3u" - } else { + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") { name += ".m3u" } m3ulist := "#EXTM3U\n" + getM3uList(tor.Status(), utils2.GetScheme(c)+"://"+c.Request.Host, fromlast) From 1e7228550bf62ee48eb1758e4ce255061c214c6f Mon Sep 17 00:00:00 2001 From: nikk gitanes Date: Tue, 31 Oct 2023 02:33:46 +0300 Subject: [PATCH 8/8] add m3u8 check in fname and handle missing fname in streamNoAuth also --- server/web/api/m3u.go | 2 +- server/web/api/stream.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/server/web/api/m3u.go b/server/web/api/m3u.go index 22aa259..6952ba5 100644 --- a/server/web/api/m3u.go +++ b/server/web/api/m3u.go @@ -69,7 +69,7 @@ func playList(c *gin.Context) { name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param if name == "" { name = tor.Name() + ".m3u" - } else { + } else if !strings.HasSuffix(strings.ToLower(name), ".m3u") && !strings.HasSuffix(strings.ToLower(name), ".m3u8") { name += ".m3u" } diff --git a/server/web/api/stream.go b/server/web/api/stream.go index 575a93b..c8fcce2 100644 --- a/server/web/api/stream.go +++ b/server/web/api/stream.go @@ -124,7 +124,7 @@ func stream(c *gin.Context) { name := strings.ReplaceAll(c.Param("fname"), `/`, "") // strip starting / from param if name == "" { name = tor.Name() + ".m3u" - } else if !strings.HasSuffix(strings.ToLower(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) @@ -207,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