diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index bf60d167..785739ea 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -219,7 +219,7 @@ func (*LocalNameServer) QueryA(domain string) <-chan *ARecord { resolver := net.SystemIPResolver() ips, err := resolver.LookupIP(domain) if err != nil { - newError("failed to lookup IPs for domain ", domain).Base(err).WriteToLog() + newError("failed to lookup IPs for domain ", domain).Base(err).AtWarning().WriteToLog() return } diff --git a/app/proxyman/inbound/always.go b/app/proxyman/inbound/always.go index ee4641ca..4d20739f 100644 --- a/app/proxyman/inbound/always.go +++ b/app/proxyman/inbound/always.go @@ -35,7 +35,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig * } for port := pr.From; port <= pr.To; port++ { if nl.HasNetwork(net.Network_TCP) { - newError("creating tcp worker on ", address, ":", port).AtDebug().WriteToLog() + newError("creating stream worker on ", address, ":", port).AtDebug().WriteToLog() worker := &tcpWorker{ address: address, port: net.Port(port), diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index f2d647e9..bedf07b2 100644 --- a/app/proxyman/inbound/inbound.go +++ b/app/proxyman/inbound/inbound.go @@ -28,7 +28,7 @@ func (m *Manager) AddHandler(ctx context.Context, config *proxyman.InboundHandle } receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig) if !ok { - return newError("not a ReceiverConfig") + return newError("not a ReceiverConfig").AtError() } proxySettings, err := config.ProxySettings.GetInstance() if err != nil { @@ -52,7 +52,7 @@ func (m *Manager) AddHandler(ctx context.Context, config *proxyman.InboundHandle } if handler == nil { - return newError("unknown allocation strategy: ", receiverSettings.AllocationStrategy.Type) + return newError("unknown allocation strategy: ", receiverSettings.AllocationStrategy.Type).AtError() } m.handlers = append(m.handlers, handler) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 4198e5b3..6fce64c8 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -77,7 +77,7 @@ func (w *tcpWorker) Start() error { conns := make(chan internet.Connection, 16) hub, err := internet.ListenTCP(ctx, w.address, w.port, conns) if err != nil { - return newError("failed to listen TCP on ", w.port).Base(err) + return newError("failed to listen TCP on ", w.port).AtWarning().Base(err) } go w.handleConnections(conns) w.hub = hub diff --git a/app/proxyman/mux/mux.go b/app/proxyman/mux/mux.go index 5d98ab15..ca34c34c 100644 --- a/app/proxyman/mux/mux.go +++ b/app/proxyman/mux/mux.go @@ -94,11 +94,7 @@ func NewClient(p proxy.Outbound, dialer proxy.Dialer, m *ClientManager) (*Client if err := p.Process(ctx, pipe, dialer); err != nil { cancel() - traceErr := errors.New("failed to handler mux client connection").Base(err) - if err != io.EOF && err != context.Canceled { - traceErr = traceErr.AtWarning() - } - traceErr.WriteToLog() + errors.New("failed to handler mux client connection").Base(err).WriteToLog() } }() @@ -254,7 +250,7 @@ func (m *Client) fetchOutput() { case SessionStatusKeep: err = m.handleStatusKeep(meta, reader) default: - newError("unknown status: ", meta.SessionStatus).AtWarning().WriteToLog() + newError("unknown status: ", meta.SessionStatus).AtError().WriteToLog() return } @@ -308,7 +304,7 @@ type ServerWorker struct { func handle(ctx context.Context, s *Session, output buf.Writer) { writer := NewResponseWriter(s.ID, output, s.transferType) if err := buf.Copy(s.input, writer); err != nil { - newError("session ", s.ID, " ends: ").Base(err).WriteToLog() + newError("session ", s.ID, " ends.").Base(err).WriteToLog() } writer.Close() s.Close() @@ -384,7 +380,7 @@ func (w *ServerWorker) handleFrame(ctx context.Context, reader *buf.BufferedRead case SessionStatusKeep: err = w.handleStatusKeep(meta, reader) default: - return newError("unknown status: ", meta.SessionStatus).AtWarning() + return newError("unknown status: ", meta.SessionStatus).AtError() } if err != nil { diff --git a/app/proxyman/mux/reader.go b/app/proxyman/mux/reader.go index df13ed2b..39e6d8ba 100644 --- a/app/proxyman/mux/reader.go +++ b/app/proxyman/mux/reader.go @@ -14,7 +14,7 @@ func ReadMetadata(reader io.Reader) (*FrameMetadata, error) { return nil, err } if metaLen > 512 { - return nil, newError("invalid metalen ", metaLen).AtWarning() + return nil, newError("invalid metalen ", metaLen).AtError() } b := buf.New() diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index a98f64f2..33e06d5e 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -62,7 +62,7 @@ func NewHandler(ctx context.Context, config *proxyman.OutboundHandlerConfig) (*H if h.senderSettings != nil && h.senderSettings.MultiplexSettings != nil && h.senderSettings.MultiplexSettings.Enabled { config := h.senderSettings.MultiplexSettings if config.Concurrency < 1 || config.Concurrency > 1024 { - return nil, newError("invalid mux concurrency: ", config.Concurrency) + return nil, newError("invalid mux concurrency: ", config.Concurrency).AtWarning() } h.mux = mux.NewClientManager(proxyHandler, h, config) } @@ -99,7 +99,7 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (internet.Conn tag := h.senderSettings.ProxySettings.Tag handler := h.outboundManager.GetHandler(tag) if handler != nil { - newError("proxying to ", tag).AtDebug().WriteToLog() + newError("proxying to ", tag, " for dest ", dest).AtDebug().WriteToLog() ctx = proxy.ContextWithTarget(ctx, dest) stream := ray.NewRay(ctx) go handler.Dispatch(ctx, stream) diff --git a/app/router/condition.go b/app/router/condition.go index 40797cfc..f55f79ce 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -98,7 +98,7 @@ func (m *CachableDomainMatcher) Add(domain *Domain) error { case Domain_Domain: m.matchers = append(m.matchers, NewSubDomainMatcher(domain.Value)) default: - return newError("unknown domain type: ", domain.Type).AtError() + return newError("unknown domain type: ", domain.Type).AtWarning() } return nil } diff --git a/app/router/config.go b/app/router/config.go index 05ff3661..16d4fac6 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -32,7 +32,7 @@ func cidrToCondition(cidr []*CIDR, source bool) (Condition, error) { } ipv6Cond.Add(matcher) default: - return nil, newError("invalid IP length").AtError() + return nil, newError("invalid IP length").AtWarning() } } @@ -92,7 +92,7 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { } if conds.Len() == 0 { - return nil, newError("this rule has no effective fields").AtError() + return nil, newError("this rule has no effective fields").AtWarning() } return conds, nil diff --git a/loader.go b/loader.go index 40ebb6fc..1dab37dd 100644 --- a/loader.go +++ b/loader.go @@ -24,7 +24,7 @@ func RegisterConfigLoader(format ConfigFormat, loader ConfigLoader) error { func LoadConfig(format ConfigFormat, input io.Reader) (*Config, error) { loader, found := configLoaderCache[format] if !found { - return nil, newError(ConfigFormat_name[int32(format)], " is not loadable.") + return nil, newError(ConfigFormat_name[int32(format)], " is not loadable.").AtWarning() } return loader(input) } diff --git a/main/config_json.go b/main/config_json.go index 0db6bc46..5e294ddd 100644 --- a/main/config_json.go +++ b/main/config_json.go @@ -41,7 +41,7 @@ func init() { core.RegisterConfigLoader(core.ConfigFormat_JSON, func(input io.Reader) (*core.Config, error) { config, err := jsonToProto(input) if err != nil { - return nil, newError("failed to execute v2ctl to convert config file.").Base(err) + return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning() } return config, nil })