route/cmd/route-httpagent/main.go

43 lines
894 B
Go
Raw Normal View History

2017-01-18 09:57:18 +00:00
package main
import (
2017-03-26 20:14:24 +00:00
"crypto/tls"
2017-01-18 09:57:18 +00:00
"flag"
2017-03-26 20:14:24 +00:00
"os"
2017-01-18 09:57:18 +00:00
2017-03-26 20:14:24 +00:00
"git.xeserv.us/xena/route/lib/tun2"
"github.com/Xe/ln"
"github.com/facebookgo/flagenv"
2017-01-18 09:57:18 +00:00
)
var (
token = flag.String("token", "", "Service identifier token")
2017-03-26 20:14:24 +00:00
domain = flag.String("domain", "", "Domain to ID as")
backend = flag.String("backend", "http://127.0.0.1:9090", "backend TCP/HTTP server")
2017-03-26 20:57:09 +00:00
serverAddr = flag.String("server", "127.0.0.1:9234", "frontend server")
connMethod = flag.String("method", "tcp", "tcp or kcp connections?")
2017-01-18 09:57:18 +00:00
)
func main() {
flagenv.Parse()
2017-01-18 09:57:18 +00:00
flag.Parse()
2017-03-26 20:14:24 +00:00
cfg := &tun2.ClientConfig{
TLSConfig: &tls.Config{},
2017-03-26 20:57:09 +00:00
ConnType: *connMethod,
ServerAddr: *serverAddr,
2017-03-26 20:14:24 +00:00
Token: *token,
Domain: *domain,
BackendURL: *backend,
2017-01-18 09:57:18 +00:00
}
2017-03-26 20:14:24 +00:00
client, _ := tun2.NewClient(cfg)
err := client.Connect()
2017-01-18 09:57:18 +00:00
if err != nil {
2017-03-26 20:14:24 +00:00
ln.Error(err, ln.F{
"action": "client_running",
})
os.Exit(1)
2017-01-18 09:57:18 +00:00
}
}