Skip to content

Commit

Permalink
Revert "Add "reset state" command to quickly revert state."
Browse files Browse the repository at this point in the history
This reverts commit 700bcf5.
  • Loading branch information
wrgeorge1983 committed Aug 28, 2020
1 parent f7a323d commit ddafd0e
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions cis.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ func sshListener(portNumber int, done chan bool) {
contextHierarchy["#"] = ">"
contextHierarchy[">"] = "exit"

defaultHostname := "cisgo1000v"
defaultContextState := ">"
hostname := defaultHostname
hostname := "cisgo1000v"
password := "admin"

specialCommands["show version"] = `Cisco IOS XE Software, Version 16.04.01
Expand Down Expand Up @@ -76,8 +74,7 @@ Processor board ID 9FKLJWM5EB0
3985132K bytes of physical memory.
7774207K bytes of virtual hard disk at bootflash:.
0K bytes of at webui:.
Configuration register is 0x2102
`
Configuration register is 0x2102`

basicCommands["show ip interface brief"] = `Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.0.2.27 YES NVRAM up up
Expand Down Expand Up @@ -279,7 +276,7 @@ end

// io.WriteString(s, fmt.Sprintf(SHOW_VERSION_PAGING_DISABLED))
term := terminal.NewTerminal(s, hostname+contextSearch["base"])
contextState := defaultContextState
contextState := ">"
for {
line, err := term.ReadLine()
if err != nil {
Expand All @@ -288,13 +285,7 @@ end

response := line
log.Println(line)
if response == "reset state" {
log.Println("resetting internal state")
contextState = defaultContextState
hostname = defaultHostname
term.SetPrompt(hostname + contextState)

} else if basicCommands[response] != "" {
if basicCommands[response] != "" {
// lookup supported commands for response
term.Write(append([]byte(basicCommands[response]), '\n'))

Expand Down Expand Up @@ -327,9 +318,6 @@ end
hostname = strings.Join(fields[1:], " ")
log.Printf("Setting hostname to %s\n", hostname)
term.SetPrompt(hostname + contextState)

} else {
term.Write(append([]byte("% Ambiguous command: \""+response+"\""), '\n'))
}

} else {
Expand Down

0 comments on commit ddafd0e

Please sign in to comment.