From b773131f9e83bf514b1a23dedf1d05c414d8c4b5 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Tue, 5 Sep 2023 20:39:54 +0200 Subject: [PATCH] Remove deprecated flag resource. --- CHANGELOG.md | 3 +++ main.go | 31 +++++-------------------------- parseconfig.go | 3 --- 3 files changed, 8 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d790466..5edac8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ - Remove unnecessary newlines after stanzas. - Fix segfault when authentication fails due to invalid username or password. +## Removed +- Removed deprecated flag and config option `resource`. + ## [v0.6.1] 2023-07-25 ### Changed - Properly close connection to server. diff --git a/main.go b/main.go index 858823a..f2996de 100644 --- a/main.go +++ b/main.go @@ -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) diff --git a/parseconfig.go b/parseconfig.go index 5d3a9c4..60efa58 100644 --- a/parseconfig.go +++ b/parseconfig.go @@ -120,9 +120,6 @@ func parseConfig(configPath string) (configuration, error) { } case "port:": output.port = row[1] - case "resource:": - output.resource = row[1] - fmt.Println(configPath+":", "Deprecated option: resource.") case "alias:": output.alias = row[1] default: