|
|
|
@ -27,7 +27,6 @@ type configuration struct {
|
|
|
|
|
jserver string
|
|
|
|
|
port string
|
|
|
|
|
password string
|
|
|
|
|
resource string
|
|
|
|
|
alias string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -79,10 +78,10 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
err error
|
|
|
|
|
message, user, server, password, resource, alias string
|
|
|
|
|
oxPrivKey *crypto.Key
|
|
|
|
|
recipients []recipientsType
|
|
|
|
|
err error
|
|
|
|
|
message, user, server, password, alias string
|
|
|
|
|
oxPrivKey *crypto.Key
|
|
|
|
|
recipients []recipientsType
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// Define command line flags.
|
|
|
|
@ -94,8 +93,6 @@ func main() {
|
|
|
|
|
flagPassword := getopt.StringLong("password", 'p', "", "Password for XMPP account.")
|
|
|
|
|
flagChatroom := getopt.BoolLong("chatroom", 'c', "Send message to a chatroom.")
|
|
|
|
|
flagDirectTLS := getopt.BoolLong("tls", 't', "Use direct TLS.")
|
|
|
|
|
flagResource := getopt.StringLong("resource", 'r', "", "Set resource. "+
|
|
|
|
|
"When sending to a chatroom this is used as 'alias'. DEPRECATED: Use --alias instead.")
|
|
|
|
|
flagAlias := getopt.StringLong("alias", 'a', "", "Set alias/nickname"+
|
|
|
|
|
"for chatrooms.")
|
|
|
|
|
flagFile := getopt.StringLong("file", 'f', "", "Set configuration file. (Default: "+
|
|
|
|
@ -180,7 +177,6 @@ func main() {
|
|
|
|
|
user = config.username
|
|
|
|
|
server = config.jserver
|
|
|
|
|
password = config.password
|
|
|
|
|
resource = config.resource
|
|
|
|
|
alias = config.alias
|
|
|
|
|
if config.port != "" {
|
|
|
|
|
server = net.JoinHostPort(server, fmt.Sprint(config.port))
|
|
|
|
@ -203,14 +199,6 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
|
// Use the resource as alias if no alias is specified otherwise but a resource is specified.
|
|
|
|
|
// Backward compat, will be removed when resource is removed.
|
|
|
|
|
case alias == "" && *flagAlias == "" && *flagResource != "":
|
|
|
|
|
alias = *flagResource
|
|
|
|
|
// Use the resource as alias if no alias is specified otherwise but a resource is specified.
|
|
|
|
|
// Backward compat, will be removed when resource is removed.
|
|
|
|
|
case alias == "" && *flagAlias == "" && resource != "":
|
|
|
|
|
alias = resource
|
|
|
|
|
// Use "go-sendxmpp" if no nick is specified via config or command line flag.
|
|
|
|
|
case alias == "" && *flagAlias == "":
|
|
|
|
|
alias = "go-sendxmpp"
|
|
|
|
@ -219,15 +207,6 @@ func main() {
|
|
|
|
|
alias = *flagAlias
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Overwrite resource if specified via command line flag.
|
|
|
|
|
if *flagResource != "" {
|
|
|
|
|
fmt.Println("Deprecated flag: --resource.")
|
|
|
|
|
resource = *flagResource
|
|
|
|
|
} else if resource == "" {
|
|
|
|
|
// Use "go-sendxmpp" plus a random string if no other resource is specified.
|
|
|
|
|
resource = "go-sendxmpp." + getShortID()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Timeout
|
|
|
|
|
timeout := time.Duration(*flagTimeout) * time.Second
|
|
|
|
|
|
|
|
|
@ -255,7 +234,7 @@ func main() {
|
|
|
|
|
Host: server,
|
|
|
|
|
User: user,
|
|
|
|
|
DialTimeout: timeout,
|
|
|
|
|
Resource: resource,
|
|
|
|
|
Resource: "go-sendxmpp." + getShortID(),
|
|
|
|
|
Password: password,
|
|
|
|
|
// NoTLS doesn't mean that no TLS is used at all but that instead
|
|
|
|
|
// of using an encrypted connection to the server (direct TLS)
|
|
|
|
|