-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathmain.go
52 lines (42 loc) · 1.31 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
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/hashicorp/yamux"
)
var session *yamux.Session
func main() {
listen := flag.String("listen", "", "listen port for receiver address:port")
socks := flag.String("socks", "127.0.0.1:1080", "socks address:port")
connect := flag.String("connect", "", "connect address:port")
version := flag.Bool("version", false, "version information")
flag.Usage = func() {
fmt.Println("rsocks - reverse socks5 server/client")
fmt.Println("https://github.com/brimstone/rsocks")
fmt.Println("")
fmt.Println("Usage:")
fmt.Println("1) Start rsocks -listen :8080 -socks 127.0.0.1:1080 on the client.")
fmt.Println("2) Start rsocks -connect client:8080 on the server.")
fmt.Println("3) Connect to 127.0.0.1:1080 on the client with any socks5 client.")
fmt.Println("4) Enjoy. :]")
}
flag.Parse()
if *version {
fmt.Println("rsocks - reverse socks5 server/client")
fmt.Println("https://github.com/brimstone/rsocks")
os.Exit(0)
}
if *listen != "" {
log.Println("Starting to listen for clients")
go listenForSocks(*listen)
log.Fatal(listenForClients(*socks))
}
if *connect != "" {
log.Println("Connecting to the far end")
log.Fatal(connectForSocks(*connect))
}
fmt.Fprintf(os.Stderr, "You must specify a listen port or a connect address")
os.Exit(1)
}