mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-03-14 18:06:34 -04:00
Added INET4 binding in BSExampleNAT and Server
This commit is contained in:
parent
5fe25fb411
commit
8983ce1783
@ -36,6 +36,8 @@ import java.net.InetAddress;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.tomp2p.connection.Bindings;
|
||||
import net.tomp2p.connection.StandardProtocolFamily;
|
||||
import net.tomp2p.futures.FutureDiscover;
|
||||
import net.tomp2p.nat.FutureNAT;
|
||||
import net.tomp2p.nat.FutureRelayNAT;
|
||||
@ -48,8 +50,8 @@ import net.tomp2p.peers.PeerAddress;
|
||||
|
||||
public class BSExampleNAT {
|
||||
// "188.226.179.109", 5000
|
||||
private final static String IP_SERVER = "188.226.179.109";
|
||||
//private final static String IP_SERVER = "128.199.251.106"; // steves
|
||||
//private final static String IP_SERVER = "188.226.179.109";
|
||||
private final static String IP_SERVER = "128.199.251.106"; // steves
|
||||
private final static int PORT_SERVER = 5000;
|
||||
private final static int PORT_CLIENT = 5500;
|
||||
/*
|
||||
@ -71,7 +73,11 @@ public class BSExampleNAT {
|
||||
|
||||
public static void startClientNAT() throws Exception {
|
||||
Random r = new Random(43L);
|
||||
Peer peer = new PeerBuilder(new Number160(r)).ports(PORT_CLIENT).behindFirewall().start();
|
||||
Bindings bindings = new Bindings();
|
||||
bindings.addProtocol(StandardProtocolFamily.INET);
|
||||
PeerBuilder peerBuilder = new PeerBuilder(new Number160(r)).ports(PORT_CLIENT).behindFirewall().bindings(bindings);
|
||||
Peer peer = peerBuilder.start();
|
||||
//Peer peer = new PeerBuilder(new Number160(r)).ports(PORT_CLIENT).behindFirewall().start();
|
||||
PeerNAT peerNAT = new PeerBuilderNAT(peer).start();
|
||||
PeerAddress pa = new PeerAddress(Number160.ZERO, InetAddress.getByName(IP_SERVER), PORT_SERVER, PORT_SERVER);
|
||||
|
||||
|
@ -34,6 +34,8 @@ package net.tomp2p.examples;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.tomp2p.connection.Bindings;
|
||||
import net.tomp2p.connection.StandardProtocolFamily;
|
||||
import net.tomp2p.p2p.Peer;
|
||||
import net.tomp2p.p2p.PeerBuilder;
|
||||
import net.tomp2p.peers.Number160;
|
||||
@ -44,7 +46,10 @@ public class BSExampleNATServer {
|
||||
|
||||
public static void startServer() throws Exception {
|
||||
Random r = new Random(42L);
|
||||
Peer peer = new PeerBuilder(new Number160(r)).ports(PORT_SERVER).start();
|
||||
Bindings bindings = new Bindings();
|
||||
bindings.addProtocol(StandardProtocolFamily.INET);
|
||||
PeerBuilder peerBuilder = new PeerBuilder(new Number160(r)).ports(PORT_SERVER).bindings(bindings);
|
||||
Peer peer = peerBuilder.start();
|
||||
System.out.println("peer started.");
|
||||
for (; ; ) {
|
||||
for (PeerAddress pa : peer.peerBean().peerMap().all()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user