Get host ssh key handler
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8051310677
commit
9a37518431
1 changed files with 38 additions and 0 deletions
|
@ -51,6 +51,7 @@ func _messageHandler(m *nats.Msg) error {
|
|||
"start": startEventHandler,
|
||||
"restart": restartEventHandler,
|
||||
"get_deploy_ssh_keys": getDeploySSHKeysEventHandler,
|
||||
"get_ssh_host_key": getSSHHostKeyEventHandler,
|
||||
"update_keys": updateKeysEventHandler,
|
||||
"set_password": setPasswordEventHandler,
|
||||
"processes": processesEventHandler,
|
||||
|
@ -438,6 +439,43 @@ func getDeploySSHKeysEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Returns SSH host key
|
||||
func getSSHHostKeyEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
processor := glue.Processor{
|
||||
AppName: message.AppName,
|
||||
DB: common.GetDBConnection(),
|
||||
SnapshotProcessor: &snapshotProcessor,
|
||||
DockerSock: config.DockerSocket,
|
||||
BindIPHTTP: config.AppsBindIPHTTP,
|
||||
BindIPSSH: config.AppsBindIPSSH,
|
||||
AppsPath: config.AppsPath,
|
||||
}
|
||||
|
||||
hostKey, err := processor.GetHostKey()
|
||||
if err != nil {
|
||||
log.Printf("backend error: %v\n", err)
|
||||
return errorReplyFormater(m, "backend error", err)
|
||||
}
|
||||
|
||||
// Assembling reply message
|
||||
reply := ReplyMessage{
|
||||
Payload: hostKey,
|
||||
}
|
||||
|
||||
data, err := json.Marshal(reply)
|
||||
if err != nil {
|
||||
return errorReplyFormater(m, "reply formatter error", err)
|
||||
}
|
||||
|
||||
err = m.Respond(data)
|
||||
if err != nil {
|
||||
log.Println("ERROR: get app:", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Copies body of the request into /srv/.ssh/authorized_keys
|
||||
func updateKeysEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
body := message.Payload
|
||||
|
|
Loading…
Reference in a new issue