Skip to content

Commit

Permalink
Improve ASN parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Dec 19, 2023
1 parent 82cdd1b commit a88de15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions profile/endpoints/endpoint-asn.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"regexp"
"strconv"
"strings"

"github.com/safing/portmaster/intel"
)
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit a88de15

Please sign in to comment.