Skip to content

Commit

Permalink
New Session constructor to specify the routers.
Browse files Browse the repository at this point in the history
New demo with a custom DHT bootstrap server.
  • Loading branch information
aldenml committed Jan 10, 2015
1 parent a04e40a commit 37db42f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/com/frostwire/jlibtorrent/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final class Session {
private final SparseArray<AlertListener[]> listenerSnapshots;
private boolean running;

public Session(Fingerprint print, Pair<Integer, Integer> prange, String iface) {
public Session(Fingerprint print, Pair<Integer, Integer> prange, String iface, List<Pair<String, Integer>> routers) {

int flags = session.session_flags_t.start_default_features.swigValue() | session.session_flags_t.add_default_plugins.swigValue();
int alert_mask = alert.category_t.all_categories.swigValue();
Expand All @@ -59,8 +59,13 @@ public Session(Fingerprint print, Pair<Integer, Integer> prange, String iface) {

alertsLoop();

s.add_dht_router(new string_int_pair("router.bittorrent.com", 6881));
s.add_dht_router(new string_int_pair("dht.transmissionbt.com", 6881));
for (Pair<String, Integer> router : routers) {
s.add_dht_router(router.to_string_int_pair());
}
}

public Session(Fingerprint print, Pair<Integer, Integer> prange, String iface) {
this(print, prange, iface, defaultRouters());
}

public Session(Fingerprint print) {
Expand Down Expand Up @@ -998,6 +1003,15 @@ private void modifyListeners(boolean adding, int type, AlertListener listener) {
listenerSnapshots.append(type, l.toArray(new AlertListener[0]));
}

private static List<Pair<String, Integer>> defaultRouters() {
List<Pair<String, Integer>> list = new LinkedList<Pair<String, Integer>>();

list.add(new Pair<String, Integer>("router.bittorrent.com", 6881));
list.add(new Pair<String, Integer>("dht.transmissionbt.com", 6881));

return list;
}

private static Map<Integer, CastAlertFunction> buildCastAlertTable() {
Map<Integer, CastAlertFunction> map = new HashMap<Integer, CastAlertFunction>();

Expand Down

0 comments on commit 37db42f

Please sign in to comment.