Allowing Commands to reconfigure app Configuration, this is will allow default ports to be currently added to remote presets

This commit is contained in:
NI
2020-02-23 17:23:24 +08:00
parent 697ee0b2a1
commit e7ca6d95ed
14 changed files with 212 additions and 79 deletions

View File

@@ -27,6 +27,7 @@ import (
"golang.org/x/crypto/ssh"
"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"
@@ -107,6 +108,10 @@ var (
sshEmptyTime = time.Time{}
)
const (
sshDefaultPortString = "22"
)
type sshRemoteConnWrapper struct {
net.Conn
@@ -198,6 +203,30 @@ func newSSH(
}
}
func parseSSHConfig(p configuration.Configuration) configuration.Configuration {
for i := range p.Presets {
if p.Presets[i].Type != "SSH" {
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,
sshDefaultPortString)
}
if len(p.Presets[i].Host) <= 0 {
p.Presets[i].Host = oldHost
}
}
return p
}
func (d *sshClient) Bootup(
r *rw.LimitedReader,
b []byte,