summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2015-03-18 13:43:48 +0100
committerDaniel Martí <mvdan@mvdan.cc>2015-03-18 13:44:59 +0100
commitced244c09f46d60715d17b8e09c609e08cac87ae (patch)
tree14110f1fbe1a6ab833857aa485fcc8bbca27a442
parent6d1b69d29985acd548895a6057aa755485785f6f (diff)
Reduce some if err != nil logic lines
-rw-r--r--obfs4proxy/obfs4proxy.go6
-rw-r--r--transports/obfs4/framing/framing.go6
-rw-r--r--transports/scramblesuit/handshake_uniformdh.go3
3 files changed, 5 insertions, 10 deletions
diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index da8f011..e489b57 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -230,8 +230,7 @@ func clientHandler(f base.ClientFactory, conn *pt.SocksConn, proxyURI *url.URL)
return
}
- err = copyLoop(conn, remote)
- if err != nil {
+ if err = copyLoop(conn, remote); err != nil {
warnf("%s(%s) - closed connection: %s", name, addrStr, elideError(err))
} else {
infof("%s(%s) - closed connection", name, addrStr)
@@ -323,8 +322,7 @@ func serverHandler(f base.ServerFactory, conn net.Conn, info *pt.ServerInfo) {
}
defer orConn.Close()
- err = copyLoop(orConn, remote)
- if err != nil {
+ if err = copyLoop(orConn, remote); err != nil {
warnf("%s(%s) - closed connection: %s", name, addrStr, elideError(err))
} else {
infof("%s(%s) - closed connection", name, addrStr)
diff --git a/transports/obfs4/framing/framing.go b/transports/obfs4/framing/framing.go
index 879765d..815a990 100644
--- a/transports/obfs4/framing/framing.go
+++ b/transports/obfs4/framing/framing.go
@@ -187,8 +187,7 @@ func (encoder *Encoder) Encode(frame, payload []byte) (n int, err error) {
// Generate a new nonce.
var nonce [nonceLength]byte
- err = encoder.nonce.bytes(&nonce)
- if err != nil {
+ if err = encoder.nonce.bytes(&nonce); err != nil {
return 0, err
}
encoder.nonce.counter++
@@ -256,8 +255,7 @@ func (decoder *Decoder) Decode(data []byte, frames *bytes.Buffer) (int, error) {
}
// Derive the nonce the peer used.
- err = decoder.nonce.bytes(&decoder.nextNonce)
- if err != nil {
+ if err = decoder.nonce.bytes(&decoder.nextNonce); err != nil {
return 0, err
}
diff --git a/transports/scramblesuit/handshake_uniformdh.go b/transports/scramblesuit/handshake_uniformdh.go
index 4345d65..4b77e5a 100644
--- a/transports/scramblesuit/handshake_uniformdh.go
+++ b/transports/scramblesuit/handshake_uniformdh.go
@@ -109,8 +109,7 @@ func (hs *ssDHClientHandshake) parseServerHandshake(resp []byte) (int, []byte, e
// Pull out the public key, and derive the server mark.
hs.serverPublicKey = &uniformdh.PublicKey{}
- err := hs.serverPublicKey.SetBytes(y)
- if err != nil {
+ if err := hs.serverPublicKey.SetBytes(y); err != nil {
return 0, nil, err
}
hs.mac.Reset()