forked from coyove/goflyway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (48 loc) · 1.48 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
package main
import (
. "./config"
"./logg"
"./lookup"
"./lru"
"./proxy"
"fmt"
"runtime"
)
func main() {
fmt.Println(` __// __ _
/.__.\ / _| |
\ \/ / __ _ ___ | |_| |_ ___ ____ _ _ _
'__/ \ / _' |/ _ \| _| | | | \ \ /\ / / _' | | | |
\- ) | (_| | (_) | | | | |_| |\ V V / (_| | |_| |
\_____/ \__, |\___/|_| |_|\__, | \_/\_/ \__,_|\__, |
____|_|____ __/ | __/ | __/ |
" " cf |___/ |___/ |___/
`)
LoadConfig()
logg.RecordLocalhostError(*G_RecordLocalError)
if *G_Key == "0123456789abcdef" {
logg.W("[WARNING] you are using the default key, please change it by setting -k=KEY")
}
G_Cache, G_RequestDummies = lru.NewCache(*G_DNSCacheEntries), lru.NewCache(6)
if *G_UseChinaList && *G_Upstream != "" {
lookup.LoadOrCreateChinaList()
}
if *G_Debug {
logg.L("debug mode on, port 8100 for local redirection, upstream on 8101")
go proxy.StartClient(":8100", ":8101", "127.0.0.1:8102")
proxy.StartServer(":8102")
return
}
if *G_Upstream != "" {
proxy.StartClient(*G_Local, *G_SocksProxy, *G_Upstream)
} else {
// save some space because server doesn't need lookup
lookup.ChinaList = nil
lookup.IPv4LookupTable = nil
lookup.IPv4PrivateLookupTable = nil
lookup.CHN_IP = ""
// global variables are pain in the ass
runtime.GC()
proxy.StartServer(*G_Local)
}
}