-
Notifications
You must be signed in to change notification settings - Fork 37
/
campaign.go
74 lines (64 loc) · 2.26 KB
/
campaign.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 campaign
import (
log "github.com/sirupsen/logrus"
"golang.org/x/crypto/scrypt"
)
type Campaign struct {
ApiKey string `json:"ApiKey"`
EncKey []byte `json:"EncKey"`
WithZip bool `json:"WithZip"`
WithEnc bool `json:"WithEnc"`
ServerUrl string `json:"ServerUrl"` // URL of the server, as viewed from the clients
PacketSendPath string `json:"PacketSendPath"`
PacketGetPath string `json:"PacketGetPath"`
FileUploadPath string `json:"FileUploadPath"`
FileDownloadPath string `json:"FileDownloadPath"`
SecureDownloadPath string `json:"SecureDownloadPath"`
ClientWebsocketPath string `json:"ClientWebsocketPath"`
AuthHeader string `json:"AuthHeader"`
UserAgent string `json:"UserAgent"`
HttpJitter int `json:"HttpJitter"` // in percent
ClientUseWebsocket bool `json:"ClientUseWebsocket"`
ProxyUrl string `json:"ProxyUrl"` // Default campaign proxy url, empty for none
DisableProxy bool `json:"DisableProxy"` // If we want to disable any proxy (mostly for testing)
AutoStartDownstreams bool `json:"AutoStartDownstreams"` // opens local tcp socket when true automagically
DoClientInfo bool `json:"DoClientInfo"` // If we want to disable ClientInfos
}
func MakeCampaign() Campaign {
c := Campaign{
ApiKey: "Secret-Api-Key",
EncKey: GetKey("Secret-Enc-Key"),
WithZip: true,
WithEnc: true,
ServerUrl: "http://127.0.0.1:8080",
PacketSendPath: "/send",
PacketGetPath: "/get/",
FileUploadPath: "/upload/",
FileDownloadPath: "/static/",
SecureDownloadPath: "/secure",
ClientWebsocketPath: "/ws",
AuthHeader: "X-Session-Token",
UserAgent: "Go-http-client/1.1",
HttpJitter: 20,
ClientUseWebsocket: true,
ProxyUrl: "",
DisableProxy: false, //
AutoStartDownstreams: false, // broken, do not use
DoClientInfo: true,
}
return c
}
func GetKey(encKey string) []byte {
key, err := scrypt.Key([]byte(encKey), []byte("antnium-salt"), 32768, 8, 1, 32)
if err != nil {
log.Fatal("Could not create key")
}
return key
}
func (c Campaign) GetProxy() (string, bool) {
if c.ProxyUrl != "" {
return c.ProxyUrl, true
} else {
return "", false
}
}