-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.go
executable file
·54 lines (46 loc) · 1 KB
/
client.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
//CLIENT
package main
import (
"fmt"
"log"
"net"
"./cmd"
"./core"
"./local"
)
var version = "master"
func main() {
fmt.Print("Ich*Liebe*Dich~ \n", "CLIENT\n")
log.SetFlags(log.Lshortfile)
// 默认配置
config := &cmd.Config{
ListenAddr: ":7448",
}
config.ReadConfig()
// 解析配置
password, err := core.ParsePassword(config.Password)
if err != nil {
log.Fatalln(err)
}
listenAddr, err := net.ResolveTCPAddr("tcp", config.ListenAddr)
if err != nil {
log.Fatalln(err)
}
remoteAddr, err := net.ResolveTCPAddr("tcp", config.RemoteAddr)
if err != nil {
log.Fatalln(err)
}
// 启动 local 端并监听
lsLocal := local.New(password, listenAddr, remoteAddr)
log.Fatalln(lsLocal.Listen(func(listenAddr net.Addr) {
log.Println("使用配置:", fmt.Sprintf(`
本地监听地址 listen:
%s
远程服务地址 remote:
%s
密码 password:
%s
`, listenAddr, remoteAddr, password))
log.Printf("lightsocks-local:%s 启动成功 监听在 %s\n", version, listenAddr.String())
}))
}