1
0
Fork 0

Reserve priority range for internal routers

Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
Baptiste Mayelle 2024-04-02 17:04:05 +02:00 committed by GitHub
parent c31f5df854
commit 2bc3fa7b4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 116 additions and 0 deletions

View file

@ -5,7 +5,9 @@ import (
"crypto/tls"
"errors"
"fmt"
"math"
"net/http"
"strings"
"github.com/traefik/traefik/v2/pkg/config/runtime"
"github.com/traefik/traefik/v2/pkg/log"
@ -18,6 +20,8 @@ import (
traefiktls "github.com/traefik/traefik/v2/pkg/tls"
)
const maxUserPriority = math.MaxInt - 1000
type middlewareBuilder interface {
BuildChain(ctx context.Context, names []string) *tcp.Chain
}
@ -291,6 +295,13 @@ func (m *Manager) addTCPHandlers(ctx context.Context, configs map[string]*runtim
continue
}
if routerConfig.Priority > maxUserPriority && !strings.HasSuffix(routerName, "@internal") {
routerErr := fmt.Errorf("the router priority %d exceeds the max user-defined priority %d", routerConfig.Priority, maxUserPriority)
routerConfig.AddError(routerErr, true)
logger.Error(routerErr)
continue
}
var handler tcp.Handler
if routerConfig.TLS == nil || routerConfig.TLS.Passthrough {
handler, err = m.buildTCPHandler(ctxRouter, routerConfig)