mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-02-01 23:21:59 +01:00
working on remote:new
This commit is contained in:
parent
62c3390d31
commit
23759b7283
@ -563,6 +563,7 @@ func RemoteNewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss
|
||||
}
|
||||
if pk.Kwargs["key"] != "" {
|
||||
keyFile := pk.Kwargs["key"]
|
||||
keyFile = base.ExpandHomeDir(keyFile)
|
||||
fd, err := os.Open(keyFile)
|
||||
if fd != nil {
|
||||
fd.Close()
|
||||
@ -572,6 +573,17 @@ func RemoteNewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (ss
|
||||
}
|
||||
sshOpts.SSHIdentity = keyFile
|
||||
}
|
||||
if pk.Kwargs["port"] != "" {
|
||||
portStr := pk.Kwargs["port"]
|
||||
portVal, err := strconv.Atoi(portStr)
|
||||
if err != nil {
|
||||
return makeRemoteEditErrorReturn(visualEdit, fmt.Errorf("/remote:new invalid port %q: %v", portStr, err))
|
||||
}
|
||||
if portVal <= 0 {
|
||||
return makeRemoteEditErrorReturn(visualEdit, fmt.Errorf("/remote:new invalid port %d (must be positive)", portVal))
|
||||
}
|
||||
sshOpts.SSHPort = portVal
|
||||
}
|
||||
remoteOpts := &sstore.RemoteOptsType{}
|
||||
if pk.Kwargs["color"] != "" {
|
||||
color := pk.Kwargs["color"]
|
||||
|
@ -123,7 +123,7 @@ func UpsertRemote(ctx context.Context, r *RemoteType) error {
|
||||
if tx.Exists(query, r.RemoteCanonicalName) {
|
||||
return fmt.Errorf("remote has duplicate canonicalname '%s', cannot create", r.RemoteCanonicalName)
|
||||
}
|
||||
query = `SELECT remoteid FROM remote WHERE alias = ?`
|
||||
query = `SELECT remoteid FROM remote WHERE remotealias = ?`
|
||||
if r.RemoteAlias != "" && tx.Exists(query, r.RemoteAlias) {
|
||||
return fmt.Errorf("remote has duplicate alias '%s', cannot create", r.RemoteAlias)
|
||||
}
|
||||
|
@ -470,11 +470,12 @@ type LineType struct {
|
||||
}
|
||||
|
||||
type SSHOpts struct {
|
||||
Local bool `json:"local"`
|
||||
Local bool `json:"local,omitempty"`
|
||||
SSHHost string `json:"sshhost"`
|
||||
SSHOptsStr string `json:"sshopts"`
|
||||
SSHIdentity string `json:"sshidentity"`
|
||||
SSHUser string `json:"sshuser"`
|
||||
SSHOptsStr string `json:"sshopts,omitempty"`
|
||||
SSHIdentity string `json:"sshidentity,omitempty"`
|
||||
SSHPort int `json:"sshport,omitempty"`
|
||||
}
|
||||
|
||||
type RemoteOptsType struct {
|
||||
|
Loading…
Reference in New Issue
Block a user