add router handler option

This commit is contained in:
ginuerzh
2021-12-31 00:03:24 +08:00
parent a430384bba
commit 9769efe33c
35 changed files with 98 additions and 281 deletions

View File

@ -36,9 +36,7 @@ func NewHandler(opts ...handler.Option) handler.Handler {
return &socks5Handler{
bypass: options.Bypass,
router: (&chain.Router{}).
WithLogger(options.Logger).
WithResolver(options.Resolver),
router: options.Router,
logger: options.Logger,
}
}
@ -55,16 +53,9 @@ func (h *socks5Handler) Init(md md.Metadata) (err error) {
noTLS: h.md.noTLS,
}
h.router.WithRetry(h.md.retryCount)
return
}
// implements chain.Chainable interface
func (h *socks5Handler) WithChain(chain *chain.Chain) {
h.router.WithChain(chain)
}
func (h *socks5Handler) Handle(ctx context.Context, conn net.Conn) {
defer conn.Close()