mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Minor logging changes for TCP plugins.
This commit is contained in:
@@ -184,20 +184,13 @@ class LanTcpPlugin extends TcpPlugin {
|
||||
if(addr.isLoopbackAddress()) continue;
|
||||
boolean link = addr.isLinkLocalAddress();
|
||||
boolean site = addr.isSiteLocalAddress();
|
||||
if(link || site) {
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Preferring " + getHostAddress(addr));
|
||||
return addr;
|
||||
}
|
||||
if(link || site) return addr;
|
||||
}
|
||||
}
|
||||
// Accept an interface without a link-local or site-local address
|
||||
for(NetworkInterface iface : ifaces) {
|
||||
for(InetAddress addr : Collections.list(iface.getInetAddresses())) {
|
||||
if(addr.isLoopbackAddress()) continue;
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Accepting " + getHostAddress(addr));
|
||||
return addr;
|
||||
if(!addr.isLoopbackAddress()) return addr;
|
||||
}
|
||||
}
|
||||
// No suitable interfaces
|
||||
|
||||
@@ -93,11 +93,8 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
return;
|
||||
}
|
||||
socket = ss;
|
||||
if(LOG.isLoggable(INFO)) {
|
||||
String addr = getHostAddress(ss.getInetAddress());
|
||||
int port = ss.getLocalPort();
|
||||
LOG.info("Listening on " + addr + " " + port);
|
||||
}
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Listening on " + ss.getLocalSocketAddress());
|
||||
setLocalSocketAddress((InetSocketAddress) ss.getLocalSocketAddress());
|
||||
acceptContactConnections(ss);
|
||||
}
|
||||
@@ -113,8 +110,7 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
protected String getHostAddress(InetAddress a) {
|
||||
String addr = a.getHostAddress();
|
||||
int percent = addr.indexOf('%');
|
||||
if(percent == -1) return addr;
|
||||
return addr.substring(0, percent);
|
||||
return percent == -1 ? addr : addr.substring(0, percent);
|
||||
}
|
||||
|
||||
protected void setLocalSocketAddress(InetSocketAddress a) {
|
||||
@@ -135,6 +131,8 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
tryToClose(ss);
|
||||
return;
|
||||
}
|
||||
if(LOG.isLoggable(INFO))
|
||||
LOG.info("Connection from " + s.getRemoteSocketAddress());
|
||||
callback.incomingConnectionCreated(new TcpTransportConnection(s,
|
||||
maxLatency));
|
||||
if(!running) return;
|
||||
@@ -179,7 +177,9 @@ abstract class TcpPlugin implements DuplexPlugin {
|
||||
if(addr == null) return null;
|
||||
Socket s = new Socket();
|
||||
try {
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Connecting to " + addr);
|
||||
s.connect(addr);
|
||||
if(LOG.isLoggable(INFO)) LOG.info("Connected to " + addr);
|
||||
return new TcpTransportConnection(s, maxLatency);
|
||||
} catch(IOException e) {
|
||||
if(LOG.isLoggable(INFO)) LOG.log(INFO, e.toString(), e);
|
||||
|
||||
Reference in New Issue
Block a user