Skip to content

Commit e76405d

Browse files
authored
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
1 parent 328fb61 commit e76405d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

listeners.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (na NetworkAddress) Listen(ctx context.Context, portOffset uint, config net
139139
}
140140

141141
// 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 {
143143
return ln, err
144144
}
145145

@@ -658,11 +658,11 @@ var unixSocketsMu sync.Mutex
658658
// getListenerFromPlugin returns a listener on the given network and address
659659
// if a plugin has registered the network name. It may return (nil, nil) if
660660
// 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) {
662662
// get listener from plugin if network type is registered
663663
if getListener, ok := networkTypes[network]; ok {
664664
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)
666666
}
667667

668668
return nil, nil
@@ -676,7 +676,7 @@ func listenerKey(network, addr string) string {
676676
// The listeners must be capable of overlapping: with Caddy, new configs are loaded
677677
// before old ones are unloaded, so listeners may overlap briefly if the configs
678678
// 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)
680680

681681
var networkTypes = map[string]ListenerFunc{}
682682

0 commit comments

Comments
 (0)