Skip to content

Commit

Permalink
PeerAddress/HttpDiscovery: accept unresolved InetSocketAddresses to a…
Browse files Browse the repository at this point in the history
…void super-slow reverse DNS lookups for HTTPSeed discovered peers.
  • Loading branch information
mikehearn committed Oct 8, 2015
1 parent 3d322d5 commit e104bfb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/core/PeerAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public PeerAddress(InetAddress addr) {
*/
public PeerAddress(InetSocketAddress addr) {
if (addr.getHostName() == null || !addr.getHostName().toLowerCase().endsWith(".onion")) {
this.addr = checkNotNull(addr.getAddress());
this.addr = addr.getHostName() == null ? addr.getAddress() : new InetSocketAddress(addr.getHostName(), addr.getPort()).getAddress();
} else {
this.hostname = addr.getHostName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public InetSocketAddress[] protoToAddrs(PeerSeedProtos.SignedPeerSeeds proto) th
InetSocketAddress[] results = new InetSocketAddress[seeds.getSeedCount()];
int i = 0;
for (PeerSeedProtos.PeerSeedData data : seeds.getSeedList())
results[i++] = new InetSocketAddress(data.getIpAddress(), data.getPort());
results[i++] = InetSocketAddress.createUnresolved(data.getIpAddress(), data.getPort());
return results;
}

Expand Down

0 comments on commit e104bfb

Please sign in to comment.