Adding things.
This commit is contained in:
@ -12,6 +12,8 @@ type Config struct {
|
||||
Resolver string `json:"resolver"`
|
||||
ResolverPort int `json:"resolverPort"`
|
||||
Domains []string `json:"domains"`
|
||||
JumpHost string `json:"jumpHost"`
|
||||
SplitString string `json:"splitString"`
|
||||
}
|
||||
|
||||
//GetConfig gets the configuration values for the api using the file in the supplied configPath.
|
||||
|
@ -30,7 +30,7 @@ func lookupName(fqdn, serverAddr string) (string, error) {
|
||||
return "", errors.New("no A record returned")
|
||||
}
|
||||
|
||||
func PerformZoneTransfer(config config.Config) {
|
||||
func PerformZoneTransfer(config config.Config) []string {
|
||||
data := make([]string, 0)
|
||||
|
||||
// Do the transfer
|
||||
@ -73,10 +73,13 @@ func PerformZoneTransfer(config config.Config) {
|
||||
}
|
||||
}
|
||||
fmt.Println(data)
|
||||
resultsToJSON(data)
|
||||
// resultsToJSON(data)
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
func resultsToJSON(data []string) {
|
||||
jsonData := make([][]byte, 0)
|
||||
for _, i := range data {
|
||||
splitStrings := strings.Split(i, " ")
|
||||
hostname := splitStrings[0]
|
||||
@ -87,7 +90,7 @@ func resultsToJSON(data []string) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(string(b))
|
||||
jsonData = append(jsonData, b)
|
||||
|
||||
}
|
||||
|
||||
|
40
pkg/shell/shell.go
Normal file
40
pkg/shell/shell.go
Normal file
@ -0,0 +1,40 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.linuxrocker.com/mattburchett/go_tab-magic/pkg/config"
|
||||
)
|
||||
|
||||
func CreateShellAliases(data []string, username string, config config.Config) {
|
||||
for _, i := range data {
|
||||
splitStrings := strings.Split(i, " ")
|
||||
hostname := splitStrings[0]
|
||||
txt := splitStrings[2]
|
||||
|
||||
jump := config.JumpHost
|
||||
stringSplit := config.SplitString
|
||||
|
||||
remoteUser := username
|
||||
sudo := "sudo su -"
|
||||
rac := "ssh"
|
||||
racOpts := "-AXt -l"
|
||||
hop := "ssh -AXt"
|
||||
prerac := ""
|
||||
|
||||
host := strings.TrimRight(hostname, stringSplit)
|
||||
fqdn := strings.TrimLeft(hostname, stringSplit)
|
||||
|
||||
greentext := "tput -T xterm setaf 2; "
|
||||
// redtext := "tput -T xterm setaf 1; "
|
||||
resettext := "tput -T xterm sgr0; "
|
||||
message := fmt.Sprintf("%vecho \"Authenticating as: %v\";%v", greentext, remoteUser, resettext)
|
||||
|
||||
if txt == "" {
|
||||
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
||||
} else {
|
||||
fmt.Printf("alias %v=\\'%v%v%v %v@%v \"%v %v %v %v %v\"'", host, message, prerac, hop, username, jump, rac, racOpts, remoteUser, fqdn, sudo)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user