mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 22:45:18 +01:00
Bug fixes
This commit is contained in:
parent
4f929ceb4b
commit
f8e8d089f7
4 changed files with 43 additions and 14 deletions
|
@ -81,7 +81,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 541
|
versionCode 542
|
||||||
versionName "2.9.1"
|
versionName "2.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ package org.telegram.messenger;
|
||||||
|
|
||||||
public class BuildVars {
|
public class BuildVars {
|
||||||
public static boolean DEBUG_VERSION = false;
|
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 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 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";
|
public static String HOCKEY_APP_HASH = "your-hockeyapp-api-key-here";
|
||||||
|
|
|
@ -526,12 +526,38 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
protected static boolean useIpv6Address() {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
NetworkInterface networkInterface;
|
NetworkInterface networkInterface;
|
||||||
|
|
||||||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
while (networkInterfaces.hasMoreElements()) {
|
while (networkInterfaces.hasMoreElements()) {
|
||||||
networkInterface = networkInterfaces.nextElement();
|
networkInterface = networkInterfaces.nextElement();
|
||||||
|
|
|
@ -107,26 +107,29 @@ public class TcpConnection extends ConnectionContext {
|
||||||
connectionState = TcpConnectionState.TcpConnectionStageConnecting;
|
connectionState = TcpConnectionState.TcpConnectionStageConnecting;
|
||||||
try {
|
try {
|
||||||
Datacenter datacenter = ConnectionsManager.getInstance().datacenterWithId(datacenterId);
|
Datacenter datacenter = ConnectionsManager.getInstance().datacenterWithId(datacenterId);
|
||||||
|
boolean isIpv6 = ConnectionsManager.useIpv6Address();
|
||||||
if (transportRequestClass == RPCRequest.RPCRequestClassDownloadMedia) {
|
if (transportRequestClass == RPCRequest.RPCRequestClassDownloadMedia) {
|
||||||
currentAddressFlag = 2;
|
currentAddressFlag = 2;
|
||||||
if (ConnectionsManager.useIpv6Address()) {
|
hostAddress = datacenter.getCurrentAddress(currentAddressFlag | (isIpv6 ? 1 : 0));
|
||||||
currentAddressFlag |= 1;
|
if (hostAddress == null) {
|
||||||
|
currentAddressFlag = 0;
|
||||||
|
hostAddress = datacenter.getCurrentAddress(currentAddressFlag | (isIpv6 ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
if (hostAddress == null && isIpv6) {
|
||||||
|
currentAddressFlag = 2;
|
||||||
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
|
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
|
||||||
if (hostAddress == null) {
|
if (hostAddress == null) {
|
||||||
currentAddressFlag = 0;
|
currentAddressFlag = 0;
|
||||||
if (ConnectionsManager.useIpv6Address()) {
|
|
||||||
currentAddressFlag |= 1;
|
|
||||||
}
|
|
||||||
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
|
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
currentAddressFlag = 0;
|
currentAddressFlag = 0;
|
||||||
if (ConnectionsManager.useIpv6Address()) {
|
hostAddress = datacenter.getCurrentAddress(currentAddressFlag | (isIpv6 ? 1 : 0));
|
||||||
currentAddressFlag |= 1;
|
if (isIpv6 && hostAddress == null) {
|
||||||
}
|
|
||||||
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
|
hostAddress = datacenter.getCurrentAddress(currentAddressFlag);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
hostPort = datacenter.getCurrentPort(currentAddressFlag);
|
hostPort = datacenter.getCurrentPort(currentAddressFlag);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue