diff --git a/Makefile b/Makefile index f31fd41..da7928f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL := bash # this is the upstream libcurl-impersonate version -VERSION := 0.7.0b6 +VERSION := 0.7.0 CURL_VERSION := curl-8_7_1 $(CURL_VERSION): diff --git a/curl_cffi/const.py b/curl_cffi/const.py index 3b77bef..e535ff3 100644 --- a/curl_cffi/const.py +++ b/curl_cffi/const.py @@ -328,6 +328,8 @@ class CurlOpt(IntEnum): TLS_EXTENSION_ORDER = 10000 + 1012 STREAM_EXCLUSIVE = 0 + 1013 TLS_KEY_USAGE_NO_CHECK = 0 + 1014 + TLS_SIGNED_CERT_TIMESTAMPS = 0 + 1015 + TLS_STATUS_REQUEST = 0 + 1016 if locals().get("WRITEDATA"): FILE = locals().get("WRITEDATA") diff --git a/curl_cffi/requests/impersonate.py b/curl_cffi/requests/impersonate.py index cd37bed..7fbca3c 100644 --- a/curl_cffi/requests/impersonate.py +++ b/curl_cffi/requests/impersonate.py @@ -262,15 +262,11 @@ def toggle_extension(curl, extension_id: int, enable: bool): # status_request elif extension_id == 5: if enable: - pass # It's now always enabled - else: - raise NotImplementedError("This extension(5) is always on for now, it will be updated later.") - # signed_certificate_timestamp + curl.setopt(CurlOpt.TLS_STATUS_REQUEST, 1) + # signed_certificate_timestamps elif extension_id == 18: if enable: - pass # It's now always enabled - else: - raise NotImplementedError("This extension(18) is always on for now, it will be updated later.") + curl.setopt(CurlOpt.TLS_SIGNED_CERT_TIMESTAMPS, 1) # session_ticket elif extension_id == 35: if enable: diff --git a/curl_cffi/requests/session.py b/curl_cffi/requests/session.py index e2597da..75e2d84 100644 --- a/curl_cffi/requests/session.py +++ b/curl_cffi/requests/session.py @@ -226,7 +226,7 @@ def __init__( self._closed = False def _toggle_extensions_by_ids(self, curl, extension_ids): - default_enabled = {0, 51, 13, 43, 5, 18, 65281, 23, 10, 45, 35, 11, 16} + default_enabled = {0, 51, 13, 43, 65281, 23, 10, 45, 35, 11, 16} to_enable_ids = extension_ids - default_enabled for ext_id in to_enable_ids: diff --git a/examples/impersonate.py b/examples/impersonate.py index e349ac8..f150366 100644 --- a/examples/impersonate.py +++ b/examples/impersonate.py @@ -9,7 +9,7 @@ [ "771", "4865-4866-4867-49195-49196-52393-49199-49200-52392-49171-49172-156-157-47-53", - "0-23-65281-10-11-35-16-5-13-51-45-43-18-21", # FIXME: 18 should not be here. + "0-23-65281-10-11-35-16-5-13-51-45-43-21", "29-23-24", "0", ] @@ -29,6 +29,16 @@ "rsa_pkcs1_sha512", "rsa_pkcs1_sha1", ] + # other options: + # tls_min_version: int = CurlSslVersion.TLSv1_2 + # tls_grease: bool = False + # tls_permute_extensions: bool = False + # tls_cert_compression: Literal["zlib", "brotli"] = "brotli" + # tls_signature_algorithms: Optional[List[str]] = None + # http2_stream_weight: int = 256 + # http2_stream_exclusive: int = 1 + + # See requests/impersonate.py and tests/unittest/test_impersonate.py for more examples } diff --git a/pyproject.toml b/pyproject.toml index 54396b8..f539150 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "curl_cffi" -version = "0.7.0b6" +version = "0.7.0b7" authors = [{ name = "Yifei Kong", email = "kong@yifei.me" }] description = "libcurl ffi bindings for Python, with impersonation support." license = { file = "LICENSE" } diff --git a/scripts/build.py b/scripts/build.py index f456631..4891867 100644 --- a/scripts/build.py +++ b/scripts/build.py @@ -10,7 +10,7 @@ from cffi import FFI # this is the upstream libcurl-impersonate version -__version__ = "0.7.0b6" +__version__ = "0.7.0" tmpdir = None diff --git a/tests/unittest/test_impersonate.py b/tests/unittest/test_impersonate.py index 515c760..1859a54 100644 --- a/tests/unittest/test_impersonate.py +++ b/tests/unittest/test_impersonate.py @@ -82,6 +82,11 @@ def test_customized_ja3_extensions(): _, _, extensions, _, _ = r["ja3_text"].split(",") assert extensions == "65281-0-11-23-5-18-27-16-17513-10-35-43-45-13-51" + ja3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,65281-0-11-23-27-16-17513-10-35-43-45-13-51,25497-29-23-24,0" + r = requests.get(url, ja3=ja3).json() + _, _, extensions, _, _ = r["ja3_text"].split(",") + assert extensions == "65281-0-11-23-27-16-17513-10-35-43-45-13-51" + # removed enable session_ticket() ja3 = "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,65281-0-11-23-5-18-27-16-17513-10-43-45-13-51,25497-29-23-24,0" r = requests.get(url, ja3=ja3).json()