From f02ed95ef1e1b1d7fbcaa630d6f5b63f3e6dcf8c Mon Sep 17 00:00:00 2001 From: Hurricanezwf <1094646850@qq.com> Date: Mon, 29 Feb 2016 12:38:45 +0800 Subject: [PATCH] enable client to connect non-local [ip:port] --- conf/frpc.ini | 1 + src/frp/models/client/client.go | 3 ++- src/frp/models/client/config.go | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/conf/frpc.ini b/conf/frpc.ini index 447cdc8..c424fe8 100644 --- a/conf/frpc.ini +++ b/conf/frpc.ini @@ -11,4 +11,5 @@ log_way = console # test1即为name [test1] passwd = 123 +local_ip = 127.0.0.1 local_port = 22 diff --git a/src/frp/models/client/client.go b/src/frp/models/client/client.go index 69d256d..3a2073f 100644 --- a/src/frp/models/client/client.go +++ b/src/frp/models/client/client.go @@ -12,11 +12,12 @@ import ( type ProxyClient struct { Name string Passwd string + LocalIp string LocalPort int64 } func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error) { - c, err = conn.ConnectServer("127.0.0.1", p.LocalPort) + c, err = conn.ConnectServer(p.LocalIp, p.LocalPort) if err != nil { log.Error("ProxyName [%s], connect to local port error, %v", p.Name, err) } diff --git a/src/frp/models/client/config.go b/src/frp/models/client/config.go index f82e6ae..0e3f814 100644 --- a/src/frp/models/client/config.go +++ b/src/frp/models/client/config.go @@ -66,6 +66,11 @@ func LoadConf(confFile string) (err error) { return fmt.Errorf("Parse ini file error: proxy [%s] no passwd found", proxyClient.Name) } + proxyClient.LocalIp, ok = section["local_ip"] + if !ok { + return fmt.Errorf("Parse ini file error: proxy [%s] no local_ip found", proxyClient.Name) + } + portStr, ok := section["local_port"] if ok { proxyClient.LocalPort, err = strconv.ParseInt(portStr, 10, 64)