From 79ae62801f62e13b23de543659f6f764594e2b19 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 30 Apr 2019 14:55:38 +0200 Subject: [PATCH] ListenRangeConfig: default network ( protocol ) to tcp --- common/net/configure_port.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/net/configure_port.go b/common/net/configure_port.go index dbce7ee8f..1d6050081 100644 --- a/common/net/configure_port.go +++ b/common/net/configure_port.go @@ -40,7 +40,7 @@ func (l *Listener) Close() error { // ListenRangeConfig contains options for listening to a free address [Min,Max) // range. ListenRangeConfig wraps a net.ListenConfig. type ListenRangeConfig struct { - // tcp", "udp" + // like "tcp" or "udp". defaults to "tcp". Network string Addr string Min, Max int @@ -51,6 +51,9 @@ type ListenRangeConfig struct { // until ctx is cancelled. // Listen uses net.ListenConfig.Listen internally. func (lc ListenRangeConfig) Listen(ctx context.Context) (*Listener, error) { + if lc.Network == "" { + lc.Network = "tcp" + } portRange := lc.Max - lc.Min for { if err := ctx.Err(); err != nil {