From 43b461107914a93f76f316b9afc8aff376a9e24a Mon Sep 17 00:00:00 2001 From: Satoshi Fukutomi Date: Thu, 15 Feb 2024 08:57:56 +0900 Subject: [PATCH] fix error for ipv4 bind addr --- shingetsu/LightCGIHTTPServer.py | 3 +-- shingetsu/httpd.py | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/shingetsu/LightCGIHTTPServer.py b/shingetsu/LightCGIHTTPServer.py index 0ee3a2d..73b25b8 100644 --- a/shingetsu/LightCGIHTTPServer.py +++ b/shingetsu/LightCGIHTTPServer.py @@ -29,7 +29,6 @@ import copy import os import re -import socket import sys import urllib.parse import http.server @@ -269,4 +268,4 @@ def copyfile(self, source, outputfile): class HTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer): - address_family = socket.AF_INET6 + pass diff --git a/shingetsu/httpd.py b/shingetsu/httpd.py index 57863d2..7e8f424 100644 --- a/shingetsu/httpd.py +++ b/shingetsu/httpd.py @@ -1,7 +1,7 @@ '''Tiny HTTP server running in another thread. ''' # -# Copyright (c) 2005-2023 shinGETsu Project. +# Copyright (c) 2005-2024 shinGETsu Project. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -25,17 +25,14 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id$ -# import os +import socket import threading from . import config from . import LightCGIHTTPServer -__version__ = "$Revision$" - class Httpd(threading.Thread): @@ -48,6 +45,8 @@ def __init__(self): HandlerClass = LightCGIHTTPServer.HTTPRequestHandler ServerClass = LightCGIHTTPServer.HTTPServer + if not config.bind_addr or ':' in config.bind_addr: + ServerClass.address_family = socket.AF_INET6 server_address = (config.bind_addr, config.port) HandlerClass.server_version = config.version HandlerClass.root_index = config.root_index