Skip to content

HostPreference not binding correctly for !6 and * special values #78

@laurenceisla

Description

@laurenceisla

We stumbled with this problem via Warp and opened an issue there: yesodweb/wai#976 (comment). But the problem was with how HostPreference was behaving which is defined in this project.

I'll copy the issue here:

Issue

When setting a !6 host preference it does not seem to bind to ipv6 exclusively, because ipv4 requests do not fail. Also, when setting the preference to *, ipv6 requests fail when they shouldn't.

I included a simple example with Warp in this Gist: https://gist.github.com/laurenceisla/61af763fb028437f24e5a869225eb1f8

These are the results I got:

It allows both ipv4 and ipv6 requests when setHost !6

$ curl "http://localhost:3000" --ipv4 -I
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Date: Thu, 08 Feb 2024 01:19:54 GMT
Server: Warp/3.4.0
Content-Type: text/plain

It does not allow ipv6 requests when setHost *

$ curl "http://localhost:3000" --ipv6 -I
curl: (7) Failed to connect to localhost port 3000 after 0 ms: Couldn't connect to server

setHost !4 working as expected

$ curl "http://localhost:3000" --ipv6 -I
curl: (7) Failed to connect to localhost port 3000 after 0 ms: Couldn't connect to server

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions