remove unnecessary conn

This commit is contained in:
ginuerzh
2022-03-15 15:45:22 +08:00
parent 422e07f4e7
commit 073ad80ce4
17 changed files with 287 additions and 303 deletions

View File

@ -81,8 +81,8 @@ func (h *tapHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.
defer conn.Close()
log := h.options.Logger
cc, ok := conn.(*tap_util.Conn)
if !ok || cc.Config() == nil {
v, _ := conn.(md.Metadatable)
if v == nil {
err := errors.New("tap: wrong connection type")
log.Error(err)
return err
@ -118,7 +118,8 @@ func (h *tapHandler) Handle(ctx context.Context, conn net.Conn, opts ...handler.
log.Infof("%s >> %s", conn.RemoteAddr(), target.Addr)
}
h.handleLoop(ctx, conn, raddr, cc.Config(), log)
config := v.GetMetadata().Get("config").(*tap_util.Config)
h.handleLoop(ctx, conn, raddr, config, log)
return nil
}