summaryrefslogtreecommitdiff
path: root/framing
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2014-05-12 23:04:39 +0000
committerYawning Angel <yawning@schwanenlied.me>2014-05-12 23:04:39 +0000
commit51a8dd5a86eeca744e0add680b1f4796c4babe2b (patch)
tree94fa1900ae3a230a23460df57151b618183b0b24 /framing
parentc3acefb7e5aa5ef4cd65fc77ad4caa917efda130 (diff)
Fix logging again.
On second thought instead of using log.Panicf(), panic() and do the logging with recover(). This somewhat centralizes logging in obfs4proxy, which will be easier to change when I invariably decide to do logging differently in the future.
Diffstat (limited to 'framing')
-rw-r--r--framing/framing.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/framing/framing.go b/framing/framing.go
index 75b9a73..62170ae 100644
--- a/framing/framing.go
+++ b/framing/framing.go
@@ -61,7 +61,6 @@ import (
"errors"
"fmt"
"hash"
- "log"
"code.google.com/p/go.crypto/nacl/secretbox"
@@ -127,7 +126,7 @@ type boxNonce struct {
func (nonce *boxNonce) init(prefix []byte) {
if noncePrefixLength != len(prefix) {
- log.Panicf("BUG: Nonce prefix length invalid: %d", len(prefix))
+ panic(fmt.Sprintf("BUG: Nonce prefix length invalid: %d", len(prefix)))
}
copy(nonce.prefix[:], prefix)
@@ -161,7 +160,7 @@ type Encoder struct {
// containing exactly KeyLength bytes of keying material.
func NewEncoder(key []byte) *Encoder {
if len(key) != KeyLength {
- log.Panicf("BUG: Invalid encoder key length: %d", len(key))
+ panic(fmt.Sprintf("BUG: Invalid encoder key length: %d", len(key)))
}
encoder := new(Encoder)
@@ -223,7 +222,7 @@ type Decoder struct {
// containing exactly KeyLength bytes of keying material.
func NewDecoder(key []byte) *Decoder {
if len(key) != KeyLength {
- log.Panicf("BUG: Invalid decoder key length: %d", len(key))
+ panic(fmt.Sprintf("BUG: Invalid decoder key length: %d", len(key)))
}
decoder := new(Decoder)
@@ -253,7 +252,7 @@ func (decoder *Decoder) Decode(data *bytes.Buffer) (int, []byte, error) {
return 0, nil, err
} else if n != lengthLength {
// Should *NEVER* happen, since at least 2 bytes exist.
- log.Panicf("BUG: Failed to read obfuscated length: %d", n)
+ panic(fmt.Sprintf("BUG: Failed to read obfuscated length: %d", n))
}
// Derive the nonce the peer used.
@@ -285,8 +284,8 @@ func (decoder *Decoder) Decode(data *bytes.Buffer) (int, []byte, error) {
return 0, nil, err
} else if n != int(decoder.nextLength) {
// Should *NEVER* happen, since at least 2 bytes exist.
- log.Panicf("BUG: Failed to read secretbox, got %d, should have %d", n,
- decoder.nextLength)
+ panic(fmt.Sprintf("BUG: Failed to read secretbox, got %d, should have %d",
+ n, decoder.nextLength))
}
out, ok := secretbox.Open(nil, box, &decoder.nextNonce, &decoder.key)
if !ok {