mirror of
https://github.com/shanghai-edu/multissh.git
synced 2025-12-16 21:37:50 +00:00
0.2.1-version
This commit is contained in:
parent
87e207932f
commit
378c12a285
3 changed files with 29 additions and 5 deletions
16
g/cfg.go
16
g/cfg.go
|
|
@ -100,7 +100,21 @@ func WriteIntoTxt(sshResult SSHResult) error {
|
||||||
return nil
|
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)
|
res, err := Getfile(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ package g
|
||||||
// 0.1 fisrt version
|
// 0.1 fisrt version
|
||||||
// 0.1.2 fix ssh error on h3c switch
|
// 0.1.2 fix ssh error on h3c switch
|
||||||
// 0.2
|
// 0.2
|
||||||
|
// 0.2.1
|
||||||
const (
|
const (
|
||||||
VERSION = "0.2"
|
VERSION = "0.2.1"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
15
main.go
15
main.go
|
|
@ -16,6 +16,7 @@ import (
|
||||||
func main() {
|
func main() {
|
||||||
version := flag.Bool("v", false, "show version")
|
version := flag.Bool("v", false, "show version")
|
||||||
hosts := flag.String("hosts", "", "host address list")
|
hosts := flag.String("hosts", "", "host address list")
|
||||||
|
ips := flag.String("ips", "", "ip address list")
|
||||||
cmds := flag.String("cmds", "", "cmds")
|
cmds := flag.String("cmds", "", "cmds")
|
||||||
username := flag.String("u", "", "username")
|
username := flag.String("u", "", "username")
|
||||||
password := flag.String("p", "", "password")
|
password := flag.String("p", "", "password")
|
||||||
|
|
@ -24,7 +25,7 @@ func main() {
|
||||||
ciphers := flag.String("ciphers", "", "ciphers")
|
ciphers := flag.String("ciphers", "", "ciphers")
|
||||||
cmdFile := flag.String("cmdfile", "", "cmdfile path")
|
cmdFile := flag.String("cmdfile", "", "cmdfile path")
|
||||||
hostFile := flag.String("hostfile", "", "hostfile 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")
|
cfgFile := flag.String("c", "", "cfg File Path")
|
||||||
jsonMode := flag.Bool("j", false, "print output in json format")
|
jsonMode := flag.Bool("j", false, "print output in json format")
|
||||||
outTxt := flag.Bool("outTxt", false, "write result into txt")
|
outTxt := flag.Bool("outTxt", false, "write result into txt")
|
||||||
|
|
@ -46,9 +47,9 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *ipFile != "" {
|
if *ipFile != "" {
|
||||||
hostList, err = g.GetIpList(*ipFile)
|
hostList, err = g.GetIpListFromFile(*ipFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("load hostlist error: ", err)
|
log.Println("load iplist error: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -60,6 +61,14 @@ func main() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if *ips != "" {
|
||||||
|
hostList, err = g.GetIpList(*ips)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("load iplist error: ", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if *hosts != "" {
|
if *hosts != "" {
|
||||||
hostList = g.SplitString(*hosts)
|
hostList = g.SplitString(*hosts)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue