|
|
@@ -32,6 +32,7 @@ import (
|
|
|
"net"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
+ "regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
|
|
|
@@ -590,6 +591,11 @@ func RecordRemoteServerListStat(
|
|
|
config, datastorePersistentStatTypeRemoteServerList, remoteServerListStatJson)
|
|
|
}
|
|
|
|
|
|
+// failedTunnelErrStripIPAddressRegex strips IPv4 address strings from
|
|
|
+// "net" package I/O error messages. This is to avoid inadvertently recording direct server IPs via error message logs.
|
|
|
+var failedTunnelErrStripIPAddressRegex = regexp.MustCompile(
|
|
|
+ "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
|
|
|
+
|
|
|
// RecordFailedTunnelStat records metrics for a failed tunnel dial, including
|
|
|
// dial parameters and error condition (tunnelErr).
|
|
|
//
|
|
|
@@ -612,7 +618,7 @@ func RecordFailedTunnelStat(
|
|
|
params["server_entry_ip_address"] = dialParams.ServerEntry.IpAddress
|
|
|
params["last_connected"] = lastConnected
|
|
|
params["client_failed_timestamp"] = common.TruncateTimestampToHour(common.GetCurrentTimestamp())
|
|
|
- params["tunnel_error"] = tunnelErr.Error()
|
|
|
+ params["tunnel_error"] = failedTunnelErrStripIPAddressRegex.ReplaceAllString(tunnelErr.Error(), "<ip-address>")
|
|
|
|
|
|
failedTunnelStatJson, err := json.Marshal(params)
|
|
|
if err != nil {
|