@@ -181,11 +181,15 @@ func NewHost(cfg HostConfig) (Host, error) {
181
181
if err := ps .AddPubKey (peerID , pub ); err != nil {
182
182
return nil , fmt .Errorf ("failed to set up peerstore with pub key: %w" , err )
183
183
}
184
- var connGtr gating.BlockingConnectionGater
185
- connGtr , err = gating .NewBlockingConnectionGater (datastore )
184
+ var connGtr gating.ExtendedConnectionGater
185
+ connGtr , err = gating .NewExtendedConnectionGater (datastore )
186
186
if err != nil {
187
187
return nil , fmt .Errorf ("failed to open connection gater: %w" , err )
188
188
}
189
+ if cfg .DisablePrivateIPScan {
190
+ // Prevent dialing of public addresses
191
+ connGtr = gating .AddBlocking (connGtr , cfg .DisablePrivateIPScan )
192
+ }
189
193
connGtr = gating .AddBanExpiry (connGtr , ps , clock .SystemClock )
190
194
connGtr = gating .AddMetering (connGtr )
191
195
@@ -302,12 +306,6 @@ func NewHost(cfg HostConfig) (Host, error) {
302
306
p2pHostConfig = append (p2pHostConfig , libp2p .ForceReachabilityPublic ())
303
307
}
304
308
305
- // TODO: this should be moved to main gater
306
- if cfg .DisablePrivateIPScan {
307
- // Prevent dialing of public addresses
308
- p2pHostConfig = append (p2pHostConfig , libp2p .ConnectionGater (NewGater (cfg .DisablePrivateIPScan )))
309
- }
310
-
311
309
// create p2p host
312
310
p2pHost , err := libp2p .New (p2pHostConfig ... )
313
311
if err != nil {
0 commit comments