router: router.id is optional

This commit is contained in:
ginuerzh
2025-02-11 20:54:52 +08:00
parent fc12e33786
commit ef440e8b4a
5 changed files with 86 additions and 44 deletions
+14 -18
View File
@@ -37,16 +37,17 @@ func init() {
}
type routerHandler struct {
id string
options handler.Options
pool *ConnectorPool
epConn net.PacketConn
md metadata
log logger.Logger
stats *stats_util.HandlerStats
limiter traffic.TrafficLimiter
cancel context.CancelFunc
sdCache *cache.Cache
id string
options handler.Options
pool *ConnectorPool
epConn net.PacketConn
md metadata
log logger.Logger
stats *stats_util.HandlerStats
limiter traffic.TrafficLimiter
cancel context.CancelFunc
sdCache *cache.Cache
routeCache *cache.Cache
}
func NewHandler(opts ...handler.Option) handler.Handler {
@@ -56,8 +57,9 @@ func NewHandler(opts ...handler.Option) handler.Handler {
}
return &routerHandler{
options: options,
sdCache: cache.NewCache(time.Minute),
options: options,
sdCache: cache.NewCache(time.Minute),
routeCache: cache.NewCache(time.Minute),
}
}
@@ -203,12 +205,6 @@ func (h *routerHandler) Handle(ctx context.Context, conn net.Conn, opts ...handl
}
}
if routerID.IsZero() {
resp.Status = relay.StatusBadRequest
resp.WriteTo(conn)
return ErrRouterID
}
if user != "" {
log = log.WithFields(map[string]any{"user": user})
}