@@ -75,7 +75,7 @@ type IPKey struct {
75
75
}
76
76
77
77
type tunnelTimeTracker struct {
78
- activeClients map [IPKey ]activeClient
78
+ activeClients map [IPKey ]* activeClient
79
79
reportTunnelTime ReportTunnelTimeFunc
80
80
}
81
81
@@ -91,14 +91,12 @@ func (t *tunnelTimeTracker) reportAll(now time.Time) {
91
91
}
92
92
93
93
// Reports time connected for a given active client.
94
- func (t * tunnelTimeTracker ) reportDuration (c activeClient , now time.Time ) {
94
+ func (t * tunnelTimeTracker ) reportDuration (c * activeClient , now time.Time ) {
95
95
connDuration := now .Sub (c .startTime )
96
96
logger .Debugf ("Reporting activity for key `%v`, duration: %v" , c .IPKey .accessKey , connDuration )
97
97
t .reportTunnelTime (c .IPKey , c .clientInfo , connDuration )
98
-
99
98
// Reset the start time now that it's been reported.
100
99
c .startTime = Now ()
101
- t .activeClients [c .IPKey ] = c
102
100
}
103
101
104
102
// Registers a new active connection for a client [net.Addr] and access key.
@@ -108,7 +106,7 @@ func (t *tunnelTimeTracker) startConnection(clientInfo ipinfo.IPInfo, clientAddr
108
106
109
107
c , exists := t .activeClients [ipKey ]
110
108
if ! exists {
111
- c = activeClient {ipKey , clientInfo , 0 , Now ()}
109
+ c = & activeClient {ipKey , clientInfo , 0 , Now ()}
112
110
}
113
111
c .connectionCount ++
114
112
t .activeClients [ipKey ] = c
@@ -119,7 +117,6 @@ func (t *tunnelTimeTracker) stopConnection(clientAddr net.Addr, accessKey string
119
117
hostname , _ , _ := net .SplitHostPort (clientAddr .String ())
120
118
ipKey := IPKey {ip : hostname , accessKey : accessKey }
121
119
122
- c := t .activeClients [ipKey ]
123
120
c , exists := t .activeClients [ipKey ]
124
121
if ! exists {
125
122
logger .Warningf ("Failed to find active client" )
@@ -135,7 +132,7 @@ func (t *tunnelTimeTracker) stopConnection(clientAddr net.Addr, accessKey string
135
132
}
136
133
137
134
func newTunnelTimeTracker (report ReportTunnelTimeFunc ) * tunnelTimeTracker {
138
- tracker := & tunnelTimeTracker {activeClients : make (map [IPKey ]activeClient ), reportTunnelTime : report }
135
+ tracker := & tunnelTimeTracker {activeClients : make (map [IPKey ]* activeClient ), reportTunnelTime : report }
139
136
ticker := time .NewTicker (tunnelTimeTrackerReportingInterval )
140
137
go func () {
141
138
for t := range ticker .C {
0 commit comments