improve config

This commit is contained in:
ginuerzh
2022-01-26 18:29:48 +08:00
parent 713586729b
commit 44acdc9215
14 changed files with 160 additions and 119 deletions

View File

@ -25,17 +25,17 @@ func (h *relayHandler) handleForward(ctx context.Context, conn net.Conn, network
}
log = log.WithFields(map[string]interface{}{
"dst": fmt.Sprintf("%s/%s", target.Addr(), network),
"dst": fmt.Sprintf("%s/%s", target.Addr, network),
"cmd": "forward",
})
log.Infof("%s >> %s", conn.RemoteAddr(), target.Addr())
log.Infof("%s >> %s", conn.RemoteAddr(), target.Addr)
cc, err := h.router.Dial(ctx, network, target.Addr())
cc, err := h.router.Dial(ctx, network, target.Addr)
if err != nil {
// TODO: the router itself may be failed due to the failed node in the router,
// the dead marker may be a wrong operation.
target.Marker().Mark()
target.Marker.Mark()
resp.Status = relay.StatusHostUnreachable
resp.WriteTo(conn)
@ -44,7 +44,7 @@ func (h *relayHandler) handleForward(ctx context.Context, conn net.Conn, network
return
}
defer cc.Close()
target.Marker().Reset()
target.Marker.Reset()
if h.md.noDelay {
if _, err := resp.WriteTo(conn); err != nil {
@ -79,9 +79,9 @@ func (h *relayHandler) handleForward(ctx context.Context, conn net.Conn, network
}
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), target.Addr())
log.Infof("%s <-> %s", conn.RemoteAddr(), target.Addr)
handler.Transport(conn, cc)
log.WithFields(map[string]interface{}{
"duration": time.Since(t),
}).Infof("%s >-< %s", conn.RemoteAddr(), target.Addr())
}).Infof("%s >-< %s", conn.RemoteAddr(), target.Addr)
}