v2ray 9 лет назад
Родитель
Сommit
4271e619fe
4 измененных файлов с 10 добавлено и 0 удалено
  1. 4 0
      proxy/dokodemo/dokodemo.go
  2. 2 0
      proxy/socks/socks.go
  3. 2 0
      proxy/socks/udp.go
  4. 2 0
      proxy/vmess/inbound/inbound.go

+ 4 - 0
proxy/dokodemo/dokodemo.go

@@ -77,7 +77,9 @@ func (this *DokodemoDoor) ListenUDP(port v2net.Port) error {
 		log.Error("Dokodemo failed to listen on port %d: %v", port, err)
 		return err
 	}
+	this.udpMutex.Lock()
 	this.udpConn = udpConn
+	this.udpMutex.Unlock()
 	go this.handleUDPPackets()
 	return nil
 }
@@ -125,7 +127,9 @@ func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
 		log.Error("Dokodemo failed to listen on port %d: %v", port, err)
 		return err
 	}
+	this.tcpMutex.Lock()
 	this.tcpListener = tcpListener
+	this.tcpMutex.Unlock()
 	go this.AcceptTCPConnections()
 	return nil
 }

+ 2 - 0
proxy/socks/socks.go

@@ -67,7 +67,9 @@ func (this *SocksServer) Listen(port v2net.Port) error {
 		return err
 	}
 	this.accepting = true
+	this.tcpMutex.Lock()
 	this.tcpListener = listener
+	this.tcpMutex.Unlock()
 	go this.AcceptConnections()
 	if this.config.UDPEnabled() {
 		this.ListenUDP(port)

+ 2 - 0
proxy/socks/udp.go

@@ -20,8 +20,10 @@ func (this *SocksServer) ListenUDP(port v2net.Port) error {
 		log.Error("Socks failed to listen UDP on port %d: %v", port, err)
 		return err
 	}
+	this.udpMutex.Lock()
 	this.udpAddress = v2net.UDPDestination(v2net.IPAddress(this.config.IP()), port)
 	this.udpConn = conn
+	this.udpMutex.Unlock()
 
 	go this.AcceptPackets()
 	return nil

+ 2 - 0
proxy/vmess/inbound/inbound.go

@@ -56,7 +56,9 @@ func (this *VMessInboundHandler) Listen(port v2net.Port) error {
 		return err
 	}
 	this.accepting = true
+	this.Lock()
 	this.listener = listener
+	this.Unlock()
 	go this.AcceptConnections()
 	return nil
 }