@@ -17,8 +17,9 @@ import (
1717)
1818
1919const (
20- bootstrapRetryInterval = 10
21- badAddrExpiryHours = 12
20+ bootstrapRetryInterval = 10
21+ badAddrExpiryHours = 12
22+ defaultSuperNodeP2PPort = 4444
2223)
2324
2425func (s * DHT ) skipBadBootstrapAddrs () {
@@ -46,24 +47,46 @@ func (s *DHT) parseNode(extP2P string, selfAddr string) (*Node, error) {
4647 return nil , errors .New ("configure: skip bad p2p boostrap addr" )
4748 }
4849
49- addr := strings .Split (extP2P , ":" )
50- if len (addr ) != 2 {
51- return nil , errors .New ("wrong number of field" )
50+ // Extract IP and port from the address
51+ var ip string
52+ var port uint16
53+
54+ if idx := strings .LastIndex (extP2P , ":" ); idx != - 1 {
55+ ip = extP2P [:idx ]
56+ portStr := extP2P [idx + 1 :]
57+
58+ // If we have a port in the address, parse it
59+ if portStr != "" {
60+ portNum , err := strconv .ParseUint (portStr , 10 , 16 )
61+ if err != nil {
62+ return nil , errors .New ("invalid port number" )
63+ }
64+
65+ // For system testing, use port+1 if SYSTEM_TEST=true
66+ if os .Getenv ("SYSTEM_TEST" ) == "true" {
67+ port = uint16 (portNum ) + 1
68+ log .P2P ().WithField ("original_port" , portNum ).
69+ WithField ("adjusted_port" , port ).
70+ Info ("Using port+1 for system testing" )
71+ } else {
72+ // For normal P2P operation, always use the default port
73+ port = defaultNetworkPort
74+ }
75+ }
76+ } else {
77+ // No port in the address
78+ ip = extP2P
79+ port = defaultNetworkPort
5280 }
53- ip := addr [0 ]
5481
5582 if ip == "" {
5683 return nil , errors .New ("empty ip" )
5784 }
5885
59- port , err := strconv .ParseUint (addr [1 ], 10 , 16 )
60- if err != nil {
61- return nil , errors .New ("invalid port number" )
62- }
63-
86+ // Create the node with the correct IP and port
6487 return & Node {
6588 IP : ip ,
66- Port : uint16 ( port ) ,
89+ Port : port ,
6790 }, nil
6891}
6992
@@ -154,9 +177,6 @@ func (s *DHT) ConfigureBootstrapNodes(ctx context.Context, bootstrapNodes string
154177
155178 // Convert the map to a slice
156179 for _ , node := range mapNodes {
157- if os .Getenv ("INTEGRATION_TEST" ) != "true" {
158- node .Port = node .Port + 1
159- }
160180 hID , _ := utils .Blake3Hash (node .ID )
161181 node .HashedID = hID
162182 fmt .Println ("node adding" , node .String (), "hashed id" , string (node .HashedID ))
0 commit comments