Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   New Feature Requests (https://www.gnutellaforums.com/new-feature-requests/)
-   -   Prefix/mask syntax for host filtering (https://www.gnutellaforums.com/new-feature-requests/21228-prefix-mask-syntax-host-filtering.html)

shamino July 28th, 2003 03:17 PM

Prefix/mask syntax for host filtering
 
Currently, I can apply block/allow filters only if the masks are aligned on an 8-bit boundary. For example: 10.11.12.13, 10.11.12.*, 10.11.*.*, 10.*.*.*, etc.

There is a problem with this, however. Some networks that I want to block don't have an entire 8-, 16-, or 24-bit address space assigned to them. They have some other amount.

For instance, suppose someone has a 4-bit network numbered 10.11.12.16 through 10.11.12.31. Right now, I have to manually add all 16 host addresses. I would prefer to be able to specify the mask (10.11.12.16/255.255.255.240) or even better, the prefix-length (10.11.12.16/28). The problem is annoying with small networks (like the 4-bit network in my example) but it is a showstopper if it involves bigger networks (like a 7-bit network - there's no way I'm going to hand-enter 128 host addresses.)

I browsed through this forum and the documentation, but I didn't find any indication that the current release supports this feature, nor have I seen any prior requests for it. Hopefully, this won't be difficult to implement.

The algorithm for doing this is really simple. Assuming that you've got your IP address stored in a 32-bit integer in host order, the algorithm is:

1) generate a mask from the prefix length:
Code:

mask = 0xFFFFFFFFu << (32 - prefixlen);
2) Match target address against prefix/mask pair:
Code:

if ((target & mask) == (prefix & mask))
{
    /* address matches */
}


sberlin July 28th, 2003 04:04 PM

I believe we do support both masks and prefix-lengths. I know our filtering code supports it, at least. I'm not exactly positive the GUI input screen will accept it, but I see no reason why it wouldn't.

If you're interested in the code that does it, you can view it here:

http://core.limewire.org/source/brow...-cvsweb-markup

Thanks.

shamino July 28th, 2003 11:23 PM

http://core.limewire.org/source/brow...-cvsweb-markup

Thanks for the pointer. The code seems to already do what I want. I hadn't actually tried it, because the documentation and the preferences dialog didn't mention that form as a possibility.

So assuming we're both right, then the only real issue is one of documentation.

Now all I have to do is figure out how to test this. Unfortunately, the preferences dialog seems to accept everything - even obviously bogus addresses like 10.1.1.527, so I can't simply enter it and assume it's OK if I don't get an error.

sberlin July 29th, 2003 07:50 AM

Yeah, I noticed the other night when I was looking through the code (prior to pasting the link) that IP would accept some pretty bogus addresses. Fortunately, it's no big deal, because all it's used for is blacklisting/whitelisting based on user-entered addresses. I'll see if I can't make it a little more robust though, and add some feedback into the preferences dialog.

sberlin July 29th, 2003 10:54 AM

FYI, I just added better validation for IPs & documentation in the preferences dialog for masks and the simplified prefix-lengths. I don't believe the next version will contain it, but the one immediately afterwards will.

Thanks.

shamino July 29th, 2003 08:11 PM

Thanks a lot. I'll look for it when the next version(s) come out.

sberlin July 29th, 2003 08:59 PM

The validation made it into 3.4.1 (the latest beta), however the documentation changes won't be around until 3.5 is released. Basically this means that enterring invalid IP addresses in the whitelist/blacklist area will beep and erase the invalid address. Try and break it. :)


All times are GMT -7. The time now is 10:34 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.