python-trio / python-trio/trio

High level API for accessing getsockname() / getpeername()

Open
#280 8 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

There needs to be some way to get at the information in getsockname and getpeername from the high-level Stream and Listener interfaces.

It should involve an await, at least on streams, to support the PROXY protocol.

What should we do with SSLStream/SSLListener? There's a conceptual problem where the stream they're talking about doesn't exactly have an address, it's "connect to the transport's address AND THEN wrap the thing in a SSLStream". But then, it's not like getsockname/getpeername exactly has any meaning for streams anyway -- like, if you have a connected socket it's useful to be able to ask it what the two halves of the TCP 5-tuple looks like, but you can't actually do anything with this, it doesn't satisfy any invariants. Except "this might be useful for forensics".

So maybe pragmatics beats purity and SSLStream should just proxy this through to the underlying transport, and we'll leave the user to figure out how to decipher it.

Maybe a SocketAddress object that has family and sockaddr fields, plus possibly host, port, path, etc., as appropriate for the particular address?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the high-level Stream, Listener, SSLStream, and SSLListener interfaces and tracing how they wrap transports. Investigate the existing getsockname() and getpeername() access paths, then determine the API and SocketAddress shape needed for both plain and SSL streams. Done requires an agreed design, implementation, and tests for address access and SSL behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.