Fix errors
This commit is contained in:
parent
e1eec55f62
commit
06776ebe8f
9 changed files with 122 additions and 127 deletions
|
|
@ -31,7 +31,7 @@ public final class InetEndpoint {
|
|||
private final boolean isResolved;
|
||||
private final Object lock = new Object();
|
||||
private final int port;
|
||||
private Instant lastResolution = Instant.EPOCH;
|
||||
private long lastResolution;
|
||||
@Nullable private InetEndpoint resolved;
|
||||
|
||||
private InetEndpoint(final String host, final boolean isResolved, final int port) {
|
||||
|
|
@ -89,7 +89,7 @@ public final class InetEndpoint {
|
|||
return Optional.of(this);
|
||||
synchronized (lock) {
|
||||
// TODO(zx2c4): Implement a real timeout mechanism using DNS TTL
|
||||
if (Duration.between(lastResolution, Instant.now()).toMinutes() > 1) {
|
||||
if (System.currentTimeMillis() - lastResolution > 60000L) {
|
||||
try {
|
||||
// Prefer v4 endpoints over v6 to work around DNS64 and IPv6 NAT issues.
|
||||
final InetAddress[] candidates = InetAddress.getAllByName(host);
|
||||
|
|
@ -101,7 +101,7 @@ public final class InetEndpoint {
|
|||
}
|
||||
}
|
||||
resolved = new InetEndpoint(address.getHostAddress(), true, port);
|
||||
lastResolution = Instant.now();
|
||||
lastResolution = System.currentTimeMillis();
|
||||
} catch (final UnknownHostException e) {
|
||||
resolved = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import android.os.Parcel
|
||||
import androidx.core.app.NotificationCompat
|
||||
import org.amnezia.vpn.shadowsocks.core.R
|
||||
import org.json.JSONObject
|
||||
|
||||
object NotificationUtil {
|
||||
|
|
@ -102,7 +103,7 @@ object NotificationUtil {
|
|||
val pendingIntent = PendingIntent.getActivity(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||
// Build our notification
|
||||
sNotificationBuilder?.let {
|
||||
it.setSmallIcon(org.amnezia.vpn.R.drawable.ic_amnezia_round)
|
||||
it.setSmallIcon(R.drawable.ic_amnezia_round)
|
||||
.setContentTitle(header)
|
||||
.setContentText(message)
|
||||
.setOnlyAlertOnce(true)
|
||||
|
|
|
|||
|
|
@ -83,29 +83,32 @@ class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runna
|
|||
if (jsonVpnConfig.getString("protocol") == "cloak") {
|
||||
val cloakConfigJson: JSONObject = jsonVpnConfig.getJSONObject("cloak_config_data")
|
||||
|
||||
if (cloakConfigJson.keySet().contains("NumConn")) {
|
||||
if (cloakConfigJson.has("NumConn")) {
|
||||
cloakConfigJson.put("NumConn", 1)
|
||||
}
|
||||
|
||||
if (cloakConfigJson.keySet().contains("ProxyMethod")) {
|
||||
if (cloakConfigJson.has("ProxyMethod")) {
|
||||
cloakConfigJson.put("ProxyMethod", "openvpn")
|
||||
}
|
||||
|
||||
if (cloakConfigJson.keySet().contains("port")) {
|
||||
if (cloakConfigJson.has("port")) {
|
||||
val portValue = cloakConfigJson.get("port")
|
||||
cloakConfigJson.remove("port")
|
||||
cloakConfigJson.put("RemotePort", portValue)
|
||||
}
|
||||
|
||||
if (cloakConfigJson.keySet().contains("remote")) {
|
||||
if (cloakConfigJson.has("remote")) {
|
||||
val hostValue = cloakConfigJson.get("remote")
|
||||
cloakConfigJson.remove("remote")
|
||||
cloakConfigJson.put("RemoteHost", hostValue)
|
||||
}
|
||||
|
||||
val cloakConfig = Base64.getEncoder().encodeToString(
|
||||
jsonVpnConfig.getJSONObject("cloak_config_data").toString().toByteArray()
|
||||
)
|
||||
val cloakConfigData = jsonVpnConfig.getJSONObject("cloak_config_data").toString().toByteArray()
|
||||
val cloakConfig = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Base64.getEncoder().encodeToString(cloakConfigData)
|
||||
} else {
|
||||
android.util.Base64.encodeToString(cloakConfigData, android.util.Base64.DEFAULT)
|
||||
}
|
||||
|
||||
resultingConfig.append("\n<cloak>\n")
|
||||
resultingConfig.append(cloakConfig)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue