mirror of
				https://github.com/v2fly/v2ray-core.git
				synced 2025-11-04 11:49:16 +00:00 
			
		
		
		
	rename transport/listener to hub
This commit is contained in:
		
							parent
							
								
									30f131b9ee
								
							
						
					
					
						commit
						925c06aeed
					
				@ -10,7 +10,7 @@ import (
 | 
			
		||||
	"github.com/v2ray/v2ray-core/common/log"
 | 
			
		||||
	v2net "github.com/v2ray/v2ray-core/common/net"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/listener"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/hub"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type DokodemoDoor struct {
 | 
			
		||||
@ -21,7 +21,7 @@ type DokodemoDoor struct {
 | 
			
		||||
	address       v2net.Address
 | 
			
		||||
	port          v2net.Port
 | 
			
		||||
	space         app.Space
 | 
			
		||||
	tcpListener   *listener.TCPListener
 | 
			
		||||
	tcpListener   *hub.TCPListener
 | 
			
		||||
	udpConn       *net.UDPConn
 | 
			
		||||
	listeningPort v2net.Port
 | 
			
		||||
}
 | 
			
		||||
@ -132,7 +132,7 @@ func (this *DokodemoDoor) handleUDPPackets() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
 | 
			
		||||
	tcpListener, err := listener.ListenTCP(port, this.HandleTCPConnection)
 | 
			
		||||
	tcpListener, err := hub.ListenTCP(port, this.HandleTCPConnection)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Error("Dokodemo: Failed to listen on port ", port, ": ", err)
 | 
			
		||||
		return err
 | 
			
		||||
@ -143,7 +143,7 @@ func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *DokodemoDoor) HandleTCPConnection(conn *listener.TCPConn) {
 | 
			
		||||
func (this *DokodemoDoor) HandleTCPConnection(conn *hub.TCPConn) {
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
 | 
			
		||||
	packet := v2net.NewPacket(v2net.TCPDestination(this.address, this.port), nil, true)
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ import (
 | 
			
		||||
	v2net "github.com/v2ray/v2ray-core/common/net"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/common/serial"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/listener"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/hub"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/ray"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ type HttpProxyServer struct {
 | 
			
		||||
	accepting     bool
 | 
			
		||||
	space         app.Space
 | 
			
		||||
	config        *Config
 | 
			
		||||
	tcpListener   *listener.TCPListener
 | 
			
		||||
	tcpListener   *hub.TCPListener
 | 
			
		||||
	listeningPort v2net.Port
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -59,7 +59,7 @@ func (this *HttpProxyServer) Listen(port v2net.Port) error {
 | 
			
		||||
	}
 | 
			
		||||
	this.listeningPort = port
 | 
			
		||||
 | 
			
		||||
	tcpListener, err := listener.ListenTCP(port, this.handleConnection)
 | 
			
		||||
	tcpListener, err := hub.ListenTCP(port, this.handleConnection)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Error("Http: Failed listen on port ", port, ": ", err)
 | 
			
		||||
		return err
 | 
			
		||||
@ -94,7 +94,7 @@ func parseHost(rawHost string, defaultPort v2net.Port) (v2net.Destination, error
 | 
			
		||||
	return v2net.TCPDestination(v2net.DomainAddress(host), port), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *HttpProxyServer) handleConnection(conn *listener.TCPConn) {
 | 
			
		||||
func (this *HttpProxyServer) handleConnection(conn *hub.TCPConn) {
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
	reader := bufio.NewReader(conn)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -12,7 +12,7 @@ import (
 | 
			
		||||
	v2net "github.com/v2ray/v2ray-core/common/net"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy/internal"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/listener"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/hub"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Shadowsocks struct {
 | 
			
		||||
@ -20,7 +20,7 @@ type Shadowsocks struct {
 | 
			
		||||
	config      *Config
 | 
			
		||||
	port        v2net.Port
 | 
			
		||||
	accepting   bool
 | 
			
		||||
	tcpListener *listener.TCPListener
 | 
			
		||||
	tcpListener *hub.TCPListener
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *Shadowsocks) Port() v2net.Port {
 | 
			
		||||
@ -42,7 +42,7 @@ func (this *Shadowsocks) Listen(port v2net.Port) error {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tcpListener, err := listener.ListenTCP(port, this.handleConnection)
 | 
			
		||||
	tcpListener, err := hub.ListenTCP(port, this.handleConnection)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Error("Shadowsocks: Failed to listen on port ", port, ": ", err)
 | 
			
		||||
		return err
 | 
			
		||||
@ -52,7 +52,7 @@ func (this *Shadowsocks) Listen(port v2net.Port) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *Shadowsocks) handleConnection(conn *listener.TCPConn) {
 | 
			
		||||
func (this *Shadowsocks) handleConnection(conn *hub.TCPConn) {
 | 
			
		||||
	defer conn.Close()
 | 
			
		||||
 | 
			
		||||
	buffer := alloc.NewSmallBuffer()
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ import (
 | 
			
		||||
	v2net "github.com/v2ray/v2ray-core/common/net"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy/socks/protocol"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/listener"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/hub"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@ -28,7 +28,7 @@ type SocksServer struct {
 | 
			
		||||
	accepting     bool
 | 
			
		||||
	space         app.Space
 | 
			
		||||
	config        *Config
 | 
			
		||||
	tcpListener   *listener.TCPListener
 | 
			
		||||
	tcpListener   *hub.TCPListener
 | 
			
		||||
	udpConn       *net.UDPConn
 | 
			
		||||
	udpAddress    v2net.Destination
 | 
			
		||||
	listeningPort v2net.Port
 | 
			
		||||
@ -71,7 +71,7 @@ func (this *SocksServer) Listen(port v2net.Port) error {
 | 
			
		||||
	}
 | 
			
		||||
	this.listeningPort = port
 | 
			
		||||
 | 
			
		||||
	listener, err := listener.ListenTCP(port, this.HandleConnection)
 | 
			
		||||
	listener, err := hub.ListenTCP(port, this.HandleConnection)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Error("Socks: failed to listen on port ", port, ": ", err)
 | 
			
		||||
		return err
 | 
			
		||||
@ -86,7 +86,7 @@ func (this *SocksServer) Listen(port v2net.Port) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *SocksServer) HandleConnection(connection *listener.TCPConn) {
 | 
			
		||||
func (this *SocksServer) HandleConnection(connection *hub.TCPConn) {
 | 
			
		||||
	defer connection.Close()
 | 
			
		||||
 | 
			
		||||
	reader := v2net.NewTimeOutReader(120, connection)
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@ import (
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy/internal"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy/vmess"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/proxy/vmess/protocol"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/listener"
 | 
			
		||||
	"github.com/v2ray/v2ray-core/transport/hub"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// Inbound connection handler that handles messages in VMess format.
 | 
			
		||||
@ -25,7 +25,7 @@ type VMessInboundHandler struct {
 | 
			
		||||
	clients       protocol.UserSet
 | 
			
		||||
	user          *vmess.User
 | 
			
		||||
	accepting     bool
 | 
			
		||||
	listener      *listener.TCPListener
 | 
			
		||||
	listener      *hub.TCPListener
 | 
			
		||||
	features      *FeaturesConfig
 | 
			
		||||
	listeningPort v2net.Port
 | 
			
		||||
}
 | 
			
		||||
@ -58,7 +58,7 @@ func (this *VMessInboundHandler) Listen(port v2net.Port) error {
 | 
			
		||||
	}
 | 
			
		||||
	this.listeningPort = port
 | 
			
		||||
 | 
			
		||||
	tcpListener, err := listener.ListenTCP(port, this.HandleConnection)
 | 
			
		||||
	tcpListener, err := hub.ListenTCP(port, this.HandleConnection)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Error("Unable to listen tcp port ", port, ": ", err)
 | 
			
		||||
		return err
 | 
			
		||||
@ -70,7 +70,7 @@ func (this *VMessInboundHandler) Listen(port v2net.Port) error {
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *VMessInboundHandler) HandleConnection(connection *listener.TCPConn) {
 | 
			
		||||
func (this *VMessInboundHandler) HandleConnection(connection *hub.TCPConn) {
 | 
			
		||||
	defer connection.Close()
 | 
			
		||||
 | 
			
		||||
	connReader := v2net.NewTimeOutReader(16, connection)
 | 
			
		||||
 | 
			
		||||
@ -1,4 +1,4 @@
 | 
			
		||||
package listener
 | 
			
		||||
package hub
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net"
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user