route/cmd/route-httpagent/main.go

40 lines
914 B
Go

package main
import (
"context"
"crypto/tls"
"flag"
"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)
err := client.Connect()
if err != nil {
ln.FatalErr(context.Background(), err, ln.Action("http agent is now running"))
}
}