mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-25 07:27:18 +01:00
Extracted default addresses into a separate class
This commit is contained in:
parent
628b14c93c
commit
3e13a0f226
4 changed files with 91 additions and 85 deletions
|
@ -1,6 +1,5 @@
|
||||||
package io.bisq.core.network;
|
package io.bisq.core.network;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
import io.bisq.core.app.BisqEnvironment;
|
import io.bisq.core.app.BisqEnvironment;
|
||||||
import io.bisq.network.NetworkOptionKeys;
|
import io.bisq.network.NetworkOptionKeys;
|
||||||
|
@ -14,86 +13,12 @@ import java.util.HashSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static io.bisq.core.network.DefaultNodeAddresses.DEFAULT_LOCALHOST_SEED_NODE_ADDRESSES;
|
||||||
|
import static io.bisq.core.network.DefaultNodeAddresses.DEFAULT_TOR_SEED_NODE_ADDRESSES;
|
||||||
|
|
||||||
class CoreSeedNodeRepositoryFactory {
|
class CoreSeedNodeRepositoryFactory {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CoreSeedNodeRepositoryFactory.class);
|
private static final Logger log = LoggerFactory.getLogger(CoreSeedNodeRepositoryFactory.class);
|
||||||
|
|
||||||
// Addresses are used if the last digit of their port match the network id:
|
|
||||||
// - mainnet use port ends in 0
|
|
||||||
// - testnet use port ends in 1
|
|
||||||
// - regtest use port ends in 2
|
|
||||||
private static final Set<NodeAddress> DEFAULT_LOCALHOST_SEED_NODE_ADDRESSES = ImmutableSet.of(
|
|
||||||
// BTC
|
|
||||||
// mainnet
|
|
||||||
new NodeAddress("localhost:2000"),
|
|
||||||
new NodeAddress("localhost:3000"),
|
|
||||||
new NodeAddress("localhost:4000"),
|
|
||||||
|
|
||||||
// testnet
|
|
||||||
new NodeAddress("localhost:2001"),
|
|
||||||
new NodeAddress("localhost:3001"),
|
|
||||||
new NodeAddress("localhost:4001"),
|
|
||||||
|
|
||||||
// regtest
|
|
||||||
new NodeAddress("localhost:2002"),
|
|
||||||
new NodeAddress("localhost:3002"),
|
|
||||||
/* new NodeAddress("localhost:4002"),*/
|
|
||||||
|
|
||||||
// LTC
|
|
||||||
// mainnet
|
|
||||||
new NodeAddress("localhost:2003"),
|
|
||||||
|
|
||||||
// regtest
|
|
||||||
new NodeAddress("localhost:2005"),
|
|
||||||
|
|
||||||
// DOGE regtest
|
|
||||||
new NodeAddress("localhost:2008"),
|
|
||||||
|
|
||||||
// DASH regtest
|
|
||||||
new NodeAddress("localhost:2011")
|
|
||||||
);
|
|
||||||
|
|
||||||
// Addresses are used if their port match the network id:
|
|
||||||
// - mainnet uses port 8000
|
|
||||||
// - testnet uses port 8001
|
|
||||||
// - regtest uses port 8002
|
|
||||||
private static final Set<NodeAddress> DEFAULT_TOR_SEED_NODE_ADDRESSES = ImmutableSet.of(
|
|
||||||
// BTC mainnet
|
|
||||||
new NodeAddress("5quyxpxheyvzmb2d.onion:8000"), // @miker
|
|
||||||
new NodeAddress("s67qglwhkgkyvr74.onion:8000"), // @emzy
|
|
||||||
new NodeAddress("ef5qnzx6znifo3df.onion:8000"), // @manfredkarrer
|
|
||||||
new NodeAddress("jhgcy2won7xnslrb.onion:8000"), // @manfredkarrer
|
|
||||||
new NodeAddress("3f3cu2yw7u457ztq.onion:8000"), // @manfredkarrer
|
|
||||||
new NodeAddress("723ljisnynbtdohi.onion:8000"), // @manfredkarrer
|
|
||||||
new NodeAddress("rm7b56wbrcczpjvl.onion:8000"), // @manfredkarrer
|
|
||||||
new NodeAddress("fl3mmribyxgrv63c.onion:8000"), // @manfredkarrer
|
|
||||||
|
|
||||||
// local dev
|
|
||||||
// new NodeAddress("joehwtpe7ijnz4df.onion:8000"),
|
|
||||||
// new NodeAddress("uqxi3zrpobhtoes6.onion:8000"),
|
|
||||||
|
|
||||||
// BTC testnet
|
|
||||||
new NodeAddress("nbphlanpgbei4okt.onion:8001"),
|
|
||||||
// new NodeAddress("vjkh4ykq7x5skdlt.onion:8001"), // dev test
|
|
||||||
|
|
||||||
// BTC regtest
|
|
||||||
// For development you need to change that to your local onion addresses
|
|
||||||
// 1. Run a seed node with prog args: --bitcoinNetwork=regtest --nodePort=8002 --myAddress=rxdkppp3vicnbgqt:8002 --appName=bisq_seed_node_rxdkppp3vicnbgqt.onion_8002
|
|
||||||
// 2. Find your local onion address in bisq_seed_node_rxdkppp3vicnbgqt.onion_8002/regtest/tor/hiddenservice/hostname
|
|
||||||
// 3. Shut down the seed node
|
|
||||||
// 4. Rename the directory with your local onion address
|
|
||||||
// 5. Edit here your found onion address (new NodeAddress("YOUR_ONION.onion:8002")
|
|
||||||
new NodeAddress("rxdkppp3vicnbgqt.onion:8002"),
|
|
||||||
|
|
||||||
// LTC mainnet
|
|
||||||
new NodeAddress("acyvotgewx46pebw.onion:8003"),
|
|
||||||
new NodeAddress("pklgy3vdfn3obkur.onion:8003"),
|
|
||||||
|
|
||||||
// DASH mainnet
|
|
||||||
new NodeAddress("toeu5ikb27ydscxt.onion:8009"),
|
|
||||||
new NodeAddress("ae4yvaivhnekkhqf.onion:8009")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
CoreSeedNodesRepository create(BisqEnvironment environment,
|
CoreSeedNodesRepository create(BisqEnvironment environment,
|
||||||
@Named(NetworkOptionKeys.USE_LOCALHOST_FOR_P2P) boolean useLocalhostForP2P,
|
@Named(NetworkOptionKeys.USE_LOCALHOST_FOR_P2P) boolean useLocalhostForP2P,
|
||||||
@Named(NetworkOptionKeys.NETWORK_ID) int networkId,
|
@Named(NetworkOptionKeys.NETWORK_ID) int networkId,
|
||||||
|
@ -104,7 +29,7 @@ class CoreSeedNodeRepositoryFactory {
|
||||||
Set<NodeAddress> delegate = useLocalhostForP2P
|
Set<NodeAddress> delegate = useLocalhostForP2P
|
||||||
? DEFAULT_LOCALHOST_SEED_NODE_ADDRESSES
|
? DEFAULT_LOCALHOST_SEED_NODE_ADDRESSES
|
||||||
: DEFAULT_TOR_SEED_NODE_ADDRESSES;
|
: DEFAULT_TOR_SEED_NODE_ADDRESSES;
|
||||||
nodeAddresses = NodeAddresses.createFromSet(delegate, networkId);
|
nodeAddresses = NodeAddresses.fromSet(delegate, networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> bannedHosts = getBannedHosts(environment);
|
Set<String> bannedHosts = getBannedHosts(environment);
|
||||||
|
|
|
@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.concurrent.NotThreadSafe;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,6 +20,7 @@ import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@NotThreadSafe
|
||||||
public class CoreSeedNodesRepository implements SeedNodesRepository {
|
public class CoreSeedNodesRepository implements SeedNodesRepository {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -55,11 +57,6 @@ public class CoreSeedNodesRepository implements SeedNodesRepository {
|
||||||
log.warn("We received banned seed nodes={}, seedNodeAddresses={}", bannedNodes, seedNodeAddresses);
|
log.warn("We received banned seed nodes={}, seedNodeAddresses={}", bannedNodes, seedNodeAddresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreSeedNodesRepository(Set<NodeAddress> seedNodeAddresses) {
|
|
||||||
this.seedNodeAddresses = seedNodeAddresses;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOperator(NodeAddress nodeAddress) {
|
public String getOperator(NodeAddress nodeAddress) {
|
||||||
switch (nodeAddress.getFullAddress()) {
|
switch (nodeAddress.getFullAddress()) {
|
||||||
case "5quyxpxheyvzmb2d.onion:8000":
|
case "5quyxpxheyvzmb2d.onion:8000":
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package io.bisq.core.network;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import io.bisq.network.p2p.NodeAddress;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
class DefaultNodeAddresses {
|
||||||
|
// Addresses are used if the last digit of their port match the network id:
|
||||||
|
// - mainnet use port ends in 0
|
||||||
|
// - testnet use port ends in 1
|
||||||
|
// - regtest use port ends in 2
|
||||||
|
static final Set<NodeAddress> DEFAULT_LOCALHOST_SEED_NODE_ADDRESSES = ImmutableSet.of(
|
||||||
|
// BTC
|
||||||
|
// mainnet
|
||||||
|
new NodeAddress("localhost:2000"),
|
||||||
|
new NodeAddress("localhost:3000"),
|
||||||
|
new NodeAddress("localhost:4000"),
|
||||||
|
|
||||||
|
// testnet
|
||||||
|
new NodeAddress("localhost:2001"),
|
||||||
|
new NodeAddress("localhost:3001"),
|
||||||
|
new NodeAddress("localhost:4001"),
|
||||||
|
|
||||||
|
// regtest
|
||||||
|
new NodeAddress("localhost:2002"),
|
||||||
|
new NodeAddress("localhost:3002"),
|
||||||
|
/* new NodeAddress("localhost:4002"),*/
|
||||||
|
|
||||||
|
// LTC
|
||||||
|
// mainnet
|
||||||
|
new NodeAddress("localhost:2003"),
|
||||||
|
|
||||||
|
// regtest
|
||||||
|
new NodeAddress("localhost:2005"),
|
||||||
|
|
||||||
|
// DOGE regtest
|
||||||
|
new NodeAddress("localhost:2008"),
|
||||||
|
|
||||||
|
// DASH regtest
|
||||||
|
new NodeAddress("localhost:2011")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Addresses are used if their port match the network id:
|
||||||
|
// - mainnet uses port 8000
|
||||||
|
// - testnet uses port 8001
|
||||||
|
// - regtest uses port 8002
|
||||||
|
static final Set<NodeAddress> DEFAULT_TOR_SEED_NODE_ADDRESSES = ImmutableSet.of(
|
||||||
|
// BTC mainnet
|
||||||
|
new NodeAddress("5quyxpxheyvzmb2d.onion:8000"), // @miker
|
||||||
|
new NodeAddress("s67qglwhkgkyvr74.onion:8000"), // @emzy
|
||||||
|
new NodeAddress("ef5qnzx6znifo3df.onion:8000"), // @manfredkarrer
|
||||||
|
new NodeAddress("jhgcy2won7xnslrb.onion:8000"), // @manfredkarrer
|
||||||
|
new NodeAddress("3f3cu2yw7u457ztq.onion:8000"), // @manfredkarrer
|
||||||
|
new NodeAddress("723ljisnynbtdohi.onion:8000"), // @manfredkarrer
|
||||||
|
new NodeAddress("rm7b56wbrcczpjvl.onion:8000"), // @manfredkarrer
|
||||||
|
new NodeAddress("fl3mmribyxgrv63c.onion:8000"), // @manfredkarrer
|
||||||
|
|
||||||
|
// local dev
|
||||||
|
// new NodeAddress("joehwtpe7ijnz4df.onion:8000"),
|
||||||
|
// new NodeAddress("uqxi3zrpobhtoes6.onion:8000"),
|
||||||
|
|
||||||
|
// BTC testnet
|
||||||
|
new NodeAddress("nbphlanpgbei4okt.onion:8001"),
|
||||||
|
// new NodeAddress("vjkh4ykq7x5skdlt.onion:8001"), // dev test
|
||||||
|
|
||||||
|
// BTC regtest
|
||||||
|
// For development you need to change that to your local onion addresses
|
||||||
|
// 1. Run a seed node with prog args: --bitcoinNetwork=regtest --nodePort=8002 --myAddress=rxdkppp3vicnbgqt:8002 --appName=bisq_seed_node_rxdkppp3vicnbgqt.onion_8002
|
||||||
|
// 2. Find your local onion address in bisq_seed_node_rxdkppp3vicnbgqt.onion_8002/regtest/tor/hiddenservice/hostname
|
||||||
|
// 3. Shut down the seed node
|
||||||
|
// 4. Rename the directory with your local onion address
|
||||||
|
// 5. Edit here your found onion address (new NodeAddress("YOUR_ONION.onion:8002")
|
||||||
|
new NodeAddress("rxdkppp3vicnbgqt.onion:8002"),
|
||||||
|
|
||||||
|
// LTC mainnet
|
||||||
|
new NodeAddress("acyvotgewx46pebw.onion:8003"),
|
||||||
|
new NodeAddress("pklgy3vdfn3obkur.onion:8003"),
|
||||||
|
|
||||||
|
// DASH mainnet
|
||||||
|
new NodeAddress("toeu5ikb27ydscxt.onion:8009"),
|
||||||
|
new NodeAddress("ae4yvaivhnekkhqf.onion:8009")
|
||||||
|
);
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ class NodeAddresses {
|
||||||
return new NodeAddresses(addresses);
|
return new NodeAddresses(addresses);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NodeAddresses createFromSet(Set<NodeAddress> addresses, int networkId) {
|
static NodeAddresses fromSet(Set<NodeAddress> addresses, int networkId) {
|
||||||
Set<NodeAddress> delegate = addresses.stream()
|
Set<NodeAddress> delegate = addresses.stream()
|
||||||
.filter(address -> isAddressFromNetwork(address, networkId))
|
.filter(address -> isAddressFromNetwork(address, networkId))
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
Loading…
Add table
Reference in a new issue