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

Add ipv6 support #60

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import sys
import io
import os
import socket
import shutil
from subprocess import Popen, PIPE
from string import Template
Expand Down Expand Up @@ -69,11 +70,16 @@ def do_GET(self):
if self.command == 'GET':
self.wfile.write(content)

class HTTPServerV6(HTTPServer):
address_family = socket.AF_INET6

class StreamingHttpServer(HTTPServer):
class WSGIServerV6(WSGIServer):
address_family = socket.AF_INET6

class StreamingHttpServer(HTTPServerV6):
def __init__(self):
super(StreamingHttpServer, self).__init__(
('', HTTP_PORT), StreamingHttpHandler)
('::', HTTP_PORT), StreamingHttpHandler)
with io.open('index.html', 'r') as f:
self.index_template = f.read()
with io.open('jsmpg.js', 'r') as f:
Expand Down Expand Up @@ -140,8 +146,8 @@ def main():
print('Initializing websockets server on port %d' % WS_PORT)
WebSocketWSGIHandler.http_version = '1.1'
websocket_server = make_server(
'', WS_PORT,
server_class=WSGIServer,
'::', WS_PORT,
server_class=WSGIServerV6,
handler_class=WebSocketWSGIRequestHandler,
app=WebSocketWSGIApplication(handler_cls=StreamingWebSocket))
websocket_server.initialize_websockets_manager()
Expand Down