diff --git a/cmd/connect.go b/cmd/connect.go index efbd9ddfd36a055f54ba662316ff4f2015fcd861..e8697dc60b8f0b5181df175274e12e881ce12b78 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 8d9c827f2b38cb2ff1668cc9431922fc32eaa99e..93b5d505d77f4846f80d1cda6b32bfa29a0ad3cf 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"