-
Notifications
You must be signed in to change notification settings - Fork 49
/
main.go
45 lines (35 loc) · 1.09 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
package main
import (
"flag"
"fmt"
"github.com/wweir/sower/conf"
"github.com/wweir/sower/proxy"
"github.com/wweir/sower/router"
"github.com/wweir/sower/transport"
)
func main() {
client, server, password := conf.Init()
switch {
case server.Upstream != "":
proxy.StartServer(server.Upstream, password, conf.ConfigDir,
server.CertFile, server.KeyFile, server.CertEmail)
case client.Address != "":
route := router.NewRoute(client.Address, password, client.Router.DetectLevel,
client.Router.BlockList, client.Router.ProxyList, client.Router.DirectList,
conf.PersistRule)
if client.Socks5Proxy != "" {
go proxy.StartSocks5Proxy(client.Socks5Proxy, client.Address, []byte(password))
}
if client.HTTPProxy != "" {
go proxy.StartHTTPProxy(client.HTTPProxy, client.Address,
[]byte(password), route.GenProxyCheck(true))
}
transport.SetDNS(nil, client.DNSUpstream)
go proxy.StartDNS(client.DNSUpstream, route.GenProxyCheck(false))
proxy.StartClient(client.Address, password,
client.PortForward, route.GenProxyCheck(true))
default:
fmt.Println()
flag.Usage()
}
}