Merge branch 'master' into old-engine

This commit is contained in:
nikk gitanes
2023-10-31 05:06:34 +03:00
4 changed files with 48 additions and 16 deletions

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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) {

View File

@@ -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