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