Added support for binding IPv4 AND IPv6 instead of just either one or the other

pull/2653/head v1.4.4-beta.41
Omar Pakker 3 months ago committed by GitHub
parent 92708e722f
commit 4e365c6aa6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -31,6 +31,8 @@ def base_url_slash_cleaner(uri):
def validate_ip_address(ip_string): def validate_ip_address(ip_string):
if ip_string == '*':
return True
try: try:
ip_address(ip_string) ip_address(ip_string)
return True return True
@ -73,7 +75,7 @@ validators = [
# general section # general section
Validator('general.flask_secret_key', must_exist=True, default=hexlify(os.urandom(16)).decode(), Validator('general.flask_secret_key', must_exist=True, default=hexlify(os.urandom(16)).decode(),
is_type_of=str), is_type_of=str),
Validator('general.ip', must_exist=True, default='0.0.0.0', is_type_of=str, condition=validate_ip_address), Validator('general.ip', must_exist=True, default='*', is_type_of=str, condition=validate_ip_address),
Validator('general.port', must_exist=True, default=6767, is_type_of=int, gte=1, lte=65535), Validator('general.port', must_exist=True, default=6767, is_type_of=int, gte=1, lte=65535),
Validator('general.base_url', must_exist=True, default='', is_type_of=str), Validator('general.base_url', must_exist=True, default='', is_type_of=str),
Validator('general.path_mappings', must_exist=True, default=[], is_type_of=list), Validator('general.path_mappings', must_exist=True, default=[], is_type_of=list),

@ -58,10 +58,13 @@ class NoExceptionFormatter(logging.Formatter):
class UnwantedWaitressMessageFilter(logging.Filter): class UnwantedWaitressMessageFilter(logging.Filter):
def filter(self, record): def filter(self, record):
if settings.general.debug: if settings.general.debug or "BAZARR" in record.msg:
# no filtering in debug mode # no filtering in debug mode or if originating from us
return True return True
if record.level != loggin.ERROR:
return False
unwantedMessages = [ unwantedMessages = [
"Exception while serving /api/socket.io/", "Exception while serving /api/socket.io/",
['Session is disconnected', 'Session not found'], ['Session is disconnected', 'Session not found'],
@ -161,7 +164,7 @@ def configure_logging(debug=False):
logging.getLogger("websocket").setLevel(logging.CRITICAL) logging.getLogger("websocket").setLevel(logging.CRITICAL)
logging.getLogger("ga4mp.ga4mp").setLevel(logging.ERROR) logging.getLogger("ga4mp.ga4mp").setLevel(logging.ERROR)
logging.getLogger("waitress").setLevel(logging.ERROR) logging.getLogger("waitress").setLevel(logging.INFO)
logging.getLogger("waitress").addFilter(UnwantedWaitressMessageFilter()) logging.getLogger("waitress").addFilter(UnwantedWaitressMessageFilter())
logging.getLogger("knowit").setLevel(logging.CRITICAL) logging.getLogger("knowit").setLevel(logging.CRITICAL)
logging.getLogger("enzyme").setLevel(logging.CRITICAL) logging.getLogger("enzyme").setLevel(logging.CRITICAL)

@ -50,7 +50,7 @@ class Server:
self.connected = True self.connected = True
except OSError as error: except OSError as error:
if error.errno == errno.EADDRNOTAVAIL: if error.errno == errno.EADDRNOTAVAIL:
logging.exception("BAZARR cannot bind to specified IP, trying with default (0.0.0.0)") logging.exception("BAZARR cannot bind to specified IP, trying with 0.0.0.0")
self.address = '0.0.0.0' self.address = '0.0.0.0'
self.connected = False self.connected = False
super(Server, self).__init__() super(Server, self).__init__()
@ -76,8 +76,7 @@ class Server:
self.shutdown(EXIT_INTERRUPT) self.shutdown(EXIT_INTERRUPT)
def start(self): def start(self):
logging.info(f'BAZARR is started and waiting for request on http://{self.server.effective_host}:' self.server.print_listen("BAZARR is started and waiting for requests on: http://{}:{}")
f'{self.server.effective_port}')
signal.signal(signal.SIGINT, self.interrupt_handler) signal.signal(signal.SIGINT, self.interrupt_handler)
try: try:
self.server.run() self.server.run()

@ -43,10 +43,10 @@ const SettingsGeneralView: FunctionComponent = () => {
<Section header="Host"> <Section header="Host">
<Text <Text
label="Address" label="Address"
placeholder="0.0.0.0" placeholder="*"
settingKey="settings-general-ip" settingKey="settings-general-ip"
></Text> ></Text>
<Message>Valid IPv4 address or '0.0.0.0' for all interfaces</Message> <Message>Valid IP address or '*' for all interfaces</Message>
<Number <Number
label="Port" label="Port"
placeholder="6767" placeholder="6767"

Loading…
Cancel
Save