This is a Nim module that evaluates if a given string is an IPv4 address. Evaluation of specific IPv4 address ranges is also possible. See examples below.
nimble test
Runs tests.
nim doc --project validateip.nim
Creates documentation for the entire project.
let myIp = "11.0.5.2".isIp4
assert myIp == true
let myIp = "11.0.5.2".isValidIp4
assert myIp == true
let myIp = isValidIp4("192.168.1.10", "local")
assert myIp == true
let myIp = isValidIp4("192.168.1.10", "lan")
assert myIp == true
let myIp = isValidIp4("192.168.1.10", "private")
assert myIp == true
let myIp = isValidIp4("111.12.1.10", "public")
assert myIp == true
let myIp = isValidIp4("111.12.1.10", "wan")
assert myIp == true
let myIp = isValidIp4("111.12.1.10", "internet")
assert myIp == true
Same applies to classes B and D.
Copyright (C) 2020 Akito [email protected]
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.