From b903f9cc63c52427706500be73f550f0cd585185 Mon Sep 17 00:00:00 2001 From: ChronosX88 Date: Tue, 5 Mar 2019 21:14:21 +0400 Subject: [PATCH] Bootstrap peer start added --- .../github/chronosx88/dhtBootstrap/Main.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java b/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java index 17b0ba5..ed747fe 100644 --- a/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java +++ b/src/main/java/io/github/chronosx88/dhtBootstrap/Main.java @@ -1,19 +1,35 @@ package io.github.chronosx88.dhtBootstrap; +import net.tomp2p.connection.RSASignatureFactory; +import net.tomp2p.dht.PeerBuilderDHT; +import net.tomp2p.dht.PeerDHT; +import net.tomp2p.p2p.PeerBuilder; +import net.tomp2p.peers.Number160; +import net.tomp2p.storage.StorageDisk; + +import java.io.File; import java.io.IOException; -import java.net.Inet4Address; +import java.util.UUID; public class Main { - //private static JKademliaNode node; + private static PeerDHT peerDHT; + private static Number160 peerID; + public static void main(String[] args) { - /* + //TODO: Save peerID and route table to config + peerID = Number160.createHash(UUID.randomUUID().toString()); try { - KademliaId kadID = new KademliaId("sgCZ+fg49g4N8FU43kW84cNVPTw="); - node = new JKademliaNode("Main Bootstrap Node", new Node(kadID, Inet4Address.getLocalHost(), 7243), 7243, new DefaultConfiguration()); - System.out.println(node.getNode().getNodeId().toString()); + peerDHT = + new PeerBuilderDHT(new PeerBuilder(peerID).ports(7243).start()) + .storage( + new StorageDisk( + peerID, + new File(System.getProperty("user.home") + "/.local/share"), + new RSASignatureFactory() + ) + ).start(); } catch (IOException e) { e.printStackTrace(); } - */ } }