mirror of
https://github.com/fatedier/frp.git
synced 2024-11-27 20:49:10 +08:00
enable client to connect non-local [ip:port]
This commit is contained in:
parent
c7b0687b2c
commit
f02ed95ef1
@ -11,4 +11,5 @@ log_way = console
|
|||||||
# test1即为name
|
# test1即为name
|
||||||
[test1]
|
[test1]
|
||||||
passwd = 123
|
passwd = 123
|
||||||
|
local_ip = 127.0.0.1
|
||||||
local_port = 22
|
local_port = 22
|
||||||
|
@ -12,11 +12,12 @@ import (
|
|||||||
type ProxyClient struct {
|
type ProxyClient struct {
|
||||||
Name string
|
Name string
|
||||||
Passwd string
|
Passwd string
|
||||||
|
LocalIp string
|
||||||
LocalPort int64
|
LocalPort int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProxyClient) GetLocalConn() (c *conn.Conn, err error) {
|
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 {
|
if err != nil {
|
||||||
log.Error("ProxyName [%s], connect to local port error, %v", p.Name, err)
|
log.Error("ProxyName [%s], connect to local port error, %v", p.Name, err)
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,11 @@ func LoadConf(confFile string) (err error) {
|
|||||||
return fmt.Errorf("Parse ini file error: proxy [%s] no passwd found", proxyClient.Name)
|
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"]
|
portStr, ok := section["local_port"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyClient.LocalPort, err = strconv.ParseInt(portStr, 10, 64)
|
proxyClient.LocalPort, err = strconv.ParseInt(portStr, 10, 64)
|
||||||
|
Loading…
Reference in New Issue
Block a user