|
|
|
@ -120,6 +120,7 @@ func main() {
|
|
|
|
|
flagOxImportPrivKey := getopt.StringLong("ox-import-privkey", 0, "",
|
|
|
|
|
"Import an existing private OpenPGP key.")
|
|
|
|
|
flagOxDeleteNodes := getopt.BoolLong("ox-delete-nodes", 0, "Delete existing OpenPGP nodes on the server.")
|
|
|
|
|
flagOOBFile := getopt.StringLong("oob-file", 0, "", "URL to send a file as out of band data.")
|
|
|
|
|
|
|
|
|
|
// Parse command line flags.
|
|
|
|
|
getopt.Parse()
|
|
|
|
@ -146,6 +147,8 @@ func main() {
|
|
|
|
|
case *flagHTTPUpload != "" && *flagMessageFile != "":
|
|
|
|
|
log.Fatal("You can't send a message while using" +
|
|
|
|
|
" http upload.")
|
|
|
|
|
case *flagOx && *flagOOBFile != "":
|
|
|
|
|
log.Fatal("No encryption possible for OOB data.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Read recipients from command line and quit if none are specified.
|
|
|
|
@ -270,7 +273,7 @@ func main() {
|
|
|
|
|
// Also for listening mode and Ox key handling.
|
|
|
|
|
if !*flagInteractive && !*flagListen && *flagHTTPUpload == "" &&
|
|
|
|
|
!*flagOxDeleteNodes && *flagOxImportPrivKey == "" &&
|
|
|
|
|
!*flagOxGenPrivKeyX25519 && !*flagOxGenPrivKeyRSA &&
|
|
|
|
|
!*flagOxGenPrivKeyX25519 && !*flagOxGenPrivKeyRSA && *flagOOBFile == "" &&
|
|
|
|
|
message == "" {
|
|
|
|
|
|
|
|
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
|
|
@ -295,7 +298,7 @@ func main() {
|
|
|
|
|
// Exit if message is empty.
|
|
|
|
|
if message == "" && !*flagInteractive && !*flagListen && !*flagOxGenPrivKeyRSA &&
|
|
|
|
|
!*flagOxGenPrivKeyX25519 && *flagOxImportPrivKey == "" &&
|
|
|
|
|
!*flagOxDeleteNodes && *flagHTTPUpload == "" {
|
|
|
|
|
!*flagOxDeleteNodes && *flagHTTPUpload == "" && *flagOOBFile == "" {
|
|
|
|
|
os.Exit(0)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -389,6 +392,16 @@ func main() {
|
|
|
|
|
*flagHTTPUpload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if *flagOOBFile != "" {
|
|
|
|
|
// Remove invalid UTF8 code points.
|
|
|
|
|
message = validUTF8(*flagOOBFile)
|
|
|
|
|
// Check if the URI is valid.
|
|
|
|
|
_, err := validURI(message)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var msgType string
|
|
|
|
|
msgType = "chat"
|
|
|
|
|
if *flagChatroom {
|
|
|
|
@ -532,7 +545,7 @@ func main() {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
switch {
|
|
|
|
|
case *flagHTTPUpload != "":
|
|
|
|
|
case *flagHTTPUpload != "" || *flagOOBFile != "":
|
|
|
|
|
_, err = client.Send(xmpp.Chat{Remote: recipient.Jid,
|
|
|
|
|
Type: msgType, Ooburl: message, Text: message})
|
|
|
|
|
if err != nil {
|
|
|
|
|