route/cmd/route-httpagent/main.go

46 lines
964 B
Go

package main
import (
"context"
"crypto/tls"
"flag"
"time"
"git.xeserv.us/xena/route/internal/tun2"
"github.com/Xe/ln"
"github.com/facebookgo/flagenv"
)
var (
token = flag.String("token", "", "Service identifier token")
domain = flag.String("domain", "", "Domain to ID as")
backend = flag.String("backend", "http://127.0.0.1:9090", "backend TCP/HTTP server")
serverAddr = flag.String("server", "127.0.0.1:9234", "frontend server")
connMethod = flag.String("method", "tcp", "tcp or kcp connections?")
)
func main() {
flagenv.Parse()
flag.Parse()
cfg := &tun2.ClientConfig{
TLSConfig: &tls.Config{},
ConnType: *connMethod,
ServerAddr: *serverAddr,
Token: *token,
Domain: *domain,
BackendURL: *backend,
}
client, _ := tun2.NewClient(cfg)
for {
err := client.Connect()
if err != nil {
ln.Error(context.Background(), err, ln.Action("client connection failed"))
}
time.Sleep(2 * time.Second)
}
}