ap-pauloafonso / ratio-spoof

A bittorrent ratio spoof tool
MIT License
90 stars 13 forks source link

Refactor proposal #14

Closed ap-pauloafonso closed 3 years ago

ap-pauloafonso commented 3 years ago

Hi @jhuggart, what do you think about these changes? Thank you !

This refactor contains the following changes on the code organization:

  1. Trimmed the ratiospoof.go file, now the projects is separated by contexts (folder/packages) inside the internal folder.
  2. Now the code responsible for printing the state lives in its own package (printer). So now i pass the the state variable by reference as argument instead of pointer receiver.

There are two points that i didn't manage to address:

to combine generate and fire announce together Reason: so the currently application works like ah scheduler, so i need to generate the announce show the user that the announce is on the way and after an interval fire it. So i don't know if combine these two would help in this case.

Usage of ticker Reason: https://github.com/ap-pauloafonso/ratio-spoof/blob/41b4ac97572f1f29e8d913ed6131f71e672bee62/ratiospoof/ratiospoof.go#L252-L258 I don't think a ticker would work in the case of ratio-spoof logic, because i can't execute something if the previous execution was not fired yet. for example: generate-annunce->wait internal->fire announce -> repeat

Before (ignore out/)

├── assets
│   └── demo.gif
├── bencode
│   ├── bencode.go
│   ├── bencode_test.go
│   └── torrent_files_test
│       ├── Fedora-Workstation-Live-x86_64-33.torrent
│       ├──Slackware142.torrent
│       └── ubuntu-20.04.1-desktop-amd64.iso.torrent
├── build.sh
├── cmd
│   └── main.go
├── emulation
│   ├── qbittorrent.go
│   └── qbittorrent_test.go
├── go.mod
├── go.sum
├── LICENSE
├── out
│   ├── linux
│   │   └── ratio-spoof
│   ├── mac
│   │   └── ratio-spoof
│   ├── ratio-spoof-test(linux-mac-windows).zip
│   └── windows
│       └── ratio-spoof.exe
├── ratiospoof
│   ├── printstate.go
│   ├── printstate_test.go
│   ├── ratiospoof.go
│   └── ratiospoof_test.go
└── README.md

After (ignore out/)

├── assets
│   └── demo.gif
├── build.sh
├── cmd
│   └── main.go
├── go.mod
├── go.sum
├── internal
│   ├── bencode
│   │   ├── bencode.go
│   │   ├── bencode_test.go
│   │   └── torrent_files_test
│   │       ├── Fedora-Workstation-Live-x86_64-33.torrent
│   │       ├── Slackware142.torrent
│   │       └── ubuntu-20.04.1-desktop-amd64.iso.torrent
│   ├── emulation
│   │   ├── qbittorrent.go
│   │   └── qbittorrent_test.go
│   ├── input
│   │   ├── input.go
│   │   └── input_test.go
│   ├── printer
│   │   ├── printer.go
│   │   └── printer_test.go
│   ├── ratiospoof
│   │   ├── ratiospoof.go
│   │   └── ratiospoof_test.go
│   └── tracker
│       └── tracker.go
├── LICENSE
├── out
│   ├── linux
│   │   └── ratio-spoof
│   ├── mac
│   │   └── ratio-spoof
│   ├── ratio-spoof-test(linux-mac-windows).zip
│   └── windows
│       └── ratio-spoof.exe
└── README.md
ap-pauloafonso commented 3 years ago

All the changes are done, let me know what you think @jhuggart. Thank you for your time ;)