Introduce NETWORK_INTERFACE_UNSPECIFIED contstant

Use an explicit value of "<unspecified>" vs. empty string ("") for
clarity when the user has not specified a network interface to use.
This commit is contained in:
Chris Beams 2014-11-10 09:07:32 +01:00
parent ed76f73897
commit 85f5f02378
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
2 changed files with 4 additions and 3 deletions

View File

@ -77,6 +77,7 @@ class BootstrappedPeerFactory {
static final String BOOTSTRAP_NODE_KEY = "bootstrapNode";
static final String NETWORK_INTERFACE_KEY = "networkInterface";
static final String NETWORK_INTERFACE_UNSPECIFIED = "<unspecified>";
private KeyPair keyPair;
private Storage storage;
@ -132,7 +133,7 @@ class BootstrappedPeerFactory {
cc.maxPermitsTCP(100);
cc.maxPermitsUDP(100);
Bindings bindings = new Bindings();
if (!networkInterface.equals(""))
if (!NETWORK_INTERFACE_UNSPECIFIED.equals(networkInterface))
bindings.addInterface(networkInterface);
peer = new PeerBuilder(keyPair).ports(port).peerMap(pm).bindings(bindings)

View File

@ -25,7 +25,7 @@ import com.google.inject.name.Names;
import java.util.Properties;
import static io.bitsquare.msg.tomp2p.BootstrappedPeerFactory.BOOTSTRAP_NODE_KEY;
import static io.bitsquare.msg.tomp2p.BootstrappedPeerFactory.*;
import static io.bitsquare.network.BootstrapNodes.DEFAULT_BOOTSTRAP_NODE;
public class TomP2PMessageModule extends MessageModule {
@ -52,7 +52,7 @@ public class TomP2PMessageModule extends MessageModule {
)
);
bindConstant().annotatedWith(Names.named(NETWORK_INTERFACE_KEY)).to(
properties.getProperty(NETWORK_INTERFACE_KEY, ""));
properties.getProperty(NETWORK_INTERFACE_KEY, NETWORK_INTERFACE_UNSPECIFIED));
bind(BootstrappedPeerFactory.class).asEagerSingleton();
}