mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-25 19:45:38 -05:00
actually close tcp and udp servers
This commit is contained in:
@@ -12,6 +12,7 @@ type Server struct {
|
||||
Port v2net.Port
|
||||
MsgProcessor func(msg []byte) []byte
|
||||
accepting bool
|
||||
listener *net.TCPListener
|
||||
}
|
||||
|
||||
func (server *Server) Start() (v2net.Destination, error) {
|
||||
@@ -23,6 +24,7 @@ func (server *Server) Start() (v2net.Destination, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
server.listener = listener
|
||||
go server.acceptConnections(listener)
|
||||
localAddr := listener.Addr().(*net.TCPAddr)
|
||||
return v2net.TCPDestination(v2net.IPAddress(localAddr.IP), v2net.Port(localAddr.Port)), nil
|
||||
@@ -55,5 +57,6 @@ func (server *Server) handleConnection(conn net.Conn) {
|
||||
}
|
||||
|
||||
func (this *Server) Close() {
|
||||
this.accepting = true
|
||||
this.accepting = false
|
||||
this.listener.Close()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user