Skip to content

Commit

Permalink
0.2.1-version
Browse files Browse the repository at this point in the history
  • Loading branch information
freedomkk-qfeng committed Jan 20, 2018
1 parent 87e2079 commit 378c12a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
16 changes: 15 additions & 1 deletion g/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@ func WriteIntoTxt(sshResult SSHResult) error {
return nil
}

func GetIpList(filePath string) ([]string, error) {
func GetIpList(ipString string) ([]string, error) {
res := SplitString(ipString)
var allIp []string
if len(res) > 0 {
for _, sip := range res {
aip := ParseIp(sip)
for _, ip := range aip {
allIp = append(allIp, ip)
}
}
}
return allIp, nil
}

func GetIpListFromFile(filePath string) ([]string, error) {
res, err := Getfile(filePath)
if err != nil {
return nil, nil
Expand Down
3 changes: 2 additions & 1 deletion g/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package g
// 0.1 fisrt version
// 0.1.2 fix ssh error on h3c switch
// 0.2
// 0.2.1
const (
VERSION = "0.2"
VERSION = "0.2.1"
)
15 changes: 12 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
func main() {
version := flag.Bool("v", false, "show version")
hosts := flag.String("hosts", "", "host address list")
ips := flag.String("ips", "", "ip address list")
cmds := flag.String("cmds", "", "cmds")
username := flag.String("u", "", "username")
password := flag.String("p", "", "password")
Expand All @@ -24,7 +25,7 @@ func main() {
ciphers := flag.String("ciphers", "", "ciphers")
cmdFile := flag.String("cmdfile", "", "cmdfile path")
hostFile := flag.String("hostfile", "", "hostfile path")
ipFile := flag.String("ipfile", "", "hostfile path")
ipFile := flag.String("ipfile", "", "ipfile path")
cfgFile := flag.String("c", "", "cfg File Path")
jsonMode := flag.Bool("j", false, "print output in json format")
outTxt := flag.Bool("outTxt", false, "write result into txt")
Expand All @@ -46,9 +47,9 @@ func main() {
}

if *ipFile != "" {
hostList, err = g.GetIpList(*ipFile)
hostList, err = g.GetIpListFromFile(*ipFile)
if err != nil {
log.Println("load hostlist error: ", err)
log.Println("load iplist error: ", err)
return
}
}
Expand All @@ -60,6 +61,14 @@ func main() {
return
}
}
if *ips != "" {
hostList, err = g.GetIpList(*ips)
if err != nil {
log.Println("load iplist error: ", err)
return
}
}

if *hosts != "" {
hostList = g.SplitString(*hosts)
}
Expand Down

0 comments on commit 378c12a

Please sign in to comment.