fix client for updated stuff

This commit is contained in:
Cadey Ratio 2017-03-26 13:14:24 -07:00
parent 8638fe9bcc
commit dbcf69c837
2 changed files with 23 additions and 12 deletions

View File

@ -1,32 +1,39 @@
package main package main
import ( import (
"crypto/tls"
"flag" "flag"
"log" "os"
"git.xeserv.us/xena/route/lib/tunnel" "git.xeserv.us/xena/route/lib/tun2"
"github.com/Xe/ln"
) )
var ( var (
token = flag.String("token", "", "Service identifier token") token = flag.String("token", "", "Service identifier token")
backend = flag.String("backend", "127.0.0.1:9090", "backend TCP/HTTP server") domain = flag.String("domain", "", "Domain to ID as")
serverAddr = flag.String("server", "127.0.0.1:9234", "frontend HTTP server") backend = flag.String("backend", "http://127.0.0.1:9090", "backend TCP/HTTP server")
serverAddr = flag.String("server", "127.0.0.1:9234", "frontend KCP server")
) )
func main() { func main() {
flag.Parse() flag.Parse()
cfg := &tunnel.ClientConfig{ cfg := &tun2.ClientConfig{
Identifier: *token, TLSConfig: &tls.Config{},
LocalAddr: *backend, ConnType: "kcp",
ServerAddr: *serverAddr, ServerAddr: *serverAddr,
Debug: true, Token: *token,
Domain: *domain,
BackendURL: *backend,
} }
client, err := tunnel.NewClient(cfg) client, _ := tun2.NewClient(cfg)
err := client.Connect()
if err != nil { if err != nil {
log.Fatal(err) ln.Error(err, ln.F{
"action": "client_running",
})
os.Exit(1)
} }
client.Start()
} }

View File

@ -38,6 +38,10 @@ func NewClient(cfg *ClientConfig) (*Client, error) {
return c, nil return c, nil
} }
func (c *Client) Connect() error {
return c.connect(c.cfg.ServerAddr)
}
func (c *Client) connect(serverAddr string) error { func (c *Client) connect(serverAddr string) error {
target, err := url.Parse(c.cfg.BackendURL) target, err := url.Parse(c.cfg.BackendURL)
if err != nil { if err != nil {