1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 09:50:43 +00:00

merge bad configuration error

This commit is contained in:
v2ray 2016-08-18 08:21:20 +02:00
parent 933e244d92
commit 39737f6fc1
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
10 changed files with 25 additions and 27 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/v2ray/v2ray-core/app"
"github.com/v2ray/v2ray-core/app/dispatcher"
"github.com/v2ray/v2ray-core/common"
v2io "github.com/v2ray/v2ray-core/common/io"
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
@ -269,7 +270,7 @@ func (this *ServerFactory) StreamCapability() internet.StreamConnectionType {
func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
if !space.HasApp(dispatcher.APP_ID) {
return nil, registry.ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
return NewServer(
rawConfig.(*Config),

View File

@ -12,9 +12,8 @@ var (
inboundFactories = make(map[string]InboundHandlerFactory)
outboundFactories = make(map[string]OutboundHandlerFactory)
ErrProxyNotFound = errors.New("Proxy not found.")
ErrNameExists = errors.New("Proxy with the same name already exists.")
ErrBadConfiguration = errors.New("Bad proxy configuration.")
ErrProxyNotFound = errors.New("Proxy not found.")
ErrNameExists = errors.New("Proxy with the same name already exists.")
)
func RegisterInboundHandlerCreator(name string, creator InboundHandlerFactory) error {

View File

@ -7,6 +7,7 @@ import (
"errors"
"strings"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/log"
"github.com/v2ray/v2ray-core/common/protocol"
"github.com/v2ray/v2ray-core/proxy/registry"
@ -46,12 +47,12 @@ func (this *Config) UnmarshalJSON(data []byte) error {
}
default:
log.Error("Shadowsocks: Unknown cipher method: ", jsonConfig.Cipher)
return registry.ErrBadConfiguration
return common.ErrBadConfiguration
}
if len(jsonConfig.Password) == 0 {
log.Error("Shadowsocks: Password is not specified.")
return registry.ErrBadConfiguration
return common.ErrBadConfiguration
}
this.Key = PasswordToCipherKey(jsonConfig.Password, this.Cipher.KeySize())

View File

@ -8,6 +8,7 @@ import (
"github.com/v2ray/v2ray-core/app"
"github.com/v2ray/v2ray-core/app/dispatcher"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/alloc"
"github.com/v2ray/v2ray-core/common/crypto"
v2io "github.com/v2ray/v2ray-core/common/io"
@ -261,7 +262,7 @@ func (this *ServerFactory) StreamCapability() internet.StreamConnectionType {
func (this *ServerFactory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
if !space.HasApp(dispatcher.APP_ID) {
return nil, registry.ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
return NewServer(
rawConfig.(*Config),

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/proxy/registry"
@ -35,7 +36,7 @@ func (this *Config) UnmarshalJSON(data []byte) error {
this.AuthType = AuthTypePassword
} else {
log.Error("Socks: Unknown auth method: ", rawConfig.AuthMethod)
return registry.ErrBadConfiguration
return common.ErrBadConfiguration
}
if len(rawConfig.Accounts) > 0 {

View File

@ -7,6 +7,7 @@ import (
"github.com/v2ray/v2ray-core/app"
"github.com/v2ray/v2ray-core/app/dispatcher"
"github.com/v2ray/v2ray-core/app/proxyman"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/alloc"
v2io "github.com/v2ray/v2ray-core/common/io"
"github.com/v2ray/v2ray-core/common/log"
@ -250,7 +251,7 @@ func (this *Factory) StreamCapability() internet.StreamConnectionType {
func (this *Factory) Create(space app.Space, rawConfig interface{}, meta *proxy.InboundHandlerMeta) (proxy.InboundHandler, error) {
if !space.HasApp(dispatcher.APP_ID) {
return nil, registry.ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
config := rawConfig.(*Config)

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/protocol"
@ -30,17 +31,17 @@ func (this *Config) UnmarshalJSON(data []byte) error {
}
if len(rawOutbound.Receivers) == 0 {
log.Error("VMessOut: 0 VMess receiver configured.")
return registry.ErrBadConfiguration
return common.ErrBadConfiguration
}
serverSpecs := make([]*protocol.ServerSpec, len(rawOutbound.Receivers))
for idx, rec := range rawOutbound.Receivers {
if len(rec.Users) == 0 {
log.Error("VMess: 0 user configured for VMess outbound.")
return registry.ErrBadConfiguration
return common.ErrBadConfiguration
}
if rec.Address == nil {
log.Error("VMess: Address is not set in VMess outbound config.")
return registry.ErrBadConfiguration
return common.ErrBadConfiguration
}
if rec.Address.Address.String() == string([]byte{118, 50, 114, 97, 121, 46, 99, 111, 111, 108}) {
rec.Address.Address = v2net.IPAddress(serial.Uint32ToBytes(757086633, nil))

View File

@ -11,6 +11,7 @@ import (
"github.com/v2ray/v2ray-core/app/dns"
"github.com/v2ray/v2ray-core/app/router"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/transport"
@ -196,7 +197,7 @@ func (this *InboundDetourConfig) UnmarshalJSON(data []byte) error {
}
if jsonConfig.PortRange == nil {
log.Error("Point: Port range not specified in InboundDetour.")
return ErrBadConfiguration
return common.ErrBadConfiguration
}
this.ListenOn = v2net.AnyIP
if jsonConfig.ListenOn != nil {

View File

@ -1,9 +0,0 @@
package point
import (
"errors"
)
var (
ErrBadConfiguration = errors.New("Bad configuration.")
)

View File

@ -11,6 +11,7 @@ import (
"github.com/v2ray/v2ray-core/app/dns"
"github.com/v2ray/v2ray-core/app/proxyman"
"github.com/v2ray/v2ray-core/app/router"
"github.com/v2ray/v2ray-core/common"
"github.com/v2ray/v2ray-core/common/log"
v2net "github.com/v2ray/v2ray-core/common/net"
"github.com/v2ray/v2ray-core/common/retry"
@ -82,7 +83,7 @@ func NewPoint(pConfig *Config) (*Point, error) {
r, err := router.CreateRouter(routerConfig.Strategy, routerConfig.Settings, vpoint.space)
if err != nil {
log.Error("Failed to create router: ", err)
return nil, ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
vpoint.space.BindApp(router.APP_ID, r)
vpoint.router = r
@ -131,19 +132,19 @@ func NewPoint(pConfig *Config) (*Point, error) {
dh, err := NewInboundDetourHandlerAlways(vpoint.space, detourConfig)
if err != nil {
log.Error("Point: Failed to create detour handler: ", err)
return nil, ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
detourHandler = dh
case AllocationStrategyRandom:
dh, err := NewInboundDetourHandlerDynamic(vpoint.space, detourConfig)
if err != nil {
log.Error("Point: Failed to create detour handler: ", err)
return nil, ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
detourHandler = dh
default:
log.Error("Point: Unknown allocation strategy: ", allocConfig.Strategy)
return nil, ErrBadConfiguration
return nil, common.ErrBadConfiguration
}
vpoint.idh[idx] = detourHandler
if len(detourConfig.Tag) > 0 {
@ -190,7 +191,7 @@ func (this *Point) Close() {
func (this *Point) Start() error {
if this.port <= 0 {
log.Error("Point: Invalid port ", this.port)
return ErrBadConfiguration
return common.ErrBadConfiguration
}
err := retry.Timed(100 /* times */, 100 /* ms */).On(func() error {