embed interfaces and readme

This commit is contained in:
ap-pauloafonso 2021-03-15 00:30:48 -03:00
parent 66a16b3cf1
commit 7821028a9c
4 changed files with 15 additions and 13 deletions

View file

@ -19,6 +19,7 @@ usage:
optional arguments:
-h show this help message and exit
-p [PORT] change the port number, the default is 8999
-c [CLIENT_CODE] change the client emulation, default: qbit-4.0.3
required arguments:
-t <TORRENT_PATH>
@ -29,6 +30,7 @@ required arguments:
<INITIAL_DOWNLOADED> and <INITIAL_UPLOADED> must be in %, b, kb, mb, gb, tb
<DOWNLOAD_SPEED> and <UPLOAD_SPEED> must be in kbps, mbps
[CLIENT_CODE] options: qbit-4.0.3, qbit-4.3.2
```
```

View file

@ -38,12 +38,12 @@ type RoundingGenerator interface {
}
type Emulation struct {
PeerIdGenerator PeerIdGenerator
KeyGenerator KeyGenerator
Query string
Name string
Headers map[string]string
RoudingGenerator RoundingGenerator
PeerIdGenerator
KeyGenerator
Query string
Name string
Headers map[string]string
RoundingGenerator
}
func NewEmulation(code string) (*Emulation, error) {
@ -67,7 +67,7 @@ func NewEmulation(code string) (*Emulation, error) {
return nil, err
}
return &Emulation{PeerIdGenerator: peerG, KeyGenerator: keyG, RoudingGenerator: roudingG,
return &Emulation{PeerIdGenerator: peerG, KeyGenerator: keyG, RoundingGenerator: roudingG,
Headers: c.Headers, Name: c.Name, Query: c.Query}, nil
}

View file

@ -16,10 +16,10 @@ func TestNewEmulation(t *testing.T) {
t.Error("should not return error ")
}
peerId := e.PeerIdGenerator.PeerId()
key := e.KeyGenerator.Key()
peerId := e.PeerId()
key := e.Key()
d, u, l := e.RoudingGenerator.Round(2*1024*1024*1024, 1024*1024*1024, 3*1024*1024*1024, 1024)
d, u, l := e.Round(2*1024*1024*1024, 1024*1024*1024, 3*1024*1024*1024, 1024)
if peerId == "" {
t.Errorf("%s.json should be able to generate PeerId", code)

View file

@ -168,11 +168,11 @@ func (R *RatioSpoof) fireAnnounce(retry bool) error {
lastAnnounce := R.AnnounceHistory.Back().(AnnounceEntry)
replacer := strings.NewReplacer("{infohash}", R.TorrentInfo.InfoHashURLEncoded,
"{port}", fmt.Sprint(R.Input.Port),
"{peerid}", R.BitTorrentClient.PeerIdGenerator.PeerId(),
"{peerid}", R.BitTorrentClient.PeerId(),
"{uploaded}", fmt.Sprint(lastAnnounce.Uploaded),
"{downloaded}", fmt.Sprint(lastAnnounce.Downloaded),
"{left}", fmt.Sprint(lastAnnounce.Left),
"{key}", R.BitTorrentClient.KeyGenerator.Key(),
"{key}", R.BitTorrentClient.Key(),
"{event}", R.Status,
"{numwant}", fmt.Sprint(R.NumWant))
query := replacer.Replace(R.BitTorrentClient.Query)
@ -203,7 +203,7 @@ func (R *RatioSpoof) generateNextAnnounce() {
leftCandidate := calculateBytesLeft(downloadCandidate, R.TorrentInfo.TotalSize)
d, u, l := R.BitTorrentClient.RoudingGenerator.Round(downloadCandidate, uploadCandidate, leftCandidate, R.TorrentInfo.PieceSize)
d, u, l := R.BitTorrentClient.Round(downloadCandidate, uploadCandidate, leftCandidate, R.TorrentInfo.PieceSize)
R.addAnnounce(d, u, l, (float32(d)/float32(R.TorrentInfo.TotalSize))*100)
}