From af11143cba54c3722e36b9cc2cc0039c8d7c0594 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Thu, 11 Oct 2018 06:39:17 -0700 Subject: [PATCH] suppress logging messages when ctl+c interrupting update readme --- README.md | 2 +- src/croc/croc.go | 6 +++++- src/croc/sending.go | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1e389bfc..ebf3516f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ## Overview -*croc* uses "code phrases" to securely transfer files. A code phrase is a combination of three random words which the sender shares with the recipient. The code phrase is used by the sender and recipient for password authenticated key exchange ([PAKE](https://github.com/schollz/pake)) to validate parties and generate a secure session key for end-to-end encryption. Since a code phrase can only be used once between two parties, an attacker only has a 1 in 16,777,216 chance to guess the right code phrase to steal the file, any attacker with the wrong code phrase will fail the PAKE and the sender will be notified. Only two people with the right code phrase will be able to computers transfer encrypted data through a relay. +*croc* uses "code phrases" to securely transfer files. A code phrase is a combination of three random words (mnemonicoded 4 bytes) which the sender shares with the recipient. The code phrase is used by the sender and recipient for password authenticated key exchange ([PAKE](https://github.com/schollz/pake)) to validate parties and generate a secure session key for end-to-end encryption. Since a code phrase can only be used once between two parties, an attacker has a chance of less than 1 in *4 billion* to guess the right code phrase to steal the file. Any attacker with the wrong code phrase will fail the PAKE and the sender will be notified. Only two people with the right code phrase will be able to computers transfer encrypted data through a relay. The actual data transfer is accomplished using a relay, either using raw TCP sockets or websockets. If both computers are on the LAN network then *croc* will use a local relay, otherwise a public relay is used. All the data going through the relay is encrypted using the PAKE-generated session key, so the relay can't spy on information passing through it. The data is transferred in blocks, where each block is compressed and encrypted, and the recipient keeps track of blocks received so that it can resume the transfer if interrupted. diff --git a/src/croc/croc.go b/src/croc/croc.go index 30618cd3..72eda0f4 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -72,10 +72,14 @@ func Init(debug bool) (c *Croc) { debugLevel = "debug" c.Debug = true } + SetDebugLevel(debugLevel) + return +} + +func SetDebugLevel(debugLevel string) { logger.SetLogLevel(debugLevel) sender.DebugLevel = debugLevel recipient.DebugLevel = debugLevel relay.DebugLevel = debugLevel zipper.DebugLevel = debugLevel - return } diff --git a/src/croc/sending.go b/src/croc/sending.go index 846b4982..98f9632a 100644 --- a/src/croc/sending.go +++ b/src/croc/sending.go @@ -135,7 +135,7 @@ func (c *Croc) sendReceive(address, websocketPort string, tcpPorts []string, fna return fmt.Errorf("codephrase is too short") } - // allow interrupts + // allow interrupts from Ctl+C interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, os.Interrupt) @@ -171,6 +171,9 @@ func (c *Croc) sendReceive(address, websocketPort string, tcpPorts []string, fna case <-done: return nil case <-interrupt: + if !c.Debug { + SetDebugLevel("critical") + } log.Debug("interrupt") err = sock.WriteMessage(websocket.TextMessage, []byte("interrupt")) if err != nil {