mirror of
https://github.com/SinTan1729/privtracker.git
synced 2024-12-25 15:08:35 -06:00
peers rename
This commit is contained in:
parent
b900c2862f
commit
1fafa13c95
2 changed files with 8 additions and 8 deletions
6
main.go
6
main.go
|
@ -57,7 +57,7 @@ func announce(c *gin.Context) {
|
|||
default:
|
||||
PutPeer(c.Param("room"), req.InfoHash, req.IP, req.Port, req.IsSeeding())
|
||||
}
|
||||
peersv4, peersv6, numSeeders, numLeechers := GetPeers(c.Param("room"), req.InfoHash, req.IP, req.Port, req.IsSeeding(), req.Numwant)
|
||||
peersIPv4, peersIPv6, numSeeders, numLeechers := GetPeers(c.Param("room"), req.InfoHash, req.IP, req.Port, req.IsSeeding(), req.Numwant)
|
||||
interval := 120
|
||||
if numSeeders == 0 {
|
||||
interval /= 2
|
||||
|
@ -68,8 +68,8 @@ func announce(c *gin.Context) {
|
|||
Interval: interval,
|
||||
Complete: numSeeders,
|
||||
Incomplete: numLeechers,
|
||||
Peers: string(peersv4),
|
||||
PeersIPv6: string(peersv6),
|
||||
Peers: string(peersIPv4),
|
||||
PeersIPv6: string(peersIPv6),
|
||||
}
|
||||
if err := bencode.Marshal(c.Writer, resp); err != nil {
|
||||
c.Error(err)
|
||||
|
|
10
storage.go
10
storage.go
|
@ -91,7 +91,7 @@ func GraduateLeecher(room, infoHash, ip string, port uint16) {
|
|||
shard.Unlock()
|
||||
}
|
||||
|
||||
func GetPeers(room, infoHash, ip string, port uint16, seeding bool, numWant uint) (peersv4, peersv6 []byte, numSeeders, numLeechers int) {
|
||||
func GetPeers(room, infoHash, ip string, port uint16, seeding bool, numWant uint) (peersIPv4, peersIPv6 []byte, numSeeders, numLeechers int) {
|
||||
h := sha1.Sum([]byte(room + infoHash))
|
||||
shard := shards[shardIndex(h)]
|
||||
shard.RLock()
|
||||
|
@ -103,9 +103,9 @@ func GetPeers(room, infoHash, ip string, port uint16, seeding bool, numWant uint
|
|||
break
|
||||
}
|
||||
if bytes.HasPrefix([]byte(peer), v4InV6Prefix) {
|
||||
peersv4 = append(peersv4, peer[12:]...)
|
||||
peersIPv4 = append(peersIPv4, peer[12:]...)
|
||||
} else {
|
||||
peersv6 = append(peersv6, peer...)
|
||||
peersIPv6 = append(peersIPv6, peer...)
|
||||
}
|
||||
numWant--
|
||||
}
|
||||
|
@ -118,9 +118,9 @@ func GetPeers(room, infoHash, ip string, port uint16, seeding bool, numWant uint
|
|||
break
|
||||
}
|
||||
if bytes.HasPrefix([]byte(peer), v4InV6Prefix) {
|
||||
peersv4 = append(peersv4, peer[12:]...)
|
||||
peersIPv4 = append(peersIPv4, peer[12:]...)
|
||||
} else {
|
||||
peersv6 = append(peersv6, peer...)
|
||||
peersIPv6 = append(peersIPv6, peer...)
|
||||
}
|
||||
numWant--
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue