Adding some more debug options
This commit is contained in:
parent
d98ac3058e
commit
bbd1680f1e
@ -34,5 +34,5 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
data := resolver.PerformZoneTransfer(cfg, debug)
|
data := resolver.PerformZoneTransfer(cfg, debug)
|
||||||
shell.CreateShellAliases(data, user, cfg)
|
shell.CreateShellAliases(data, user, cfg, debug)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// LookupName returns IPv4 address from A record or error.
|
// LookupName returns IPv4 address from A record or error.
|
||||||
func lookupName(fqdn, serverAddr string) (string, error) {
|
func lookupName(fqdn, serverAddr string, debug bool) (string, error) {
|
||||||
|
if debug {
|
||||||
|
defer utils.LogElapsedTime("Lookup Name")
|
||||||
|
}
|
||||||
m := &dns.Msg{}
|
m := &dns.Msg{}
|
||||||
m.SetQuestion(dns.Fqdn(fqdn), dns.TypeA)
|
m.SetQuestion(dns.Fqdn(fqdn), dns.TypeA)
|
||||||
in, err := dns.Exchange(m, serverAddr)
|
in, err := dns.Exchange(m, serverAddr)
|
||||||
@ -52,7 +55,7 @@ func PerformZoneTransfer(config config.Config, debug bool) []string {
|
|||||||
switch v := a.(type) {
|
switch v := a.(type) {
|
||||||
case *dns.TXT:
|
case *dns.TXT:
|
||||||
hostname = v.Hdr.Name
|
hostname = v.Hdr.Name
|
||||||
cip, err := lookupName(strings.TrimRight(v.Hdr.Name, "."), server)
|
cip, err := lookupName(strings.TrimRight(v.Hdr.Name, "."), server, debug)
|
||||||
if err != nil || cip == "" {
|
if err != nil || cip == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -61,7 +64,7 @@ func PerformZoneTransfer(config config.Config, debug bool) []string {
|
|||||||
ip = v.A.String()
|
ip = v.A.String()
|
||||||
hostname = v.Hdr.Name
|
hostname = v.Hdr.Name
|
||||||
case *dns.CNAME:
|
case *dns.CNAME:
|
||||||
cip, err := lookupName(v.Target, server)
|
cip, err := lookupName(v.Target, server, debug)
|
||||||
if err != nil || cip == "" {
|
if err != nil || cip == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,17 @@ package shell
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"rfi-sower/pkg/utils"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.linuxrocker.com/mattburchett/go_tab-magic/pkg/config"
|
"git.linuxrocker.com/mattburchett/go_tab-magic/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateShellAliases will create shell aliases and fmt.Println them
|
// CreateShellAliases will create shell aliases and fmt.Println them
|
||||||
func CreateShellAliases(data []string, username string, config config.Config) {
|
func CreateShellAliases(data []string, username string, config config.Config, debug bool) {
|
||||||
|
if debug {
|
||||||
|
defer utils.LogElapsedTime("Create Shell Aliases")
|
||||||
|
}
|
||||||
for _, i := range data {
|
for _, i := range data {
|
||||||
splitStrings := strings.Split(i, " ")
|
splitStrings := strings.Split(i, " ")
|
||||||
hostname := splitStrings[0]
|
hostname := splitStrings[0]
|
||||||
@ -63,8 +67,9 @@ func CreateShellAliases(data []string, username string, config config.Config) {
|
|||||||
remoteUser = user
|
remoteUser = user
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if debug {
|
||||||
if useJump {
|
fmt.Println("Disabled Output due to Debug Mode")
|
||||||
|
} else if useJump {
|
||||||
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'\n", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("alias %v=\\'%v %v %v %v %v %v\n", host, message, rac, racOpts, remoteUser, fqdn, sudo)
|
fmt.Printf("alias %v=\\'%v %v %v %v %v %v\n", host, message, rac, racOpts, remoteUser, fqdn, sudo)
|
||||||
|
Loading…
Reference in New Issue
Block a user