Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add "--insecure" for wss endpoints #1675#1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
abex-py wants to merge1 commit intopython-websockets:main
base:main
Choose a base branch
Loading
fromabex-py:main
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletionssrc/websockets/cli.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@
from .exceptions import ConnectionClosed
from .frames import Close
from .streams import StreamReader
from .uri import parse_uri
from .version import version as websockets_version


Expand DownExpand Up@@ -101,9 +102,14 @@ async def send_outgoing_messages(
break


async def interactive_client(uri: str) -> None:
async def interactive_client(uri: str, insecure: bool = False) -> None:
try:
websocket = await connect(uri)
if insecure and parse_uri(uri).secure:
import ssl

websocket = await connect(uri, ssl=ssl._create_unverified_context())
else:
websocket = await connect(uri)
except Exception as exc:
print(f"Failed to connect to {uri}: {exc}.")
sys.exit(1)
Expand DownExpand Up@@ -151,6 +157,9 @@ def main(argv: list[str] | None = None) -> None:
group = parser.add_mutually_exclusive_group()
group.add_argument("--version", action="store_true")
group.add_argument("uri", metavar="<uri>", nargs="?")

parser.add_argument("--insecure", action="store_true")

args = parser.parse_args(argv)

if args.version:
Expand All@@ -173,6 +182,6 @@ def main(argv: list[str] | None = None) -> None:

# Remove the try/except block when dropping Python < 3.11.
try:
asyncio.run(interactive_client(args.uri))
asyncio.run(interactive_client(args.uri, insecure=args.insecure))
except KeyboardInterrupt: # pragma: no cover
pass

[8]ページ先頭

©2009-2025 Movatter.jp