Skip to content

Commit

Permalink
Merge pull request fatedier#184 from fatedier/fatedier/udp
Browse files Browse the repository at this point in the history
udp: fix privilege_mode not success for udp type
  • Loading branch information
fatedier authored Dec 19, 2016
2 parents d9304d8 + d04d31b commit d7d2b72
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/models/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func (pc *ProxyClient) StartUdpTunnelOnce(addr string, port int64) {
}
if err != nil {
log.Error("ProxyName [%s], udp tunnel connect to server [%s:%d] error, %v", pc.Name, addr, port, err)
time.Sleep(5 * time.Second)
time.Sleep(10 * time.Second)
continue
}
log.Info("ProxyName [%s], udp tunnel reconnect to server [%s:%d] success", pc.Name, addr, port)

nowTime := time.Now().Unix()
req := &msg.ControlReq{
Expand Down
2 changes: 1 addition & 1 deletion src/models/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func LoadConf(confFile string) (err error) {
proxyClient.PrivilegeToken = PrivilegeToken
}

if proxyClient.Type == "tcp" {
if proxyClient.Type == "tcp" || proxyClient.Type == "udp" {
// remote_port
tmpStr, ok = section["remote_port"]
if ok {
Expand Down
12 changes: 6 additions & 6 deletions src/models/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewProxyServerFromCtlMsg(req *msg.ControlReq) (p *ProxyServer) {
p.PrivilegeMode = req.PrivilegeMode
p.PrivilegeToken = PrivilegeToken
p.BindAddr = BindAddr
if p.Type == "tcp" {
if p.Type == "tcp" || p.Type == "udp" {
p.ListenPort = req.RemotePort
} else if p.Type == "http" {
p.ListenPort = VhostHttpPort
Expand Down Expand Up @@ -160,11 +160,6 @@ func (p *ProxyServer) Start(c *conn.Conn) (err error) {
p.Unlock()
metric.SetStatus(p.Name, p.Status)

// create connection pool if needed
if p.PoolCount > 0 {
go p.connectionPoolManager(p.closeChan)
}

if p.Type == "udp" {
// udp is special
p.udpConn, err = conn.ListenUDP(p.BindAddr, p.ListenPort)
Expand All @@ -191,6 +186,11 @@ func (p *ProxyServer) Start(c *conn.Conn) (err error) {
}
}()
} else {
// create connection pool if needed
if p.PoolCount > 0 {
go p.connectionPoolManager(p.closeChan)
}

// start a goroutine for every listener to accept user connection
for _, listener := range p.listeners {
go func(l Listener) {
Expand Down

0 comments on commit d7d2b72

Please sign in to comment.