mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Synchronize access to superclass members.
This commit is contained in:
@@ -24,7 +24,7 @@ public class SimpleSocketPlugin extends SocketPlugin {
|
||||
super(executor);
|
||||
this.pollingInterval = pollingInterval;
|
||||
}
|
||||
|
||||
|
||||
public TransportId getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -39,33 +39,18 @@ public class SimpleSocketPlugin extends SocketPlugin {
|
||||
|
||||
@Override
|
||||
protected SocketAddress getLocalSocketAddress() {
|
||||
assert localProperties != null;
|
||||
assert started && localProperties != null;
|
||||
return createSocketAddress(localProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SocketAddress getSocketAddress(ContactId c) {
|
||||
assert remoteProperties != null;
|
||||
assert started && remoteProperties != null;
|
||||
Map<String, String> properties = remoteProperties.get(c);
|
||||
if(properties == null) return null;
|
||||
return createSocketAddress(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setLocalSocketAddress(SocketAddress s) {
|
||||
assert localProperties != null;
|
||||
if(!(s instanceof InetSocketAddress))
|
||||
throw new IllegalArgumentException();
|
||||
InetSocketAddress i = (InetSocketAddress) s;
|
||||
String host = i.getAddress().getHostAddress();
|
||||
String port = String.valueOf(i.getPort());
|
||||
// FIXME: Special handling for private IP addresses?
|
||||
Map<String, String> m = new TreeMap<String, String>(localProperties);
|
||||
m.put("host", host);
|
||||
m.put("port", port);
|
||||
callback.setLocalProperties(m);
|
||||
}
|
||||
|
||||
private SocketAddress createSocketAddress(Map<String, String> properties) {
|
||||
assert properties != null;
|
||||
String host = properties.get("host");
|
||||
@@ -80,13 +65,30 @@ public class SimpleSocketPlugin extends SocketPlugin {
|
||||
return new InetSocketAddress(host, port);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setLocalSocketAddress(SocketAddress s) {
|
||||
assert started && localProperties != null;
|
||||
if(!(s instanceof InetSocketAddress))
|
||||
throw new IllegalArgumentException();
|
||||
InetSocketAddress i = (InetSocketAddress) s;
|
||||
String host = i.getAddress().getHostAddress();
|
||||
String port = String.valueOf(i.getPort());
|
||||
// FIXME: Special handling for private IP addresses?
|
||||
Map<String, String> m = new TreeMap<String, String>(localProperties);
|
||||
m.put("host", host);
|
||||
m.put("port", port);
|
||||
callback.setLocalProperties(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Socket createClientSocket() throws IOException {
|
||||
assert started;
|
||||
return new Socket();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ServerSocket createServerSocket() throws IOException {
|
||||
assert started;
|
||||
return new ServerSocket();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user