From 2c60bcd1923d73c3e8c6ee25f2bcbf07701a2c8a Mon Sep 17 00:00:00 2001 From: joshemb <josh@elixxir.io> Date: Wed, 3 Aug 2022 16:18:44 -0700 Subject: [PATCH] Remove disconnect flag --- cmd/connect.go | 38 +++++++++++++++++++------------------- cmd/flags.go | 1 - 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/cmd/connect.go b/cmd/connect.go index efbd9ddfd..e8697dc60 100644 --- a/cmd/connect.go +++ b/cmd/connect.go @@ -147,7 +147,6 @@ func secureConnServer(forceLegacy bool, statePass []byte, statePath, regCode str case conn := <-connChan: // Perform functionality shared by client & server miscConnectionFunctions(connectServer.User, conn) - case <-connectionTimeout.C: connectionTimeout.Stop() jww.FATAL.Panicf("[CONN] Failed to establish connection within " + @@ -375,6 +374,15 @@ func secureConnClient(forceLegacy bool, statePass []byte, statePath, regCode str miscConnectionFunctions(user, conn) + // Close the connection + if err = conn.Close(); err != nil { + jww.FATAL.Panicf("Failed to disconnect with %s: %v", + conn.GetPartner().PartnerId(), err) + } + jww.INFO.Printf("[CONN] Disconnected from %s", + conn.GetPartner().PartnerId()) + fmt.Println("Disconnected from partner") + } // Insecure (unauthenticated) connection client path @@ -450,6 +458,16 @@ func insecureConnClient(forceLegacy bool, statePass []byte, statePath, regCode s jww.INFO.Printf("[CONN] Established connection with %s", handler.GetPartner().PartnerId()) miscConnectionFunctions(user, handler) + + // Close the connection + if err = handler.Close(); err != nil { + jww.FATAL.Panicf("Failed to disconnect with %s: %v", + handler.GetPartner().PartnerId(), err) + } + jww.INFO.Printf("[CONN] Disconnected from %s", + handler.GetPartner().PartnerId()) + fmt.Println("Disconnected from partner") + } //////////////////////////////////////////////////////////////////////////////////////////// @@ -488,17 +506,6 @@ func miscConnectionFunctions(user *xxdk.E2e, conn connect.Connection) { } } - // Disconnect from connection partner-------------------------------------------- - if viper.GetBool(connectionDisconnectFlag) { - // Close the connection - if err := conn.Close(); err != nil { - jww.FATAL.Panicf("Failed to disconnect with %s: %v", - conn.GetPartner().PartnerId(), err) - } - jww.INFO.Printf("[CONN] Disconnected from %s", - conn.GetPartner().PartnerId()) - fmt.Println("Disconnected from partner") - } } /////////////////////////////////////////////////////////////////////////////// @@ -556,13 +563,6 @@ func init() { "long-running.") bindFlagHelper(connectionServerTimeoutFlag, connectionCmd) - connectionCmd.Flags().Bool(connectionDisconnectFlag, false, - "This flag is available to both server and client. "+ - "This uses a contact object from a file specified by --destfile."+ - "This will close the connection with the given contact "+ - "if it exists.") - bindFlagHelper(connectionDisconnectFlag, connectionCmd) - connectionCmd.Flags().Bool(connectionAuthenticatedFlag, false, "This flag is available to both server and client. "+ "This flag operates as a switch for the authenticated code-path. "+ diff --git a/cmd/flags.go b/cmd/flags.go index 8d9c827f2..93b5d505d 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -98,7 +98,6 @@ const ( connectionFlag = "connect" connectionStartServerFlag = "startServer" connectionServerTimeoutFlag = "serverTimeout" - connectionDisconnectFlag = "disconnect" connectionAuthenticatedFlag = "authenticated" connectionEphemeralFlag = "ephemeral" -- GitLab