mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
VersionMessage: Use Guava InetAddresses for localhost address.
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.net.InetAddresses;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
@@ -97,15 +99,9 @@ public class VersionMessage extends Message {
|
||||
time = System.currentTimeMillis() / 1000;
|
||||
// Note that the Bitcoin Core doesn't do anything with these, and finding out your own external IP address
|
||||
// is kind of tricky anyway, so we just put nonsense here for now.
|
||||
try {
|
||||
// We hard-code the IPv4 localhost address here rather than use InetAddress.getLocalHost() because some
|
||||
// mobile phones have broken localhost DNS entries, also, this is faster.
|
||||
final byte[] localhost = { 127, 0, 0, 1 };
|
||||
myAddr = new PeerAddress(params, InetAddress.getByAddress(localhost), params.getPort(), 0);
|
||||
theirAddr = new PeerAddress(params, InetAddress.getByAddress(localhost), params.getPort(), 0);
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e); // Cannot happen (illegal IP length).
|
||||
}
|
||||
InetAddress localhost = InetAddresses.forString("127.0.0.1");
|
||||
myAddr = new PeerAddress(params, localhost, params.getPort(), 0);
|
||||
theirAddr = new PeerAddress(params, localhost, params.getPort(), 0);
|
||||
subVer = LIBRARY_SUBVER;
|
||||
bestHeight = newBestHeight;
|
||||
relayTxesBeforeFilter = true;
|
||||
|
Reference in New Issue
Block a user