mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
frpc: add parameter nat_hole_server_addr (#3351)
This commit is contained in:
parent
968ba4d3a1
commit
fccd518512
@ -305,8 +305,12 @@ func (pxy *XTCPProxy) InWorkConn(conn net.Conn, m *msg.StartWorkConn) {
|
||||
ProxyName: pxy.cfg.ProxyName,
|
||||
Sid: natHoleSidMsg.Sid,
|
||||
}
|
||||
serverAddr := pxy.clientCfg.NatHoleServerAddr
|
||||
if serverAddr == "" {
|
||||
serverAddr = pxy.clientCfg.ServerAddr
|
||||
}
|
||||
raddr, _ := net.ResolveUDPAddr("udp",
|
||||
net.JoinHostPort(pxy.clientCfg.ServerAddr, strconv.Itoa(pxy.serverUDPPort)))
|
||||
net.JoinHostPort(serverAddr, strconv.Itoa(pxy.serverUDPPort)))
|
||||
clientConn, err := net.DialUDP("udp", nil, raddr)
|
||||
if err != nil {
|
||||
xl.Error("dial server udp addr error: %v", err)
|
||||
|
@ -210,8 +210,12 @@ func (sv *XTCPVisitor) handleConn(userConn net.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
serverAddr := sv.ctl.clientCfg.NatHoleServerAddr
|
||||
if serverAddr == "" {
|
||||
serverAddr = sv.ctl.clientCfg.ServerAddr
|
||||
}
|
||||
raddr, err := net.ResolveUDPAddr("udp",
|
||||
net.JoinHostPort(sv.ctl.clientCfg.ServerAddr, strconv.Itoa(sv.ctl.serverUDPPort)))
|
||||
net.JoinHostPort(serverAddr, strconv.Itoa(sv.ctl.serverUDPPort)))
|
||||
if err != nil {
|
||||
xl.Error("resolve server UDP addr error")
|
||||
return
|
||||
|
@ -6,6 +6,10 @@
|
||||
server_addr = 0.0.0.0
|
||||
server_port = 7000
|
||||
|
||||
# Specify another address of the server to connect for nat hole. By default, it's same with
|
||||
# server_addr.
|
||||
# nat_hole_server_addr = 0.0.0.0
|
||||
|
||||
# The maximum amount of time a dial to server will wait for a connect to complete. Default value is 10 seconds.
|
||||
# dial_server_timeout = 10
|
||||
|
||||
|
@ -35,6 +35,9 @@ type ClientCommonConf struct {
|
||||
// ServerAddr specifies the address of the server to connect to. By
|
||||
// default, this value is "0.0.0.0".
|
||||
ServerAddr string `ini:"server_addr" json:"server_addr"`
|
||||
// Specify another address of the server to connect for nat hole. By default, it's same with
|
||||
// ServerAddr.
|
||||
NatHoleServerAddr string `ini:"nat_hole_server_addr" json:"nat_hole_server_addr"`
|
||||
// ServerPort specifies the port to connect to the server on. By default,
|
||||
// this value is 7000.
|
||||
ServerPort int `ini:"server_port" json:"server_port"`
|
||||
|
Loading…
Reference in New Issue
Block a user