file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
src/handshake_token.rs
Rust
use crate::error::Result; use crate::hkdf::Hkdf; use crate::key::{AeadKey, Key}; use crate::secret::Secret; use crate::suite::CipherSuite; use quinn_proto::crypto; pub struct HandshakeTokenKey(Key); impl HandshakeTokenKey { /// Creates a new randomized HandshakeTokenKey. pub fn new() -> Result<Self> { ...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/hkdf.rs
Rust
use crate::error::{map_result, Error, Result}; use boring::hash::MessageDigest; use boring_sys as bffi; use bytes::{BufMut, BytesMut}; use once_cell::sync::Lazy; /// The block size used by the supported digest algorithms (64). pub(crate) const DIGEST_BLOCK_LEN: usize = bffi::SHA_CBLOCK as _; // /// The digest size fo...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/hmac.rs
Rust
use crate::error::map_ptr_result; use crate::hkdf::DIGEST_BLOCK_LEN; use boring::hash::MessageDigest; use boring_sys as bffi; use quinn_proto::crypto; use rand::RngCore; use std::ffi::{c_uint, c_void}; use std::result::Result as StdResult; const SIGNATURE_LEN_SHA_256: usize = 32; /// Implementation of [crypto::HmacKe...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/key.rs
Rust
use crate::error::{map_result, map_result_zero_is_success, Result}; use crate::macros::bounded_array; use crate::secret::Secret; use crate::suite::{CipherSuite, ID}; use crate::{Error, QuicVersion}; use boring_sys as bffi; use bytes::BytesMut; use quinn_proto::crypto; use std::ffi::c_uint; use std::fmt::{Debug, Formatt...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/key_log.rs
Rust
use crate::Error; use std::fmt::{Debug, Display, Formatter}; use std::str::FromStr; const CLIENT_RANDOM: &str = "CLIENT_RANDOM"; const CLIENT_EARLY_TRAFFIC_SECRET: &str = "CLIENT_EARLY_TRAFFIC_SECRET"; const CLIENT_HANDSHAKE_TRAFFIC_SECRET: &str = "CLIENT_HANDSHAKE_TRAFFIC_SECRET"; const SERVER_HANDSHAKE_TRAFFIC_SECRE...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/lib.rs
Rust
mod aead; mod alert; mod alpn; mod bffi_ext; mod client; mod error; mod handshake_token; mod hkdf; mod hmac; mod key; mod key_log; mod macros; mod retry; mod secret; mod server; mod session_cache; mod session_state; mod suite; mod version; // Export the public interface. pub use bffi_ext::*; pub use client::Config as ...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/macros.rs
Rust
macro_rules! bounded_array { {$( $(#[$struct_docs:meta])* $vis:vis struct $struct_name:ident($max_len:ident) ),*} => { $( $(#[$struct_docs])* #[derive(Copy, Clone, Eq, PartialEq)] $vis struct $struct_name { buf: [u8; Self::MAX_LEN], len: u8, ...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/retry.rs
Rust
use crate::key::{AeadKey, Key, Nonce}; use crate::suite::CipherSuite; use crate::{aead, QuicVersion}; use quinn_proto::ConnectionId; const TAG_LEN: usize = aead::AES_GCM_TAG_LEN; #[inline] pub(crate) fn retry_tag( version: &QuicVersion, orig_dst_cid: &ConnectionId, packet: &[u8], ) -> [u8; TAG_LEN] { ...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/secret.rs
Rust
use crate::error::Result; use crate::hkdf; use crate::key::{HeaderKey, KeyPair, Keys, PacketKey}; use crate::macros::bounded_array; use crate::suite::CipherSuite; use crate::version::QuicVersion; use quinn_proto::{ConnectionId, Side}; const MAX_SECRET_LEN: usize = hkdf::DIGEST_BLOCK_LEN; bounded_array! { /// A bu...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/server.rs
Rust
use crate::alpn::AlpnProtocols; use crate::bffi_ext::QuicSsl; use crate::error::{map_result, Result}; use crate::secret::Secrets; use crate::session_state::{SessionState, QUIC_METHOD}; use crate::version::QuicVersion; use crate::{retry, KeyLog, NoKeyLog, QuicSslContext}; use boring::ssl::{Ssl, SslContext, SslContextBui...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/session_cache.rs
Rust
use crate::error::Result; use crate::{Error, QuicSslSession}; use boring::ssl::{SslContextRef, SslSession}; use bytes::{Buf, BufMut, Bytes, BytesMut}; use lru::LruCache; use quinn_proto::{transport_parameters::TransportParameters, Side}; use std::num::NonZeroUsize; use std::sync::Mutex; /// A client-side Session cache...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/session_state.rs
Rust
use crate::alert::Alert; use crate::error::{map_cb_result, map_result, Result}; use crate::secret::{Secret, Secrets, SecretsBuilder}; use crate::suite::CipherSuite; use crate::{ retry, Error, HandshakeData, KeyLog, KeyLogLabel, Level, QuicSsl, QuicVersion, SslError, }; use boring::error::ErrorStack; use boring::ssl...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/suite.rs
Rust
use crate::aead::Aead; use crate::error::{Error, Result}; use crate::hkdf::Hkdf; use boring_sys as bffi; use once_cell::sync::Lazy; use std::fmt::{Debug, Formatter}; // For AEAD_AES_128_GCM and AEAD_AES_256_GCM ... endpoints that do not send // packets larger than 2^11 bytes cannot protect more than 2^28 packets. // h...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
src/version.rs
Rust
use quinn_proto::crypto; use std::result::Result as StdResult; /// QUIC protocol version /// /// Governs version-specific behavior in the TLS layer // TODO: add support for draft version 2. #[non_exhaustive] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum QuicVersion { V1Draft29, V1Draft30, V1Draft31...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
tests/integration_tests.rs
Rust
use anyhow::{anyhow, Result}; use boring::pkey::{PKey, Private}; use boring::x509::X509; use boring_sys as bffi; use core::fmt::{Debug, Formatter}; use once_cell::sync::Lazy; use quinn::{Connecting, Connection, RecvStream, SendStream, WriteError, ZeroRttAccepted}; use quinn_boring2::{ClientConfig, QuicSslContext, Serve...
0x676e67/quinn-boring2
0
A crypto provider for quinn based on BoringSSL
Rust
0x676e67
.github/musl_build.sh
Shell
#!/bin/bash if [ -z "$1" ]; then echo "Usage: $0 <target> [maturin_args]" exit 1 fi TARGET=$1 ARGS=$2 IMAGE="ghcr.io/0x676e67/rust-musl-cross" VOLUME_MAPPING="-v $(pwd):/home/rust/src" MATURIN_CMD="maturin build --release --out dist $ARGS" case $TARGET in x86_64-unknown-linux-musl | \ aarch64-unknown-linux-...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
bench/benchmark.py
Python
""" HTTP Client Benchmark Tool This module provides comprehensive benchmarking for various HTTP client libraries. Each client has dedicated test methods to eliminate runtime overhead from dynamic dispatch. """ import argparse import asyncio import time from concurrent.futures import ThreadPoolExecutor, as_completed f...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
bench/chart.py
Python
import matplotlib.pyplot as plt import numpy as np def _plot_main_sessions(df, main_sessions, sizes, stat_types, filename): """Plot main sessions (sync and async)""" num_sessions = len(main_sessions) # Allocate more height for each subplot to ensure sufficient spacing subplot_height = 8 # Fixed heigh...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
bench/server.py
Python
import os from starlette.applications import Starlette from starlette.responses import PlainTextResponse from starlette.routing import Route random_20k = os.urandom(20 * 1024) random_50k = os.urandom(50 * 1024) random_200k = os.urandom(200 * 1024) app = Starlette( routes=[ Route("/20k", lambda r: PlainT...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/auth.py
Python
import asyncio import rnet async def main(): resp = await rnet.get( "https://httpbin.io/anything", auth="token", ) print(await resp.text()) if __name__ == "__main__": asyncio.run(main())
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/basic_auth.py
Python
import asyncio import rnet async def main(): resp = await rnet.get( "https://httpbin.io/anything", basic_auth=("username", "password"), ) print(await resp.text()) if __name__ == "__main__": asyncio.run(main())
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/bearer_auth.py
Python
import asyncio import rnet async def main(): resp = await rnet.get( "https://httpbin.io/anything", bearer_auth="token", ) print(await resp.text()) if __name__ == "__main__": asyncio.run(main())
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/auth.py
Python
from rnet.blocking import Client def main(): client = Client() resp = client.get( "https://httpbin.io/anything", auth="token", ) print("Status Code: ", resp.status) print("Version: ", resp.version) print("Response URL: ", resp.url) print("Headers: ", resp.headers) print...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/basic_auth.py
Python
from rnet.blocking import Client def main(): client = Client() resp = client.get( "https://httpbin.io/anything", basic_auth=("username", "password"), ) print(resp.text()) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/bearer_auth.py
Python
from rnet.blocking import Client def main(): client = Client() resp = client.get( "https://httpbin.io/anything", bearer_auth="token", ) print(resp.text()) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/body.py
Python
from rnet.blocking import Client def gen(): for i in range(10): yield i.to_bytes() def main(): client = Client() resp = client.post( "https://httpbin.io/anything", headers={"Content-Type": "application/x-www-form-urlencoded"}, body=gen(), ) print(resp.json()) if...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/client.py
Python
from rnet import Proxy from rnet.blocking import Client from rnet.emulation import Emulation def main(): client = Client( emulation=Emulation.Firefox133, user_agent="rnet", proxies=[ Proxy.http("socks5h://abc:def@127.0.0.1:1080"), Proxy.https(url="socks5h://127.0.0....
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/cookie.py
Python
from rnet.blocking import Client, Method def main(): client = Client() resp = client.request(Method.GET, "https://www.google.com/") for resp in resp.cookies: print(f"{resp.name}: {resp.value}") if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/emulation.py
Python
from rnet.blocking import Client from rnet.emulation import Emulation def main(): client = Client(emulation=Emulation.Firefox135) with client.get("https://tls.peet.ws/api/all") as resp: print("Status Code: ", resp.status) print("Version: ", resp.version) print("Response URL: ", resp.ur...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/form.py
Python
from rnet.blocking import Client def main(): client = Client() resp = client.post( "https://httpbin.io/anything", form=[("key", "value")], ) print(resp.text()) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/get.py
Python
import datetime from rnet.blocking import Client from rnet.emulation import Emulation def main(): client = Client() resp = client.get( "https://tls.peet.ws/api/all", timeout=datetime.timedelta(seconds=10), emulation=Emulation.Firefox139, ) print(resp.text()) if __name__ == "_...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/json.py
Python
from rnet.blocking import Client def main(): client = Client() resp = client.post( "https://httpbin.io/anything", json={"key": "value"}, ) print(resp.text()) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/multipart.py
Python
from pathlib import Path from rnet.blocking import Client from rnet import Multipart, Part def file_to_bytes_stream(file_path): with open(file_path, "rb") as f: while chunk := f.read(1024): yield chunk def main(): client = Client() resp = client.post( "https://httpbin.io/anyt...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/proxy.py
Python
from rnet.blocking import Client from rnet.proxy import Proxy def main(): client = Client() resp = client.post( "https://httpbin.io/anything", proxy=Proxy.all("http://127.0.0.1:6152"), ) print(resp.text()) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/query.py
Python
from rnet.blocking import Client def main(): client = Client() resp = client.get( "https://httpbin.io/anything", query=[("key", "value")], ) print(resp.text()) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/blocking/stream.py
Python
import time import rnet import rnet.blocking def main(): with rnet.blocking.get("https://httpbin.io/stream/20") as resp: with resp.stream() as streamer: for chunk in streamer: print(chunk) time.sleep(0.1) if __name__ == "__main__": main()
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/body.py
Python
import asyncio import rnet async def gen(): for i in range(10): await asyncio.sleep(0.1) if i <= 5: # bytes chunk yield bytes(f"Hello {i}\n", "utf-8") else: # str chunk yield str("Hello {}\n".format(i)).encode("utf-8") async def main(): ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/emulation.py
Python
import asyncio from rnet import Client, Response from rnet.emulation import Emulation, EmulationOS, EmulationOption from rnet.tls import TlsOptions, TlsVersion, AlpnProtocol from rnet.http2 import Http2Options, PseudoId, PseudoOrder from rnet.header import HeaderMap, OrigHeaderMap async def print_response_info(resp: ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/exceptions.py
Python
import datetime import rnet import asyncio import rnet.exceptions as exceptions rnet_errors = ( exceptions.BodyError, exceptions.BuilderError, exceptions.ConnectionError, exceptions.ConnectionResetError, exceptions.DecodingError, exceptions.RedirectError, exceptions.TimeoutError, except...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/form.py
Python
import asyncio import rnet async def main(): client = rnet.Client() # use a list of tuples resp = await client.post( "https://httpbin.io/anything", form=[ ("key1", "value1"), ("key2", "value2"), ("number", 123), ("flag", True), (...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/header_map.py
Python
from rnet.header import HeaderMap if __name__ == "__main__": headers = HeaderMap() # Add Content-Type header headers.insert("Content-Type", "application/json") # Add Accept header (first value) headers.insert("Accept", "application/json") # Add Accept header (second value) headers.insert("...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/http1_websocket.py
Python
import asyncio import datetime import signal import rnet from rnet import Message, WebSocket from rnet import exceptions async def send_message(ws: WebSocket): print("Starting to send messages...") for i in range(20): print(f"Sending: Message {i + 1}") await ws.send(Message.from_text(f"Message...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/http2_websocket.py
Python
import asyncio import datetime import signal import rnet from rnet import Message, WebSocket from rnet import exceptions async def send_message(ws): print("Starting to send messages...") for i in range(20): print(f"Sending: Message {i + 1}") await ws.send(Message.from_text(f"Message {i + 1}"))...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/json.py
Python
import asyncio import rnet async def main(): resp = await rnet.post( "https://httpbin.io/anything", json={"key": "value"}, ) print(await resp.json()) if __name__ == "__main__": asyncio.run(main())
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/keylog.py
Python
import asyncio from rnet import Client from rnet.tls import KeyLog async def main(): client = Client(keylog=KeyLog.file("keylog.log")) resp = await client.get("https://www.google.com") async with resp: print(await resp.text()) if __name__ == "__main__": asyncio.run(main())
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/multipart.py
Python
from pathlib import Path import asyncio import aiofiles import rnet from rnet import Multipart, Part async def file_to_bytes_stream(file_path): async with aiofiles.open(file_path, "rb") as f: while chunk := await f.read(1024): yield chunk async def main(): resp = await rnet.post( ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/orig_headers.py
Python
import asyncio import rnet from rnet.emulation import Emulation async def main(): ws = await rnet.websocket( "wss://gateway.discord.gg/", emulation=Emulation.Chrome137, headers={"Origin": "https://discord.com"}, # Preserve HTTP/1 case and header order orig_headers=[ ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/proxy.py
Python
import asyncio import rnet from rnet import Client, Proxy async def main(): # Create a client with multiple proxies client = Client( proxies=[Proxy.http("socks5h://abc:def@127.0.0.1:6152")], ) # Send request via the client proxy resp = await client.get("https://httpbin.io/anything") p...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/query.py
Python
import asyncio import rnet async def main(): # Send list of tuples as query parameters resp = await rnet.get( "https://httpbin.io/anything", query=[ ("key1", "value1"), ("key2", "value2"), ("number", 123), ("flag", True), ("float", 45...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/redirect.py
Python
""" Custom redirect policy example. Demonstrates how to use custom redirect policies with Python callbacks. """ import asyncio from rnet import Client, Response, redirect from rnet.redirect import Attempt, Action def custom_policy(attempt: Attempt) -> Action: """Custom redirect policy that blocks example.com re...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/request.py
Python
import asyncio import rnet from rnet import Method async def main(): resp: rnet.Response = await rnet.request(Method.GET, url="https://www.google.com/") print("Status Code: ", resp.status) print("Version: ", resp.version) print("Response URL: ", resp.url) print("Headers: ", resp.headers) print...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
examples/stream.py
Python
import asyncio import rnet from rnet import Response async def main(): resp: Response = await rnet.get("https://httpbin.io/stream/20") async with resp: async with resp.stream() as streamer: async for chunk in streamer: print(chunk) await asyncio.sleep(0.1) ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/__init__.py
Python
# rnet/__init__.py from .rnet import * from .rnet import __all__ from .cookie import * from .exceptions import * from .header import * from .emulation import * from .http1 import * from .http2 import * from .tls import * from .dns import * from .redirect import * from .proxy import * __all__ = ( header.__all__ ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/__init__.pyi
Python
import datetime from enum import Enum, auto from ipaddress import IPv4Address, IPv6Address from pathlib import Path from typing import ( Any, AsyncGenerator, Dict, Generator, NotRequired, Sequence, Tuple, TypedDict, Unpack, final, ) from . import redirect from .cookie import * f...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/blocking.py
Python
import datetime from typing import ( Any, Sequence, Unpack, ) from . import ( ClientConfig, Message, Method, Request, SocketAddr, StatusCode, Streamer, Version, WebSocketRequest, ) from .cookie import Cookie, Jar from .header import HeaderMap from .redirect import Histor...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/cookie.py
Python
""" HTTP Cookie Management This module provides classes for creating, managing, and storing HTTP cookies in a thread-safe manner. It includes support for all standard cookie attributes and provides a cookie jar for automatic cookie handling during HTTP requests. """ import datetime from enum import Enum, auto from ty...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/dns.py
Python
"""DNS resolution types and utilities.""" from enum import Enum, auto from typing import Sequence, final from ipaddress import IPv4Address, IPv6Address __all__ = [ "LookupIpStrategy", "ResolverOptions", ] @final class LookupIpStrategy(Enum): """IP lookup strategy for DNS resolution. Determines the ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/emulation.py
Python
""" This module provides functionality for emulating various browsers and HTTP clients to bypass detection and fingerprinting. It supports emulating Chrome, Firefox, Edge, Safari, Opera, and OkHttp clients across different operating systems and versions. The emulation system modifies HTTP/2 settings, TLS fingerprints,...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/exceptions.py
Python
""" HTTP Client Exceptions This module defines all exceptions that can be raised by the rnet HTTP client. The exceptions are organized into logical categories based on their cause and severity, making it easier to handle specific types of errors appropriately. """ __all__ = [ "TlsError", "ConnectionError", ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/header.py
Python
""" HTTP Header Management This module provides efficient storage and manipulation of HTTP headers with support for multiple values per header name. The HeaderMap class is designed to handle the complexities of HTTP header processing, including case-insensitive header names and multiple header values. The implementat...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/http1.py
Python
""" HTTP/1 connection configuration. """ from typing import TypedDict, Unpack, NotRequired, final __all__ = ["Http1Options", "Params"] class Params(TypedDict): """ All parameters for HTTP/1 connections. """ http09_responses: NotRequired[bool] """ Enable support for HTTP/0.9 responses. "...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/http2.py
Python
""" HTTP/2 connection configuration. """ import datetime from enum import Enum, auto from typing import ClassVar, Self, TypedDict, NotRequired, Unpack, final __all__ = [ "StreamId", "StreamDependency", "Priority", "Priorities", "PseudoId", "PseudoOrder", "SettingId", "SettingsOrder", ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/proxy.py
Python
from typing import Dict, NotRequired, TypedDict, Unpack, final from rnet.header import HeaderMap __all__ = ["Proxy"] class ProxyConfig(TypedDict): username: NotRequired[str] r"""Username for proxy authentication.""" password: NotRequired[str] r"""Password for proxy authentication.""" custom_ht...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/redirect.py
Python
from typing import Callable, Sequence, final from .header import HeaderMap from . import StatusCode __all__ = ["Policy", "Attempt", "Action", "History"] @final class Policy: """ Represents the redirect policy for HTTP requests. The default value will catch redirect loops, and has a maximum of 10 re...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
python/rnet/tls.py
Python
""" TLS Utilities and Types This module provides types and utilities for configuring TLS (Transport Layer Security) in HTTP clients. """ from enum import Enum, auto from pathlib import Path from typing import Sequence, NotRequired, TypedDict, Unpack, final __all__ = [ "TlsVersion", "Identity", "CertStore...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/buffer.rs
Rust
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client.rs
Rust
pub mod body; pub mod nogil; pub mod req; pub mod resp; mod param; mod query; use std::{ fmt, net::{IpAddr, Ipv4Addr, Ipv6Addr}, sync::Arc, time::Duration, }; use pyo3::{IntoPyObjectExt, coroutine::CancelHandle, prelude::*, pybacked::PyBackedStr}; use req::{Request, WebSocketRequest}; use wreq::{Prox...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/body.rs
Rust
//! Types and utilities for representing HTTP request bodies. mod form; mod json; pub mod multipart; mod stream; use bytes::Bytes; use pyo3::{ FromPyObject, PyResult, prelude::*, pybacked::{PyBackedBytes, PyBackedStr}, }; pub use self::{ form::Form, json::Json, stream::{PyStream, Streamer}, }...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/body/form.rs
Rust
/// Alias for form parameters. pub type Form = crate::client::param::Params;
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/body/json.rs
Rust
use indexmap::IndexMap; use pyo3::{FromPyObject, prelude::*, pybacked::PyBackedStr}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Represents a JSON value for HTTP requests. /// Supports objects, arrays, numbers, strings, booleans, and null. #[derive(FromPyObject, IntoPyObject, Serialize, Deserial...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/body/multipart.rs
Rust
use std::path::PathBuf; use bytes::Bytes; use pyo3::{ prelude::*, pybacked::{PyBackedBytes, PyBackedStr}, types::PyTuple, }; use wreq::{Body, multipart}; use crate::{client::body::PyStream, error::Error, header::HeaderMap}; /// A multipart form for a request. #[pyclass(subclass)] pub struct Multipart(pub...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/body/stream.rs
Rust
use std::{ pin::Pin, sync::Arc, task::{Context, Poll}, }; use bytes::Bytes; use futures_util::{FutureExt, Stream, StreamExt, stream::BoxStream}; use http_body_util::BodyExt; use pyo3::{ coroutine::CancelHandle, intern, prelude::*, pybacked::{PyBackedBytes, PyBackedStr}, }; use tokio::{sync:...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/nogil.rs
Rust
use std::{ future::Future, pin::Pin, task::{Context, Poll}, }; use pin_project_lite::pin_project; use pyo3::{ coroutine::CancelHandle, exceptions::{PyRuntimeError, asyncio::CancelledError}, prelude::*, }; use tokio::task::JoinHandle; pin_project! { /// A future that allows Python threads t...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/param.rs
Rust
use indexmap::IndexMap; use pyo3::{FromPyObject, pybacked::PyBackedStr}; use serde::{ Serialize, Serializer, ser::{SerializeMap, SerializeSeq}, }; /// Represents HTTP parameters from Python as either a mapping or a sequence of key-value pairs. /// /// This enum is used for both URL query parameters and form-en...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/query.rs
Rust
/// Alias for query parameters. pub type Query = super::param::Params;
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/req.rs
Rust
use std::{ net::{IpAddr, Ipv4Addr, Ipv6Addr}, time::Duration, }; use futures_util::TryFutureExt; use http::header::COOKIE; use pyo3::{PyResult, prelude::*, pybacked::PyBackedStr}; use wreq::Client; use wreq_util::EmulationOption; use crate::{ client::{ body::{Body, Form, Json, multipart::Multipart...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/resp.rs
Rust
mod ext; mod http; mod ws; pub use self::{ http::{BlockingResponse, Response}, ws::{BlockingWebSocket, WebSocket, msg::Message}, };
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/resp/ext.rs
Rust
use bytes::Bytes; use crate::error::Error; /// Extension trait for [`wreq::Response`] that provides convenient methods for consuming response /// bodies. /// /// This trait wraps the underlying [`wreq::Response`] methods and converts their errors to our /// custom `Error` type. pub trait ResponseExt { /// Returns...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/resp/http.rs
Rust
use std::{fmt::Display, sync::Arc}; use arc_swap::ArcSwapOption; use bytes::Bytes; use futures_util::TryFutureExt; use http::response::{Parts, Response as HttpResponse}; use http_body_util::BodyExt; use pyo3::{coroutine::CancelHandle, prelude::*, pybacked::PyBackedStr}; use wreq::{self, Uri}; use crate::{ buffer:...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/resp/ws.rs
Rust
mod cmd; pub mod msg; use std::{fmt::Display, time::Duration}; use msg::Message; use pyo3::{coroutine::CancelHandle, prelude::*, pybacked::PyBackedStr}; use tokio::sync::mpsc; use wreq::{ header::HeaderValue, ws::{self, WebSocketResponse, message::Utf8Bytes}, }; use crate::{ client::{SocketAddr, nogil::N...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/resp/ws/cmd.rs
Rust
//! WebSocket Command Utilities //! //! This module defines the `Command` enum for representing WebSocket operations //! (send, receive, close) and provides async helpers for sending commands to the //! WebSocket background task. It enables safe, concurrent, and ergonomic control //! of WebSocket communication from Pyt...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/resp/ws/msg.rs
Rust
//! WebSocket Message Utilities //! //! This module provides the `Message` type for representing WebSocket messages, //! including text, binary, ping, pong, and close frames. It offers constructors //! for creating messages of various types, as well as methods and getters for //! extracting message content (such as tex...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/cookie.rs
Rust
use std::{fmt, sync::Arc, time::SystemTime}; use bytes::Bytes; use cookie::{Cookie as RawCookie, Expiration, ParseError, time::Duration}; use pyo3::{prelude::*, pybacked::PyBackedStr, types::PyDict}; use wreq::header::{self, HeaderMap, HeaderValue}; use crate::error::Error; define_enum!( /// The Cookie SameSite ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/dns.rs
Rust
//! DNS resolution via the [hickory-resolver](https://github.com/hickory-dns/hickory-dns) crate use std::{ net::{IpAddr, SocketAddr}, sync::{Arc, OnceLock}, }; use hickory_resolver::{ TokioResolver, config::ResolverConfig, lookup_ip::LookupIpIntoIter, name_server::TokioConnectionProvider, }; use pyo3:...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/emulation.rs
Rust
use pyo3::prelude::*; define_enum!( /// An emulation. const, Emulation, wreq_util::Emulation, Chrome100, Chrome101, Chrome104, Chrome105, Chrome106, Chrome107, Chrome108, Chrome109, Chrome110, Chrome114, Chrome116, Chrome117, Chrome118, Chrome119,...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/error.rs
Rust
use pyo3::{ PyErr, create_exception, exceptions::{PyException, PyRuntimeError, PyStopAsyncIteration, PyStopIteration}, }; use wreq::header; const RACE_CONDITION_ERROR_MSG: &str = r#"Due to Rust's memory management with borrowing, you cannot use certain instances multiple times as they may be consumed. This er...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/extractor.rs
Rust
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use pyo3::{FromPyObject, prelude::*, types::PyList}; use crate::{ emulation::{Emulation, EmulationOption}, proxy::Proxy, }; /// A generic extractor for various types. pub struct Extractor<T>(pub T); impl FromPyObject<'_, '_> for Extractor<wreq_util::EmulationOptio...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/header.rs
Rust
use std::fmt; use bytes::Bytes; use pyo3::{ prelude::*, pybacked::{PyBackedBytes, PyBackedStr}, types::{PyDict, PyIterator, PyList}, }; use wreq::header::{self, HeaderName, HeaderValue}; use crate::{buffer::PyBuffer, error::Error}; /// A HTTP header map. #[derive(Clone)] #[pyclass(subclass, str, skip_fro...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/http.rs
Rust
use std::fmt; use pyo3::{class::basic::CompareOp, prelude::*}; define_enum!( /// An HTTP version. const, Version, wreq::Version, HTTP_09, HTTP_10, HTTP_11, HTTP_2, HTTP_3, ); define_enum!( /// An HTTP method. Method, wreq::Method, GET, HEAD, POST, PUT, ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/http1.rs
Rust
use pyo3::prelude::*; /// A builder for [`Http1Options`]. #[derive(Default)] struct Builder { /// Enable support for HTTP/0.9 responses. http09_responses: Option<bool>, /// Whether to use vectored writes for HTTP/1 connections. writev: Option<bool>, /// Maximum number of headers allowed in HTTP/1...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/http2.rs
Rust
use std::time::Duration; use pyo3::prelude::*; define_enum!( /// Represents the order of HTTP/2 pseudo-header fields in the header block. /// /// HTTP/2 pseudo-header fields are a set of predefined header fields that start with ':'. /// The order of these fields in a header block is significant. This ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/lib.rs
Rust
#![deny(unused)] #![deny(unsafe_code)] #![cfg_attr(test, deny(warnings))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #[macro_use] mod macros; mod buffer; mod client; mod cookie; mod dns; mod emulation; mod error; mod extractor; mod header; mod http; mod http1; mod http2; mod proxy; mod redirect; mod tls;...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/macros.rs
Rust
macro_rules! apply_option { (set_if_some, $builder:expr, $option:expr, $method:ident) => { if let Some(value) = $option.take() { $builder = $builder.$method(value); } }; (set_if_some_ref, $builder:expr, $option:expr, $method:ident) => { if let Some(value) = $option.take()...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/proxy.rs
Rust
use core::fmt; use std::fmt::Debug; use bytes::Bytes; use pyo3::{prelude::*, pybacked::PyBackedStr}; use wreq::header::HeaderValue; use crate::{error::Error, header::HeaderMap}; /// A builder for `Proxy`. #[derive(Default)] struct Builder { // Optional username for proxy authentication. username: Option<PyBa...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/redirect.rs
Rust
use std::{ fmt::{self, Debug, Display}, sync::Arc, }; use pyo3::prelude::*; use crate::{header::HeaderMap, http::StatusCode}; /// Represents the redirect policy for HTTP requests. #[derive(Clone)] #[pyclass(frozen, str, from_py_object)] pub struct Policy(pub wreq::redirect::Policy); /// A type that holds in...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls.rs
Rust
mod identity; mod keylog; mod store; use pyo3::prelude::*; pub use self::{identity::Identity, keylog::KeyLog, store::CertStore}; use crate::buffer::PyBuffer; define_enum!( /// The TLS version. const, TlsVersion, wreq::tls::TlsVersion, TLS_1_0, TLS_1_1, TLS_1_2, TLS_1_3, ); #[derive(F...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/identity.rs
Rust
use pyo3::{ PyResult, pybacked::{PyBackedBytes, PyBackedStr}, pyclass, pymethods, }; use crate::error::Error; /// Represents a private key and X509 cert as a client certificate. #[derive(Clone)] #[pyclass(from_py_object)] pub struct Identity(pub wreq::tls::Identity); #[pymethods] impl Identity { /// ...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/keylog.rs
Rust
use std::path::PathBuf; use pyo3::{pyclass, pymethods}; /// Specifies the intent for a (TLS) keylogger to be used in a client or server configuration. /// /// This type allows you to control how TLS session keys are logged for debugging or analysis. /// You can either use the default environment variable (`SSLKEYLOGF...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/store.rs
Rust
use pyo3::{ PyResult, pybacked::{PyBackedBytes, PyBackedStr}, pyclass, pymethods, }; use crate::error::Error; #[derive(Clone)] #[pyclass(from_py_object)] pub struct CertStore(pub wreq::tls::CertStore); #[pymethods] impl CertStore { /// Creates a new `CertStore`. #[new] #[pyo3(signature = (der...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67
tests/cookie_test.py
Python
import pytest import rnet from rnet.cookie import Cookie client = rnet.Client() @pytest.mark.asyncio @pytest.mark.flaky(reruns=3, reruns_delay=2) async def test_get_cookie(): jar = rnet.Jar() url = "http://localhost:8080/cookies" cookie = Cookie("test_cookie", "12345", domain="localhost", path="/cookies"...
0x676e67/rnet
1,216
An ergonomic Python HTTP Client with TLS fingerprint
Rust
0x676e67