1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-06-30 22:22:57 +00:00

Bug fixes

This commit is contained in:
DrKLO 2015-05-22 04:45:27 +03:00
parent 4f929ceb4b
commit f8e8d089f7
4 changed files with 43 additions and 14 deletions

View File

@ -81,7 +81,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 22
versionCode 541
versionCode 542
versionName "2.9.1"
}
}

View File

@ -10,7 +10,7 @@ package org.telegram.messenger;
public class BuildVars {
public static boolean DEBUG_VERSION = false;
public static int BUILD_VERSION = 541;
public static int BUILD_VERSION = 542;
public static int APP_ID = 0; //obtain your own APP_ID at https://core.telegram.org/api/obtaining_api_id
public static String APP_HASH = ""; //obtain your own APP_HASH at https://core.telegram.org/api/obtaining_api_id
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";

View File

@ -526,12 +526,38 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
@SuppressLint("NewApi")
protected static boolean useIpv6Address() {
if (Build.VERSION.SDK_INT < 19) {
if (BuildVars.DEBUG_VERSION && Build.VERSION.SDK_INT >= 19) {
try {
NetworkInterface networkInterface;
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
networkInterface = networkInterfaces.nextElement();
if (!networkInterface.isUp() || networkInterface.isLoopback() || networkInterface.getInterfaceAddresses().isEmpty()) {
continue;
}
FileLog.e("tmessages", "valid interface: " + networkInterface);
for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
InetAddress inetAddress = address.getAddress();
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "address: " + inetAddress.getHostAddress());
}
if (inetAddress.isLinkLocalAddress() || inetAddress.isLoopbackAddress() || inetAddress.isMulticastAddress()) {
continue;
}
if (BuildVars.DEBUG_VERSION) {
FileLog.e("tmessages", "address is good");
}
}
}
} catch (Throwable e) {
FileLog.e("tmessages", e);
}
}
if (Build.VERSION.SDK_INT < 50) {
return false;
}
try {
NetworkInterface networkInterface;
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
networkInterface = networkInterfaces.nextElement();

View File

@ -107,25 +107,28 @@ public class TcpConnection extends ConnectionContext {
connectionState = TcpConnectionState.TcpConnectionStageConnecting;
try {
Datacenter datacenter = ConnectionsManager.getInstance().datacenterWithId(datacenterId);
boolean isIpv6 = ConnectionsManager.useIpv6Address();
if (transportRequestClass == RPCRequest.RPCRequestClassDownloadMedia) {
currentAddressFlag = 2;
if (ConnectionsManager.useIpv6Address()) {
currentAddressFlag |= 1;
}
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
hostAddress = datacenter.getCurrentAddress(currentAddressFlag | (isIpv6 ? 1 : 0));
if (hostAddress == null) {
currentAddressFlag = 0;
if (ConnectionsManager.useIpv6Address()) {
currentAddressFlag |= 1;
}
hostAddress = datacenter.getCurrentAddress(currentAddressFlag | (isIpv6 ? 1 : 0));
}
if (hostAddress == null && isIpv6) {
currentAddressFlag = 2;
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
if (hostAddress == null) {
currentAddressFlag = 0;
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
}
}
} else {
currentAddressFlag = 0;
if (ConnectionsManager.useIpv6Address()) {
currentAddressFlag |= 1;
hostAddress = datacenter.getCurrentAddress(currentAddressFlag | (isIpv6 ? 1 : 0));
if (isIpv6 && hostAddress == null) {
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
}
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
}
hostPort = datacenter.getCurrentPort(currentAddressFlag);