From a88de1532c2f1df71157317d24a503abf8e2826a Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 19 Dec 2023 15:11:27 +0100 Subject: [PATCH] Improve ASN parsing --- profile/endpoints/endpoint-asn.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/profile/endpoints/endpoint-asn.go b/profile/endpoints/endpoint-asn.go index 898d9bfc..5341f81b 100644 --- a/profile/endpoints/endpoint-asn.go +++ b/profile/endpoints/endpoint-asn.go @@ -5,6 +5,7 @@ import ( "fmt" "regexp" "strconv" + "strings" "github.com/safing/portmaster/intel" ) @@ -48,9 +49,10 @@ func (ep *EndpointASN) String() string { func parseTypeASN(fields []string) (Endpoint, error) { if asnRegex.MatchString(fields[1]) { - asn, err := strconv.ParseUint(fields[1][2:], 10, 64) + asnString := strings.TrimPrefix(fields[1], "AS") + asn, err := strconv.ParseUint(asnString, 10, 64) if err != nil { - return nil, fmt.Errorf("failed to parse AS number %s", fields[1]) + return nil, fmt.Errorf("failed to parse AS number %s", asnString) } ep := &EndpointASN{