소스 검색

rename SocksServer to Server

v2ray 9 년 전
부모
커밋
991cea01ab
4개의 변경된 파일16개의 추가작업 그리고 16개의 파일을 삭제
  1. 13 13
      proxy/socks/server.go
  2. 0 0
      proxy/socks/server_test.go
  3. 1 1
      proxy/socks/socksfactory.go
  4. 2 2
      proxy/socks/udp.go

+ 13 - 13
proxy/socks/socks.go → proxy/socks/server.go

@@ -20,8 +20,8 @@ var (
 	ErrorUnsupportedAuthMethod   = errors.New("Unsupported auth method.")
 )
 
-// SocksServer is a SOCKS 5 proxy server
-type SocksServer struct {
+// Server is a SOCKS 5 proxy server
+type Server struct {
 	tcpMutex         sync.RWMutex
 	udpMutex         sync.RWMutex
 	accepting        bool
@@ -34,21 +34,21 @@ type SocksServer struct {
 	listeningPort    v2net.Port
 }
 
-// NewSocksSocks creates a new SocksServer object.
-func NewSocksServer(config *Config, packetDispatcher dispatcher.PacketDispatcher) *SocksServer {
-	return &SocksServer{
+// NewServer creates a new Server object.
+func NewServer(config *Config, packetDispatcher dispatcher.PacketDispatcher) *Server {
+	return &Server{
 		config:           config,
 		packetDispatcher: packetDispatcher,
 	}
 }
 
 // Port implements InboundHandler.Port().
-func (this *SocksServer) Port() v2net.Port {
+func (this *Server) Port() v2net.Port {
 	return this.listeningPort
 }
 
 // Close implements InboundHandler.Close().
-func (this *SocksServer) Close() {
+func (this *Server) Close() {
 	this.accepting = false
 	if this.tcpListener != nil {
 		this.tcpMutex.Lock()
@@ -65,7 +65,7 @@ func (this *SocksServer) Close() {
 }
 
 // Listen implements InboundHandler.Listen().
-func (this *SocksServer) Listen(port v2net.Port) error {
+func (this *Server) Listen(port v2net.Port) error {
 	if this.accepting {
 		if this.listeningPort == port {
 			return nil
@@ -90,7 +90,7 @@ func (this *SocksServer) Listen(port v2net.Port) error {
 	return nil
 }
 
-func (this *SocksServer) handleConnection(connection *hub.TCPConn) {
+func (this *Server) handleConnection(connection *hub.TCPConn) {
 	defer connection.Close()
 
 	timedReader := v2net.NewTimeOutReader(120, connection)
@@ -113,7 +113,7 @@ func (this *SocksServer) handleConnection(connection *hub.TCPConn) {
 	}
 }
 
-func (this *SocksServer) handleSocks5(reader *v2io.BufferedReader, writer *v2io.BufferedWriter, auth protocol.Socks5AuthenticationRequest) error {
+func (this *Server) handleSocks5(reader *v2io.BufferedReader, writer *v2io.BufferedWriter, auth protocol.Socks5AuthenticationRequest) error {
 	expectedAuthMethod := protocol.AuthNotRequired
 	if this.config.AuthType == AuthTypePassword {
 		expectedAuthMethod = protocol.AuthUserPass
@@ -210,7 +210,7 @@ func (this *SocksServer) handleSocks5(reader *v2io.BufferedReader, writer *v2io.
 	return nil
 }
 
-func (this *SocksServer) handleUDP(reader io.Reader, writer *v2io.BufferedWriter) error {
+func (this *Server) handleUDP(reader io.Reader, writer *v2io.BufferedWriter) error {
 	response := protocol.NewSocks5Response()
 	response.Error = protocol.ErrorSuccess
 
@@ -242,7 +242,7 @@ func (this *SocksServer) handleUDP(reader io.Reader, writer *v2io.BufferedWriter
 	return nil
 }
 
-func (this *SocksServer) handleSocks4(reader *v2io.BufferedReader, writer *v2io.BufferedWriter, auth protocol.Socks4AuthenticationRequest) error {
+func (this *Server) handleSocks4(reader *v2io.BufferedReader, writer *v2io.BufferedWriter, auth protocol.Socks4AuthenticationRequest) error {
 	result := protocol.Socks4RequestGranted
 	if auth.Command == protocol.CmdBind {
 		result = protocol.Socks4RequestRejected
@@ -264,7 +264,7 @@ func (this *SocksServer) handleSocks4(reader *v2io.BufferedReader, writer *v2io.
 	return nil
 }
 
-func (this *SocksServer) transport(reader io.Reader, writer io.Writer, destination v2net.Destination) {
+func (this *Server) transport(reader io.Reader, writer io.Writer, destination v2net.Destination) {
 	ray := this.packetDispatcher.DispatchToOutbound(destination)
 	input := ray.InboundInput()
 	output := ray.InboundOutput()

+ 0 - 0
proxy/socks/socks_test.go → proxy/socks/server_test.go


+ 1 - 1
proxy/socks/socksfactory.go

@@ -13,7 +13,7 @@ func init() {
 			if !space.HasApp(dispatcher.APP_ID) {
 				return nil, internal.ErrorBadConfiguration
 			}
-			return NewSocksServer(
+			return NewServer(
 				rawConfig.(*Config),
 				space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher)), nil
 		})

+ 2 - 2
proxy/socks/udp.go

@@ -8,7 +8,7 @@ import (
 	"github.com/v2ray/v2ray-core/transport/hub"
 )
 
-func (this *SocksServer) listenUDP(port v2net.Port) error {
+func (this *Server) listenUDP(port v2net.Port) error {
 	this.udpServer = hub.NewUDPServer(this.packetDispatcher)
 	udpHub, err := hub.ListenUDP(port, this.handleUDPPayload)
 	if err != nil {
@@ -22,7 +22,7 @@ func (this *SocksServer) listenUDP(port v2net.Port) error {
 	return nil
 }
 
-func (this *SocksServer) handleUDPPayload(payload *alloc.Buffer, source v2net.Destination) {
+func (this *Server) handleUDPPayload(payload *alloc.Buffer, source v2net.Destination) {
 	log.Info("Socks: Client UDP connection from ", source)
 	request, err := protocol.ReadUDPRequest(payload.Value)
 	payload.Release()