Skip to content

fish_config: Listen on both IPv6 and IPv4. - #1324

Closed
anders wants to merge 1 commit into
fish-shell:masterfrom
anders:ipv6-config
Closed

anders wants to merge 1 commit into
fish-shell:masterfrom
anders:ipv6-config

Conversation

@anders

@anders anders commented Mar 4, 2014

Copy link
Copy Markdown
Contributor

Right now it only listens on IPv4. Let's take one step into the future ;)

anders referenced this pull request Mar 4, 2014
Before this change, fish config used 0 as its address. However, this
isn't a good idea from security point of view, as web service can be
accessed from everywhere, and do anything on the account it was ran on.

This also deals with firewalls which block the access to 0 even from
the host machine itself. It possibly might fix #673, but I'm not sure.
@geoff-nixon

Copy link
Copy Markdown
Contributor

👍 For anyone who missed the memo, the discussion rationale for this PR is here.

@ridiculousfish

Copy link
Copy Markdown
Member

This breaks fish_config for me. In this test:

class FishConfigTCPServer(SocketServer.TCPServer):
    """TCPServer that only accepts connections from localhost (IPv4/IPv6)."""
    WHITELIST = set(['::1', '127.0.0.1'])

    address_family = socket.AF_INET6

    def verify_request(self, request, client_address):
        return client_address[0] in FishConfigTCPServer.WHITELIST

I see that client_address[0] is ::ffff:127.0.0.1, which is not in the whitelist, so is rejected by verify_request. Not sure what the right fix is.

@geoff-nixon

Copy link
Copy Markdown
Contributor

Grr.

A subclass of TCPServer was created to deny any non-local connections and to
listen using an IPv6 socket.
@anders

anders commented Mar 6, 2014

Copy link
Copy Markdown
Contributor Author

Sorry, that was a dumb mistake of mine. Didn't take v4-mapped addresses into consideration. Fixed it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From http://docs.python.org/2/library/socketserver.html :

"Note The SocketServer module has been renamed to socketserver in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3."

It would be nice if you could update this pull request and test it with python3 too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have Python 3 (OS X) but the code already used SocketServer. If fish_config works with Python 3 now, then it should still work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sisteshwar: socketserver for Python 3 is already imported correctly.

if IS_PY2:
    import SimpleHTTPServer
    import SocketServer
    try:
        from urllib.parse import parse_qs
    except ImportError:
        from cgi import parse_qs
else:
    import http.server as SimpleHTTPServer
    import socketserver as SocketServer
    from urllib.parse import parse_qs

@ridiculousfish

Copy link
Copy Markdown
Member

Works for me with Python 2 and 3. Thanks for the fix! Merged as 44b35f7

@anders
anders deleted the ipv6-config branch December 1, 2014 02:42
@anders
anders restored the ipv6-config branch December 1, 2014 02:43
@anders
anders deleted the ipv6-config branch December 1, 2014 02:43
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants