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
import (
"crypto/tls"
"flag"
"log"
"os"
"git.xeserv.us/xena/route/lib/tunnel"
"git.xeserv.us/xena/route/lib/tun2"
"github.com/Xe/ln"
)
var (
token = flag.String("token", "", "Service identifier token")
backend = flag.String("backend", "127.0.0.1:9090", "backend TCP/HTTP server")
serverAddr = flag.String("server", "127.0.0.1:9234", "frontend HTTP server")
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 KCP server")
)
func main() {
flag.Parse()
cfg := &tunnel.ClientConfig{
Identifier: *token,
LocalAddr: *backend,
cfg := &tun2.ClientConfig{
TLSConfig: &tls.Config{},
ConnType: "kcp",
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 {
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
}
func (c *Client) Connect() error {
return c.connect(c.cfg.ServerAddr)
}
func (c *Client) connect(serverAddr string) error {
target, err := url.Parse(c.cfg.BackendURL)
if err != nil {