[Pkg-privacy-commits] [obfs4proxy] 131/151: Reduce some if err != nil logic lines

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:59:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfs4proxy.

commit ced244c09f46d60715d17b8e09c609e08cac87ae
Author: Daniel Martí <mvdan at mvdan.cc>
Date:   Wed Mar 18 13:43:48 2015 +0100

    Reduce some if err != nil logic lines
---
 obfs4proxy/obfs4proxy.go                       | 6 ++----
 transports/obfs4/framing/framing.go            | 6 ++----
 transports/scramblesuit/handshake_uniformdh.go | 3 +--
 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()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfs4proxy.git



More information about the Pkg-privacy-commits mailing list