uv init
uv add aioquic
uv run python client.py
Created
March 2, 2026 05:58
-
-
Save masakielastic/a2040cba2a76ea595a9078155dd0ba7d to your computer and use it in GitHub Desktop.
aioquic でハンドシェイクのみ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import ssl | |
| from aioquic.asyncio import connect, QuicConnectionProtocol | |
| from aioquic.quic.configuration import QuicConfiguration | |
| HOST = "localhost" | |
| PORT = 4433 | |
| class HandshakeOnly(QuicConnectionProtocol): | |
| # 何も処理しない(HTTP/3の受信uni streamが来ても握りつぶす) | |
| def quic_event_received(self, event) -> None: | |
| return | |
| async def main() -> None: | |
| cfg = QuicConfiguration( | |
| is_client=True, | |
| alpn_protocols=["h3"], | |
| ) | |
| cfg.verify_mode = ssl.CERT_NONE | |
| async with connect( | |
| HOST, | |
| PORT, | |
| configuration=cfg, | |
| create_protocol=HandshakeOnly, | |
| wait_connected=True, | |
| ) as proto: | |
| # ここに来た時点でハンドシェイク成功 | |
| proto._quic.close(error_code=0x0, reason_phrase="bye") | |
| await asyncio.sleep(0.05) # close を送る猶予 | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment