Skip to content

Commit

Permalink
suppress logging messages when ctl+c interrupting
Browse files Browse the repository at this point in the history
update readme
  • Loading branch information
schollz committed Oct 11, 2018
1 parent f9b79ed commit af11143
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 5 additions & 1 deletion src/croc/croc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 4 additions & 1 deletion src/croc/sending.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit af11143

Please sign in to comment.