mirror of https://github.com/v2ray/v2ray-core
parent
75b8dd9521
commit
545fa5b53c
|
@ -19,8 +19,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrorUnsupportedSocksCommand = errors.New("Unsupported socks command.")
|
ErrUnsupportedSocksCommand = errors.New("Unsupported socks command.")
|
||||||
ErrorUnsupportedAuthMethod = errors.New("Unsupported auth method.")
|
ErrUnsupportedAuthMethod = errors.New("Unsupported auth method.")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server is a SOCKS 5 proxy server
|
// Server is a SOCKS 5 proxy server
|
||||||
|
@ -142,7 +142,7 @@ func (this *Server) handleSocks5(clientAddr string, reader *v2io.BufferedReader,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Warning("Socks: client doesn't support any allowed auth methods.")
|
log.Warning("Socks: client doesn't support any allowed auth methods.")
|
||||||
return ErrorUnsupportedAuthMethod
|
return ErrUnsupportedAuthMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
authResponse := protocol.NewAuthenticationResponse(expectedAuthMethod)
|
authResponse := protocol.NewAuthenticationResponse(expectedAuthMethod)
|
||||||
|
@ -199,7 +199,7 @@ func (this *Server) handleSocks5(clientAddr string, reader *v2io.BufferedReader,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Warning("Socks: Unsupported socks command ", request.Command)
|
log.Warning("Socks: Unsupported socks command ", request.Command)
|
||||||
return ErrorUnsupportedSocksCommand
|
return ErrUnsupportedSocksCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
response := protocol.NewSocks5Response()
|
response := protocol.NewSocks5Response()
|
||||||
|
@ -269,8 +269,8 @@ func (this *Server) handleSocks4(clientAddr string, reader *v2io.BufferedReader,
|
||||||
|
|
||||||
if result == protocol.Socks4RequestRejected {
|
if result == protocol.Socks4RequestRejected {
|
||||||
log.Warning("Socks: Unsupported socks 4 command ", auth.Command)
|
log.Warning("Socks: Unsupported socks 4 command ", auth.Command)
|
||||||
log.Access(clientAddr, "", log.AccessRejected, ErrorUnsupportedSocksCommand)
|
log.Access(clientAddr, "", log.AccessRejected, ErrUnsupportedSocksCommand)
|
||||||
return ErrorUnsupportedSocksCommand
|
return ErrUnsupportedSocksCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
reader.SetCached(false)
|
reader.SetCached(false)
|
||||||
|
|
|
@ -80,7 +80,7 @@ var (
|
||||||
|
|
||||||
func LoadConfig(init string) (*Config, error) {
|
func LoadConfig(init string) (*Config, error) {
|
||||||
if configLoader == nil {
|
if configLoader == nil {
|
||||||
return nil, ErrorBadConfiguration
|
return nil, ErrBadConfiguration
|
||||||
}
|
}
|
||||||
return configLoader(init)
|
return configLoader(init)
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,7 +193,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
|
||||||
}
|
}
|
||||||
if jsonConfig.PortRange == nil {
|
if jsonConfig.PortRange == nil {
|
||||||
log.Error("Point: Port range not specified in InboundDetour.")
|
log.Error("Point: Port range not specified in InboundDetour.")
|
||||||
return ErrorBadConfiguration
|
return ErrBadConfiguration
|
||||||
}
|
}
|
||||||
this.ListenOn = v2net.AnyIP
|
this.ListenOn = v2net.AnyIP
|
||||||
if jsonConfig.ListenOn != nil {
|
if jsonConfig.ListenOn != nil {
|
||||||
|
|
|
@ -5,5 +5,5 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrorBadConfiguration = errors.New("Bad configuration.")
|
ErrBadConfiguration = errors.New("Bad configuration.")
|
||||||
)
|
)
|
||||||
|
|
|
@ -82,7 +82,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
|
||||||
r, err := router.CreateRouter(routerConfig.Strategy, routerConfig.Settings, vpoint.space)
|
r, err := router.CreateRouter(routerConfig.Strategy, routerConfig.Settings, vpoint.space)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Failed to create router: ", err)
|
log.Error("Failed to create router: ", err)
|
||||||
return nil, ErrorBadConfiguration
|
return nil, ErrBadConfiguration
|
||||||
}
|
}
|
||||||
vpoint.space.BindApp(router.APP_ID, r)
|
vpoint.space.BindApp(router.APP_ID, r)
|
||||||
vpoint.router = r
|
vpoint.router = r
|
||||||
|
@ -129,19 +129,19 @@ func NewPoint(pConfig *Config) (*Point, error) {
|
||||||
dh, err := NewInboundDetourHandlerAlways(vpoint.space, detourConfig)
|
dh, err := NewInboundDetourHandlerAlways(vpoint.space, detourConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Point: Failed to create detour handler: ", err)
|
log.Error("Point: Failed to create detour handler: ", err)
|
||||||
return nil, ErrorBadConfiguration
|
return nil, ErrBadConfiguration
|
||||||
}
|
}
|
||||||
detourHandler = dh
|
detourHandler = dh
|
||||||
case AllocationStrategyRandom:
|
case AllocationStrategyRandom:
|
||||||
dh, err := NewInboundDetourHandlerDynamic(vpoint.space, detourConfig)
|
dh, err := NewInboundDetourHandlerDynamic(vpoint.space, detourConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Point: Failed to create detour handler: ", err)
|
log.Error("Point: Failed to create detour handler: ", err)
|
||||||
return nil, ErrorBadConfiguration
|
return nil, ErrBadConfiguration
|
||||||
}
|
}
|
||||||
detourHandler = dh
|
detourHandler = dh
|
||||||
default:
|
default:
|
||||||
log.Error("Point: Unknown allocation strategy: ", allocConfig.Strategy)
|
log.Error("Point: Unknown allocation strategy: ", allocConfig.Strategy)
|
||||||
return nil, ErrorBadConfiguration
|
return nil, ErrBadConfiguration
|
||||||
}
|
}
|
||||||
vpoint.idh[idx] = detourHandler
|
vpoint.idh[idx] = detourHandler
|
||||||
if len(detourConfig.Tag) > 0 {
|
if len(detourConfig.Tag) > 0 {
|
||||||
|
@ -188,7 +188,7 @@ func (this *Point) Close() {
|
||||||
func (this *Point) Start() error {
|
func (this *Point) Start() error {
|
||||||
if this.port <= 0 {
|
if this.port <= 0 {
|
||||||
log.Error("Point: Invalid port ", this.port)
|
log.Error("Point: Invalid port ", this.port)
|
||||||
return ErrorBadConfiguration
|
return ErrBadConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
||||||
|
|
Loading…
Reference in New Issue