@@ -16,8 +16,8 @@ import (
1616)
1717
1818// The new test output filename is joint of hostname, server boot time, and socker TCO cookie.
19- // like: pboothe2.nyc.corp.google .com_1548788619_00000000000084FF
20- var IGNORE_IPV4_NETS = []string {"127." , "128.112.139." , "::ffff:127.0.0.1" }
19+ // like: myhost.example .com_1548788619_00000000000084FF
20+ var localIPv4 = []string {"127." , "128.112.139." , "::ffff:127.0.0.1" }
2121
2222// parseIPAndPort returns a valid IP and port from "ss -e" output.
2323func parseIPAndPort (input string ) (string , int , error ) {
@@ -29,7 +29,7 @@ func parseIPAndPort(input string) (string, int, error) {
2929 if IPStr [0 ] == '[' {
3030 IPStr = IPStr [1 : len (IPStr )- 1 ]
3131 }
32- for _ , prefix := range IGNORE_IPV4_NETS {
32+ for _ , prefix := range localIPv4 {
3333 if strings .HasPrefix (IPStr , prefix ) {
3434 return "" , 0 , errors .New ("ignore this IP address" )
3535 }
@@ -78,7 +78,14 @@ func parseSSLine(line string) (*connection.Connection, error) {
7878 return nil , err
7979 }
8080
81- output := & connection.Connection {Remote_ip : remoteIP , Remote_port : remotePort , Local_ip : localIP , Local_port : localPort , Cookie : cookie }
81+ output := & connection.Connection {
82+ RemoteIP : remoteIP ,
83+ RemotePort : remotePort ,
84+ LocalIP : localIP ,
85+ LocalPort : localPort ,
86+ Cookie : cookie ,
87+ }
88+
8289 return output , nil
8390}
8491
@@ -118,11 +125,11 @@ func (c *ConnectionWatcher) GetClosedCollection() []connection.Connection {
118125 c .getConnections ()
119126 fmt .Printf ("new connection size %d\n " , len (c .connectionPool ))
120127 var closed []connection.Connection
121- for conn , _ := range oldConn {
122- if ! c .connectionPool [conn ] && ! c .recentIPCache .Has (conn .Remote_ip ) {
128+ for conn := range oldConn {
129+ if ! c .connectionPool [conn ] && ! c .recentIPCache .Has (conn .RemoteIP ) {
123130 closed = append (closed , conn )
124- log .Printf ("Try to add " + conn .Remote_ip )
125- c .recentIPCache .Add (conn .Remote_ip )
131+ log .Printf ("Try to add " + conn .RemoteIP )
132+ c .recentIPCache .Add (conn .RemoteIP )
126133 }
127134 }
128135 return closed
0 commit comments