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

update error message

This commit is contained in:
Darien Raymond 2017-04-06 21:44:20 +02:00
parent 75f5cb9afb
commit 67956b9120
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
12 changed files with 26 additions and 26 deletions

View File

@ -23,13 +23,13 @@ type DefaultDispatcher struct {
func NewDefaultDispatcher(ctx context.Context, config *dispatcher.Config) (*DefaultDispatcher, error) {
space := app.SpaceFromContext(ctx)
if space == nil {
return nil, errors.New("DefaultDispatcher: No space in context.")
return nil, errors.New("no space in context").Path("App", "Dispatcher", "Default")
}
d := &DefaultDispatcher{}
space.OnInitialize(func() error {
d.ohm = proxyman.OutboundHandlerManagerFromSpace(space)
if d.ohm == nil {
return errors.New("DefaultDispatcher: OutboundHandlerManager is not found in the space.")
return errors.New("OutboundHandlerManager is not found in the space").Path("App", "Dispatcher", "Default")
}
d.router = router.FromSpace(space)
return nil

View File

@ -12,7 +12,7 @@ func (v *Config) GetInternalHosts() map[string]net.IP {
for domain, ipOrDomain := range v.GetHosts() {
address := ipOrDomain.AsAddress()
if address.Family().IsDomain() {
log.Trace(errors.New("DNS: Ignoring domain address in static hosts: ", address.Domain()).AtWarning())
log.Trace(errors.New("ignoring domain address in static hosts: ", address.Domain()).AtWarning().Path("App", "DNS", "Config"))
continue
}
hosts[domain] = address.IP()

View File

@ -89,7 +89,7 @@ func (v *UDPNameServer) AssignUnusedID(response chan<- *ARecord) uint16 {
if _, found := v.requests[id]; found {
continue
}
log.Trace(errors.New("DNS: Add pending request id ", id).AtDebug())
log.Trace(errors.New("add pending request id ", id).AtDebug().Path("App", "DNS", "UDPNameServer"))
v.requests[id] = &PendingRequest{
expire: time.Now().Add(time.Second * 8),
response: response,
@ -105,7 +105,7 @@ func (v *UDPNameServer) HandleResponse(payload *buf.Buffer) {
msg := new(dns.Msg)
err := msg.Unpack(payload.Bytes())
if err != nil {
log.Trace(errors.New("DNS: Failed to parse DNS response: ", err).AtWarning())
log.Trace(errors.New("failed to parse DNS response").Base(err).AtWarning().Path("App", "DNS", "UDPNameServer"))
return
}
record := &ARecord{
@ -113,7 +113,7 @@ func (v *UDPNameServer) HandleResponse(payload *buf.Buffer) {
}
id := msg.Id
ttl := DefaultTTL
log.Trace(errors.New("DNS: Handling response for id ", id, " content: ", msg.String()).AtDebug())
log.Trace(errors.New("handling response for id ", id, " content: ", msg.String()).AtDebug().Path("App", "DNS", "UDPNameServer"))
v.Lock()
request, found := v.requests[id]
@ -201,7 +201,7 @@ func (v *LocalNameServer) QueryA(domain string) <-chan *ARecord {
ips, err := net.LookupIP(domain)
if err != nil {
log.Trace(errors.New("failed to lookup IPs for domain ", domain).Path("App", "DNS").Base(err))
log.Trace(errors.New("failed to lookup IPs for domain ", domain).Path("App", "DNS", "LocalNameServer").Base(err))
return
}

View File

@ -35,7 +35,7 @@ type CacheServer struct {
func NewCacheServer(ctx context.Context, config *dns.Config) (*CacheServer, error) {
space := app.SpaceFromContext(ctx)
if space == nil {
return nil, errors.New("DNSCacheServer: No space in context.")
return nil, errors.New("no space in context").Path("App", "DNS", "CacheServer")
}
server := &CacheServer{
records: make(map[string]*DomainRecord),
@ -45,7 +45,7 @@ func NewCacheServer(ctx context.Context, config *dns.Config) (*CacheServer, erro
space.OnInitialize(func() error {
disp := dispatcher.FromSpace(space)
if disp == nil {
return errors.New("DNS: Dispatcher is not found in the space.")
return errors.New("dispatcher is not found in the space").Path("App", "DNS", "CacheServer")
}
for idx, destPB := range config.NameServers {
address := destPB.Address.AsAddress()
@ -113,13 +113,13 @@ func (v *CacheServer) Get(domain string) []net.IP {
A: a,
}
v.Unlock()
log.Trace(errors.New("DNS: Returning ", len(a.IPs), " IPs for domain ", domain).AtDebug())
log.Trace(errors.New("returning ", len(a.IPs), " IPs for domain ", domain).AtDebug().Path("App", "DNS", "CacheServer"))
return a.IPs
case <-time.After(QueryTimeout):
}
}
log.Trace(errors.New("DNS: Returning nil for domain ", domain).AtDebug())
log.Trace(errors.New("returning nil for domain ", domain).AtDebug().Path("App", "DNS", "CacheServer"))
return nil
}

View File

@ -21,7 +21,7 @@ var (
func InitAccessLogger(file string) error {
logger, err := internal.NewFileLogWriter(file)
if err != nil {
return errors.New("Failed to create access logger on file: ", file).Base(err).Path("App", "Log")
return errors.New("failed to create access logger on file: ", file).Base(err).Path("App", "Log")
}
accessLoggerInstance = logger
return nil

View File

@ -2,8 +2,8 @@ package proxyman
import (
"context"
"errors"
"v2ray.com/core/common/errors"
"v2ray.com/core/proxy"
)
@ -23,7 +23,7 @@ func (s *AllocationStrategy) GetRefreshValue() uint32 {
func (c *OutboundHandlerConfig) GetProxyHandler(ctx context.Context) (proxy.Outbound, error) {
if c == nil {
return nil, errors.New("Proxyman: OutboundHandlerConfig is nil.")
return nil, errors.New("OutboundHandlerConfig is nil").Path("App", "Proxyman", "Outbound", "OutboundHandlerConfig")
}
config, err := c.ProxySettings.GetInstance()
if err != nil {

View File

@ -37,7 +37,7 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
}
for port := pr.From; port <= pr.To; port++ {
if nl.HasNetwork(net.Network_TCP) {
log.Trace(errors.New("Proxyman|DefaultInboundHandler: creating tcp worker on ", address, ":", port).AtDebug())
log.Trace(errors.New("creating tcp worker on ", address, ":", port).AtDebug().Path("App", "Proxyman", "Inbound", "AlwaysOnInboundHandler"))
worker := &tcpWorker{
address: address,
port: net.Port(port),

View File

@ -93,7 +93,7 @@ func (h *DynamicInboundHandler) refresh() error {
port := h.allocatePort()
p, err := proxy.CreateInboundHandler(ctx, h.proxyConfig)
if err != nil {
log.Trace(errors.New("failed to create proxy instance").Base(err).Path("Proxyman", "Inbound", "DynamicInboundHandler").AtWarning())
log.Trace(errors.New("failed to create proxy instance").Base(err).Path("App", "Proxyman", "Inbound", "DynamicInboundHandler").AtWarning())
continue
}
nl := p.Network()
@ -108,7 +108,7 @@ func (h *DynamicInboundHandler) refresh() error {
dispatcher: h.mux,
}
if err := worker.Start(); err != nil {
log.Trace(errors.New("Proxyman:InboundHandler: Failed to create TCP worker: ", err).AtWarning())
log.Trace(errors.New("failed to create TCP worker").Base(err).AtWarning().Path("App", "Proxyman", "Inbound", "DynamicInboundHandler"))
continue
}
workers = append(workers, worker)
@ -124,7 +124,7 @@ func (h *DynamicInboundHandler) refresh() error {
dispatcher: h.mux,
}
if err := worker.Start(); err != nil {
log.Trace(errors.New("Proxyman:InboundHandler: Failed to create UDP worker: ", err).AtWarning())
log.Trace(errors.New("failed to create UDP worker").Base(err).AtWarning().Path("App", "Proxyman", "Inbound", "DynamicInboundHandler"))
continue
}
workers = append(workers, worker)

View File

@ -26,7 +26,7 @@ func (m *DefaultInboundHandlerManager) AddHandler(ctx context.Context, config *p
}
receiverSettings, ok := rawReceiverSettings.(*proxyman.ReceiverConfig)
if !ok {
return errors.New("Proxyman|DefaultInboundHandlerManager: Not a ReceiverConfig.")
return errors.New("not a ReceiverConfig").Path("App", "Proxyman", "Inbound", "DefaultInboundHandlerManager")
}
proxySettings, err := config.ProxySettings.GetInstance()
if err != nil {
@ -50,7 +50,7 @@ func (m *DefaultInboundHandlerManager) AddHandler(ctx context.Context, config *p
}
if handler == nil {
return errors.New("Proxyman|DefaultInboundHandlerManager: Unknown allocation strategy: ", receiverSettings.AllocationStrategy.Type)
return errors.New("unknown allocation strategy: ", receiverSettings.AllocationStrategy.Type).Path("App", "Proxyman", "Inbound", "DefaultInboundHandlerManager")
}
m.handlers = append(m.handlers, handler)
@ -63,7 +63,7 @@ func (m *DefaultInboundHandlerManager) AddHandler(ctx context.Context, config *p
func (m *DefaultInboundHandlerManager) GetHandler(ctx context.Context, tag string) (proxyman.InboundHandler, error) {
handler, found := m.taggedHandlers[tag]
if !found {
return nil, errors.New("Proxymand|DefaultInboundHandlerManager: Handler not found: ", tag)
return nil, errors.New("handler not found: ", tag).Path("App", "Proxyman", "Inbound", "DefaultInboundHandlerManager")
}
return handler, nil
}

View File

@ -54,7 +54,7 @@ func (w *tcpWorker) callback(conn internet.Connection) {
ctx = proxy.ContextWithInboundEntryPoint(ctx, v2net.TCPDestination(w.address, w.port))
ctx = proxy.ContextWithSource(ctx, v2net.DestinationFromAddr(conn.RemoteAddr()))
if err := w.proxy.Process(ctx, v2net.Network_TCP, conn, w.dispatcher); err != nil {
log.Trace(errors.New("connection ends").Base(err).Path("Proxyman", "TCPWorker"))
log.Trace(errors.New("connection ends").Base(err).Path("App", "Proxyman", "Inbound", "TCPWorker"))
}
cancel()
conn.Close()

View File

@ -114,7 +114,7 @@ func (f FrameMetadata) AsSupplier() buf.Supplier {
func ReadFrameFrom(b []byte) (*FrameMetadata, error) {
if len(b) < 4 {
return nil, errors.New("Proxyman|Mux: Insufficient buffer: ", len(b))
return nil, errors.New("insufficient buffer: ", len(b)).Path("App", "Proxyman", "Mux", "Frame")
}
f := &FrameMetadata{
@ -144,7 +144,7 @@ func ReadFrameFrom(b []byte) (*FrameMetadata, error) {
addr = net.DomainAddress(string(b[1 : 1+nDomain]))
b = b[nDomain+1:]
default:
return nil, errors.New("Proxyman|Mux: Unknown address type: ", addrType)
return nil, errors.New("unknown address type: ", addrType).Path("App", "Proxyman", "Mux", "Frame")
}
switch network {
case TargetNetworkTCP:
@ -152,7 +152,7 @@ func ReadFrameFrom(b []byte) (*FrameMetadata, error) {
case TargetNetworkUDP:
f.Target = net.UDPDestination(addr, port)
default:
return nil, errors.New("Proxymann|Mux: Unknown network type: ", network)
return nil, errors.New("unknown network type: ", network).Path("App", "Proxyman", "Mux", "Frame")
}
}

View File

@ -83,7 +83,7 @@ func (m *ClientManager) Dispatch(ctx context.Context, outboundRay ray.OutboundRa
client, err := NewClient(m.proxy, m.dialer, m)
if err != nil {
return errors.New("failed to create client").Base(err).Path("Proxymann", "Mux", "ClientManager")
return errors.New("failed to create client").Base(err).Path("App", "Proxyman", "Mux", "ClientManager")
}
m.clients = append(m.clients, client)
client.Dispatch(ctx, outboundRay)