From e3fdd4890eee0ecd47478233479a170a4a03ae8d Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 8 Feb 2018 23:52:31 +1100 Subject: [PATCH] Simplify crypto select func --- handshake.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/handshake.go b/handshake.go index 6627b608..260c5420 100644 --- a/handshake.go +++ b/handshake.go @@ -188,19 +188,16 @@ func handleEncryption( } headerEncrypted = true ret, err = mse.ReceiveHandshake(rw, skeys, func(provides uint32) uint32 { - cryptoMethod = func() uint32 { - switch { - case policy.ForceEncryption: - return mse.CryptoMethodRC4 - case policy.DisableEncryption: - return mse.CryptoMethodPlaintext - case policy.PreferNoEncryption && provides&mse.CryptoMethodPlaintext != 0: - return mse.CryptoMethodPlaintext - default: - return mse.DefaultCryptoSelector(provides) - } - }() - return cryptoMethod + switch { + case policy.ForceEncryption: + return mse.CryptoMethodRC4 + case policy.DisableEncryption: + return mse.CryptoMethodPlaintext + case policy.PreferNoEncryption && provides&mse.CryptoMethodPlaintext != 0: + return mse.CryptoMethodPlaintext + default: + return mse.DefaultCryptoSelector(provides) + } }) return }