-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
54 lines (42 loc) · 1.15 KB
/
config.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
package main
import (
"log"
"net"
"os"
"strconv"
)
//very simple and bad format of config parser, its better to use
// golang default config parsers like go-ini, go-config ....
//FIXME: read from config file (config.yml)
func ParseConfig() *vpnConfig {
config := new(vpnConfig)
RemoteIp := os.Args[1]
RemotePort :=os.Args[2]
LocalIp := os.Args[3]
LocalPort :=os.Args[4]
remoteIp := net.ParseIP(RemoteIp)
if remoteIp==nil {
log.Fatalln("your remote ip is not valid ipv4")
}
remotePort,e :=strconv.Atoi(RemotePort)
if e!=nil {
log.Fatalln("your port is not valid port")
}
localIp := net.ParseIP(LocalIp)
if localIp==nil {
log.Fatalln("your local ip is not valid ipv4")
}
localPort,e :=strconv.Atoi(LocalPort)
if e!=nil {
log.Fatalln("your local port is not valid port")
}
config.remoteIp = remoteIp
config.remotePort= (uint16)(remotePort)
config.localIp = localIp
config.localPort= (uint16)(localPort)
log.Printf("Ip to Connect: %s Port:%s",RemoteIp,RemotePort)
config.xorKey=[]byte{1,2,3,4,5,6,7,8,9,10,11,12}
config.desKey=[]byte("masoudisgoodboyandheistryintosolveproblems!!")
config.encryptionMethod = "xor"
return config
}