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

@ -16,7 +16,6 @@ import (
"time"
"github.com/go-gost/core/bypass"
"github.com/go-gost/core/chain"
"github.com/go-gost/core/handler"
"github.com/go-gost/core/logger"
md "github.com/go-gost/core/metadata"
@ -32,7 +31,6 @@ func init() {
}
type sniHandler struct {
router *chain.Router
md metadata
options handler.Options
}
@ -55,11 +53,6 @@ func (h *sniHandler) 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 nil
}
@ -128,7 +121,7 @@ func (h *sniHandler) handleHTTP(ctx context.Context, rw io.ReadWriter, raddr net
ctx = ctxvalue.ContextWithHash(ctx, &ctxvalue.Hash{Source: host})
}
cc, err := h.router.Dial(ctx, "tcp", host)
cc, err := h.options.Router.Dial(ctx, "tcp", host)
if err != nil {
log.Error(err)
return err
@ -196,7 +189,7 @@ func (h *sniHandler) handleHTTPS(ctx context.Context, rw io.ReadWriter, raddr ne
ctx = ctxvalue.ContextWithHash(ctx, &ctxvalue.Hash{Source: host})
}
cc, err := h.router.Dial(ctx, "tcp", host)
cc, err := h.options.Router.Dial(ctx, "tcp", host)
if err != nil {
log.Error(err)
return err