-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery Starbot ⭐ refactored ancker010/exabgp-flowspec-generator #1
base: master
Are you sure you want to change the base?
Conversation
subnet = IPv4Network("192.168.0.0/16") | ||
subnet = IPv4Network("192.168.0.0/16") | ||
bits = getrandbits(subnet.max_prefixlen - subnet.prefixlen) | ||
addr = IPv4Address(subnet.network_address + bits) | ||
addr_str = str(addr) | ||
return addr_str | ||
return str(addr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function genipv4 refactored with the following changes:
- Inline variable that is only used once
addr_str6 = str(addr6) | ||
return addr_str6 | ||
return str(addr6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function genipv6 refactored with the following changes:
- Inline variable that is only used once
flow_types = [] | ||
flow_types.append( | ||
"announce flow route { match { source " + genipv4() + "/32; destination 192.168.255.10/32; destination-port =" + str(random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " + str(random.randint(9600, 51200)) + "; } }") | ||
flow_types = [ | ||
"announce flow route { match { source " + genipv4() + | ||
"/32; destination 192.168.255.10/32; destination-port =" + str( | ||
random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " + | ||
str(random.randint(9600, 51200)) + "; } }" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function genflows refactored with the following changes:
- Merge append into list assignment
flow_types6 = [] | ||
flow_types6.append( | ||
"announce flow route { match { source " + genipv6() + "/128; destination 2001:DB8:beef:cafe::1/128; destination-port =" + str(random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " + str(random.randint(9600, 51200)) + "; } }") | ||
flow_types6 = [ | ||
"announce flow route { match { source " + genipv6() + | ||
"/128; destination 2001:DB8:beef:cafe::1/128; destination-port =" + str( | ||
random.randint(1024, 65530)) + "; protocol tcp; } then { rate-limit " + | ||
str(random.randint(9600, 51200)) + "; } }" | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function genflows6 refactored with the following changes:
- Merge append into list assignment
for x in range(0, count): | ||
for _ in range(count): | ||
flows = genflows() | ||
messages.append(random.choice(flows)) | ||
|
||
for x in range(0, count): | ||
for x in range(count): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 66-70 refactored with the following changes:
- Replace range(0, x) with range(x)
- Replace unused for index with underscore
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: