-
Notifications
You must be signed in to change notification settings - Fork 188
/
Copy pathmain.go
66 lines (61 loc) · 1.63 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
package main
import (
"fmt"
"iox/operate"
"iox/option"
"os"
)
const VERSION = "0.4"
func Usage() {
fmt.Printf(
"iox v%v\n"+
" Access intranet easily (https://github.com/eddieivan01/iox)\n\n"+
"Usage: iox fwd/proxy [-l [*][HOST:]PORT] [-r [*]HOST:PORT] [-k HEX] [-t TIMEOUT] [-u] [-h] [-v]\n\n"+
"Options:\n"+
" -l [*][HOST:]PORT\n"+
" address to listen on. `*` means encrypted socket\n"+
" -r [*]HOST:PORT\n"+
" remote host to connect, HOST can be IP or Domain. `*` means encrypted socket\n"+
" -k HEX\n"+
" hexadecimal format key, be used to generate Key and IV\n"+
" -u\n"+
" udp forward mode\n"+
" -t TIMEOUT\n"+
" set connection timeout(millisecond), default is 5000\n"+
" -v\n"+
" enable log output\n"+
" -h\n"+
" print usage then exit\n", VERSION,
)
}
func main() {
mode, submode, local, remote, lenc, renc, err := option.ParseCli(os.Args[1:])
if err != nil {
if err == option.PrintUsage {
Usage()
} else {
fmt.Println(err.Error())
}
return
}
switch mode {
case "fwd":
switch submode {
case option.SUBMODE_L2R:
operate.Local2Remote(local[0], remote[0], lenc[0], renc[0])
case option.SUBMODE_L2L:
operate.Local2Local(local[0], local[1], lenc[0], lenc[1])
case option.SUBMODE_R2R:
operate.Remote2Remote(remote[0], remote[1], renc[0], renc[1])
}
case "proxy":
switch submode {
case option.SUBMODE_LP:
operate.ProxyLocal(local[0], lenc[0])
case option.SUBMODE_RP:
operate.ProxyRemote(remote[0], renc[0])
case option.SUBMODE_RPL2L:
operate.ProxyRemoteL2L(local[0], local[1], lenc[0], lenc[1])
}
}
}