From 5ccc915f8f8c6c03ede828299d08941ba2295447 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 10 Feb 2017 16:50:45 +0100 Subject: [PATCH 1/2] typo --- proxy/blackhole/blackhole.go | 2 +- transport/internet/tcp/dialer.go | 4 ++-- transport/internet/tcp_hub.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/blackhole/blackhole.go b/proxy/blackhole/blackhole.go index 18b920b2..5b7d9fd4 100644 --- a/proxy/blackhole/blackhole.go +++ b/proxy/blackhole/blackhole.go @@ -10,7 +10,7 @@ import ( "v2ray.com/core/transport/ray" ) -// Handler is an outbound connection that sliently swallow the entire payload. +// Handler is an outbound connection that silently swallow the entire payload. type Handler struct { response ResponseConfig } diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index 07c293b7..7fa4eeab 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -5,9 +5,9 @@ import ( "crypto/tls" "net" + "v2ray.com/core/app/log" "v2ray.com/core/common" "v2ray.com/core/common/errors" - "v2ray.com/core/app/log" v2net "v2ray.com/core/common/net" "v2ray.com/core/transport/internet" "v2ray.com/core/transport/internet/internal" @@ -48,7 +48,7 @@ func Dial(ctx context.Context, dest v2net.Destination) (internet.Connection, err if tcpSettings.HeaderSettings != nil { headerConfig, err := tcpSettings.HeaderSettings.GetInstance() if err != nil { - return nil, errors.Base(err).Message("Interent|TCP: Failed to get header settings.") + return nil, errors.Base(err).Message("Internet|TCP: Failed to get header settings.") } auth, err := internet.CreateConnectionAuthenticator(headerConfig) if err != nil { diff --git a/transport/internet/tcp_hub.go b/transport/internet/tcp_hub.go index 7a8713e9..dc8468b4 100644 --- a/transport/internet/tcp_hub.go +++ b/transport/internet/tcp_hub.go @@ -51,7 +51,7 @@ func ListenTCP(address v2net.Address, port v2net.Port, callback ConnectionHandle } listener, err := listenFunc(address, port, options) if err != nil { - return nil, errors.Base(err).Message("Interent|TCPHub: Failed to listen on address: ", address, ":", port) + return nil, errors.Base(err).Message("Internet|TCPHub: Failed to listen on address: ", address, ":", port) } hub := &TCPHub{ From 6c0fc4b0eca0f3331d8d71b0d22cb7f0e5ebc4e9 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 10 Feb 2017 16:54:51 +0100 Subject: [PATCH 2/2] fix ineffectual assign in core --- v2ray.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/v2ray.go b/v2ray.go index 2bc77552..74ac10a8 100644 --- a/v2ray.go +++ b/v2ray.go @@ -8,6 +8,8 @@ import ( "v2ray.com/core/app/dns" "v2ray.com/core/app/log" "v2ray.com/core/app/proxyman" + "v2ray.com/core/common" + "v2ray.com/core/common/errors" "v2ray.com/core/common/net" ) @@ -59,15 +61,14 @@ func NewPoint(config *Config) (*Point, error) { } } - logger := log.FromSpace(space) - if logger == nil { + if log.FromSpace(space) == nil { l, err := app.CreateAppFromConfig(ctx, &log.Config{ ErrorLogType: log.LogType_Console, ErrorLogLevel: log.LogLevel_Warning, AccessLogType: log.LogType_None, }) if err != nil { - return nil, err + return nil, errors.Base(err).Message("Core: Failed apply default log settings.") } space.AddApplication(l) } @@ -78,7 +79,9 @@ func NewPoint(config *Config) (*Point, error) { if err != nil { return nil, err } - space.AddApplication(o) + if err := space.AddApplication(o); err != nil { + return nil, errors.Base(err).Message("Core: Failed to add default outbound handler manager.") + } outboundHandlerManager = o.(proxyman.OutboundHandlerManager) } @@ -88,12 +91,13 @@ func NewPoint(config *Config) (*Point, error) { if err != nil { return nil, err } - space.AddApplication(o) + if err := space.AddApplication(o); err != nil { + return nil, errors.Base(err).Message("Core: Failed to add default inbound handler manager.") + } inboundHandlerManager = o.(proxyman.InboundHandlerManager) } - dnsServer := dns.FromSpace(space) - if dnsServer == nil { + if dns.FromSpace(space) == nil { dnsConfig := &dns.Config{ NameServers: []*net.Endpoint{{ Address: net.NewIPOrDomain(net.LocalHostDomain), @@ -103,8 +107,7 @@ func NewPoint(config *Config) (*Point, error) { if err != nil { return nil, err } - space.AddApplication(d) - dnsServer = d.(dns.Server) + common.Must(space.AddApplication(d)) } disp := dispatcher.FromSpace(space)