package org.torproject.jtor;


import java.security.Security;
import java.util.List;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.torproject.jtor.circuits.Circuit;
import org.torproject.jtor.circuits.impl.CircuitManagerImpl;
import org.torproject.jtor.circuits.impl.ConnectionManagerImpl;
import org.torproject.jtor.directory.Directory;
import org.torproject.jtor.directory.RouterDescriptor;
import org.torproject.jtor.directory.impl.DirectoryImpl;
import org.torproject.jtor.directory.impl.DocumentParserFactoryImpl;
import org.torproject.jtor.directory.parsing.DocumentParserFactory;

public class Tor {
	private final Directory directory;
	private final DocumentParserFactory parserFactory;
	private final ConnectionManagerImpl connectionManager;
	private final CircuitManagerImpl circuitManager;
	private final Logger logger;
	
	public Tor() {
		this(new ConsoleLogger());
	}
	
	public Tor(Logger logger) {
		Security.addProvider(new BouncyCastleProvider());
		this.logger = logger;
		this.directory = new DirectoryImpl(logger);
		parserFactory = new DocumentParserFactoryImpl(logger);
		connectionManager = new ConnectionManagerImpl();
		circuitManager = new CircuitManagerImpl(directory, connectionManager);
	}
	
	public Circuit createCircuitFromNicknames(List<String> nicknamePath) {
		final List<RouterDescriptor> path = directory.getRouterListByNames(nicknamePath);
		return createCircuit(path);
	}
	
	public Circuit createCircuit(List<RouterDescriptor> path) {
		return circuitManager.createCircuitFromPath(path);
	}
	
	public Logger getLogger() {
		return logger;
	}
	
	public Directory getDirectory() {
		return directory;
	}
	
	public DocumentParserFactory getDocumentParserFactory() {
		return parserFactory;
	}

	public ConnectionManagerImpl getConnectionManager() {
		return connectionManager;
	}
}

@@ -300,32 +300,86 @@
 ionManagerImpl;%0A
+import org.torproject.jtor.config.impl.TorConfigImpl;%0A
 import org.torpr
@@ -453,26 +453,16 @@
 y.Router
-Descriptor
 ;%0Aimport
@@ -573,32 +573,96 @@
 serFactoryImpl;%0A
+import org.torproject.jtor.directory.impl.NetworkStatusManager;%0A
 import org.torpr
@@ -957,16 +957,100 @@
 logger;%0A
+%09private final TorConfig config;%0A%09private final NetworkStatusManager statusManager;%0A
 %09%0A%09publi
@@ -1198,16 +1198,53 @@
 logger;%0A
+%09%09this.config = new TorConfigImpl();%0A
 %09%09this.d
@@ -1274,24 +1274,32 @@
 yImpl(logger
+, config
 );%0A%09%09parserF
@@ -1470,16 +1470,183 @@
 nager);%0A
+%09%09statusManager = new NetworkStatusManager(directory, logger);%0A%09%7D%0A%09%0A%09%0A%09public void start() %7B%0A%09%09directory.loadFromStore();%0A%09%09statusManager.startDownloadingDocuments();%0A
 %09%7D%0A%09%0A%09pu
@@ -1729,34 +1729,24 @@
  List%3CRouter
-Descriptor
 %3E path = dir
@@ -1868,18 +1868,8 @@
 uter
-Descriptor
 %3E pa
@@ -2039,24 +2039,78 @@
 ctory;%0A%09%7D%0A%09%0A
+%09public TorConfig getConfig() %7B%0A%09%09return config;%0A%09%7D%0A%09%0A
 %09public Docu
@@ -2270,10 +2270,12 @@
 ger;%0A%09%7D%0A
+%09%0A
 %7D%0A

Add network status manager and config to Tor