-
Notifications
You must be signed in to change notification settings - Fork 157
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
Bulk ASN #159
Bulk ASN #159
Conversation
BE-2184 CLI ASN Bulk
Related to issue : #56 Right now we don't support looking up ASNs in bulk, but it's a useful feature to have. In the process, we should actually support mixing together IPs & ASNs in one bulk lookup, by default. And as a further improvement to the API, we should deprecate the Here's a specific checklist of things to consider:
|
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.
@Harisabdullah I'll review this when we develop the generic solution for reading inputs from any place.
Restructure the codebase to enhance input handling from various sources
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.
We require essentially 'passing down' the op func to make it work in a 'streaming' way - without buffering inputs at lower levels and bringing them up higher, because otherwise it won't scale.
ipinfo/cmd_init.go
Outdated
@@ -134,7 +134,7 @@ func cmdInit() error { | |||
} | |||
|
|||
// save token to file. | |||
gConfig.Token = tok | |||
gConfig.Token = newtoken |
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.
Is this intentional?
lib/utils_input.go
Outdated
INPUT_TYPE_IP INPUT_TYPE = "IP" | ||
INPUT_TYPE_IP_RANGE INPUT_TYPE = "IPRange" | ||
INPUT_TYPE_CIDR INPUT_TYPE = "CIDR" | ||
INPUT_TYPE_FILE INPUT_TYPE = "File" |
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.
Files are a source, not an input type: the generic functionality, if told to read from files by the user, should do so by opening them and parsing their inputs for ips/ranges/cidrs/asns/etc. The same way it transparently 'opens' the 'stdin file' and reads from it when requested.
lib/utils_input.go
Outdated
} | ||
|
||
if isPiped || isTyping || stat.Size() > 0 { | ||
inputs = append(inputs, ReadStringsFromStdin()...) |
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.
This should actually be doing an op
per string coming from stdin
on the fly, instead of having it be returned. Otherwise for operations like prips
this won't scale, because it'll store the whole thing in memory before proceeding and in some inputs that won't be even possible (huge IP ranges/cidrs).
lib/utils_input.go
Outdated
} | ||
|
||
// readStringsFromFile reads strings from a file, one per line. | ||
func readStringsFromFile(filename string) ([]string, error) { |
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.
We need to ensure all of our actions are not buffering inputs into an arbitrarily large array - this will make certain use cases not scale. We need to perform the op per input in the file if we're told to open files.
lib/utils_input.go
Outdated
} | ||
|
||
// ReadStringsFromStdin reads strings from stdin until an empty line is entered. | ||
func ReadStringsFromStdin() []string { |
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.
Same argument here
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.
Nice, let's try this out in main
Flow of Control is as follows
->
ipinfo as500
->cmd_asn_single
->
ipinfo asn
->cmd_asn
->
ipinfo asn bulk
->cmd_asn_bulk
Hence the refactor of files
Implements #56