From 9050ed7aaf2a793186612de0769162d183ef5551 Mon Sep 17 00:00:00 2001 From: frank Date: Wed, 24 Jan 2024 09:09:43 +0800 Subject: [PATCH] fix: waku udp port conflict (#4610) --- api/backend_test.go | 2 -- wakuv2/waku.go | 19 ------------------- wakuv2/waku_test.go | 2 -- 3 files changed, 23 deletions(-) diff --git a/api/backend_test.go b/api/backend_test.go index 1f4ee4585..1d6a869ba 100644 --- a/api/backend_test.go +++ b/api/backend_test.go @@ -751,7 +751,6 @@ func TestLoginWithKey(t *testing.T) { require.NotNil(t, activeAccount.ColorHash) } -/* func TestLoginAccount(t *testing.T) { utils.Init() password := "some-password" @@ -794,7 +793,6 @@ func TestLoginAccount(t *testing.T) { t.FailNow() } } -*/ func TestVerifyDatabasePassword(t *testing.T) { utils.Init() diff --git a/wakuv2/waku.go b/wakuv2/waku.go index 7c576c3f2..870bb2f86 100644 --- a/wakuv2/waku.go +++ b/wakuv2/waku.go @@ -173,18 +173,6 @@ func (w *Waku) SetStatusTelemetryClient(client ITelemetryClient) { w.statusTelemetryClient = client } -func getUsableUDPPort() (int, error) { - conn, err := net.ListenUDP("udp", &net.UDPAddr{ - IP: net.IPv4zero, - Port: 0, - }) - if err != nil { - return 0, err - } - defer conn.Close() - return conn.LocalAddr().(*net.UDPAddr).Port, nil -} - // New creates a WakuV2 client ready to communicate through the LibP2P network. func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *sql.DB, ts *timesource.NTPTimeSource, onHistoricMessagesRequestFailed func([]byte, peer.ID, error), onPeerStats func(types.ConnStatus)) (*Waku, error) { var err error @@ -201,13 +189,6 @@ func New(nodeKey string, fleet string, cfg *Config, logger *zap.Logger, appDB *s cfg = setDefaults(cfg) - if cfg.UDPPort == 0 { - cfg.UDPPort, err = getUsableUDPPort() - if err != nil { - return nil, err - } - } - logger.Info("starting wakuv2 with config", zap.Any("config", cfg)) ctx, cancel := context.WithCancel(context.Background()) diff --git a/wakuv2/waku_test.go b/wakuv2/waku_test.go index ca9054521..e8f3e2afb 100644 --- a/wakuv2/waku_test.go +++ b/wakuv2/waku_test.go @@ -40,7 +40,6 @@ func TestDiscoveryV5(t *testing.T) { config.EnableDiscV5 = true config.DiscV5BootstrapNodes = []string{testENRBootstrap} config.DiscoveryLimit = 20 - config.UDPPort = 9001 w, err := New("", "", config, nil, nil, nil, nil, nil) require.NoError(t, err) @@ -288,7 +287,6 @@ func TestWakuV2Filter(t *testing.T) { config.EnableDiscV5 = true config.DiscV5BootstrapNodes = []string{enrTreeAddress} config.DiscoveryLimit = 20 - config.UDPPort = 9001 config.WakuNodes = []string{enrTreeAddress} fleet := "status.test" // Need a name fleet so that LightClient is not set to false w, err := New("", fleet, config, nil, nil, nil, nil, nil)