Skip to content

Commit

Permalink
Merge pull request #112 from Starry-OvO/develop
Browse files Browse the repository at this point in the history
Update 3.3.2
  • Loading branch information
Starry-OvO committed Mar 31, 2023
2 parents 7277209 + fd5e602 commit cf10d85
Show file tree
Hide file tree
Showing 12 changed files with 185 additions and 182 deletions.
8 changes: 4 additions & 4 deletions 3rdparty/mbedtls/include/mbedtls/build_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
* Major, Minor, Patchlevel
*/
#define MBEDTLS_VERSION_MAJOR 3
#define MBEDTLS_VERSION_MINOR 3
#define MBEDTLS_VERSION_MINOR 4
#define MBEDTLS_VERSION_PATCH 0

/**
* The single version number has the following structure:
* MMNNPP00
* Major version | Minor version | Patch version
*/
#define MBEDTLS_VERSION_NUMBER 0x03030000
#define MBEDTLS_VERSION_STRING "3.3.0"
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 3.3.0"
#define MBEDTLS_VERSION_NUMBER 0x03040000
#define MBEDTLS_VERSION_STRING "3.4.0"
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 3.4.0"

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
#define _CRT_SECURE_NO_DEPRECATE 1
Expand Down
116 changes: 61 additions & 55 deletions 3rdparty/mbedtls/library/alignment.h

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions 3rdparty/mbedtls/library/md5.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ int mbedtls_md5_finish(mbedtls_md5_context *ctx,
return 0;
}



/*
* output = MD5( input buffer )
*/
Expand Down
58 changes: 52 additions & 6 deletions 3rdparty/mbedtls/library/platform_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,49 @@

/*
* Ensure gmtime_r is available even with -std=c99; must be defined before
* mbedtls_config.h, which pulls in glibc's features.h. Harmless on other platforms.
* mbedtls_config.h, which pulls in glibc's features.h. Harmless on other platforms
* except OpenBSD, where it stops us accessing explicit_bzero.
*/
#if !defined(_POSIX_C_SOURCE)
#if !defined(_POSIX_C_SOURCE) && !defined(__OpenBSD__)
#define _POSIX_C_SOURCE 200112L
#endif

#if !defined(_GNU_SOURCE)
/* Clang requires this to get support for explicit_bzero */
#define _GNU_SOURCE
#endif

#include "common.h"

#include "mbedtls/platform_util.h"
#include "mbedtls/platform.h"

#include <stddef.h>

#ifndef __STDC_WANT_LIB_EXT1__
#define __STDC_WANT_LIB_EXT1__ 1 /* Ask for the C11 gmtime_s() and memset_s() if available */
#endif
#include <string.h>

#if defined(_WIN32)
#include <windows.h>
#endif

// Detect platforms known to support explicit_bzero()
#if defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 25)
#define MBEDTLS_PLATFORM_HAS_EXPLICIT_BZERO 1
#elif (defined(__FreeBSD__) && (__FreeBSD_version >= 1100037)) || defined(__OpenBSD__)
#define MBEDTLS_PLATFORM_HAS_EXPLICIT_BZERO 1
#endif

#if !defined(MBEDTLS_PLATFORM_ZEROIZE_ALT)
/*
* This implementation should never be optimized out by the compiler
* Where possible, we try to detect the presence of a platform-provided
* secure memset, such as explicit_bzero(), that is safe against being optimized
* out, and use that.
*
* For other platforms, we provide an implementation that aims not to be
* optimized out by the compiler.
*
* This implementation for mbedtls_platform_zeroize() was inspired from Colin
* Percival's blog article at:
Expand All @@ -51,24 +77,44 @@
* (refer to http://www.daemonology.net/blog/2014-09-05-erratum.html for
* details), optimizations of the following form are still possible:
*
* if( memset_func != memset )
* memset_func( buf, 0, len );
* if (memset_func != memset)
* memset_func(buf, 0, len);
*
* Note that it is extremely difficult to guarantee that
* mbedtls_platform_zeroize() will not be optimized out by aggressive compilers
* the memset() call will not be optimized out by aggressive compilers
* in a portable way. For this reason, Mbed TLS also provides the configuration
* option MBEDTLS_PLATFORM_ZEROIZE_ALT, which allows users to configure
* mbedtls_platform_zeroize() to use a suitable implementation for their
* platform and needs.
*/
#if !defined(MBEDTLS_PLATFORM_HAS_EXPLICIT_BZERO) && !defined(__STDC_LIB_EXT1__) \
&& !defined(_WIN32)
static void *(*const volatile memset_func)(void *, int, size_t) = memset;
#endif

void mbedtls_platform_zeroize(void *buf, size_t len)
{
MBEDTLS_INTERNAL_VALIDATE(len == 0 || buf != NULL);

if (len > 0) {
#if defined(MBEDTLS_PLATFORM_HAS_EXPLICIT_BZERO)
explicit_bzero(buf, len);
#if defined(HAVE_MEMORY_SANITIZER)
/* You'd think that Msan would recognize explicit_bzero() as
* equivalent to bzero(), but it actually doesn't on several
* platforms, including Linux (Ubuntu 20.04).
* https://github.com/google/sanitizers/issues/1507
* https://github.com/openssh/openssh-portable/commit/74433a19bb6f4cef607680fa4d1d7d81ca3826aa
*/
__msan_unpoison(buf, len);
#endif
#elif defined(__STDC_LIB_EXT1__)
memset_s(buf, len, 0, len);
#elif defined(_WIN32)
SecureZeroMemory(buf, len);
#else
memset_func(buf, 0, len);
#endif
}
}
#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.3.1"
__version__ = "3.3.2"
9 changes: 7 additions & 2 deletions aiotieba/api/agree/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ def parse_body(body: bytes) -> None:
raise TiebaServerError(code, res_json['error_msg'])


async def request(http_core: HttpCore, tid: int, pid: int, is_disagree: bool, is_undo: bool) -> bool:
async def request(http_core: HttpCore, tid: int, pid: int, is_floor: bool, is_disagree: bool, is_undo: bool) -> bool:
if pid:
obj_type = '2' if is_floor else '1'
else:
obj_type = '3'

data = [
('BDUSS', http_core.account._BDUSS),
('_client_version', MAIN_VERSION),
('agree_type', '5' if is_disagree else '2'),
('cuid', http_core.account.cuid_galaxy2),
('obj_type', '1' if pid else '3'),
('obj_type', obj_type),
('op_type', str(int(is_undo))),
('post_id', pid),
('tbs', http_core.account._tbs),
Expand Down
28 changes: 0 additions & 28 deletions aiotieba/api/get_posts/_classdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,6 @@ class UserInfo_pt(object):
level (int): 等级
glevel (int): 贴吧成长等级
fan_num (int): 粉丝数
ip (str): ip归属地
is_bawu (bool): 是否吧务
Expand All @@ -1580,7 +1579,6 @@ class UserInfo_pt(object):
'_nick_name_new',
'_level',
'_glevel',
'_fan_num',
'_ip',
'_is_bawu',
'_is_vip',
Expand All @@ -1599,7 +1597,6 @@ def _init(self, data_proto: TypeMessage) -> "UserInfo_pt":
self._nick_name_new = data_proto.name_show
self._level = data_proto.level_id
self._glevel = data_proto.user_growth.level_id
self._fan_num = data_proto.fans_num
self._ip = data_proto.ip_address
self._is_bawu = bool(data_proto.is_bawu)
self._is_vip = bool(data_proto.new_tshow_icon)
Expand All @@ -1615,7 +1612,6 @@ def _init_null(self) -> "UserInfo_pt":
self._nick_name_new = ''
self._level = 0
self._glevel = 0
self._fan_num = 0
self._ip = ''
self._is_bawu = False
self._is_vip = False
Expand All @@ -1636,7 +1632,6 @@ def __repr__(self) -> str:
'show_name': self.show_name,
'level': self._level,
'glevel': self._glevel,
'fan_num': self._fan_num,
'ip': self._ip,
'priv_like': self._priv_like,
'priv_reply': self._priv_reply,
Expand Down Expand Up @@ -1714,14 +1709,6 @@ def glevel(self) -> int:

return self._glevel

@property
def fan_num(self) -> int:
"""
粉丝数
"""

return self._fan_num

@property
def ip(self) -> str:
"""
Expand Down Expand Up @@ -1979,7 +1966,6 @@ class Thread_p(object):
agree (int): 点赞数
disagree (int): 点踩数
create_time (int): 创建时间
last_time (int): 最后回复时间
"""

__slots__ = [
Expand All @@ -2001,7 +1987,6 @@ class Thread_p(object):
'_agree',
'_disagree',
'_create_time',
'_last_time',
]

def _init(self, data_proto: TypeMessage) -> "Thread_p":
Expand All @@ -2018,7 +2003,6 @@ def _init(self, data_proto: TypeMessage) -> "Thread_p":
self._agree = data_proto.agree.agree_num
self._disagree = data_proto.agree.disagree_num
self._create_time = data_proto.create_time
self._last_time = data_proto.last_time_int

if not self._is_share:
self._contents = Contents_pt()._init(data_proto.origin_thread_info.content)
Expand Down Expand Up @@ -2054,7 +2038,6 @@ def _init_null(self) -> "Thread_p":
self._agree = 0
self._disagree = 0
self._create_time = 0
self._last_time = 0
return self

def __repr__(self) -> str:
Expand Down Expand Up @@ -2236,17 +2219,6 @@ def create_time(self) -> int:

return self._create_time

@property
def last_time(self) -> int:
"""
最后回复时间
Note:
10位时间戳 以秒为单位
"""

return self._last_time


class Posts(Containers[Post]):
"""
Expand Down
20 changes: 12 additions & 8 deletions aiotieba/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1694,13 +1694,14 @@ async def get_dislike_forums(self, pn: int = 1, /, *, rn: int = 20) -> get_disli
return await get_dislike_forums.request_http(self._http_core, pn, rn)

@handle_exception(bool, no_format=True)
async def agree(self, tid: int, pid: int = 0) -> bool:
async def agree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
点赞主题帖或回复
Args:
tid (int): 待点赞的主题帖或回复所在的主题帖的tid
pid (int, optional): 待点赞的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
Expand All @@ -1712,58 +1713,61 @@ async def agree(self, tid: int, pid: int = 0) -> bool:

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=False, is_undo=False)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=False, is_undo=False)

@handle_exception(bool, no_format=True)
async def unagree(self, tid: int, pid: int = 0) -> bool:
async def unagree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
取消点赞主题帖或回复
Args:
tid (int): 待取消点赞的主题帖或回复所在的主题帖的tid
pid (int, optional): 待取消点赞的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
"""

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=False, is_undo=True)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=False, is_undo=True)

@handle_exception(bool, no_format=True)
async def disagree(self, tid: int, pid: int = 0) -> bool:
async def disagree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
点踩主题帖或回复
Args:
tid (int): 待点踩的主题帖或回复所在的主题帖的tid
pid (int, optional): 待点踩的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
"""

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=True, is_undo=False)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=True, is_undo=False)

@handle_exception(bool, no_format=True)
async def undisagree(self, tid: int, pid: int = 0) -> bool:
async def undisagree(self, tid: int, pid: int = 0, is_floor: bool = False) -> bool:
"""
取消点踩主题帖或回复
Args:
tid (int): 待取消点踩的主题帖或回复所在的主题帖的tid
pid (int, optional): 待取消点踩的回复pid. Defaults to 0.
is_floor (bool, optional): pid是否指向楼中楼. Defaults to False.
Returns:
bool: True成功 False失败
"""

await self.__init_tbs()

return await agree.request(self._http_core, tid, pid, is_disagree=True, is_undo=True)
return await agree.request(self._http_core, tid, pid, is_floor, is_disagree=True, is_undo=True)

@handle_exception(bool, no_format=True)
async def agree_vimage(self, _id: Union[str, int]) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion aiotieba/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MAIN_VERSION = "12.37.0.1"
MAIN_VERSION = "12.38.2.0"
POST_VERSION = "9.1.0.0"

APP_SECURE_SCHEME = "https"
Expand Down
Loading

0 comments on commit cf10d85

Please sign in to comment.