-
-
Notifications
You must be signed in to change notification settings - Fork 135
/
DhtStorageTest.java
53 lines (42 loc) · 1.54 KB
/
DhtStorageTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package com.frostwire.jlibtorrent.demo;
import com.frostwire.jlibtorrent.*;
import com.frostwire.jlibtorrent.alerts.Alert;
import com.frostwire.jlibtorrent.plugins.DhtStorage;
import com.frostwire.jlibtorrent.plugins.DhtStorageBase;
import com.frostwire.jlibtorrent.plugins.DhtStorageConstructor;
import com.frostwire.jlibtorrent.swig.settings_pack;
/**
* @author gubatron
* @author aldenml
*/
public final class DhtStorageTest {
public static void main(String[] args) throws Throwable {
AlertListener l = new AlertListener() {
@Override
public int[] types() {
return null;
}
@Override
public void alert(Alert<?> alert) {
System.out.println(alert.getType() + " - " + alert.getSwig().what() + " - " + alert.getSwig().message());
}
};
SettingsPack sp = new SettingsPack();
sp.setString(settings_pack.string_types.listen_interfaces.swigValue(), "0.0.0.0:0");
sp.enableDht(false);
//Session s = new Session(sp, false, l);
Session s = new Session("0.0.0.0", 0, 10, false, l);
s.setDhtStorage(new DhtStorageConstructor() {
@Override
public DhtStorage create(Sha1Hash id, DhtSettings settings) {
return new DhtStorageBase(id, settings, true);
}
});
sp = new SettingsPack();
sp.enableDht(true);
s.applySettings(sp);
System.out.println("Press ENTER to exit");
System.in.read();
s.abort();
}
}