localAddresses in Sock5Proxy is used by Socks5 file transfer in jingle FT method. The values are initialised when user is first authenticated (JingleS5BTransportManager), basing on the device current active network connection e.g. WiFi. It is found that when the WiFi is disabled and network connection is made via the mobile network, the localAddresses are not being updated hence contained an invalid transport candidate i.e. intranet IP.
aTalk made the following source changes to fix the problem.
- JingleS5BTransportManager.java file
a. Remove the condition resumed test in authenticated() method.
public void authenticated(XMPPConnection connection, boolean resumed) {
// if (!resumed)
try {
Socks5Proxy socks5Proxy = Socks5Proxy.getSocks5Proxy();
if (!socks5Proxy.isRunning()) {
socks5Proxy.start();
}
localStreamHosts = queryLocalStreamHosts();
availableStreamHosts = queryAvailableStreamHosts();
Timber.w("On authenticated resumed: %s; %s\n%s", resumed, localStreamHosts, availableStreamHosts);
} catch (InterruptedException | SmackException.NoResponseException | SmackException.NotConnectedException |
XMPPException.XMPPErrorException e) {
LOGGER.log(Level.WARNING, "Could not query available StreamHosts: " + e, e);
}
}
b. Override connectionClosedOnError to call connectionClosed.
@Override
public void connectionClosedOnError(Exception e) {
connectionClosed();
}
- Socks5Proxy
a. set socks5Server to null in stop method.
/**
* Stops the local SOCKS5 proxy server. If it is not running this method does nothing.
*/
public synchronized void stop() {
if (!isRunning()) {
return;
}
RUNNING_PROXIES.remove(this);
CloseableUtil.maybeClose(this.serverSocket, LOGGER);
if (this.serverThread != null && this.serverThread.isAlive()) {
try {
this.serverThread.interrupt();
this.serverThread.join();
}
catch (InterruptedException e) {
LOGGER.log(Level.WARNING, "SOCKS5 server thread termination was interrupted", e);
}
}
this.serverThread = null;
this.serverSocket = null;
// Stop Sock5Proxy so a new localAddresses are retrieved on new authentication process.
socks5Server = null;
}