-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
39 lines (29 loc) · 871 Bytes
/
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
package main
import (
"flag"
"os"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
var (
listenAddr = flag.String("listen", ":4444", "proxy listen address")
upstreamAddr = flag.String("upstream", "", "proxy upstream address")
signalServerAddr = flag.String("signal", "ws://localhost:8000/connection/websocket", "signaling server address")
secret = flag.String("secret", "", "server secret")
as = flag.String("as", "", "proxy ID")
to = flag.String("to", "", "proxy target ID")
)
func main() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout})
flag.Parse()
if *as != "" {
NewAs(*as, *secret, *upstreamAddr, *signalServerAddr)
for {
}
} else if *to != "" {
p := NewTo(*to, *secret, *signalServerAddr, *listenAddr)
log.Print("Proxy listening" + p.Listen + " to target " + p.ID)
p.ListenAndServe()
return
}
}