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

Listen on IPv6 #48

Closed
limbo127 opened this issue Apr 18, 2019 · 1 comment · Fixed by #55
Closed

Listen on IPv6 #48

limbo127 opened this issue Apr 18, 2019 · 1 comment · Fixed by #55
Assignees

Comments

@limbo127
Copy link

limbo127 commented Apr 18, 2019

hello,
how listen only on specifiq ipv6 address

python /tmp/proxy.py --hostname [fd00::8e2:97ff:fe2e:f1ea] --port 8081 --log-level DEBUG
2019-04-18 15:32:05,116 - INFO - run:633 - Starting server on port 8081
2019-04-18 15:32:05,125 - ERROR - run:643 - Exception while running the server gaierror(-2, 'Name or service not known')
Traceback (most recent call last):
  File "/tmp/proxy.py", line 636, in run
    self.socket.bind((self.hostname, self.port))
  File "/usr/lib64/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
gaierror: [Errno -2] Name or service not known
2019-04-18 15:32:05,126 - INFO - run:645 - Closing server socket
python /tmp/proxy.py --hostname fd00::8e2:97ff:fe2e:f1ea --port 8081 --log-level DEBUG
2019-04-18 15:32:17,082 - INFO - run:633 - Starting server on port 8081
2019-04-18 15:32:17,082 - ERROR - run:643 - Exception while running the server gaierror(-9, 'Address family for hostname not supported')
Traceback (most recent call last):
  File "/tmp/proxy.py", line 636, in run
    self.socket.bind((self.hostname, self.port))
  File "/usr/lib64/python2.7/socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
gaierror: [Errno -9] Address family for hostname not supported
2019-04-18 15:32:17,082 - INFO - run:645 - Closing server socket
Repository owner deleted a comment from limbo127 Apr 19, 2019
@abhinavsingh abhinavsingh added enhancement Question Questions related to proxy server labels Apr 19, 2019
@abhinavsingh abhinavsingh changed the title how listen on ipv6 Listen on IPv6 Apr 19, 2019
@abhinavsingh
Copy link
Owner

This should be possible with a single line of change

diff --git a/proxy.py b/proxy.py
index c633ac9..30532b9 100755
--- a/proxy.py
+++ b/proxy.py
@@ -631,7 +631,7 @@ class TCP(object):
     def run(self):
         try:
             logger.info('Starting server on port %d' % self.port)
-            self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+            self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
             self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
             self.socket.bind((self.hostname, self.port))
             self.socket.listen(self.backlog)

However, instead of hardcoding AF_INET6 its better to enable IPv6 via a command line flag. I'll send out a PR to address the same. In the meantime, you can make this 1 line change to unblock yourself :)

@abhinavsingh abhinavsingh self-assigned this Apr 19, 2019
@abhinavsingh abhinavsingh removed the Question Questions related to proxy server label Jul 9, 2019
abhinavsingh added a commit that referenced this issue Jul 20, 2019
Use `--ipv4 1` to only listen on IPv4. Fixes #48
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 a pull request may close this issue.

2 participants