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

@ -66,7 +66,7 @@ func (h *relayHandler) handleConnect(ctx context.Context, conn net.Conn, network
case "serial":
cc, err = serial.OpenPort(serial.ParseConfigFromAddr(address))
default:
cc, err = h.router.Dial(ctx, network, address)
cc, err = h.options.Router.Dial(ctx, network, address)
}
if err != nil {
resp.Status = relay.StatusNetworkUnreachable

View File

@ -38,7 +38,7 @@ func (h *relayHandler) handleForward(ctx context.Context, conn net.Conn, network
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 {
// 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

@ -7,7 +7,6 @@ import (
"strconv"
"time"
"github.com/go-gost/core/chain"
"github.com/go-gost/core/handler"
"github.com/go-gost/core/hop"
md "github.com/go-gost/core/metadata"
@ -30,7 +29,6 @@ func init() {
type relayHandler struct {
hop hop.Hop
router *chain.Router
md metadata
options handler.Options
stats *stats_util.HandlerStats
@ -54,11 +52,6 @@ func (h *relayHandler) Init(md md.Metadata) (err error) {
return err
}
h.router = h.options.Router
if h.router == nil {
h.router = chain.NewRouter(chain.LoggerRouterOption(h.options.Logger))
}
ctx, cancel := context.WithCancel(context.Background())
h.cancel = cancel