2017-01-18 09:57:18 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-10-01 13:28:13 +00:00
|
|
|
"context"
|
2017-03-26 20:14:24 +00:00
|
|
|
"crypto/tls"
|
2017-01-18 09:57:18 +00:00
|
|
|
"flag"
|
2017-10-01 20:42:33 +00:00
|
|
|
"time"
|
2017-01-18 09:57:18 +00:00
|
|
|
|
2017-10-01 15:23:08 +00:00
|
|
|
"git.xeserv.us/xena/route/internal/tun2"
|
2017-03-26 20:14:24 +00:00
|
|
|
"github.com/Xe/ln"
|
2017-09-30 14:26:28 +00:00
|
|
|
"github.com/facebookgo/flagenv"
|
2017-12-15 18:57:17 +00:00
|
|
|
_ "github.com/joho/godotenv"
|
2017-01-18 09:57:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2017-12-15 18:57:17 +00:00
|
|
|
token = flag.String("token", "", "authentication token used to authenticate with routed")
|
|
|
|
domain = flag.String("domain", "", "domain to use when authenticating with routed")
|
|
|
|
backend = flag.String("backend", "http://127.0.0.1:9090", "backend TCP/HTTP server route-httpagent should relay traffic to/from")
|
|
|
|
serverAddr = flag.String("server", "127.0.0.1:9234", "the address that routed is listening on for backend connections")
|
|
|
|
connMethod = flag.String("method", "tcp", "the connection method used to talk to routed (MUST be either 'tcp' or 'kcp')")
|
2017-01-18 09:57:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-09-30 14:26:28 +00:00
|
|
|
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,
|
2017-01-22 17:48:37 +00:00
|
|
|
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)
|
2017-10-01 20:42:33 +00:00
|
|
|
|
|
|
|
for {
|
2017-10-04 07:00:16 +00:00
|
|
|
err := client.Connect(context.Background())
|
2017-10-01 20:42:33 +00:00
|
|
|
if err != nil {
|
|
|
|
ln.Error(context.Background(), err, ln.Action("client connection failed"))
|
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(2 * time.Second)
|
2017-01-18 09:57:18 +00:00
|
|
|
}
|
|
|
|
}
|