update registry

This commit is contained in:
ginuerzh
2022-02-27 22:32:15 +08:00
parent 0aee4f0ebd
commit 07132d8de7
115 changed files with 651 additions and 680 deletions

View File

@ -14,7 +14,7 @@ import (
)
func (h *relayHandler) handleBind(ctx context.Context, conn net.Conn, network, address string, log logger.Logger) {
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"dst": fmt.Sprintf("%s/%s", address, network),
"cmd": "bind",
})
@ -70,7 +70,7 @@ func (h *relayHandler) bindTCP(ctx context.Context, conn net.Conn, network, addr
return
}
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"bind": fmt.Sprintf("%s/%s", ln.Addr(), ln.Addr().Network()),
})
log.Debugf("bind on %s OK", ln.Addr())
@ -107,7 +107,7 @@ func (h *relayHandler) bindUDP(ctx context.Context, conn net.Conn, network, addr
return
}
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"bind": pc.LocalAddr().String(),
})
log.Debugf("bind on %s OK", pc.LocalAddr())
@ -120,7 +120,7 @@ func (h *relayHandler) bindUDP(ctx context.Context, conn net.Conn, network, addr
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), pc.LocalAddr())
relay.Run()
log.WithFields(map[string]interface{}{
log.WithFields(map[string]any{
"duration": time.Since(t),
}).Infof("%s >-< %s", conn.RemoteAddr(), pc.LocalAddr())
}
@ -157,7 +157,7 @@ func (h *relayHandler) serveTCPBind(ctx context.Context, conn net.Conn, ln net.L
go func(c net.Conn) {
defer c.Close()
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"local": ln.Addr().String(),
"remote": c.RemoteAddr().String(),
})
@ -184,7 +184,7 @@ func (h *relayHandler) serveTCPBind(ctx context.Context, conn net.Conn, ln net.L
t := time.Now()
log.Infof("%s <-> %s", c.LocalAddr(), c.RemoteAddr())
handler.Transport(sc, c)
log.WithFields(map[string]interface{}{"duration": time.Since(t)}).
log.WithFields(map[string]any{"duration": time.Since(t)}).
Infof("%s >-< %s", c.LocalAddr(), c.RemoteAddr())
}(rc)
}

View File

@ -12,7 +12,7 @@ import (
)
func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network, address string, log logger.Logger) {
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"dst": fmt.Sprintf("%s/%s", address, network),
"cmd": "connect",
})
@ -81,7 +81,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), address)
handler.Transport(conn, cc)
log.WithFields(map[string]interface{}{
log.WithFields(map[string]any{
"duration": time.Since(t),
}).Infof("%s >-< %s", conn.RemoteAddr(), address)
}

View File

@ -24,7 +24,7 @@ func (h *relayHandler) handleForward(ctx context.Context, conn net.Conn, network
return
}
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"dst": fmt.Sprintf("%s/%s", target.Addr, network),
"cmd": "forward",
})
@ -81,7 +81,7 @@ func (h *relayHandler) handleForward(ctx context.Context, conn net.Conn, network
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), target.Addr)
handler.Transport(conn, cc)
log.WithFields(map[string]interface{}{
log.WithFields(map[string]any{
"duration": time.Since(t),
}).Infof("%s >-< %s", conn.RemoteAddr(), target.Addr)
}

View File

@ -14,7 +14,7 @@ import (
)
func init() {
registry.RegisterHandler("relay", NewHandler)
registry.HandlerRegistry().Register("relay", NewHandler)
}
type relayHandler struct {
@ -59,14 +59,14 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn) {
defer conn.Close()
start := time.Now()
log := h.options.Logger.WithFields(map[string]interface{}{
log := h.options.Logger.WithFields(map[string]any{
"remote": conn.RemoteAddr().String(),
"local": conn.LocalAddr().String(),
})
log.Infof("%s <> %s", conn.RemoteAddr(), conn.LocalAddr())
defer func() {
log.WithFields(map[string]interface{}{
log.WithFields(map[string]any{
"duration": time.Since(start),
}).Infof("%s >< %s", conn.RemoteAddr(), conn.LocalAddr())
}()
@ -102,7 +102,7 @@ func (h *relayHandler) Handle(ctx context.Context, conn net.Conn) {
}
if user != "" {
log = log.WithFields(map[string]interface{}{"user": user})
log = log.WithFields(map[string]any{"user": user})
}
resp := relay.Response{