blob: 751208ba91e1b3cd4b1d43054ae57a7522616ef2 (
plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
|
package se.leap.bitmaskclient.pluggableTransports;
import client.Client;
import client.HopClient;
import de.blinkt.openvpn.core.VpnStatus;
import se.leap.bitmaskclient.base.models.Constants;
public class HoppingObfsVpnClient implements PtClientInterface {
public static final int PORT = 8080;
public static final String IP = "127.0.0.1";
public final HopClient client;
public HoppingObfsVpnClient(Obfs4Options options) throws IllegalStateException {
//FIXME: use a different strategy here
//Basically we would want to track if the more performant transport protocol (KCP?/TCP?) usage was successful
//if so, we stick to it, otherwise we flip the flag
boolean kcp = Constants.KCP.equals(options.transport.getProtocols()[0]);
HoppingConfig hoppingConfig = new HoppingConfig(kcp,IP+":"+PORT, options, 10, 10);
try {
client = Client.newFFIHopClient(hoppingConfig.toString());
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
@Override
public int start() {
try {
client.setEventLogger(this);
return client.start() ? PORT : 0;
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
@Override
public void stop() {
try {
client.stop();
} catch (Exception e) {
e.printStackTrace();
} finally {
client.setEventLogger(null);
}
}
@Override
public boolean isStarted() {
return client.isStarted();
}
@Override
public void error(String s) {
VpnStatus.logError("[hopping-obfs4] " + s);
}
@Override
public void log(String state, String message) {
VpnStatus.logDebug("[hopping-obfs4] " + state + ": " + message);
}
}
|