Skip to content

Conversation

@Julow
Copy link
Contributor

@Julow Julow commented Jul 2, 2025

This improve the API for querying the client's connection info, which makes less sense since the added support for unix domain sockets.

The client_conn type no longer loose connection information:

  • The client port is available.
  • Failure points are removed in favor of a `Unknown case

The `Forwarded_for case makes sure that IP addresses reported through the x_forwarded_for HTTP header can't be used by Accesscontrol by mistake.

There are two API for this information:

  • client_conn_to_string: Returns the information in textual form for when the data don't need to be parsed back. For example, ideal in log messages. It's also used to set the x_forwarded_for header, where using a wrong format is better than inventing data in cases where we don't use Internet.
  • client_conn: The full data without superfluous transformations.

An other change is that the client IP address doesn't go through getaddrinfo (via Ipaddr_unix.to_inet_addr). This doesn't change anything in the general case but might remove a potential exploit on servers where /etc/hosts is compromised.

This is a second attempt at #270 which was partially reverted because the API name was bad. This new attempt is also free of workarounds and conversions to and from Unix.inet_addr.

This improve the API for querying the client's connection info, which
makes less sense since the added support for unix domain sockets.

The `client_conn` type no longer loose connection information:
- The client port is available.
- Failure points are removed in favor of a `` `Unknown `` case

The `` `Forwarded_for `` case makes sure that IP addresses reported
through the `x_forwarded_for` HTTP header can't be used by
`Accesscontrol` by mistake.

There are two API for this information:
- `client_conn_to_string`: Returns the information in textual form for when the
  data don't need to be parsed back. For example, ideal in log messages.
  It's also used to set the `x_forwarded_for` header, where using a
  wrong format is better than inventing data in cases where we don't use
  Internet.
- `client_conn`: The full data without superfluous transformations.
Julow added a commit to Julow/eliom that referenced this pull request Jul 3, 2025
@balat balat merged commit c39e80f into ocsigen:master Jul 6, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants