forked from javacafevn/vss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
170 lines (142 loc) · 4.71 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package main
import (
"flag"
"fmt"
"os"
"runtime"
"strings"
"time"
"github.com/aztecrabbit/brainfuck-psiphon-pro-go/src/libpsiphon"
"github.com/aztecrabbit/libinject"
"github.com/aztecrabbit/liblog"
"github.com/aztecrabbit/libproxyrotator"
"github.com/aztecrabbit/libredsocks"
"github.com/aztecrabbit/libutils"
)
const (
appName = "Brainfuck Tunnel"
appVersionName = "Psiphon Pro Go"
appVersionCode = "1.3.210109"
copyrightYear = "2020"
copyrightAuthor = "Aztec Rabbit"
)
var (
InterruptHandler = new(libutils.InterruptHandler)
Redsocks = new(libredsocks.Redsocks)
)
type Config struct {
ProxyRotator *libproxyrotator.Config
Inject *libinject.Config
PsiphonCore int
Psiphon *libpsiphon.Config
}
func init() {
InterruptHandler.Handle = func() {
libpsiphon.Stop()
libredsocks.Stop(Redsocks)
liblog.LogKeyboardInterrupt()
}
InterruptHandler.Start()
}
func GetConfigPath(filename string) string {
return libutils.GetConfigPath("brainfuck-psiphon-pro-go", filename)
}
func main() {
liblog.Header(
[]string{
fmt.Sprintf("%s [%s Version. %s]", appName, appVersionName, appVersionCode),
fmt.Sprintf("(c) %s %s.", copyrightYear, copyrightAuthor),
},
liblog.Colors["G1"],
)
config := new(Config)
defaultConfig := new(Config)
defaultConfig.ProxyRotator = libproxyrotator.DefaultConfig
defaultConfig.Inject = libinject.DefaultConfig
defaultConfig.Inject.Type = 2
defaultConfig.Inject.Rules = map[string][]string{
"akamai.net:80": []string{
"125.235.36.177",
},
}
defaultConfig.Inject.Payload = ""
defaultConfig.Inject.Timeout = 5
defaultConfig.PsiphonCore = 4
defaultConfig.Psiphon = libpsiphon.DefaultConfig
if runtime.GOOS == "windows" {
defaultConfig.Psiphon.CoreName += ".exe"
}
libutils.JsonReadWrite(GetConfigPath("config.json"), config, defaultConfig)
var flagPro = true
var flagRefresh = false
var flagVerbose = false
var flagFrontend string
var flagWhitelist string
flag.BoolVar(&flagPro, "pro", flagPro, "Pro Version?")
flag.BoolVar(&flagRefresh, "refresh", flagRefresh, "Refresh Data")
flag.BoolVar(&flagVerbose, "verbose", flagVerbose, "Verbose Log?")
flag.StringVar(&flagFrontend, "f", flagFrontend, "-f frontend-domains (e.g. -f cdn.com,cdn.com:443)")
flag.StringVar(&flagWhitelist, "w", flagWhitelist, "-w whitelist-request (e.g. -w akamai.net:80)")
flag.IntVar(&config.Inject.MeekType, "mt", config.Inject.MeekType, "-mt meek type (0 and 1 for fastly)")
flag.IntVar(&config.PsiphonCore, "c", config.PsiphonCore, "-c core (e.g. -c 4) (1 for Pro Version)")
flag.StringVar(&config.Psiphon.Region, "r", config.Psiphon.Region, "-r region (e.g. -r sg)")
flag.IntVar(&config.Psiphon.Tunnel, "t", config.Psiphon.Tunnel, "-t tunnel (e.g. -t 4) (1 for Reconnect Version)")
flag.IntVar(&config.Psiphon.TunnelWorkers, "tw", config.Psiphon.TunnelWorkers, "-tw tunnel-workers (e.g. -tw 6) (8 for Pro Version)")
flag.IntVar(&config.Psiphon.KuotaDataLimit, "l", config.Psiphon.KuotaDataLimit, "-l limit (in MB) (e.g. -l 4) (0 for Pro Version (unlimited))")
flag.Parse()
if !flagPro {
config.Psiphon.Authorizations = make([]string, 0)
}
if flagRefresh {
libpsiphon.RemoveData()
}
if flagFrontend != "" || flagWhitelist != "" {
if flagFrontend == "" {
flagFrontend = "*"
}
if flagWhitelist == "" {
flagWhitelist = "*:*"
}
config.Inject.Rules = map[string][]string{
flagWhitelist: strings.Split(flagFrontend, ","),
}
}
ProxyRotator := new(libproxyrotator.ProxyRotator)
ProxyRotator.Config = config.ProxyRotator
Inject := new(libinject.Inject)
Inject.Redsocks = Redsocks
Inject.Config = config.Inject
go ProxyRotator.Start()
go Inject.Start()
time.Sleep(200 * time.Millisecond)
liblog.LogInfo("Domain Fronting running on port "+Inject.Config.Port, "INFO", liblog.Colors["G1"])
liblog.LogInfo("Proxy Rotator running on port "+ProxyRotator.Config.Port, "INFO", liblog.Colors["G1"])
if _, err := os.Stat(libutils.RealPath(config.Psiphon.CoreName)); os.IsNotExist(err) {
liblog.LogInfo(
fmt.Sprintf(
"Exception:\n\n"+
"| File '%s' not exist!\n"+
"| Exiting...\n"+
"|\n",
config.Psiphon.CoreName,
),
"INFO", liblog.Colors["R1"],
)
return
}
Redsocks.Config = libredsocks.DefaultConfig
Redsocks.Config.LogOutput = GetConfigPath("redsocks.log")
Redsocks.Config.ConfigOutput = GetConfigPath("redsocks.conf")
Redsocks.Start()
for i := 1; i <= config.PsiphonCore; i++ {
Psiphon := new(libpsiphon.Psiphon)
Psiphon.ProxyRotator = ProxyRotator
Psiphon.Config = config.Psiphon
Psiphon.ProxyPort = Inject.Config.Port
Psiphon.KuotaData = libpsiphon.DefaultKuotaData
Psiphon.ListenPort = libutils.Atoi(ProxyRotator.Config.Port) + i
Psiphon.Verbose = flagVerbose
go Psiphon.Start()
}
InterruptHandler.Wait()
}