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

@ -24,7 +24,7 @@ import (
)
func init() {
registry.RegisterHandler("http", NewHandler)
registry.HandlerRegistry().Register("http", NewHandler)
}
type httpHandler struct {
@ -64,13 +64,13 @@ func (h *httpHandler) 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())
}()
@ -120,7 +120,7 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
addr = net.JoinHostPort(addr, "80")
}
fields := map[string]interface{}{
fields := map[string]any{
"dst": addr,
}
if u, _, _ := h.basicProxyAuth(req.Header.Get("Proxy-Authorization"), log); u != "" {
@ -216,7 +216,7 @@ func (h *httpHandler) handleRequest(ctx context.Context, conn net.Conn, req *htt
start := time.Now()
log.Infof("%s <-> %s", conn.RemoteAddr(), addr)
handler.Transport(conn, cc)
log.WithFields(map[string]interface{}{
log.WithFields(map[string]any{
"duration": time.Since(start),
}).Infof("%s >-< %s", conn.RemoteAddr(), addr)
}

View File

@ -13,7 +13,7 @@ import (
)
func (h *httpHandler) handleUDP(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",
})
@ -70,7 +70,7 @@ func (h *httpHandler) handleUDP(ctx context.Context, conn net.Conn, network, add
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())
}