Pārlūkot izejas kodu

fix error levels

Darien Raymond 7 gadi atpakaļ
vecāks
revīzija
2bf5a008f0

+ 1 - 1
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
 		}
 

+ 1 - 1
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),

+ 2 - 2
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)

+ 1 - 1
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

+ 4 - 8
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 {

+ 1 - 1
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()

+ 2 - 2
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)

+ 1 - 1
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
 }

+ 2 - 2
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

+ 1 - 1
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)
 }

+ 1 - 1
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
 	})