Added unsigned option, and password checking.
This commit is contained in:
@ -24,13 +24,20 @@ func send(e Email, api keybase.ChatAPI) {
|
||||
log.LogDebug(message)
|
||||
log.LogInfo("Sending message")
|
||||
chat.React(api.Msg.ID, ":mailbox_with_no_mail:")
|
||||
if conf.KeyPass == "" {
|
||||
chat.React(api.Msg.ID, ":unlock:")
|
||||
} else {
|
||||
chat.React(api.Msg.ID, ":lock_with_ink_pen:")
|
||||
}
|
||||
err := smtp.SendMail(conf.SmtpServer,
|
||||
smtp.PlainAuth("", conf.MyEmail, conf.EmailPass, conf.AuthServer),
|
||||
conf.MyEmail, e.Recipients, []byte(message))
|
||||
chat.React(api.Msg.ID, ":mailbox_with_no_mail:")
|
||||
if err != nil {
|
||||
log.LogErrorType(err)
|
||||
chat.React(api.Msg.ID, ":warning:")
|
||||
return
|
||||
}
|
||||
chat.React(api.Msg.ID, ":mailbox_with_no_mail:")
|
||||
chat.React(api.Msg.ID, ":mailbox_with_mail:")
|
||||
log.LogInfo("Email Sent")
|
||||
}
|
||||
|
||||
18
main.go
18
main.go
@ -131,16 +131,22 @@ func loadConfig() Config {
|
||||
return c
|
||||
}
|
||||
func setupCredentials() {
|
||||
log.LogCritical("Enter pgp key passphrase:")
|
||||
log.LogCritical("Enter optional pgp key passphrase:")
|
||||
bytePass, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
log.LogCritical(fmt.Sprintf("Error reading pgp password:\n```%+v```", err))
|
||||
}
|
||||
conf.KeyPass = strings.TrimSpace(string(bytePass))
|
||||
log.LogCritical("Enter email passphrase:")
|
||||
bytePass, err = terminal.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
log.LogCritical(fmt.Sprintf("Error reading email password:\n```%+v```", err))
|
||||
if conf.KeyPass == "" {
|
||||
log.LogCritical("Starting without PGP signature capabilities.")
|
||||
}
|
||||
for i := len(conf.EmailPass); i < 1; i = len(conf.EmailPass) {
|
||||
log.LogCritical("Enter required email passphrase:")
|
||||
bytePass, err = terminal.ReadPassword(int(syscall.Stdin))
|
||||
if err != nil {
|
||||
log.LogCritical(fmt.Sprintf("Error reading email password:\n```%+v```", err))
|
||||
}
|
||||
conf.EmailPass = strings.TrimSpace(string(bytePass))
|
||||
|
||||
}
|
||||
conf.EmailPass = strings.TrimSpace(string(bytePass))
|
||||
}
|
||||
|
||||
@ -39,6 +39,9 @@ func getPrivateKey() *openpgp.Entity {
|
||||
}
|
||||
|
||||
func signMessage(m string) string {
|
||||
if conf.KeyPass == "" {
|
||||
return m
|
||||
}
|
||||
pk := getPrivateKey()
|
||||
out := new(bytes.Buffer)
|
||||
in, err := clearsign.Encode(out, pk.PrivateKey, nil)
|
||||
|
||||
Reference in New Issue
Block a user