Update to master of jtorproxy

This commit is contained in:
Manfred Karrer 2015-11-17 23:54:57 +01:00
parent cefcf5b3d8
commit 9b1108aa0a
30 changed files with 1043 additions and 924 deletions

View file

@ -13,18 +13,27 @@ import java.util.concurrent.ExecutionException;
public class TorNodeTest {
private static final int hsPort = 55555;
private static CountDownLatch serverLatch = new CountDownLatch(1);
private static CountDownLatch serverLatch = new CountDownLatch(2);
private static TorNode<JavaOnionProxyManager, JavaOnionProxyContext> node;
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException, InstantiationException {
public static void main(String[] args)
throws IOException, InterruptedException, ExecutionException, InstantiationException {
File dir = new File("tor-test");
dir.mkdirs();
for (String str : args)
System.out.print(str + " ");
node = new TorNode<JavaOnionProxyManager, JavaOnionProxyContext>(dir) {
};
final ServiceDescriptor hiddenService = node.createHiddenService(hsPort);
node = new JavaTorNode(dir);
final ServiceDescriptor hiddenService = node.createHiddenService(hsPort, new HiddenServiceReadyListener() {
@Override
public void onConnect(HiddenServiceDescriptor descriptor) {
System.out.println("Successfully published hidden service " + descriptor.getFullAddress());
serverLatch.countDown();
}
});
new Thread(new Server(hiddenService.getServerSocket())).start();
serverLatch.await();
@ -94,7 +103,8 @@ public class TorNodeTest {
while (true) {
Socket sock = socket.accept();
System.out.println("Accepting Client " + sock.getRemoteSocketAddress() + " on port " + sock.getLocalPort());
System.out.println(
"Accepting Client " + sock.getRemoteSocketAddress() + " on port " + sock.getLocalPort());
BufferedReader in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
OutputStreamWriter out = new OutputStreamWriter(sock.getOutputStream());
String aLine = null;

View file

@ -61,11 +61,16 @@ public class NodeTest {
if (args.length == 2) {
File dir = new File(args[0]);
dir.mkdirs();
TorNode<JavaOnionProxyManager, JavaOnionProxyContext> tor = new TorNode<JavaOnionProxyManager, JavaOnionProxyContext>(
dir) {
};
TorNode<JavaOnionProxyManager, JavaOnionProxyContext> tor = new JavaTorNode(dir);
node = new Node(tor.createHiddenService(Integer.parseInt(args[1])), tor);
node = new Node(tor.createHiddenService(Integer.parseInt(args[1]), new HiddenServiceReadyListener() {
@Override
public void onConnect(HiddenServiceDescriptor descriptor) {
System.out.println("Successfully published hidden service " + descriptor.getFullAddress() + " ");
}
}), tor);
} else {
node = new Node(new TCPServiceDescriptor("localhost", Integer.parseInt(args[0])));
}
@ -138,7 +143,7 @@ public class NodeTest {
default:
break;
}
System.out.print("\n" + node.getLocalName() + ":" + (currentCon == null ? "" : currentCon.getPeer()) + " >");
System.out.print("\n" + node.getLocalName() + (currentCon == null ? "" : (":" + currentCon.getPeer())) + " >");
}
}