From 4713a9e8940da04d15724227a94fdab8f6fc9231 Mon Sep 17 00:00:00 2001 From: ap-pauloafonso Date: Mon, 18 Jan 2021 22:16:30 -0300 Subject: [PATCH] qbit emulation refactor --- emulation/qbittorrent.go | 4 ++-- ratiospoof/ratiospoof.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/emulation/qbittorrent.go b/emulation/qbittorrent.go index 0b43f52..62f859d 100644 --- a/emulation/qbittorrent.go +++ b/emulation/qbittorrent.go @@ -13,7 +13,8 @@ const ( query = "info_hash={infohash}&peer_id={peerid}&port={port}&uploaded={uploaded}&downloaded={downloaded}&left={left}&corrupt=0&key={key}&event={event}&numwant={numwant}&compact=1&no_peer_id=1&supportcrypto=1&redundant=0" ) -type TypeTest struct { +func init() { + rand.Seed(time.Now().UnixNano()) } type qbitTorrent struct { @@ -68,7 +69,6 @@ func generatePeerID() string { } func randStringBytes(n int) string { - rand.Seed(time.Now().UnixNano()) b := make([]byte, n) for i := range b { b[i] = letterBytes[rand.Intn(len(letterBytes))] diff --git a/ratiospoof/ratiospoof.go b/ratiospoof/ratiospoof.go index b31ab07..7f804db 100644 --- a/ratiospoof/ratiospoof.go +++ b/ratiospoof/ratiospoof.go @@ -35,7 +35,7 @@ type ratioSpoofState struct { httpClient HttpClient torrentInfo *torrentInfo input *inputParsed - bitTorrentClient TorrentClient + bitTorrentClient TorrentClientEmulation currentAnnounceTimer int announceInterval int numWant int @@ -121,7 +121,7 @@ func (I *InputArgs) parseInput(torrentInfo *torrentInfo) (*inputParsed, error) { }, nil } -func NewRatioSPoofState(input InputArgs, torrentClient TorrentClient, httpclient HttpClient) (*ratioSpoofState, error) { +func NewRatioSPoofState(input InputArgs, torrentClient TorrentClientEmulation, httpclient HttpClient) (*ratioSpoofState, error) { torrentInfo, err := extractTorrentInfo(input.TorrentPath) if err != nil { @@ -201,7 +201,7 @@ type trackerResponse struct { leechers int } -type TorrentClient interface { +type TorrentClientEmulation interface { PeerID() string Key() string Query() string