1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

rename TCPListener to TCPHub

This commit is contained in:
v2ray 2016-01-28 20:47:00 +01:00
parent 4be27a6377
commit 1f9bd5f692
6 changed files with 12 additions and 12 deletions

View File

@ -20,7 +20,7 @@ type DokodemoDoor struct {
address v2net.Address address v2net.Address
port v2net.Port port v2net.Port
space app.Space space app.Space
tcpListener *hub.TCPListener tcpListener *hub.TCPHub
udpHub *hub.UDPHub udpHub *hub.UDPHub
listeningPort v2net.Port listeningPort v2net.Port
} }

View File

@ -24,7 +24,7 @@ type HttpProxyServer struct {
accepting bool accepting bool
space app.Space space app.Space
config *Config config *Config
tcpListener *hub.TCPListener tcpListener *hub.TCPHub
listeningPort v2net.Port listeningPort v2net.Port
} }

View File

@ -20,7 +20,7 @@ type Shadowsocks struct {
config *Config config *Config
port v2net.Port port v2net.Port
accepting bool accepting bool
tcpListener *hub.TCPListener tcpListener *hub.TCPHub
} }
func (this *Shadowsocks) Port() v2net.Port { func (this *Shadowsocks) Port() v2net.Port {

View File

@ -28,7 +28,7 @@ type SocksServer struct {
accepting bool accepting bool
space app.Space space app.Space
config *Config config *Config
tcpListener *hub.TCPListener tcpListener *hub.TCPHub
udpConn *net.UDPConn udpConn *net.UDPConn
udpAddress v2net.Destination udpAddress v2net.Destination
listeningPort v2net.Port listeningPort v2net.Port

View File

@ -25,7 +25,7 @@ type VMessInboundHandler struct {
clients protocol.UserSet clients protocol.UserSet
user *vmess.User user *vmess.User
accepting bool accepting bool
listener *hub.TCPListener listener *hub.TCPHub
features *FeaturesConfig features *FeaturesConfig
listeningPort v2net.Port listeningPort v2net.Port
} }

View File

@ -10,7 +10,7 @@ import (
type TCPConn struct { type TCPConn struct {
conn *net.TCPConn conn *net.TCPConn
listener *TCPListener listener *TCPHub
dirty bool dirty bool
} }
@ -62,13 +62,13 @@ func (this *TCPConn) CloseWrite() error {
return this.conn.CloseWrite() return this.conn.CloseWrite()
} }
type TCPListener struct { type TCPHub struct {
listener *net.TCPListener listener *net.TCPListener
connCallback func(*TCPConn) connCallback func(*TCPConn)
accepting bool accepting bool
} }
func ListenTCP(port v2net.Port, callback func(*TCPConn)) (*TCPListener, error) { func ListenTCP(port v2net.Port, callback func(*TCPConn)) (*TCPHub, error) {
listener, err := net.ListenTCP("tcp", &net.TCPAddr{ listener, err := net.ListenTCP("tcp", &net.TCPAddr{
IP: []byte{0, 0, 0, 0}, IP: []byte{0, 0, 0, 0},
Port: int(port), Port: int(port),
@ -77,7 +77,7 @@ func ListenTCP(port v2net.Port, callback func(*TCPConn)) (*TCPListener, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
tcpListener := &TCPListener{ tcpListener := &TCPHub{
listener: listener, listener: listener,
connCallback: callback, connCallback: callback,
} }
@ -85,12 +85,12 @@ func ListenTCP(port v2net.Port, callback func(*TCPConn)) (*TCPListener, error) {
return tcpListener, nil return tcpListener, nil
} }
func (this *TCPListener) Close() { func (this *TCPHub) Close() {
this.accepting = false this.accepting = false
this.listener.Close() this.listener.Close()
} }
func (this *TCPListener) start() { func (this *TCPHub) start() {
this.accepting = true this.accepting = true
for this.accepting { for this.accepting {
conn, err := this.listener.AcceptTCP() conn, err := this.listener.AcceptTCP()
@ -105,6 +105,6 @@ func (this *TCPListener) start() {
} }
} }
func (this *TCPListener) recycle(conn *net.TCPConn) { func (this *TCPHub) recycle(conn *net.TCPConn) {
} }