diff --git a/port_prediction.nim b/port_prediction.nim index 6a0549c..947e564 100644 --- a/port_prediction.nim +++ b/port_prediction.nim @@ -56,13 +56,13 @@ proc getNatProperties*(localPort: uint16, probedPorts: seq[uint16]): NatProperties = if probedPorts.len == 0: # No probed ports, so our only guess can be that the NAT is a cone-type NAT - # and the port mapping preserves the local Port. + # and the port allocation preserves the local Port. return NatProperties(natType: Unknown, guess: @[localPort]) if probedPorts.len == 1: # Only one server was used for probing, so we cannot know if the NAT is # symmetric or not. We are trying the probed port (assuming cone-type NAT) # and the next port in a progressive sequence if applicable (assuming - # symmetric NAT with progressive port mapping). + # symmetric NAT with progressive port allocation). result = NatProperties(natType: Unknown, guess: @[probedPorts[0]]) if probedPorts[0] > localPort: let offset = probedPorts[0] - localPort @@ -87,16 +87,16 @@ proc getNatProperties*(localPort: uint16, probedPorts: seq[uint16]): maxDistance = max(maxDistance, distance) if maxDistance < 10: if probedPorts.isSorted(Ascending): - # assume symmetric NAT with positive-progressive port mapping + # assume symmetric NAT with positive-progressive port allocation return NatProperties(natType: SymmetricProgressive, order: Ascending, previousPort: maxPort, minDistance: minDistance, maxDistance: maxDistance) if probedPorts.isSorted(Descending): - # assume symmetric NAT with negative-progressive port mapping + # assume symmetric NAT with negative-progressive port allocation return NatProperties(natType: SymmetricProgressive, order: Descending, previousPort: minPort, minDistance: minDistance, maxDistance: maxDistance) - # assume symmetric NAT with random port mapping + # assume symmetric NAT with random port allocation return NatProperties(natType: SymmetricRandom, minPort: minPort, maxPort: maxPort) @@ -272,7 +272,7 @@ suite "port prediction tests": let predicted = predictPortRange(props) check(predicted == @[Port(65533)]) - test "random mapping": + test "random port allocation": let props = getNatProperties(1234'u16, @[20000'u16, 24000'u16]) check(props.natType == SymmetricRandom) check(props.minPort == 20000'u16) @@ -281,7 +281,7 @@ suite "port prediction tests": let half = RandomPortCount div 2'u16 check(predicted == toSeq(countup(22000'u16 - half, 22000'u16 + half - 1)).map(toPort)) - test "random mapping, low": + test "random port allocation": let props = getNatProperties(1234'u16, @[1200'u16, 1600'u16]) check(props.natType == SymmetricRandom) check(props.minPort == 1200'u16) @@ -290,7 +290,7 @@ suite "port prediction tests": check(predicted.len == RandomPortCount.int) check(predicted == toSeq(countup(1024'u16, 1024'u16 + RandomPortCount - 1)).map(toPort)) - test "random mapping, high": + test "random port allocation, high": let props = getNatProperties(1234'u16, @[65000'u16, 65400'u16]) check(props.natType == SymmetricRandom) check(props.minPort == 65000'u16)