diff --git a/fakedevices/genericFakeDevice.go b/fakedevices/genericFakeDevice.go index 1374a6f..9c34f3c 100644 --- a/fakedevices/genericFakeDevice.go +++ b/fakedevices/genericFakeDevice.go @@ -15,6 +15,7 @@ type FakeDevice struct { Vendor string // Vendor of this fake device Platform string // Platform of this fake device Hostname string // Hostname of the fake device + DefaultHostname string // Default Hostname of the fake device (for resetting) Password string // Password of the fake device SupportedCommands SupportedCommands // What commands this fake device supports ContextSearch map[string]string // The available CLI prompt/contexts on this fake device @@ -70,6 +71,7 @@ func InitGeneric( Vendor: vendor, Platform: platform, Hostname: deviceHostname, + DefaultHostname: deviceHostname, Password: devicePassword, SupportedCommands: supportedCommands, ContextSearch: contextSearch, diff --git a/ssh_server/handlers/ciscohandlers.go b/ssh_server/handlers/ciscohandlers.go index 34ca11c..20783ea 100644 --- a/ssh_server/handlers/ciscohandlers.go +++ b/ssh_server/handlers/ciscohandlers.go @@ -68,6 +68,14 @@ func GenericCiscoHandler(myFakeDevice *fakedevices.FakeDevice) { ContextState = myFakeDevice.ContextHierarchy[ContextState] continue } + } else if userInput == "reset state" { + term.Write(append([]byte("Resetting State..."), '\n')) + ContextState = myFakeDevice.ContextSearch["base"] + myFakeDevice.Hostname = myFakeDevice.DefaultHostname + term.SetPrompt(string( + myFakeDevice.Hostname + ContextState, + )) + continue } // Split user input into fields @@ -108,7 +116,7 @@ func GenericCiscoHandler(myFakeDevice *fakedevices.FakeDevice) { continue } else { // If all else fails, we did not recognize the input! - term.Write(append([]byte("% Ambiguous command: \""+userInput+"\""), '\n')) + term.Write(append([]byte("% Unknown command: \""+userInput+"\""), '\n')) continue } }