add port range support for service

This commit is contained in:
ginuerzh
2024-07-08 22:38:21 +08:00
parent 96f4d7bf5c
commit c1d0887a9b
73 changed files with 1915 additions and 316 deletions

View File

@ -37,7 +37,6 @@ func init() {
type forwardHandler struct {
hop hop.Hop
router *chain.Router
md metadata
options handler.Options
}
@ -58,11 +57,6 @@ func (h *forwardHandler) Init(md md.Metadata) (err error) {
return
}
h.router = h.options.Router
if h.router == nil {
h.router = chain.NewRouter(chain.LoggerRouterOption(h.options.Logger))
}
return
}
@ -157,7 +151,7 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
log.Debugf("%s >> %s", conn.RemoteAddr(), addr)
cc, err := h.router.Dial(ctx, network, addr)
cc, err := h.options.Router.Dial(ctx, network, addr)
if err != nil {
log.Error(err)
// TODO: the router itself may be failed due to the failed node in the router,
@ -277,7 +271,7 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, remot
}
}
cc, err = h.router.Dial(ctx, "tcp", target.Addr)
cc, err = h.options.Router.Dial(ctx, "tcp", target.Addr)
if err != nil {
// TODO: the router itself may be failed due to the failed node in the router,
// the dead marker may be a wrong operation.

View File

@ -38,7 +38,6 @@ func init() {
type forwardHandler struct {
hop hop.Hop
router *chain.Router
md metadata
options handler.Options
}
@ -59,11 +58,6 @@ func (h *forwardHandler) Init(md mdata.Metadata) (err error) {
return
}
h.router = h.options.Router
if h.router == nil {
h.router = chain.NewRouter(chain.LoggerRouterOption(h.options.Logger))
}
return
}
@ -156,7 +150,7 @@ func (h *forwardHandler) Handle(ctx context.Context, conn net.Conn, opts ...hand
log.Debugf("%s >> %s", conn.RemoteAddr(), target.Addr)
cc, err := h.router.Dial(ctx, network, target.Addr)
cc, err := h.options.Router.Dial(ctx, network, target.Addr)
if err != nil {
log.Error(err)
// TODO: the router itself may be failed due to the failed node in the router,
@ -277,7 +271,7 @@ func (h *forwardHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, remot
}
}
cc, err = h.router.Dial(ctx, "tcp", target.Addr)
cc, err = h.options.Router.Dial(ctx, "tcp", target.Addr)
if err != nil {
// TODO: the router itself may be failed due to the failed node in the router,
// the dead marker may be a wrong operation.