add recorder for relay tunnel endpoint

This commit is contained in:
ginuerzh
2023-10-14 21:06:03 +08:00
parent 4be7d60147
commit 5488076801
5 changed files with 25 additions and 9 deletions

View File

@ -13,10 +13,12 @@ import (
"github.com/go-gost/core/hop"
"github.com/go-gost/core/listener"
md "github.com/go-gost/core/metadata"
"github.com/go-gost/core/recorder"
"github.com/go-gost/core/service"
"github.com/go-gost/relay"
xnet "github.com/go-gost/x/internal/net"
auth_util "github.com/go-gost/x/internal/util/auth"
xrecorder "github.com/go-gost/x/recorder"
"github.com/go-gost/x/registry"
xservice "github.com/go-gost/x/service"
)
@ -33,12 +35,13 @@ func init() {
}
type relayHandler struct {
hop hop.Hop
router *chain.Router
md metadata
options handler.Options
ep service.Service
pool *ConnectorPool
hop hop.Hop
router *chain.Router
md metadata
options handler.Options
ep service.Service
pool *ConnectorPool
recorder recorder.RecorderObject
}
func NewHandler(opts ...handler.Option) handler.Handler {
@ -63,6 +66,15 @@ func (h *relayHandler) Init(md md.Metadata) (err error) {
h.router = chain.NewRouter(chain.LoggerRouterOption(h.options.Logger))
}
if opts := h.router.Options(); opts != nil {
for _, ro := range opts.Recorders {
if ro.Record == xrecorder.RecorderServiceHandlerRelayTunnelEndpoint {
h.recorder = ro
break
}
}
}
if err = h.initEntryPoint(); err != nil {
return
}