egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Testing if a IP is valid

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Mon Jun 28, 2021 6:31 pm    Post subject: Testing if a IP is valid Reply with quote

So i am trying to find a code that will check if a IP has the correct syntax of a IPv4 or IPv6 IP, i have no idea how that would look, but all help is much appreciated Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
CrazyCat
Owner


Joined: 13 Jan 2002
Posts: 848
Location: France

PostPosted: Tue Jun 29, 2021 2:36 am    Post subject: Reply with quote

Hum, did you look @ https://regex101.com/library?orderBy=RELEVANCE&page=1&search=IP ?
_________________
https://www.eggdrop.fr
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3733
Location: Mint Factory

PostPosted: Tue Jun 29, 2021 3:01 am    Post subject: Reply with quote

Here's a better link with Regular Expression Examples.

If you don't want to fiddle with regexp and basically reinvent the wheel, then use the ip package that comes with TCLlib that offers some tools to validate ipv4 or ipv6, like:
Code:

% package require ip
1.4
::ip::version 192.168.0.1
1
% ::ip::version 192.168.0.256
-1
% ::ip::is ipv4 192.168.0.1
1
% ::ip::version 192.198.0.256
-1
% ::ip::version 2001:bc8:32d7:26c::
6

You can find the source code of a previous version here (or if you are on Debian you should find it in /usr/share/tcltk/tcllib1.20/dns/ip.tcl, if not do a locate ip.tcl) to see what other commands are available.
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
ComputerTech
Master


Joined: 22 Feb 2020
Posts: 374

PostPosted: Tue Jun 29, 2021 9:06 am    Post subject: Reply with quote

Awesome! Thanks very much caesar Very Happy

And thanks CrazyCat for the link you provided as well Smile
_________________
ComputerTech
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber