diff --git a/profile/endpoints.go b/profile/endpoints.go index 9809a56a..8e584c5c 100644 --- a/profile/endpoints.go +++ b/profile/endpoints.go @@ -1,6 +1,7 @@ package profile import ( + "context" "fmt" "net" "strconv" @@ -91,7 +92,7 @@ func (e Endpoints) CheckIP(domain string, ip net.IP, protocol uint8, port uint16 // setup caching wrapper cachedGetDomainOfIP = func() string { if !ipResolved { - result, err := intel.ResolveIPAndValidate(ip.String(), securityLevel) + result, err := intel.ResolveIPAndValidate(context.TODO(), ip.String(), securityLevel) if err != nil { // log.Debug() ipName = result diff --git a/profile/endpoints_test.go b/profile/endpoints_test.go index 07e43018..18044dda 100644 --- a/profile/endpoints_test.go +++ b/profile/endpoints_test.go @@ -3,8 +3,6 @@ package profile import ( "net" "testing" - - "github.com/safing/portbase/utils/testutils" ) func testEndpointDomainMatch(t *testing.T, ep *EndpointPermission, domain string, expectedResult EPResult) { @@ -13,7 +11,7 @@ func testEndpointDomainMatch(t *testing.T, ep *EndpointPermission, domain string if result != expectedResult { t.Errorf( "line %d: unexpected result for endpoint domain match %s: result=%s, expected=%s", - testutils.GetLineNumberOfCaller(1), + getLineNumberOfCaller(1), domain, result, expectedResult, @@ -27,7 +25,7 @@ func testEndpointIPMatch(t *testing.T, ep *EndpointPermission, domain string, ip if result != expectedResult { t.Errorf( "line %d: unexpected result for endpoint %s/%s/%d/%d: result=%s, expected=%s", - testutils.GetLineNumberOfCaller(1), + getLineNumberOfCaller(1), domain, ip, protocol, diff --git a/profile/set_test.go b/profile/set_test.go index 4b9cd8e9..07b5a4ce 100644 --- a/profile/set_test.go +++ b/profile/set_test.go @@ -3,10 +3,10 @@ package profile import ( "context" "net" + "runtime" "testing" "time" - "github.com/safing/portbase/utils/testutils" "github.com/safing/portmaster/status" ) @@ -113,7 +113,7 @@ func testEndpointDomain(t *testing.T, set *Set, domain string, expectedResult EP if result != expectedResult { t.Errorf( "line %d: unexpected result for endpoint domain %s: result=%s, expected=%s", - testutils.GetLineNumberOfCaller(1), + getLineNumberOfCaller(1), domain, result, expectedResult, @@ -127,7 +127,7 @@ func testEndpointIP(t *testing.T, set *Set, domain string, ip net.IP, protocol u if result != expectedResult { t.Errorf( "line %d: unexpected result for endpoint %s/%s/%d/%d/%v: result=%s, expected=%s", - testutils.GetLineNumberOfCaller(1), + getLineNumberOfCaller(1), domain, ip, protocol, @@ -171,3 +171,8 @@ func TestProfileSet(t *testing.T) { testEndpointIP(t, set, "", net.ParseIP("10.2.3.4"), 6, 80, false, NoMatch) testEndpointDomain(t, set, "bad2.example.com.", Undeterminable) } + +func getLineNumberOfCaller(levels int) int { + _, _, line, _ := runtime.Caller(levels + 1) + return line +}