add observer

This commit is contained in:
ginuerzh
2024-01-03 20:55:06 +08:00
parent e1ae379048
commit c959fc2f73
95 changed files with 2371 additions and 890 deletions

View File

@ -14,6 +14,7 @@ import (
mdx "github.com/go-gost/x/metadata"
metrics "github.com/go-gost/x/metrics/wrapper"
"github.com/go-gost/x/registry"
stats "github.com/go-gost/x/stats/wrapper"
)
func init() {
@ -27,7 +28,7 @@ type tunListener struct {
logger logger.Logger
md metadata
options listener.Options
routes []*router.Route
routes []*router.Route
}
func NewListener(opts ...listener.Option) listener.Listener {
@ -91,6 +92,7 @@ func (l *tunListener) listenLoop() {
cancel: cancel,
}
c = metrics.WrapConn(l.options.Service, c)
c = stats.WrapConn(c, l.options.Stats)
c = limiter.WrapConn(l.options.TrafficLimiter, c)
c = withMetadata(mdx.NewMetadata(map[string]any{
"config": l.md.config,