Allowing Commands to reconfigure app Configuration, this is will allow default ports to be currently added to remote presets
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/niruix/sshwifty/application/command"
|
||||
"github.com/niruix/sshwifty/application/configuration"
|
||||
"github.com/niruix/sshwifty/application/log"
|
||||
"github.com/niruix/sshwifty/application/network"
|
||||
"github.com/niruix/sshwifty/application/rw"
|
||||
@@ -40,6 +41,10 @@ const (
|
||||
TelnetRequestErrorBadRemoteAddress = command.StreamError(0x01)
|
||||
)
|
||||
|
||||
const (
|
||||
telnetDefaultPortString = "23"
|
||||
)
|
||||
|
||||
// Server signal codes
|
||||
const (
|
||||
TelnetServerRemoteBand = 0x00
|
||||
@@ -71,6 +76,32 @@ func newTelnet(
|
||||
}
|
||||
}
|
||||
|
||||
func parseTelnetConfig(
|
||||
p configuration.Configuration,
|
||||
) configuration.Configuration {
|
||||
for i := range p.Presets {
|
||||
if p.Presets[i].Type != "Telnet" {
|
||||
continue
|
||||
}
|
||||
|
||||
oldHost := p.Presets[i].Host
|
||||
|
||||
_, _, sErr := net.SplitHostPort(p.Presets[i].Host)
|
||||
|
||||
if sErr != nil {
|
||||
p.Presets[i].Host = net.JoinHostPort(
|
||||
p.Presets[i].Host,
|
||||
telnetDefaultPortString)
|
||||
}
|
||||
|
||||
if len(p.Presets[i].Host) <= 0 {
|
||||
p.Presets[i].Host = oldHost
|
||||
}
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
func (d *telnetClient) Bootup(
|
||||
r *rw.LimitedReader,
|
||||
b []byte) (command.FSMState, command.FSMError) {
|
||||
|
||||
Reference in New Issue
Block a user