make outbound info more useful and more like the inbound
This commit is contained in:
parent
f8ed2e0444
commit
894fe8adae
|
@ -77,13 +77,12 @@ public class NetPortMap {
|
||||||
String ip = conn.getRemoteAddress();
|
String ip = conn.getRemoteAddress();
|
||||||
|
|
||||||
if (addresses == null) {
|
if (addresses == null) {
|
||||||
ip = conn.getLocalAddress();
|
ip = conn.getRemoteAddress();
|
||||||
String key =
|
port = new Long(conn.getRemotePort());
|
||||||
conn.getRemoteAddress() + ":" + conn.getRemotePort();
|
addresses = (Map)this.outbound.get(port);
|
||||||
addresses = (Map)this.outbound.get(key);
|
|
||||||
if (addresses == null) {
|
if (addresses == null) {
|
||||||
addresses = new HashMap();
|
addresses = new HashMap();
|
||||||
this.outbound.put(key, addresses);
|
this.outbound.put(port, addresses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +112,8 @@ public class NetPortMap {
|
||||||
return this.states;
|
return this.states;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
private static void dumpConnections(Map map) {
|
||||||
NetPortMap map = new NetPortMap();
|
for (Iterator it = map.entrySet().iterator();
|
||||||
map.stat();
|
|
||||||
|
|
||||||
System.out.println("Inbound Connections...");
|
|
||||||
Map ports = map.getInboundConnections();
|
|
||||||
|
|
||||||
for (Iterator it = ports.entrySet().iterator();
|
|
||||||
it.hasNext();)
|
it.hasNext();)
|
||||||
{
|
{
|
||||||
Map.Entry entry = (Map.Entry)it.next();
|
Map.Entry entry = (Map.Entry)it.next();
|
||||||
|
@ -128,18 +121,17 @@ public class NetPortMap {
|
||||||
Map addresses = (Map)entry.getValue();
|
Map addresses = (Map)entry.getValue();
|
||||||
System.out.println(port + "=" + addresses);
|
System.out.println(port + "=" + addresses);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
NetPortMap map = new NetPortMap();
|
||||||
|
map.stat();
|
||||||
|
|
||||||
|
System.out.println("Inbound Connections...");
|
||||||
|
dumpConnections(map.getInboundConnections());
|
||||||
|
|
||||||
System.out.println("\nOutbound Connections...");
|
System.out.println("\nOutbound Connections...");
|
||||||
Map outbound = map.getOutboundConnections();
|
dumpConnections(map.getOutboundConnections());
|
||||||
|
|
||||||
for (Iterator it = outbound.entrySet().iterator();
|
|
||||||
it.hasNext();)
|
|
||||||
{
|
|
||||||
Map.Entry entry = (Map.Entry)it.next();
|
|
||||||
String server = (String)entry.getKey();
|
|
||||||
Map addresses = (Map)entry.getValue();
|
|
||||||
System.out.println(server + "=" + addresses);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("\nStates...");
|
System.out.println("\nStates...");
|
||||||
int[] states = map.getStates();
|
int[] states = map.getStates();
|
||||||
|
|
Loading…
Reference in New Issue