File tree 1 file changed +7
-0
lines changed
1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ type IPKey struct {
77
77
}
78
78
79
79
type tunnelTimeTracker struct {
80
+ mu sync.Mutex
80
81
activeClients map [IPKey ]* activeClient
81
82
reportTunnelTime ReportTunnelTimeFunc
82
83
}
@@ -87,6 +88,8 @@ func (t *tunnelTimeTracker) reportAll(now time.Time) {
87
88
logger .Debugf ("No active clients. No TunnelTime activity to report." )
88
89
return
89
90
}
91
+ t .mu .Lock ()
92
+ defer t .mu .Unlock ()
90
93
for _ , c := range t .activeClients {
91
94
t .reportDuration (c , now )
92
95
}
@@ -108,6 +111,8 @@ func (t *tunnelTimeTracker) startConnection(clientInfo ipinfo.IPInfo, clientAddr
108
111
hostname , _ , _ := net .SplitHostPort (clientAddr .String ())
109
112
ipKey := IPKey {ip : hostname , accessKey : accessKey }
110
113
114
+ t .mu .Lock ()
115
+ defer t .mu .Unlock ()
111
116
c , exists := t .activeClients [ipKey ]
112
117
if ! exists {
113
118
c = & activeClient {
@@ -125,6 +130,8 @@ func (t *tunnelTimeTracker) stopConnection(clientAddr net.Addr, accessKey string
125
130
hostname , _ , _ := net .SplitHostPort (clientAddr .String ())
126
131
ipKey := IPKey {ip : hostname , accessKey : accessKey }
127
132
133
+ t .mu .Lock ()
134
+ defer t .mu .Unlock ()
128
135
c , exists := t .activeClients [ipKey ]
129
136
if ! exists {
130
137
logger .Warningf ("Failed to find active client" )
You can’t perform that action at this time.
0 commit comments