blob: 19ea180df0df5db869abed77d02ff84ebd10d3fd (
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
67
68
69
70
71
72
|
package de.blinkt.openvpn.core.connection;
import static se.leap.bitmaskclient.base.utils.BuildConfigHelper.useObfsVpn;
import static se.leap.bitmaskclient.pluggableTransports.ShapeshifterClient.DISPATCHER_IP;
import static se.leap.bitmaskclient.pluggableTransports.ShapeshifterClient.DISPATCHER_PORT;
import se.leap.bitmaskclient.pluggableTransports.HoppingObfsVpnClient;
import se.leap.bitmaskclient.pluggableTransports.Obfs4Options;
import se.leap.bitmaskclient.pluggableTransports.ObfsVpnClient;
/**
* Created by cyberta on 08.03.19.
*/
public class Obfs4Connection extends Connection {
private static final String TAG = Obfs4Connection.class.getName();
private Obfs4Options options;
public Obfs4Connection(Obfs4Options options) {
if (useObfsVpn()) {
setServerName(options.gatewayIP);
setServerPort(options.transport.getPorts()[0]);
setProxyName(ObfsVpnClient.SOCKS_IP);
setProxyType(ProxyType.SOCKS5);
switch (options.transport.getTransportType()) {
case OBFS4:
setUseUdp(false);
setProxyPort(String.valueOf(ObfsVpnClient.SOCKS_PORT.get()));
break;
case OBFS4_HOP:
setUseUdp(true);
setProxyPort(String.valueOf(HoppingObfsVpnClient.PORT));
break;
default:break;
}
} else {
setServerName(DISPATCHER_IP);
setServerPort(DISPATCHER_PORT);
setProxyName("");
setProxyPort("");
setProxyType(ProxyType.NONE);
// while udp/kcp might be used on the wire,
// we don't use udp for openvpn in case of a obfs4 connection
setUseUdp(false);
}
setProxyAuthUser(null);
setProxyAuthPassword(null);
setUseProxyAuth(false);
this.options = options;
}
@Override
public Connection clone() throws CloneNotSupportedException {
Obfs4Connection connection = (Obfs4Connection) super.clone();
connection.options = this.options;
return connection;
}
@Override
public TransportType getTransportType() {
return TransportType.OBFS4;
}
public Obfs4Options getObfs4Options() {
return options;
}
}
|