1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 01:57:12 -05:00

fix error levels

This commit is contained in:
Darien Raymond 2017-12-27 22:25:12 +01:00
parent 9b15e2f6f7
commit 2bf5a008f0
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
11 changed files with 17 additions and 21 deletions

View File

@ -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
}

View File

@ -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),

View File

@ -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)

View File

@ -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

View File

@ -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 {

View File

@ -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()

View File

@ -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)

View File

@ -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
}

View File

@ -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

View File

@ -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)
}

View File

@ -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
})