File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -475,14 +475,26 @@ func (cfg *Config) validate() error {
475
475
return errors .New ("cannot use shared TCP listener with PSK" )
476
476
}
477
477
478
+ // check for duplicate listen addresses and remove them
479
+ listenAddresses := cfg .ListenAddrs
480
+ // Remove duplicates while keeping the first occurrence of each address
481
+ seen := make (map [string ]bool )
482
+ listenAddresses = slices .DeleteFunc (listenAddresses , func (addr ma.Multiaddr ) bool {
483
+ addrStr := addr .String ()
484
+ if seen [addrStr ] {
485
+ return true // Remove this duplicate
486
+ }
487
+ seen [addrStr ] = true
488
+ return false // Keep this first occurrence
489
+ })
490
+ cfg .ListenAddrs = listenAddresses
478
491
return nil
479
492
}
480
493
481
494
// NewNode constructs a new libp2p Host from the Config.
482
495
//
483
496
// This function consumes the config. Do not reuse it (really!).
484
497
func (cfg * Config ) NewNode () (host.Host , error ) {
485
-
486
498
validateErr := cfg .validate ()
487
499
if validateErr != nil {
488
500
if cfg .ResourceManager != nil {
You can’t perform that action at this time.
0 commit comments