Comments (4)
I have a fix locally along with some tests:
MAX_IP = int(ipaddress.IPv4Address('255.255.255.255'))
def traverse_expander(ip, n=5):
class_c = get_class_c_network(ip)
ip_min = max(int(ip) - n, 0)
ip_max = min(int(ip) + n, MAX_IP)
result = [ipaddress.IPv4Address(i) for i in range(ip_min, ip_max + 1)]
result = [i for i in result if i in class_c]
return result
...but it occurs to me that the class-bounding is a little redundant with the other min/max stuff and they could be combined. However, IPv4Address
doesn't seem to have any convenient "take this apart into octets" so I'll need to poke at this a bit longer.
from fierce.
Your fix looks sane to me! One suggestion I have would be to just constant-ify the max IP - using ipaddress.IPv4Address
seems like unnecessary overhead. Something like:
def traverse_expander(ip, n=5):
class_c = get_class_c_network(ip)
ip = int(ip)
ipv4_min = 0
ipv4_max = 2**32 - 1
ip_min = max(ip - n, ipv4_min)
ip_max = min(ip + n, ipv4_max)
result = [ipaddress.IPv4Address(i) for i in range(ip_min, ip_max + 1)]
result = [i for i in result if i in class_c]
return result
it occurs to me that the class-bounding is a little redundant with the other min/max stuff and they could be combined.
Not entirely sure what you're getting at here, but this solution LGTM!
from fierce.
Re: the class-bounding, this is probably just bikeshedding, but I was noticing that the filtering IPs by whether they're in the same class C could be accomplished at the same time as the bounds check filtering by just setting the ip_min and ip_max to the lowest and highest of the class C (rather than the lowest and highest of all IPv4 addresses.) A little math oughtta do it. :-)
from fierce.
Heads up @timmc, I just released version 1.3.0
(https://pypi.org/project/fierce/1.3.0/) which includes your changes. Thanks again!
from fierce.
Related Issues (20)
- Socket errors with --connect option HOT 1
- Doen't work with cloudflare DNS HOT 3
- ConnectionRefusedError: [Errno 111] Connection refused HOT 1
- NoneType issues when using DNS file HOT 3
- Problem for two subdomains separated by dot with --subdomain-file HOT 3
- Problem with subdomains and wildcard failure HOT 1
- `dns.name.EmptyLabel` stack trace HOT 4
- Timeout from DNS resolver crashes program HOT 3
- Timeout during AXFR HOT 1
- Homebrew formula? HOT 3
- FileNotFoundError: [Errno 2] No such file or directory: 'default.txt' HOT 26
- Zone transfer error: REFUSED / NOTAUTH HOT 5
- Zone: failure & Wildcard: failure
- Allow later dnspython releases
- problem using fierce against an internal DNS
- Pull
- Zone transfert not working when DNS is badly configured
- TypeError: 'float' object cannot be interpreted as an integer HOT 2
- File 'lists/default.txt' missing HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fierce.