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

@ -12,7 +12,7 @@ import (
)
func (h *socks5Handler) 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",
})
@ -59,7 +59,7 @@ func (h *socks5Handler) bindLocal(ctx context.Context, conn net.Conn, network, a
}
log.Debug(reply)
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"bind": fmt.Sprintf("%s/%s", ln.Addr(), ln.Addr().Network()),
})
@ -120,7 +120,7 @@ func (h *socks5Handler) serveBind(ctx context.Context, conn net.Conn, ln net.Lis
log.Debugf("peer %s accepted", rc.RemoteAddr())
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"local": rc.LocalAddr().String(),
"remote": rc.RemoteAddr().String(),
})
@ -136,7 +136,7 @@ func (h *socks5Handler) serveBind(ctx context.Context, conn net.Conn, ln net.Lis
start := time.Now()
log.Infof("%s <-> %s", rc.LocalAddr(), rc.RemoteAddr())
handler.Transport(pc2, rc)
log.WithFields(map[string]interface{}{"duration": time.Since(start)}).
log.WithFields(map[string]any{"duration": time.Since(start)}).
Infof("%s >-< %s", rc.LocalAddr(), rc.RemoteAddr())
case err := <-pipe():

View File

@ -12,7 +12,7 @@ import (
)
func (h *socks5Handler) 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",
})
@ -46,7 +46,7 @@ func (h *socks5Handler) handleConnect(ctx context.Context, conn net.Conn, networ
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

@ -14,8 +14,8 @@ import (
)
func init() {
registry.RegisterHandler("socks5", NewHandler)
registry.RegisterHandler("socks", NewHandler)
registry.HandlerRegistry().Register("socks5", NewHandler)
registry.HandlerRegistry().Register("socks", NewHandler)
}
type socks5Handler struct {
@ -64,14 +64,14 @@ func (h *socks5Handler) Handle(ctx context.Context, conn net.Conn) {
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())
}()

View File

@ -13,7 +13,7 @@ import (
)
func (h *socks5Handler) handleMuxBind(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": "mbind",
})
@ -60,7 +60,7 @@ func (h *socks5Handler) muxBindLocal(ctx context.Context, conn net.Conn, network
}
log.Debug(reply)
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"bind": fmt.Sprintf("%s/%s", ln.Addr(), ln.Addr().Network()),
})
@ -101,7 +101,7 @@ func (h *socks5Handler) serveMuxBind(ctx context.Context, conn net.Conn, ln net.
go func(c net.Conn) {
defer c.Close()
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"local": rc.LocalAddr().String(),
"remote": rc.RemoteAddr().String(),
})
@ -127,7 +127,7 @@ func (h *socks5Handler) serveMuxBind(ctx context.Context, conn net.Conn, ln net.
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

@ -15,7 +15,7 @@ import (
)
func (h *socks5Handler) handleUDP(ctx context.Context, conn net.Conn, log logger.Logger) {
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"cmd": "udp",
})
@ -48,7 +48,7 @@ func (h *socks5Handler) handleUDP(ctx context.Context, conn net.Conn, log logger
}
log.Debug(reply)
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"bind": fmt.Sprintf("%s/%s", cc.LocalAddr(), cc.LocalAddr().Network()),
})
log.Debugf("bind on %s OK", cc.LocalAddr())
@ -77,6 +77,6 @@ func (h *socks5Handler) handleUDP(ctx context.Context, conn net.Conn, log logger
t := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), cc.LocalAddr())
io.Copy(ioutil.Discard, conn)
log.WithFields(map[string]interface{}{"duration": time.Since(t)}).
log.WithFields(map[string]any{"duration": time.Since(t)}).
Infof("%s >-< %s", conn.RemoteAddr(), cc.LocalAddr())
}

View File

@ -12,7 +12,7 @@ import (
)
func (h *socks5Handler) handleUDPTun(ctx context.Context, conn net.Conn, network, address string, log logger.Logger) {
log = log.WithFields(map[string]interface{}{
log = log.WithFields(map[string]any{
"cmd": "udp-tun",
})
@ -66,7 +66,7 @@ func (h *socks5Handler) handleUDPTun(ctx context.Context, conn net.Conn, network
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())
}