-
Notifications
You must be signed in to change notification settings - Fork 126
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
Pass domains as arguments similar to dig #418
Closed
Closed
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5ede1ce
dig-style domains passing smoke tests
phillip-stephens e67fb0a
add help info on inputs, fix issues with alookup and friends, passing…
phillip-stephens 8f1e24c
handle bad module better with better feedback for user
phillip-stephens 8086f92
added dig integration test
phillip-stephens a0a9854
lint
phillip-stephens f675d33
fixed up comment
phillip-stephens e60c2f4
remove unused arg in inHandler
phillip-stephens e02d170
add --type
phillip-stephens 4fe2357
lint
phillip-stephens 4b0b927
handle seperate module commands (nslookup)
phillip-stephens dc085c1
fix integration test
phillip-stephens 3af7d32
Merge branch 'main' into phillip/266-new
phillip-stephens 1203e01
Merge remote-tracking branch 'origin/main' into phillip/266-new
phillip-stephens 44b3f60
add integration test for --name-server-mode
phillip-stephens f4cac6b
Merge branch 'main' into phillip/266-new
phillip-stephens 27af3c4
switch verbage from type to module
phillip-stephens 26eb4f8
add new avail-modules cmd
phillip-stephens dd66533
cleanup
phillip-stephens 578e7df
added details to err msgs
phillip-stephens 81ae118
avail-modules is a cmd, not flag
phillip-stephens 43f0b89
handle special commands
phillip-stephens c15fe97
cleanup
phillip-stephens 52e166a
removed dead metadata code
phillip-stephens 5d015e8
make arg handling more succint
phillip-stephens 6c8b235
lint
phillip-stephens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* ZDNS Copyright 2024 Regents of the University of Michigan | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy | ||
* of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package iohandlers | ||
|
||
import ( | ||
"sync" | ||
|
||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// StringSliceInputHandler Feeds a channel with the strings in the slice. | ||
type StringSliceInputHandler struct { | ||
Names []string | ||
} | ||
|
||
func NewStringSliceInputHandler(domains []string) *StringSliceInputHandler { | ||
if len(domains) == 0 { | ||
log.Fatal("No domains provided, cannot create a string slice input handler") | ||
} | ||
return &StringSliceInputHandler{Names: domains} | ||
} | ||
|
||
func (h *StringSliceInputHandler) FeedChannel(in chan<- string, wg *sync.WaitGroup) error { | ||
defer close(in) | ||
defer wg.Done() | ||
for _, name := range h.Names { | ||
in <- name | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't understand why they shouldn't be printed as part of modules. It seems like we want the user to know they exist? They are modules.
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.
They're modules in the way we mean it with ZDNS but in terms of Cobra/the CLI, they're commands. We register them as "commands" and they get printed by Cobra here:
So they must be called with
./zdns mxlookup
., or./zdns_binary CMD_NAME
We can't have./zdns --module=mxlookup
since Cobra only initializes the command specific flags (--mx-cache-size
here) if the command is used as cobra expects.So I'd say they are modules in the ZDNS sense but we must call them like Cobra expects commands to be called. Cobra will print out
mxlookup
andnslookup
in theAvailable Commands
section, and we'll print out the other ZDNS modules in the new section of--help
, Available modules:In this way, the user will know about all available options.
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 there a reason to not just define our own
--help
that patches this up? Does cobra allow us to define that ourselves?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.
I'm not really sure how that would solve things.
The
--ipv4-lookup
and--ipv6-lookup
don't matter too much because we also define those on therootCmd
, but themx-cache-size
is only defined here.Cobra will only initialize that flag if the
mxlookup
command is used as a "Cobra command", ie.zdns mxlookup
.Unless we define
--mx-cache-size
on the root command and let it be used by all modules, we must treat it separately because Cobra handles it differently.