From 2cd02dcc511b663388c384774f2fc92054957e14 Mon Sep 17 00:00:00 2001 From: Akkariiin Date: Mon, 20 Aug 2018 13:37:33 +0800 Subject: [PATCH] analysis and add typing hint --- shadowsocks/obfsplugin/auth_akarin.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/shadowsocks/obfsplugin/auth_akarin.py b/shadowsocks/obfsplugin/auth_akarin.py index fd6cbe5..d9f7f60 100644 --- a/shadowsocks/obfsplugin/auth_akarin.py +++ b/shadowsocks/obfsplugin/auth_akarin.py @@ -572,15 +572,27 @@ class auth_akarin_rand(auth_base): struct.pack(' bytes: + """ + + header= + |packed data(auth_data)| + + ret_data= + |header:(if first pack)|packed data(buf)| + + :param buf: bytes plain data + :return: bytes encrypted data + """ ret = b'' ogn_data_len = len(buf) if not self.has_sent_header: head_size = self.get_head_size(buf, 30) datalen = min(len(buf), random.randint(0, 31) + head_size) - ret += self.pack_auth_data(self.auth_data(), buf[:datalen]) + ret += self.pack_auth_data(self.auth_data(), buf[:datalen]) # TODO buf[:datalen] may overflow buf = buf[datalen:] self.has_sent_header = True while len(buf) > self.unit_len: