-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
74 lines (61 loc) · 1.94 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"flag"
"fmt"
"github.com/ap-pauloafonso/ratio-spoof/input"
"github.com/ap-pauloafonso/ratio-spoof/printer"
"github.com/ap-pauloafonso/ratio-spoof/ratiospoof"
"log"
"os"
)
func main() {
//required
torrentPath := flag.String("t", "", "torrent path")
initialDownload := flag.String("d", "", "a INITIAL_DOWNLOADED")
downloadSpeed := flag.String("ds", "", "a DOWNLOAD_SPEED")
initialUpload := flag.String("u", "", "a INITIAL_UPLOADED")
uploadSpeed := flag.String("us", "", "a UPLOAD_SPEED")
//optional
port := flag.Int("p", 8999, "a PORT")
debug := flag.Bool("debug", false, "")
client := flag.String("c", "qbit-4.0.3", "emulated client")
flag.Usage = func() {
fmt.Printf("usage: %s -t <TORRENT_PATH> -d <INITIAL_DOWNLOADED> -ds <DOWNLOAD_SPEED> -u <INITIAL_UPLOADED> -us <UPLOAD_SPEED>\n", os.Args[0])
fmt.Print(`
optional arguments:
-h show this help message and exit
-p [PORT] change the port number, default: 8999
-c [CLIENT_CODE] change the client emulation, default: qbit-4.0.3
required arguments:
-t <TORRENT_PATH>
-d <INITIAL_DOWNLOADED>
-ds <DOWNLOAD_SPEED>
-u <INITIAL_UPLOADED>
-us <UPLOAD_SPEED>
<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.3
`)
}
flag.Parse()
if *torrentPath == "" || *initialDownload == "" || *downloadSpeed == "" || *initialUpload == "" || *uploadSpeed == "" {
flag.Usage()
return
}
r, err := ratiospoof.NewRatioSpoofState(
input.InputArgs{
TorrentPath: *torrentPath,
InitialDownloaded: *initialDownload,
DownloadSpeed: *downloadSpeed,
InitialUploaded: *initialUpload,
UploadSpeed: *uploadSpeed,
Port: *port,
Debug: *debug,
Client: *client,
})
if err != nil {
log.Fatalln(err)
}
go printer.PrintState(r)
r.Run()
}