-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
58 lines (53 loc) · 1.71 KB
/
config.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
package main
import (
"os"
"fmt"
"strconv"
"bufio"
"github.com/fogcreek/mini"
)
var D_PROXY_LIST []string
const D_CAPTCHA_URL = "http://topofgames.com/imageverify.php"
var Target string
var ConfigStruct struct {
ProxyListFilepath string `json:"proxy_list_filepath"`
TargetID int `json:"target_id"`
WorkerCount int `json:"worker_count"`
DBCUsername string `json:"dbc_username"`
DBCPassword string `json:"dbc_password"`
ProxyType string `json:"proxy_type"`
Timeout int `json:"timeout"`
}
func LoadConfig() error {
//read config
configFile, err := mini.LoadConfiguration("settings.ini")
if err != nil {
return err
}
ConfigStruct.ProxyListFilepath = configFile.String("proxy_list_path","proxies.txt")
ConfigStruct.TargetID = int(configFile.Integer("target_id",80397))
ConfigStruct.WorkerCount = int(configFile.Integer("worker_count", 20))
ConfigStruct.DBCUsername = configFile.String("deathbycaptcha_username","username")
ConfigStruct.DBCPassword = configFile.String("deathbycaptcha_password","password")
ConfigStruct.ProxyType = configFile.String("proxy_type","http")
ConfigStruct.Timeout = int(configFile.Integer("timeout", 20))
Target = "http://topofgames.com/index.php?do=votes&id="+strconv.Itoa(ConfigStruct.TargetID)
return nil
}
func LoadProxies() error{
//load proxies
if _, err := os.Stat(ConfigStruct.ProxyListFilepath); err != nil {
err := fmt.Errorf("Proxy file parsing error.")
return err
}
proxyFile, err := os.Open(ConfigStruct.ProxyListFilepath)
if err != nil {
return err
}
defer proxyFile.Close()
scanner := bufio.NewScanner(proxyFile)
for scanner.Scan() {
D_PROXY_LIST = append(D_PROXY_LIST, scanner.Text())
}
return nil
}