1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

rename SocksServer to Server

This commit is contained in:
v2ray 2016-04-26 00:33:16 +02:00
parent 42907ff2e8
commit 991cea01ab
4 changed files with 16 additions and 16 deletions

View File

@ -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()

View File

@ -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
})

View File

@ -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()