mirror of
https://github.com/fatedier/frp.git
synced 2024-12-12 17:50:51 +01:00
commands for xtcp, stcp add 'bind_port', fix #767
This commit is contained in:
parent
c7a457a045
commit
3e349455a0
@ -69,6 +69,7 @@ var (
|
|||||||
sk string
|
sk string
|
||||||
serverName string
|
serverName string
|
||||||
bindAddr string
|
bindAddr string
|
||||||
|
bindPort int
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -39,7 +39,8 @@ func init() {
|
|||||||
stcpCmd.PersistentFlags().StringVarP(&serverName, "server_name", "", "", "server name")
|
stcpCmd.PersistentFlags().StringVarP(&serverName, "server_name", "", "", "server name")
|
||||||
stcpCmd.PersistentFlags().StringVarP(&localIp, "local_ip", "i", "127.0.0.1", "local ip")
|
stcpCmd.PersistentFlags().StringVarP(&localIp, "local_ip", "i", "127.0.0.1", "local ip")
|
||||||
stcpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
|
stcpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
|
||||||
stcpCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "", "bind addr such as 127.0.0.1:9000")
|
stcpCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "", "bind addr")
|
||||||
|
stcpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port")
|
||||||
stcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
|
stcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
|
||||||
stcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")
|
stcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ var stcpCmd = &cobra.Command{
|
|||||||
cfg.LocalIp = localIp
|
cfg.LocalIp = localIp
|
||||||
cfg.LocalPort = localPort
|
cfg.LocalPort = localPort
|
||||||
cfg.BindAddr = bindAddr
|
cfg.BindAddr = bindAddr
|
||||||
|
cfg.BindPort = bindPort
|
||||||
cfg.UseEncryption = useEncryption
|
cfg.UseEncryption = useEncryption
|
||||||
cfg.UseCompression = useCompression
|
cfg.UseCompression = useCompression
|
||||||
|
|
||||||
|
@ -39,7 +39,8 @@ func init() {
|
|||||||
xtcpCmd.PersistentFlags().StringVarP(&serverName, "server_name", "", "", "server name")
|
xtcpCmd.PersistentFlags().StringVarP(&serverName, "server_name", "", "", "server name")
|
||||||
xtcpCmd.PersistentFlags().StringVarP(&localIp, "local_ip", "i", "127.0.0.1", "local ip")
|
xtcpCmd.PersistentFlags().StringVarP(&localIp, "local_ip", "i", "127.0.0.1", "local ip")
|
||||||
xtcpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
|
xtcpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
|
||||||
xtcpCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "", "bind addr such as 127.0.0.1:9000")
|
xtcpCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "", "bind addr")
|
||||||
|
xtcpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port")
|
||||||
xtcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
|
xtcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
|
||||||
xtcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")
|
xtcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")
|
||||||
|
|
||||||
@ -69,6 +70,7 @@ var xtcpCmd = &cobra.Command{
|
|||||||
cfg.LocalIp = localIp
|
cfg.LocalIp = localIp
|
||||||
cfg.LocalPort = localPort
|
cfg.LocalPort = localPort
|
||||||
cfg.BindAddr = bindAddr
|
cfg.BindAddr = bindAddr
|
||||||
|
cfg.BindPort = bindPort
|
||||||
cfg.UseEncryption = useEncryption
|
cfg.UseEncryption = useEncryption
|
||||||
cfg.UseCompression = useCompression
|
cfg.UseCompression = useCompression
|
||||||
|
|
||||||
|
@ -675,6 +675,10 @@ func (cfg *StcpProxyConf) CheckForCli() (err error) {
|
|||||||
err = fmt.Errorf("bind_addr shouldn't be empty")
|
err = fmt.Errorf("bind_addr shouldn't be empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if cfg.BindPort == 0 {
|
||||||
|
err = fmt.Errorf("bind_port should be set")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -777,6 +781,10 @@ func (cfg *XtcpProxyConf) CheckForCli() (err error) {
|
|||||||
err = fmt.Errorf("bind_addr shouldn't be empty")
|
err = fmt.Errorf("bind_addr shouldn't be empty")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if cfg.BindPort == 0 {
|
||||||
|
err = fmt.Errorf("bind_port should be set")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,17 @@ func (nc *NatHoleController) HandleVisitor(m *msg.NatHoleVisitor, raddr *net.UDP
|
|||||||
}
|
}
|
||||||
nc.mu.Lock()
|
nc.mu.Lock()
|
||||||
clientCfg, ok := nc.clientCfgs[m.ProxyName]
|
clientCfg, ok := nc.clientCfgs[m.ProxyName]
|
||||||
if !ok || m.SignKey != util.GetAuthKey(clientCfg.Sk, m.Timestamp) {
|
if !ok {
|
||||||
nc.mu.Unlock()
|
nc.mu.Unlock()
|
||||||
|
log.Debug("xtcp server for [%s] doesn't exist", m.ProxyName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if m.SignKey != util.GetAuthKey(clientCfg.Sk, m.Timestamp) {
|
||||||
|
nc.mu.Unlock()
|
||||||
|
log.Debug("xtcp connection of [%s] auth failed", m.ProxyName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
nc.sessions[sid] = session
|
nc.sessions[sid] = session
|
||||||
nc.mu.Unlock()
|
nc.mu.Unlock()
|
||||||
log.Trace("handle visitor message, sid [%s]", sid)
|
log.Trace("handle visitor message, sid [%s]", sid)
|
||||||
|
Loading…
Reference in New Issue
Block a user