Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions service/profile/endpoints/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ func (ep *EndpointBase) parsePPP(typedEp Endpoint, fields []string) (Endpoint, e
if n16 == 0 {
return nil, invalidDefinitionError(fields, "port number cannot be 0")
}
if n16 < ep.StartPort {
return nil, invalidDefinitionError(fields, "start port cannot be greater than end port")
}
ep.EndPort = n16
}
}
Expand Down
13 changes: 13 additions & 0 deletions service/profile/endpoints/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ func TestEndpointParsing(t *testing.T) {

// TODO: Test fails:
// testParsing(t, "+ 1234")

// invalid protocol and ports
testParsingFails(t, "+ * TCP/443-80")
testParsingFails(t, "- * UDP/HTTPS-HTTP")
}

func testParsingFails(t *testing.T, value string) {
t.Helper()

ep, err := parseEndpoint(value)
if err == nil {
t.Errorf(`parsing "%s" should fail, but returned "%s"`, value, ep.String())
}
}

func testParsing(t *testing.T, value string) {
Expand Down