Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow IPv6 bind in http.server #68397

Closed
LinkMauve mannequin opened this issue May 16, 2015 · 6 comments
Closed

Allow IPv6 bind in http.server #68397

LinkMauve mannequin opened this issue May 16, 2015 · 6 comments
Assignees
Labels
3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@LinkMauve
Copy link
Mannequin

LinkMauve mannequin commented May 16, 2015

BPO 24209
Nosy @gpshead, @jaraco, @berkerpeksag, @vadmium, @jleedev, @demianbrecht, @lisroach, @mayankasthana, @rpodgorny
PRs
  • bpo-24209: Adds IPv6 support when invoking http.server directly. #10595
  • bpo-24209: In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. #11767
  • bpo-24209: In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. #11767
  • bpo-24209: In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. #11767
  • Files
  • ipv6.patch: Patch adding IPv6 support to http.server.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/jaraco'
    closed_at = <Date 2019-02-07.13:28:36.405>
    created_at = <Date 2015-05-16.13:54:45.872>
    labels = ['3.8', 'type-feature', 'library']
    title = 'Allow IPv6 bind in http.server'
    updated_at = <Date 2019-02-07.13:28:36.404>
    user = 'https://bugs.python.org/LinkMauve'

    bugs.python.org fields:

    activity = <Date 2019-02-07.13:28:36.404>
    actor = 'jaraco'
    assignee = 'jaraco'
    closed = True
    closed_date = <Date 2019-02-07.13:28:36.405>
    closer = 'jaraco'
    components = ['Library (Lib)']
    creation = <Date 2015-05-16.13:54:45.872>
    creator = 'Link Mauve'
    dependencies = []
    files = ['39390']
    hgrepos = []
    issue_num = 24209
    keywords = ['patch']
    message_count = 6.0
    messages = ['243317', '243883', '315853', '330071', '334897', '335020']
    nosy_count = 10.0
    nosy_names = ['gregory.p.smith', 'jaraco', 'berker.peksag', 'martin.panter', 'jleedev', 'demian.brecht', 'Link Mauve', 'lisroach', 'masthana', 'rpodgorny']
    pr_nums = ['10595', '11767', '11767', '11767']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue24209'
    versions = ['Python 3.8']

    @LinkMauve
    Copy link
    Mannequin Author

    LinkMauve mannequin commented May 16, 2015

    When running `python -m http.server -b ::` (or any other IPv6), I’d expect people to be able to download from my IPv6.

    This patch fixes that issue.

    I also tested it on a dual-stack kernel, IPv4 requests work just fine and appear as ::ffff:127.0.0.1 for example.

    @LinkMauve LinkMauve mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels May 16, 2015
    @vadmium
    Copy link
    Member

    vadmium commented May 23, 2015

    I am no IPv6 expert, but this looks like a reasonable first approximation. The “http.server” module documentation should also be updated to say IPv6 addresses are supported on the command line, and I guess there should be a test case added.

    But maybe see Lib/smtpd.py line 657 for how this is done in a more general way for the SMTP server module (bpo-14758), using getaddrinfo(). There is also bpo-20215 proposing to do something equivalent in the lower level “socketserver” module, which would probably make this change redundant.

    It would also be nice for it to bind to both IPv4 and IPv6 if possible, but that is apparently not easy to do cross platform; see bpo-3213.

    @jaraco
    Copy link
    Member

    jaraco commented Apr 27, 2018

    From what I can tell, there's not currently any tests for the behavior of http.server as a script, and that sounds like a non-trivial behavior to test. I agree documentation updates for this change are essential, but I'd suggest a test is too high a burden to ask for a change like this when there aren't already tests exercising the related functionality.

    @lisroach
    Copy link
    Contributor

    Looks like the original author isn't around anymore (feel free to chime in if you are, Link!), so I went ahead and made a PR. I added a quick unit test, it's not much but more than nothing, plus updated the documentation.

    @gpshead gpshead added the 3.8 only security fixes label Nov 19, 2018
    @jaraco
    Copy link
    Member

    jaraco commented Feb 6, 2019

    I don't believe the current patch as accepted has the right behaviors. First off, the default behavior, which indicates "all interfaces" only binds to IPv4 interfaces. Additionally, "-b localhost" only binds to IPv4 localhost.

    Ideally, the bind should happen on all stacks unless a specific stack is indicated.

    @jaraco jaraco self-assigned this Feb 6, 2019
    @jaraco
    Copy link
    Member

    jaraco commented Feb 7, 2019

    New changeset f289084 by Jason R. Coombs in branch 'master':
    bpo-24209: In http.server script, rely on getaddrinfo to bind to preferred address based on the bind parameter. (bpo-11767)
    f289084

    @jaraco jaraco closed this as completed Feb 7, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants