From c0417409404d56a778b8bd07f32b1169be8e17d7 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Mon, 21 Nov 2016 21:13:01 +0100 Subject: [PATCH] remove ErrMissingApplication --- app/dispatcher/impl/default.go | 4 ++-- app/dns/server.go | 4 ++-- app/router/router.go | 3 +-- app/space.go | 4 ---- proxy/dokodemo/dokodemo.go | 4 ++-- proxy/freedom/freedom.go | 4 ++-- proxy/shadowsocks/server.go | 2 +- proxy/socks/server.go | 3 +-- 8 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/dispatcher/impl/default.go b/app/dispatcher/impl/default.go index bf2f69d02..4485d46f6 100644 --- a/app/dispatcher/impl/default.go +++ b/app/dispatcher/impl/default.go @@ -1,6 +1,7 @@ package impl import ( + "errors" "v2ray.com/core/app" "v2ray.com/core/app/proxyman" "v2ray.com/core/app/router" @@ -27,8 +28,7 @@ func NewDefaultDispatcher(space app.Space) *DefaultDispatcher { // Private: Used by app.Space only. func (this *DefaultDispatcher) Initialize(space app.Space) error { if !space.HasApp(proxyman.APP_ID_OUTBOUND_MANAGER) { - log.Error("DefaultDispatcher: OutboundHandlerManager is not found in the space.") - return app.ErrMissingApplication + return errors.New("DefaultDispatcher: OutboundHandlerManager is not found in the space.") } this.ohm = space.GetApp(proxyman.APP_ID_OUTBOUND_MANAGER).(proxyman.OutboundHandlerManager) diff --git a/app/dns/server.go b/app/dns/server.go index 30e26464c..bb267e4f8 100644 --- a/app/dns/server.go +++ b/app/dns/server.go @@ -1,6 +1,7 @@ package dns import ( + "errors" "net" "sync" "time" @@ -38,8 +39,7 @@ func NewCacheServer(space app.Space, config *Config) *CacheServer { } space.InitializeApplication(func() error { if !space.HasApp(dispatcher.APP_ID) { - log.Error("DNS: Dispatcher is not found in the space.") - return app.ErrMissingApplication + return errors.New("DNS: Dispatcher is not found in the space.") } dispatcher := space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher) diff --git a/app/router/router.go b/app/router/router.go index 8bcfd2b82..33b4c862c 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -45,8 +45,7 @@ func NewRouter(config *Config, space app.Space) *Router { } if !space.HasApp(dns.APP_ID) { - log.Error("Router: DNS is not found in the space.") - return app.ErrMissingApplication + return errors.New("Router: DNS is not found in the space.") } r.dnsServer = space.GetApp(dns.APP_ID).(dns.Server) return nil diff --git a/app/space.go b/app/space.go index 12115e7a1..5e18b9010 100644 --- a/app/space.go +++ b/app/space.go @@ -6,10 +6,6 @@ import ( "v2ray.com/core/common" ) -var ( - ErrMissingApplication = errors.New("App: Failed to found one or more applications.") -) - type ID int // Context of a function call from proxy to app. diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 15c3c4c0f..a50c7cbcb 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -3,6 +3,7 @@ package dokodemo import ( "sync" + "errors" "v2ray.com/core/app" "v2ray.com/core/app/dispatcher" "v2ray.com/core/common/alloc" @@ -39,8 +40,7 @@ func NewDokodemoDoor(config *Config, space app.Space, meta *proxy.InboundHandler } space.InitializeApplication(func() error { if !space.HasApp(dispatcher.APP_ID) { - log.Error("Dokodemo: Dispatcher is not found in the space.") - return app.ErrMissingApplication + return errors.New("Dokodemo: Dispatcher is not found in the space.") } d.packetDispatcher = space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher) return nil diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 610024d08..32bd965db 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -3,6 +3,7 @@ package freedom import ( "io" + "errors" "v2ray.com/core/app" "v2ray.com/core/app/dns" "v2ray.com/core/common/alloc" @@ -35,8 +36,7 @@ func NewFreedomConnection(config *Config, space app.Space, meta *proxy.OutboundH space.InitializeApplication(func() error { if config.DomainStrategy == Config_USE_IP { if !space.HasApp(dns.APP_ID) { - log.Error("Freedom: DNS server is not found in the space.") - return app.ErrMissingApplication + return errors.New("Freedom: DNS server is not found in the space.") } f.dns = space.GetApp(dns.APP_ID).(dns.Server) } diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index 1cf813253..ed95ef759 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -50,7 +50,7 @@ func NewServer(config *ServerConfig, space app.Space, meta *proxy.InboundHandler space.InitializeApplication(func() error { if !space.HasApp(dispatcher.APP_ID) { - return app.ErrMissingApplication + return errors.New("Shadowsocks|Server: Dispatcher is not found in space.") } s.packetDispatcher = space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher) return nil diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 9f5445789..d3030f0e4 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -46,8 +46,7 @@ func NewServer(config *ServerConfig, space app.Space, meta *proxy.InboundHandler } space.InitializeApplication(func() error { if !space.HasApp(dispatcher.APP_ID) { - log.Error("Socks|Server: Dispatcher is not found in the space.") - return app.ErrMissingApplication + return errors.New("Socks|Server: Dispatcher is not found in the space.") } s.packetDispatcher = space.GetApp(dispatcher.APP_ID).(dispatcher.PacketDispatcher) return nil