@marcel91200 / caddy Mirror · read-only / commits / e76405d5
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 04:30 UTC

core: Change ListenerFunc signature (#6651)

* right side in tls ln * remove ParseNetworkAddressFromHostPort * ignore placeholder port * remove println * update test cases (!!!) * [] * comment * Trim * err * Update addresses.go * revert na.JoinHostPort * Update listeners.go

Aaron Paterson committed Dec 12, 2024 at 17:34 UTC e76405d55058b0a3e5ba222b44b5ef00516116aa
1 file changed +4 -4
listeners.go
+4 -4
@@ -139,7 +139,7 @@ func (na NetworkAddress) Listen(ctx context.Context, portOffset uint, config net
139 }
140
141 // check to see if plugin provides listener
142 - if ln, err := getListenerFromPlugin(ctx, na.Network, na.JoinHostPort(portOffset), config); ln != nil || err != nil {
142 + if ln, err := getListenerFromPlugin(ctx, na.Network, na.Host, na.port(), portOffset, config); ln != nil || err != nil {
143 return ln, err
144 }
145
@@ -658,11 +658,11 @@ var unixSocketsMu sync.Mutex
658 // getListenerFromPlugin returns a listener on the given network and address
659 // if a plugin has registered the network name. It may return (nil, nil) if
660 // no plugin can provide a listener.
661 -func getListenerFromPlugin(ctx context.Context, network, addr string, config net.ListenConfig) (any, error) {
661 +func getListenerFromPlugin(ctx context.Context, network, host, port string, portOffset uint, config net.ListenConfig) (any, error) {
662 // get listener from plugin if network type is registered
663 if getListener, ok := networkTypes[network]; ok {
664 Log().Debug("getting listener from plugin", zap.String("network", network))
665 - return getListener(ctx, network, addr, config)
665 + return getListener(ctx, network, host, port, portOffset, config)
666 }
667
668 return nil, nil
@@ -676,7 +676,7 @@ func listenerKey(network, addr string) string {
676 // The listeners must be capable of overlapping: with Caddy, new configs are loaded
677 // before old ones are unloaded, so listeners may overlap briefly if the configs
678 // both need the same listener. EXPERIMENTAL and subject to change.
679 -type ListenerFunc func(ctx context.Context, network, addr string, cfg net.ListenConfig) (any, error)
679 +type ListenerFunc func(ctx context.Context, network, host, portRange string, portOffset uint, cfg net.ListenConfig) (any, error)
680
681 var networkTypes = map[string]ListenerFunc{}
682