Skip to content

Commit af11143

Browse files
committed
suppress logging messages when ctl+c interrupting
update readme
1 parent f9b79ed commit af11143

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
## Overview
1717

18-
*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.
18+
*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.
1919

2020
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.
2121

src/croc/croc.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,14 @@ func Init(debug bool) (c *Croc) {
7272
debugLevel = "debug"
7373
c.Debug = true
7474
}
75+
SetDebugLevel(debugLevel)
76+
return
77+
}
78+
79+
func SetDebugLevel(debugLevel string) {
7580
logger.SetLogLevel(debugLevel)
7681
sender.DebugLevel = debugLevel
7782
recipient.DebugLevel = debugLevel
7883
relay.DebugLevel = debugLevel
7984
zipper.DebugLevel = debugLevel
80-
return
8185
}

src/croc/sending.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func (c *Croc) sendReceive(address, websocketPort string, tcpPorts []string, fna
135135
return fmt.Errorf("codephrase is too short")
136136
}
137137

138-
// allow interrupts
138+
// allow interrupts from Ctl+C
139139
interrupt := make(chan os.Signal, 1)
140140
signal.Notify(interrupt, os.Interrupt)
141141

@@ -171,6 +171,9 @@ func (c *Croc) sendReceive(address, websocketPort string, tcpPorts []string, fna
171171
case <-done:
172172
return nil
173173
case <-interrupt:
174+
if !c.Debug {
175+
SetDebugLevel("critical")
176+
}
174177
log.Debug("interrupt")
175178
err = sock.WriteMessage(websocket.TextMessage, []byte("interrupt"))
176179
if err != nil {

0 commit comments

Comments
 (0)