Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Google, Yandex, Sogou, DotBot, Yahoo!, Bing

Members: 0
Guests: 11
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » CIDR Range Banning
Forum Rules | Mark all | Recent Posts

CIDR Range Banning
< Newer Topic :: Older Topic > Must be a way...

Pages:<< prev 1 next >>
Post is unread #1 Nov 19, 2014, 7:14 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

I've spent the better part of my spare time today on the hunt for how to handle checking an IP against a CIDR range to see if it's within that range.

ie: seeing if 1.2.3.4 falls within 1.2.0.0/15 or something.

The CIDR value could be entered via a ban command manually, or if possible calculated into the string form of 1.2.0.0/15 from the user's existing IP and added to a list for future comparisons.

Pretty much every post I've been able to find is either of the form "break it up and compare" (who never go on to explain what they mean) or consists of huge libraries that are bigger than the entire codebase, which are impractical for obvious reasons.

Does C++ not have some standard thing for this? Why does this seem like people think it's ridiculously easy to do yet can't be bothered to post their code if it really is this simple? Nobody has ever done this in MUD code before?

I have some PHP code in my blog that can do this in 7 lines of code, but it appears to be relying in part on some native libraries inside PHP that C++ doesn't have and I don't know how to translate it.

I'm hoping for a nice, clean, easy solution to this that can be trivially dropped in to use for ban comparisons.
       
Post is unread #2 Nov 20, 2014, 3:28 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

so you want to ban everything in that range or what?
       
Post is unread #3 Nov 20, 2014, 4:03 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

It's just an example, but yes.

In any case, I've been in contact with the author of something I found on GitHub late last night and he's given permission to use the code he has which should solve the issue nicely and in relatively few lines of code.
       
Post is unread #4 Nov 20, 2014, 4:23 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,866
JoinedJul 26, 2005

cool, glad to see you got it done :)
       
Post is unread #5 Nov 21, 2014, 2:01 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Yep, and it all seems to be working well too.

https://github.com/Arthmoor/AFKMud/commit/dcf958e2d07da3af28236b7d6971968903efe796 if you want to see the details :)
       
Pages:<< prev 1 next >>