python类init_from_bin_len()的实例源码

auth_chain.py 文件源码 项目:ssrr 作者: do21 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        other_data_size = buf_size + self.server_info.overhead
        # ????random???????????????????????????????
        random.init_from_bin_len(last_hash, buf_size)
        # final_pos ?????pos~(data_size_list0.len-1)??
        # ??data_size_list0?????????????????buf
        if other_data_size >= self.data_size_list0[-1]:
            if other_data_size >= 1440:
                return 0
            if other_data_size > 1300:
                return random.next() % 31
            if other_data_size > 900:
                return random.next() % 127
            if other_data_size > 400:
                return random.next() % 521
            return random.next() % 1021

        pos = bisect.bisect_left(self.data_size_list0, other_data_size)
        # random select a size in the leftover data_size_list0
        final_pos = pos + random.next() % (len(self.data_size_list0) - pos)
        return self.data_size_list0[final_pos] - other_data_size
auth_chain.py 文件源码 项目:shadowsocksr-python 作者: nanqinlang-shadowsocksr 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size >= 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        pos = bisect.bisect_left(self.data_size_list, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list))
        if final_pos < len(self.data_size_list):
            return self.data_size_list[final_pos] - buf_size - self.server_info.overhead

        pos = bisect.bisect_left(self.data_size_list2, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list2))
        if final_pos < len(self.data_size_list2):
            return self.data_size_list2[final_pos] - buf_size - self.server_info.overhead
        if final_pos < pos + len(self.data_size_list2) - 1:
            return 0

        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:luci-oso21 作者: oso21 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        other_data_size = buf_size + self.server_info.overhead
        # ????random???????????????????????????????
        random.init_from_bin_len(last_hash, buf_size)
        # final_pos ?????pos~(data_size_list0.len-1)??
        # ??data_size_list0?????????????????buf
        if other_data_size >= self.data_size_list0[-1]:
            if other_data_size >= 1440:
                return 0
            if other_data_size > 1300:
                return random.next() % 31
            if other_data_size > 900:
                return random.next() % 127
            if other_data_size > 400:
                return random.next() % 521
            return random.next() % 1021

        pos = bisect.bisect_left(self.data_size_list0, other_data_size)
        # random select a size in the leftover data_size_list0
        final_pos = pos + random.next() % (len(self.data_size_list0) - pos)
        return self.data_size_list0[final_pos] - other_data_size
auth_chain.py 文件源码 项目:ShadowSocksShare-OpenShift 作者: the0demiurge 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size >= 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        pos = bisect.bisect_left(self.data_size_list, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list))
        if final_pos < len(self.data_size_list):
            return self.data_size_list[final_pos] - buf_size - self.server_info.overhead

        pos = bisect.bisect_left(self.data_size_list2, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list2))
        if final_pos < len(self.data_size_list2):
            return self.data_size_list2[final_pos] - buf_size - self.server_info.overhead
        if final_pos < pos + len(self.data_size_list2) - 1:
            return 0

        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:shadowsocksR-b 作者: hao35954514 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:shadowsocksR-b 作者: hao35954514 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:ssrr 作者: do21 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:ssrr 作者: do21 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:ssrr 作者: do21 项目源码 文件源码 阅读 46 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size >= 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        pos = bisect.bisect_left(self.data_size_list, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list))
        # ??random??????????????????if false
        if final_pos < len(self.data_size_list):
            return self.data_size_list[final_pos] - buf_size - self.server_info.overhead

        # ??if false???2?????????????????
        pos = bisect.bisect_left(self.data_size_list2, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list2))
        if final_pos < len(self.data_size_list2):
            return self.data_size_list2[final_pos] - buf_size - self.server_info.overhead
        # final_pos ?????pos~(data_size_list2.len-1)??
        if final_pos < pos + len(self.data_size_list2) - 1:
            return 0
        # ?1/len(self.data_size_list2)?????????if  ?
        # ?????????????????????  ?
        # assert False

        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:ssrr 作者: do21 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        other_data_size = buf_size + self.server_info.overhead
        # if other_data_size > the bigest item in data_size_list0, not padding any data
        if other_data_size >= self.data_size_list0[-1]:
            return 0

        random.init_from_bin_len(last_hash, buf_size)
        pos = bisect.bisect_left(self.data_size_list0, other_data_size)
        # random select a size in the leftover data_size_list0
        final_pos = pos + random.next() % (len(self.data_size_list0) - pos)
        return self.data_size_list0[final_pos] - other_data_size
auth_chain.py 文件源码 项目:shadowsocksr-python 作者: nanqinlang-shadowsocksr 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:shadowsocksr-python 作者: nanqinlang-shadowsocksr 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:luci-oso21 作者: oso21 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:luci-oso21 作者: oso21 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:luci-oso21 作者: oso21 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size >= 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        pos = bisect.bisect_left(self.data_size_list, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list))
        # ??random??????????????????if false
        if final_pos < len(self.data_size_list):
            return self.data_size_list[final_pos] - buf_size - self.server_info.overhead

        # ??if false???2?????????????????
        pos = bisect.bisect_left(self.data_size_list2, buf_size + self.server_info.overhead)
        final_pos = pos + random.next() % (len(self.data_size_list2))
        if final_pos < len(self.data_size_list2):
            return self.data_size_list2[final_pos] - buf_size - self.server_info.overhead
        # final_pos ?????pos~(data_size_list2.len-1)??
        if final_pos < pos + len(self.data_size_list2) - 1:
            return 0
        # ?1/len(self.data_size_list2)?????????if

        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:luci-oso21 作者: oso21 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        other_data_size = buf_size + self.server_info.overhead
        # if other_data_size > the bigest item in data_size_list0, not padding any data
        if other_data_size >= self.data_size_list0[-1]:
            return 0

        random.init_from_bin_len(last_hash, buf_size)
        pos = bisect.bisect_left(self.data_size_list0, other_data_size)
        # random select a size in the leftover data_size_list0
        final_pos = pos + random.next() % (len(self.data_size_list0) - pos)
        return self.data_size_list0[final_pos] - other_data_size
auth_chain.py 文件源码 项目:shadowsocksr 作者: emacsenli 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:shadowsocksr 作者: emacsenli 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:shadowsocksrh 作者: hhhizzz 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:shadowsocksrh 作者: hhhizzz 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021
auth_chain.py 文件源码 项目:ShadowSocksShare-OpenShift 作者: the0demiurge 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def init_from_bin_len(self, bin, length):
        bin += b'\0' * 16
        bin = struct.pack('<H', length) + bin[2:]
        self.v0 = struct.unpack('<Q', bin[:8])[0]
        self.v1 = struct.unpack('<Q', bin[8:16])[0]

        for i in range(4):
            self.next()
auth_chain.py 文件源码 项目:ShadowSocksShare-OpenShift 作者: the0demiurge 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def rnd_data_len(self, buf_size, last_hash, random):
        if buf_size > 1440:
            return 0
        random.init_from_bin_len(last_hash, buf_size)
        if buf_size > 1300:
            return random.next() % 31
        if buf_size > 900:
            return random.next() % 127
        if buf_size > 400:
            return random.next() % 521
        return random.next() % 1021


问题


面经


文章

微信
公众号

扫码关注公众号