-
Notifications
You must be signed in to change notification settings - Fork 26
/
cissh.go
34 lines (27 loc) · 1.12 KB
/
cissh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"github.com/tbotnz/cisshgo/fakedevices"
"github.com/tbotnz/cisshgo/ssh_server/handlers"
"github.com/tbotnz/cisshgo/ssh_server/sshlistners"
"github.com/tbotnz/cisshgo/utils"
)
func main() {
// Parse the command line arguments
numListeners, startingPortPtr, myTranscriptMap := utils.ParseArgs()
// Initialize our fake device
myFakeDevice := fakedevices.InitGeneric(
"cisco", // Vendor
"csr1000v", // Platform
myTranscriptMap, // Transcript map with locations of command output to play back
)
// Make a Channel named "done" for handling Goroutines, which expects a bool as return value
done := make(chan bool, 1)
// Iterate through the server ports and spawn a Goroutine for each
for portNumber := *startingPortPtr; portNumber < numListeners; portNumber++ {
// Today this is just spawning a generic listener.
// In the future, this is where we could split out listeners/handlers by device type.
go sshlistners.GenericListener(myFakeDevice, portNumber, handlers.GenericCiscoHandler, done)
}
// Receive all the values from the channel (essentially wait on it to be empty)
<-done
}