mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Merge branch '1745-try-to-bind-on-connectivity-change' into 'master'
Try to bind IPv4 and IPv6 sockets whenever connectivity changes Closes #1745 See merge request briar/briar!1275
This commit is contained in:
@@ -277,11 +277,11 @@ class AndroidLanTcpPlugin extends LanTcpPlugin {
|
||||
// make outgoing connections on API 21+ if another network
|
||||
// has internet access
|
||||
socketFactory = SocketFactory.getDefault();
|
||||
if (s == INACTIVE) bind();
|
||||
bind();
|
||||
} else {
|
||||
LOG.info("Connected to wifi");
|
||||
socketFactory = getSocketFactory();
|
||||
if (s == INACTIVE) bind();
|
||||
bind();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -149,15 +149,21 @@ abstract class TcpPlugin implements DuplexPlugin, EventListener {
|
||||
|
||||
protected void bind() {
|
||||
bindExecutor.execute(() -> {
|
||||
if (getState() != INACTIVE) return;
|
||||
State s = getState();
|
||||
if (s != ACTIVE && s != INACTIVE) return;
|
||||
bind(true);
|
||||
bind(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void bind(boolean ipv4) {
|
||||
ServerSocket old = state.getServerSocket(ipv4);
|
||||
ServerSocket ss = null;
|
||||
for (InetSocketAddress addr : getLocalSocketAddresses(ipv4)) {
|
||||
if (old != null && addr.equals(old.getLocalSocketAddress())) {
|
||||
LOG.info("Server socket already bound");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ss = new ServerSocket();
|
||||
ss.bind(addr);
|
||||
|
||||
Reference in New Issue
Block a user