Merge pull request #9 from ap-pauloafonso/qbit-refactor

qbit emulation refactor
This commit is contained in:
ap-pauloafonso 2021-01-18 22:18:06 -03:00 committed by GitHub
commit fe5c6bde7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View file

@ -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" 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 { type qbitTorrent struct {
@ -68,7 +69,6 @@ func generatePeerID() string {
} }
func randStringBytes(n int) string { func randStringBytes(n int) string {
rand.Seed(time.Now().UnixNano())
b := make([]byte, n) b := make([]byte, n)
for i := range b { for i := range b {
b[i] = letterBytes[rand.Intn(len(letterBytes))] b[i] = letterBytes[rand.Intn(len(letterBytes))]

View file

@ -35,7 +35,7 @@ type ratioSpoofState struct {
httpClient HttpClient httpClient HttpClient
torrentInfo *torrentInfo torrentInfo *torrentInfo
input *inputParsed input *inputParsed
bitTorrentClient TorrentClient bitTorrentClient TorrentClientEmulation
currentAnnounceTimer int currentAnnounceTimer int
announceInterval int announceInterval int
numWant int numWant int
@ -121,7 +121,7 @@ func (I *InputArgs) parseInput(torrentInfo *torrentInfo) (*inputParsed, error) {
}, nil }, 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) torrentInfo, err := extractTorrentInfo(input.TorrentPath)
if err != nil { if err != nil {
@ -201,7 +201,7 @@ type trackerResponse struct {
leechers int leechers int
} }
type TorrentClient interface { type TorrentClientEmulation interface {
PeerID() string PeerID() string
Key() string Key() string
Query() string Query() string