Browse Source

cleanup error messages

pull/432/head
Darien Raymond 8 years ago
parent
commit
68bc9ea8e4
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 6
      app/router/config.go
  2. 4
      app/router/router.go
  3. 6
      app/space.go
  4. 2
      common/buf/io.go
  5. 4
      common/crypto/auth.go
  6. 2
      common/net/address.go
  7. 4
      common/net/port.go
  8. 4
      common/type.go
  9. 6
      proxy/dokodemo/dokodemo.go
  10. 4
      proxy/handler_cache.go
  11. 8
      tools/conf/common.go
  12. 4
      tools/conf/freedom.go
  13. 10
      tools/conf/loader.go
  14. 4
      tools/conf/shadowsocks.go
  15. 6
      tools/conf/socks.go
  16. 6
      tools/conf/transport.go
  17. 4
      tools/conf/transport_authenticators.go
  18. 16
      tools/conf/transport_internet.go
  19. 30
      tools/conf/v2ray.go
  20. 14
      tools/conf/vmess.go
  21. 2
      transport/internet/config.go
  22. 4
      transport/internet/header.go
  23. 4
      transport/internet/kcp/crypt.go
  24. 2
      transport/internet/tls/config.go

6
app/router/config.go

@ -52,7 +52,7 @@ func (v *RoutingRule) BuildCondition() (Condition, error) {
}
ipv6Cond.Add(matcher)
default:
return nil, newError("Router: Invalid IP length.")
return nil, newError("invalid IP length").AtError()
}
}
@ -93,7 +93,7 @@ func (v *RoutingRule) BuildCondition() (Condition, error) {
}
ipv6Cond.Add(matcher)
default:
return nil, newError("Router: Invalid IP length.")
return nil, newError("invalid IP length").AtError()
}
}
@ -118,7 +118,7 @@ func (v *RoutingRule) BuildCondition() (Condition, error) {
}
if conds.Len() == 0 {
return nil, newError("Router: This rule has no effective fields.")
return nil, newError("this rule has no effective fields").AtError()
}
return conds, nil

4
app/router/router.go

@ -26,7 +26,7 @@ type Router struct {
func NewRouter(ctx context.Context, config *Config) (*Router, error) {
space := app.SpaceFromContext(ctx)
if space == nil {
return nil, newError("Router: No space in context.")
return nil, newError("no space in context")
}
r := &Router{
domainStrategy: config.DomainStrategy,
@ -45,7 +45,7 @@ func NewRouter(ctx context.Context, config *Config) (*Router, error) {
r.dnsServer = dns.FromSpace(space)
if r.dnsServer == nil {
return newError("Router: DNS is not found in the space.")
return newError("DNS is not found in the space")
}
return nil
})

6
app/space.go

@ -24,7 +24,7 @@ func CreateAppFromConfig(ctx context.Context, config interface{}) (Application,
case Application:
return a, nil
default:
return nil, newError("App: Not an application.")
return nil, newError("not an application")
}
}
@ -81,7 +81,7 @@ func (v *spaceImpl) GetApplication(appInterface interface{}) Application {
func (v *spaceImpl) AddApplication(app Application) error {
if v == nil {
return newError("App: Nil space.")
return newError("nil space").AtError()
}
appType := reflect.TypeOf(app.Interface())
v.cache[appType] = app
@ -112,7 +112,7 @@ const (
func AddApplicationToSpace(ctx context.Context, appConfig interface{}) error {
space := SpaceFromContext(ctx)
if space == nil {
return newError("App: No space in context.")
return newError("no space in context").AtError()
}
application, err := CreateAppFromConfig(ctx, appConfig)
if err != nil {

2
common/buf/io.go

@ -14,7 +14,7 @@ type Reader interface {
Read() (*Buffer, error)
}
var ErrReadTimeout = newError("Buf: IO timeout.")
var ErrReadTimeout = newError("IO timeout")
type TimeoutReader interface {
ReadTimeout(time.Duration) (*Buffer, error)

4
common/crypto/auth.go

@ -51,7 +51,7 @@ type AEADAuthenticator struct {
func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error) {
iv := v.NonceGenerator.Next()
if len(iv) != v.AEAD.NonceSize() {
return nil, newError("Crypto:AEADAuthenticator: Invalid nonce size: ", len(iv))
return nil, newError("invalid AEAD nonce size: ", len(iv))
}
additionalData := v.AdditionalDataGenerator.Next()
@ -61,7 +61,7 @@ func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error) {
func (v *AEADAuthenticator) Seal(dst, plainText []byte) ([]byte, error) {
iv := v.NonceGenerator.Next()
if len(iv) != v.AEAD.NonceSize() {
return nil, newError("Crypto:AEADAuthenticator: Invalid nonce size: ", len(iv))
return nil, newError("invalid AEAD nonce size: ", len(iv))
}
additionalData := v.AdditionalDataGenerator.Next()

2
common/net/address.go

@ -94,7 +94,7 @@ func IPAddress(ip []byte) Address {
}
return addr
default:
log.Trace(newError("Net: Invalid IP format: ", ip).AtError())
log.Trace(newError("invalid IP format: ", ip).AtError())
return nil
}
}

4
common/net/port.go

@ -19,7 +19,7 @@ func PortFromBytes(port []byte) Port {
// @error when the integer is not positive or larger then 65535
func PortFromInt(val uint32) (Port, error) {
if val > 65535 {
return Port(0), newError("Net: Invalid port range: ", val)
return Port(0), newError("invalid port range: ", val)
}
return Port(val), nil
}
@ -29,7 +29,7 @@ func PortFromInt(val uint32) (Port, error) {
func PortFromString(s string) (Port, error) {
val, err := strconv.ParseUint(s, 10, 32)
if err != nil {
return Port(0), newError("Net: Invalid port range: ", s)
return Port(0), newError("invalid port range: ", s)
}
return PortFromInt(uint32(val))
}

4
common/type.go

@ -16,7 +16,7 @@ var (
func RegisterConfig(config interface{}, configCreator ConfigCreator) error {
configType := reflect.TypeOf(config)
if _, found := typeCreatorRegistry[configType]; found {
return newError("Common: " + configType.Name() + " is already registered.")
return newError(configType.Name() + " is already registered").AtError()
}
typeCreatorRegistry[configType] = configCreator
return nil
@ -27,7 +27,7 @@ func CreateObject(ctx context.Context, config interface{}) (interface{}, error)
configType := reflect.TypeOf(config)
creator, found := typeCreatorRegistry[configType]
if !found {
return nil, newError("Common: " + configType.String() + " is not registered.")
return nil, newError(configType.String() + " is not registered").AtError()
}
return creator(ctx, config)
}

6
proxy/dokodemo/dokodemo.go

@ -27,10 +27,10 @@ type DokodemoDoor struct {
func New(ctx context.Context, config *Config) (*DokodemoDoor, error) {
space := app.SpaceFromContext(ctx)
if space == nil {
return nil, newError("Dokodemo: No space in context.")
return nil, newError("no space in context")
}
if config.NetworkList == nil || config.NetworkList.Size() == 0 {
return nil, newError("DokodemoDoor: No network specified.")
return nil, newError("no network specified")
}
d := &DokodemoDoor{
config: config,
@ -45,7 +45,7 @@ func (d *DokodemoDoor) Network() net.NetworkList {
}
func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn internet.Connection, dispatcher dispatcher.Interface) error {
log.Trace(newError("Dokodemo: processing connection from: ", conn.RemoteAddr()).AtDebug())
log.Trace(newError("processing connection from: ", conn.RemoteAddr()).AtDebug())
dest := net.Destination{
Network: network,
Address: d.address,

4
proxy/handler_cache.go

@ -15,7 +15,7 @@ func CreateInboundHandler(ctx context.Context, config interface{}) (Inbound, err
case Inbound:
return h, nil
default:
return nil, newError("Proxy: Not a InboundHandler.")
return nil, newError("not a InboundHandler")
}
}
@ -28,6 +28,6 @@ func CreateOutboundHandler(ctx context.Context, config interface{}) (Outbound, e
case Outbound:
return h, nil
default:
return nil, newError("Proxy: Not a OutboundHandler.")
return nil, newError("not a OutboundHandler")
}
}

8
tools/conf/common.go

@ -32,7 +32,7 @@ func (v *StringList) UnmarshalJSON(data []byte) error {
*v = *NewStringList(strlist)
return nil
}
return newError("Config: Unknown format of a string list: " + string(data))
return newError("unknown format of a string list: " + string(data))
}
type Address struct {
@ -79,7 +79,7 @@ func (v *NetworkList) UnmarshalJSON(data []byte) error {
*v = nl
return nil
}
return newError("Config: Unknown format of a string list: " + string(data))
return newError("unknown format of a string list: " + string(data))
}
func (v *NetworkList) Build() *v2net.NetworkList {
@ -157,12 +157,12 @@ func (v *PortRange) UnmarshalJSON(data []byte) error {
v.From = uint32(from)
v.To = uint32(to)
if v.From > v.To {
return newError("Config: Invalid port range ", v.From, " -> ", v.To)
return newError("invalid port range ", v.From, " -> ", v.To)
}
return nil
}
return newError("Config: Invalid port range: ", string(data))
return newError("invalid port range: ", string(data))
}
type User struct {

4
tools/conf/freedom.go

@ -30,11 +30,11 @@ func (v *FreedomConfig) Build() (*serial.TypedMessage, error) {
if len(v.Redirect) > 0 {
host, portStr, err := net.SplitHostPort(v.Redirect)
if err != nil {
return nil, newError("Config: Invalid redirect address: ", v.Redirect, ": ", err).Base(err)
return nil, newError("invalid redirect address: ", v.Redirect, ": ", err).Base(err)
}
port, err := v2net.PortFromString(portStr)
if err != nil {
return nil, newError("Config: Invalid redirect port: ", v.Redirect, ": ", err).Base(err)
return nil, newError("invalid redirect port: ", v.Redirect, ": ", err).Base(err)
}
if len(host) == 0 {
host = "127.0.0.1"

10
tools/conf/loader.go

@ -8,7 +8,7 @@ type ConfigCreatorCache map[string]ConfigCreator
func (v ConfigCreatorCache) RegisterCreator(id string, creator ConfigCreator) error {
if _, found := v[id]; found {
return newError("Config: ", id, " already registered.")
return newError(id, " already registered.").AtError()
}
v[id] = creator
@ -18,7 +18,7 @@ func (v ConfigCreatorCache) RegisterCreator(id string, creator ConfigCreator) er
func (v ConfigCreatorCache) CreateConfig(id string) (interface{}, error) {
creator, found := v[id]
if !found {
return nil, newError("Config: Unknown config id: ", id)
return nil, newError("unknown config id: ", id)
}
return creator(), nil
}
@ -40,7 +40,7 @@ func NewJSONConfigLoader(cache ConfigCreatorCache, idKey string, configKey strin
func (v *JSONConfigLoader) LoadWithID(raw []byte, id string) (interface{}, error) {
creator, found := v.cache[id]
if !found {
return nil, newError("Config: Unknown config id: ", id)
return nil, newError("unknown config id: ", id).AtError()
}
config := creator()
@ -57,7 +57,7 @@ func (v *JSONConfigLoader) Load(raw []byte) (interface{}, string, error) {
}
rawID, found := obj[v.idKey]
if !found {
return nil, "", newError("Config: ", v.idKey, " not found in JSON context.")
return nil, "", newError(v.idKey, " not found in JSON context").AtError()
}
var id string
if err := json.Unmarshal(rawID, &id); err != nil {
@ -67,7 +67,7 @@ func (v *JSONConfigLoader) Load(raw []byte) (interface{}, string, error) {
if len(v.configKey) > 0 {
configValue, found := obj[v.configKey]
if !found {
return nil, "", newError("Config: ", v.configKey, " not found in JSON content.")
return nil, "", newError(v.configKey, " not found in JSON content").AtError()
}
rawConfig = configValue
}

4
tools/conf/shadowsocks.go

@ -46,7 +46,7 @@ func (v *ShadowsocksServerConfig) Build() (*serial.TypedMessage, error) {
case "chacha20-ietf":
account.CipherType = shadowsocks.CipherType_CHACHA20_IETF
default:
return nil, newError("Unknown cipher method: " + cipher)
return nil, newError("unknown cipher method: " + cipher)
}
config.User = &protocol.User{
@ -107,7 +107,7 @@ func (v *ShadowsocksClientConfig) Build() (*serial.TypedMessage, error) {
case "chacha20-ietf":
account.CipherType = shadowsocks.CipherType_CHACHA20_IETF
default:
return nil, newError("Unknown cipher method: " + cipher)
return nil, newError("unknown cipher method: " + cipher)
}
ss := &protocol.ServerEndpoint{

6
tools/conf/socks.go

@ -40,7 +40,7 @@ func (v *SocksServerConfig) Build() (*serial.TypedMessage, error) {
} else if v.AuthMethod == AuthMethodUserPass {
config.AuthType = socks.AuthType_PASSWORD
} else {
return nil, newError("Config: Unknown socks auth method: " + v.AuthMethod)
return nil, newError("unknown socks auth method: " + v.AuthMethod).AtError()
}
if len(v.Accounts) > 0 {
@ -79,11 +79,11 @@ func (v *SocksClientConfig) Build() (*serial.TypedMessage, error) {
for _, rawUser := range serverConfig.Users {
user := new(protocol.User)
if err := json.Unmarshal(rawUser, user); err != nil {
return nil, newError("Config: Failed to parse Socks user.").Base(err)
return nil, newError("failed to parse Socks user").Base(err).AtError()
}
account := new(SocksAccount)
if err := json.Unmarshal(rawUser, account); err != nil {
return nil, newError("Config: Failed to parse socks account.").Base(err)
return nil, newError("failed to parse socks account").Base(err).AtError()
}
user.Account = serial.ToTypedMessage(account.Build())
server.User = append(server.User, user)

6
tools/conf/transport.go

@ -17,7 +17,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
if v.TCPConfig != nil {
ts, err := v.TCPConfig.Build()
if err != nil {
return nil, newError("Config: Failed to build TCP config.").Base(err)
return nil, newError("failed to build TCP config").Base(err).AtError()
}
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
Protocol: internet.TransportProtocol_TCP,
@ -28,7 +28,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
if v.KCPConfig != nil {
ts, err := v.KCPConfig.Build()
if err != nil {
return nil, newError("Config: Failed to build mKCP config.").Base(err)
return nil, newError("failed to build mKCP config").Base(err).AtError()
}
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
Protocol: internet.TransportProtocol_MKCP,
@ -39,7 +39,7 @@ func (v *TransportConfig) Build() (*transport.Config, error) {
if v.WSConfig != nil {
ts, err := v.WSConfig.Build()
if err != nil {
return nil, newError("Config: Failed to build WebSocket config.").Base(err)
return nil, newError("failed to build WebSocket config").Base(err)
}
config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
Protocol: internet.TransportProtocol_WebSocket,

4
tools/conf/transport_authenticators.go

@ -92,7 +92,7 @@ func (v *HTTPAuthenticatorRequest) Build() (*http.RequestConfig, error) {
config.Header = make([]*http.Header, 0, len(v.Headers))
for key, value := range v.Headers {
if value == nil {
return nil, newError("Config: Empty HTTP header value: " + key)
return nil, newError("empty HTTP header value: " + key).AtError()
}
config.Header = append(config.Header, &http.Header{
Name: key,
@ -158,7 +158,7 @@ func (v *HTTPAuthenticatorResponse) Build() (*http.ResponseConfig, error) {
config.Header = make([]*http.Header, 0, len(v.Headers))
for key, value := range v.Headers {
if value == nil {
return nil, newError("Config: Empty HTTP header value: " + key)
return nil, newError("empty HTTP header value: " + key).AtError()
}
config.Header = append(config.Header, &http.Header{
Name: key,

16
tools/conf/transport_internet.go

@ -44,14 +44,14 @@ func (v *KCPConfig) Build() (*serial.TypedMessage, error) {
if v.Mtu != nil {
mtu := *v.Mtu
if mtu < 576 || mtu > 1460 {
return nil, newError("Config: Invalid mKCP MTU size: ", mtu)
return nil, newError("invalid mKCP MTU size: ", mtu).AtError()
}
config.Mtu = &kcp.MTU{Value: mtu}
}
if v.Tti != nil {
tti := *v.Tti
if tti < 10 || tti > 100 {
return nil, newError("Config: Invalid mKCP TTI: ", tti)
return nil, newError("invalid mKCP TTI: ", tti).AtError()
}
config.Tti = &kcp.TTI{Value: tti}
}
@ -83,11 +83,11 @@ func (v *KCPConfig) Build() (*serial.TypedMessage, error) {
if len(v.HeaderConfig) > 0 {
headerConfig, _, err := kcpHeaderLoader.Load(v.HeaderConfig)
if err != nil {
return nil, newError("Config: Invalid mKCP header config.").Base(err)
return nil, newError("invalid mKCP header config.").Base(err).AtError()
}
ts, err := headerConfig.(Buildable).Build()
if err != nil {
return nil, newError("Config: Invalid mKCP header config.").Base(err)
return nil, newError("invalid mKCP header config").Base(err).AtError()
}
config.HeaderConfig = ts
}
@ -104,11 +104,11 @@ func (v *TCPConfig) Build() (*serial.TypedMessage, error) {
if len(v.HeaderConfig) > 0 {
headerConfig, _, err := tcpHeaderLoader.Load(v.HeaderConfig)
if err != nil {
return nil, newError("Config: Invalid TCP header config.").Base(err)
return nil, newError("invalid TCP header config").Base(err).AtError()
}
ts, err := headerConfig.(Buildable).Build()
if err != nil {
return nil, newError("Config: Invalid TCP header config.").Base(err)
return nil, newError("invalid TCP header config").Base(err).AtError()
}
config.HeaderSettings = ts
}
@ -143,11 +143,11 @@ func (v *TLSConfig) Build() (*serial.TypedMessage, error) {
for idx, certConf := range v.Certs {
cert, err := ioutil.ReadFile(certConf.CertFile)
if err != nil {
return nil, newError("Failed to load TLS certificate file: ", certConf.CertFile).Base(err)
return nil, newError("failed to load TLS certificate file: ", certConf.CertFile).Base(err).AtError()
}
key, err := ioutil.ReadFile(certConf.KeyFile)
if err != nil {
return nil, newError("Failed to load TLS key file: ", certConf.KeyFile).Base(err)
return nil, newError("failed to load TLS key file: ", certConf.KeyFile).Base(err).AtError()
}
config.Certificate[idx] = &tls.Certificate{
Key: key,

30
tools/conf/v2ray.go

@ -48,7 +48,7 @@ func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error
}
if v.Listen != nil {
if v.Listen.Family().IsDomain() {
return nil, newError("Config: Unable to listen on domain address: " + v.Listen.Domain())
return nil, newError("unable to listen on domain address: " + v.Listen.Domain())
}
receiverConfig.Listen = v.Listen.Build()
}
@ -62,7 +62,7 @@ func (v *InboundConnectionConfig) Build() (*proxyman.InboundHandlerConfig, error
jsonConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
if err != nil {
return nil, newError("Config: Failed to load inbound config.").Base(err)
return nil, newError("failed to load inbound config.").Base(err)
}
if dokodemoConfig, ok := jsonConfig.(*DokodemoConfig); ok {
receiverConfig.ReceiveOriginalDestination = dokodemoConfig.Redirect
@ -99,7 +99,7 @@ func (v *OutboundConnectionConfig) Build() (*proxyman.OutboundHandlerConfig, err
if v.SendThrough != nil {
address := v.SendThrough
if address.Family().IsDomain() {
return nil, newError("Config: Invalid sendThrough address: " + address.String())
return nil, newError("invalid sendThrough address: " + address.String())
}
senderSettings.Via = address.Build()
}
@ -113,7 +113,7 @@ func (v *OutboundConnectionConfig) Build() (*proxyman.OutboundHandlerConfig, err
if v.ProxySettings != nil {
ps, err := v.ProxySettings.Build()
if err != nil {
return nil, newError("Config: Invalid outbound proxy settings.").Base(err)
return nil, newError("invalid outbound proxy settings").Base(err)
}
senderSettings.ProxySettings = ps
}
@ -126,7 +126,7 @@ func (v *OutboundConnectionConfig) Build() (*proxyman.OutboundHandlerConfig, err
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
if err != nil {
return nil, newError("Config: Failed to parse outbound config.").Base(err)
return nil, newError("failed to parse outbound config").Base(err)
}
ts, err := rawConfig.(Buildable).Build()
if err != nil {
@ -156,7 +156,7 @@ func (v *InboundDetourAllocationConfig) Build() (*proxyman.AllocationStrategy, e
case "external":
config.Type = proxyman.AllocationStrategy_External
default:
return nil, newError("Config: Unknown allocation strategy: ", v.Strategy)
return nil, newError("unknown allocation strategy: ", v.Strategy)
}
if v.Concurrency != nil {
config.Concurrency = &proxyman.AllocationStrategy_AllocationStrategyConcurrency{
@ -187,13 +187,13 @@ func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
receiverSettings := &proxyman.ReceiverConfig{}
if v.PortRange == nil {
return nil, newError("Config: Port range not specified in InboundDetour.")
return nil, newError("port range not specified in InboundDetour.")
}
receiverSettings.PortRange = v.PortRange.Build()
if v.ListenOn != nil {
if v.ListenOn.Family().IsDomain() {
return nil, newError("Config: Unable to listen on domain address: ", v.ListenOn.Domain())
return nil, newError("unable to listen on domain address: ", v.ListenOn.Domain())
}
receiverSettings.Listen = v.ListenOn.Build()
}
@ -214,7 +214,7 @@ func (v *InboundDetourConfig) Build() (*proxyman.InboundHandlerConfig, error) {
rawConfig, err := inboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
if err != nil {
return nil, newError("Config: Failed to load inbound detour config.").Base(err)
return nil, newError("failed to load inbound detour config.").Base(err)
}
if dokodemoConfig, ok := rawConfig.(*DokodemoConfig); ok {
receiverSettings.ReceiveOriginalDestination = dokodemoConfig.Redirect
@ -247,7 +247,7 @@ func (v *OutboundDetourConfig) Build() (*proxyman.OutboundHandlerConfig, error)
if v.SendThrough != nil {
address := v.SendThrough
if address.Family().IsDomain() {
return nil, newError("Config: Unable to send through: " + address.String())
return nil, newError("unable to send through: " + address.String())
}
senderSettings.Via = address.Build()
}
@ -263,7 +263,7 @@ func (v *OutboundDetourConfig) Build() (*proxyman.OutboundHandlerConfig, error)
if v.ProxySettings != nil {
ps, err := v.ProxySettings.Build()
if err != nil {
return nil, newError("Config: Invalid outbound detour proxy settings.").Base(err)
return nil, newError("invalid outbound detour proxy settings.").Base(err)
}
senderSettings.ProxySettings = ps
}
@ -276,7 +276,7 @@ func (v *OutboundDetourConfig) Build() (*proxyman.OutboundHandlerConfig, error)
rawConfig, err := outboundConfigLoader.LoadWithID(v.Settings, v.Protocol)
if err != nil {
return nil, newError("Config: Failed to parse to outbound detour config.").Base(err)
return nil, newError("failed to parse to outbound detour config.").Base(err)
}
ts, err := rawConfig.(Buildable).Build()
if err != nil {
@ -330,7 +330,7 @@ func (v *Config) Build() (*core.Config, error) {
}
if v.InboundConfig == nil {
return nil, newError("Config: No inbound config specified.")
return nil, newError("no inbound config specified")
}
if v.InboundConfig.Port == 0 && v.Port > 0 {
@ -352,7 +352,7 @@ func (v *Config) Build() (*core.Config, error) {
}
if v.OutboundConfig == nil {
return nil, newError("Config: No outbound config specified.")
return nil, newError("no outbound config specified")
}
oc, err := v.OutboundConfig.Build()
if err != nil {
@ -379,7 +379,7 @@ func init() {
})
err := decoder.Decode(jsonConfig)
if err != nil {
return nil, newError("Config: Invalid V2Ray config.").Base(err)
return nil, newError("invalid V2Ray config").Base(err)
}
return jsonConfig.Build()

14
tools/conf/vmess.go

@ -94,11 +94,11 @@ func (v *VMessInboundConfig) Build() (*serial.TypedMessage, error) {
for idx, rawData := range v.Users {
user := new(protocol.User)
if err := json.Unmarshal(rawData, user); err != nil {
return nil, newError("Config: Invalid VMess user.").Base(err)
return nil, newError("invalid VMess user").Base(err)
}
account := new(VMessAccount)
if err := json.Unmarshal(rawData, account); err != nil {
return nil, newError("Config: Invalid VMess user.").Base(err)
return nil, newError("invalid VMess user").Base(err)
}
user.Account = serial.ToTypedMessage(account.Build())
config.User[idx] = user
@ -120,15 +120,15 @@ func (v *VMessOutboundConfig) Build() (*serial.TypedMessage, error) {
config := new(outbound.Config)
if len(v.Receivers) == 0 {
return nil, newError("Config: 0 VMess receiver configured.")
return nil, newError("0 VMess receiver configured")
}
serverSpecs := make([]*protocol.ServerEndpoint, len(v.Receivers))
for idx, rec := range v.Receivers {
if len(rec.Users) == 0 {
return nil, newError("Config: 0 user configured for VMess outbound.")
return nil, newError("0 user configured for VMess outbound")
}
if rec.Address == nil {
return nil, newError("Config: Address is not set in VMess outbound config.")
return nil, newError("address is not set in VMess outbound config")
}
if rec.Address.String() == string([]byte{118, 50, 114, 97, 121, 46, 99, 111, 111, 108}) {
rec.Address.Address = v2net.IPAddress(serial.Uint32ToBytes(757086633, nil))
@ -140,11 +140,11 @@ func (v *VMessOutboundConfig) Build() (*serial.TypedMessage, error) {
for _, rawUser := range rec.Users {
user := new(protocol.User)
if err := json.Unmarshal(rawUser, user); err != nil {
return nil, newError("Config: Invalid VMess user.").Base(err)
return nil, newError("invalid VMess user").Base(err)
}
account := new(VMessAccount)
if err := json.Unmarshal(rawUser, account); err != nil {
return nil, newError("Config: Invalid VMess user.").Base(err)
return nil, newError("invalid VMess user").Base(err)
}
user.Account = serial.ToTypedMessage(account.Build())
spec.User = append(spec.User, user)

2
transport/internet/config.go

@ -18,7 +18,7 @@ func RegisterProtocolConfigCreator(protocol TransportProtocol, creator ConfigCre
func CreateTransportConfig(protocol TransportProtocol) (interface{}, error) {
creator, ok := globalTransportConfigCreatorCache[protocol]
if !ok {
return nil, newError("Internet: Unknown transport protocol: ", protocol)
return nil, newError("unknown transport protocol: ", protocol)
}
return creator(), nil
}

4
transport/internet/header.go

@ -20,7 +20,7 @@ func CreatePacketHeader(config interface{}) (PacketHeader, error) {
if h, ok := header.(PacketHeader); ok {
return h, nil
}
return nil, newError("Internet: Not a packet header.")
return nil, newError("not a packet header")
}
type ConnectionAuthenticator interface {
@ -36,5 +36,5 @@ func CreateConnectionAuthenticator(config interface{}) (ConnectionAuthenticator,
if a, ok := auth.(ConnectionAuthenticator); ok {
return a, nil
}
return nil, newError("Internet: Not a ConnectionAuthenticator.")
return nil, newError("not a ConnectionAuthenticator")
}

4
transport/internet/kcp/crypt.go

@ -63,12 +63,12 @@ func (v *SimpleAuthenticator) Open(dst, nonce, cipherText, extra []byte) ([]byte
fnvHash := fnv.New32a()
fnvHash.Write(dst[4:])
if serial.BytesToUint32(dst[:4]) != fnvHash.Sum32() {
return nil, newError("KCP:SimpleAuthenticator: Invalid auth.")
return nil, newError("invalid auth")
}
length := serial.BytesToUint16(dst[4:6])
if len(dst)-6 != int(length) {
return nil, newError("KCP:SimpleAuthenticator: Invalid auth.")
return nil, newError("invalid auth")
}
return dst[6:], nil

2
transport/internet/tls/config.go

@ -15,7 +15,7 @@ func (v *Config) BuildCertificates() []tls.Certificate {
for _, entry := range v.Certificate {
keyPair, err := tls.X509KeyPair(entry.Certificate, entry.Key)
if err != nil {
log.Trace(newError("TLS: ignoring invalid X509 key pair").Base(err).AtWarning())
log.Trace(newError("ignoring invalid X509 key pair").Base(err).AtWarning())
continue
}
certs = append(certs, keyPair)

Loading…
Cancel
Save