Add TCP Middlewares support
This commit is contained in:
parent
679def0151
commit
fc9f41b955
134 changed files with 5865 additions and 1852 deletions
|
@ -17,13 +17,14 @@ const (
|
|||
|
||||
// Configuration holds the information about the currently running traefik instance.
|
||||
type Configuration struct {
|
||||
Routers map[string]*RouterInfo `json:"routers,omitempty"`
|
||||
Middlewares map[string]*MiddlewareInfo `json:"middlewares,omitempty"`
|
||||
Services map[string]*ServiceInfo `json:"services,omitempty"`
|
||||
TCPRouters map[string]*TCPRouterInfo `json:"tcpRouters,omitempty"`
|
||||
TCPServices map[string]*TCPServiceInfo `json:"tcpServices,omitempty"`
|
||||
UDPRouters map[string]*UDPRouterInfo `json:"udpRouters,omitempty"`
|
||||
UDPServices map[string]*UDPServiceInfo `json:"udpServices,omitempty"`
|
||||
Routers map[string]*RouterInfo `json:"routers,omitempty"`
|
||||
Middlewares map[string]*MiddlewareInfo `json:"middlewares,omitempty"`
|
||||
TCPMiddlewares map[string]*TCPMiddlewareInfo `json:"tcpMiddlewares,omitempty"`
|
||||
Services map[string]*ServiceInfo `json:"services,omitempty"`
|
||||
TCPRouters map[string]*TCPRouterInfo `json:"tcpRouters,omitempty"`
|
||||
TCPServices map[string]*TCPServiceInfo `json:"tcpServices,omitempty"`
|
||||
UDPRouters map[string]*UDPRouterInfo `json:"udpRouters,omitempty"`
|
||||
UDPServices map[string]*UDPServiceInfo `json:"udpServices,omitempty"`
|
||||
}
|
||||
|
||||
// NewConfig returns a Configuration initialized with the given conf. It never returns nil.
|
||||
|
@ -74,6 +75,13 @@ func NewConfig(conf dynamic.Configuration) *Configuration {
|
|||
runtimeConfig.TCPServices[k] = &TCPServiceInfo{TCPService: v, Status: StatusEnabled}
|
||||
}
|
||||
}
|
||||
|
||||
if len(conf.TCP.Middlewares) > 0 {
|
||||
runtimeConfig.TCPMiddlewares = make(map[string]*TCPMiddlewareInfo, len(conf.TCP.Middlewares))
|
||||
for k, v := range conf.TCP.Middlewares {
|
||||
runtimeConfig.TCPMiddlewares[k] = &TCPMiddlewareInfo{TCPMiddleware: v, Status: StatusEnabled}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if conf.UDP != nil {
|
||||
|
@ -177,6 +185,15 @@ func (c *Configuration) PopulateUsedBy() {
|
|||
sort.Strings(c.TCPServices[k].UsedBy)
|
||||
}
|
||||
|
||||
for midName, mid := range c.TCPMiddlewares {
|
||||
// lazily initialize Status in case caller forgot to do it
|
||||
if mid.Status == "" {
|
||||
mid.Status = StatusEnabled
|
||||
}
|
||||
|
||||
sort.Strings(c.TCPMiddlewares[midName].UsedBy)
|
||||
}
|
||||
|
||||
for routerName, routerInfo := range c.UDPRouters {
|
||||
// lazily initialize Status in case caller forgot to do it
|
||||
if routerInfo.Status == "" {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue