-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pulled out module cli commands into seperate files, fixed NSLOOKUP er…
…ror as is in a PR in main
- Loading branch information
1 parent
d51acb1
commit c415226
Showing
6 changed files
with
179 additions
and
44 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 cmd | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/zmap/zdns/internal/util" | ||
"github.com/zmap/zdns/pkg/zdns" | ||
) | ||
|
||
// nslookupCmd represents the nslookup command | ||
var nslookupCmd = &cobra.Command{ | ||
Use: "nslookup", | ||
Short: "Run a more exhaustive nslookup", | ||
Long: `nslookup will additionally do an A/AAAA lookup for the IP addresses that correspond with name server records.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
GC.Module = strings.ToUpper("nslookup") | ||
zdns.Run(GC, cmd.Flags(), | ||
&Timeout, &IterationTimeout, | ||
&Class_string, &Servers_string, | ||
&Config_file, &Localaddr_string, | ||
&Localif_string, &NanoSeconds, &ClientSubnet_string, &NSID) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(nslookupCmd) | ||
|
||
nslookupCmd.PersistentFlags().Bool("ipv4-lookup", false, "perform A lookups for each NS server") | ||
nslookupCmd.PersistentFlags().Bool("ipv6-lookup", false, "perform AAAA record lookups for each NS server") | ||
|
||
util.BindFlags(nslookupCmd, viper.GetViper(), util.EnvPrefix) | ||
} |
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,45 @@ | ||
/* | ||
* 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 cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/zmap/zdns/internal/util" | ||
"strings" | ||
) | ||
|
||
// alookupCmd represents the alookup command | ||
var alookupCmd = &cobra.Command{ | ||
Use: "alookup", | ||
Short: "A record lookups that follow CNAME records", | ||
Long: `alookup will get the information that is typically desired, instead of just | ||
the information that exists in a single record. | ||
Specifically, alookup acts similar to nslookup and will follow CNAME records.`, | ||
Args: cobra.MatchAll(cobra.ExactArgs(0), cobra.OnlyValidArgs), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
GC.Module = strings.ToUpper("alookup") | ||
Run(GC, cmd.Flags()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(alookupCmd) | ||
|
||
alookupCmd.PersistentFlags().Bool("ipv4-lookup", false, "perform A lookups for each MX server") | ||
alookupCmd.PersistentFlags().Bool("ipv6-lookup", false, "perform AAAA record lookups for each MX server") | ||
|
||
util.BindFlags(alookupCmd, viper.GetViper(), util.EnvPrefix) | ||
} |
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,44 @@ | ||
/* | ||
* 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 cmd | ||
|
||
import ( | ||
"github.com/spf13/viper" | ||
"github.com/zmap/zdns/internal/util" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// mxlookupCmd represents the mxlookup command | ||
var mxlookupCmd = &cobra.Command{ | ||
Use: "mxlookup", | ||
Short: "Run a more exhaustive mxlookup", | ||
Long: `mxlookup will additionally do an A lookup for the IP addresses that | ||
correspond with an exchange record.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
GC.Module = strings.ToUpper("mxlookup") | ||
Run(GC, cmd.Flags()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(mxlookupCmd) | ||
|
||
mxlookupCmd.PersistentFlags().Bool("ipv4-lookup", false, "perform A lookups for each MX server") | ||
mxlookupCmd.PersistentFlags().Bool("ipv6-lookup", false, "perform AAAA record lookups for each MX server") | ||
mxlookupCmd.PersistentFlags().Int("mx-cache-size", 1000, "number of records to store in MX -> A/AAAA cache") | ||
|
||
util.BindFlags(mxlookupCmd, viper.GetViper(), util.EnvPrefix) | ||
} |
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 cmd | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/zmap/zdns/internal/util" | ||
) | ||
|
||
// nslookupCmd represents the nslookup command | ||
var nslookupCmd = &cobra.Command{ | ||
Use: "nslookup", | ||
Short: "Run a more exhaustive nslookup", | ||
Long: `nslookup will additionally do an A/AAAA lookup for the IP addresses that correspond with name server records.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
GC.Module = strings.ToUpper("nslookup") | ||
Run(GC, cmd.Flags()) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(nslookupCmd) | ||
|
||
nslookupCmd.PersistentFlags().Bool("ipv4-lookup", false, "perform A lookups for each NS server") | ||
nslookupCmd.PersistentFlags().Bool("ipv6-lookup", false, "perform AAAA record lookups for each NS server") | ||
|
||
util.BindFlags(nslookupCmd, viper.GetViper(), util.EnvPrefix) | ||
} |
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