server: add options to choose the address to bind to
Sometimes a user might want to bind to localhost only for testing or have multiple interfaces per IP version and only one must be used.
This commit is contained in:
parent
5f20fe2365
commit
534f7f2af5
@ -38,6 +38,7 @@ def failed4(f):
|
||||
def main():
|
||||
argsGetter = ConfigurationGetter()
|
||||
args = argsGetter.getConfiguration()
|
||||
|
||||
factory = SyncFactory(
|
||||
args.port,
|
||||
args.password,
|
||||
@ -55,15 +56,15 @@ def main():
|
||||
)
|
||||
|
||||
if args.ipv6_only is True:
|
||||
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port))
|
||||
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port), interface=args.interface_ipv6)
|
||||
endpoint6.listen(factory).addCallbacks(isListening6, failed6)
|
||||
elif args.ipv4_only is True:
|
||||
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port))
|
||||
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port), interface=args.interface_ipv4)
|
||||
endpoint4.listen(factory).addCallbacks(isListening4, failed4)
|
||||
else:
|
||||
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port))
|
||||
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port), interface=args.interface_ipv6)
|
||||
endpoint6.listen(factory).addCallbacks(isListening6, failed6)
|
||||
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port))
|
||||
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port), interface=args.interface_ipv4)
|
||||
endpoint4.listen(factory).addCallbacks(isListening4, failed4)
|
||||
|
||||
if ServerStatus.listening6 or ServerStatus.listening4:
|
||||
|
||||
@ -501,6 +501,8 @@ de = {
|
||||
"server-messed-up-motd-too-long": "Die Nachricht des Tages ist zu lang - Maximal {} Zeichen, aktuell {}.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Unbekannter Befehl {}", # message
|
||||
|
||||
@ -502,6 +502,8 @@ en = {
|
||||
"server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Unknown command {}", # message
|
||||
|
||||
@ -505,6 +505,8 @@ eo = {
|
||||
"server-messed-up-motd-too-long": "Mesaĝo de tago estas tro longa – maksimuma kvanto estas {} signoj, sed {} estas donitaj.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Nekonata ordono {}", # message
|
||||
|
||||
@ -501,6 +501,8 @@ es = {
|
||||
"server-messed-up-motd-too-long": "El mensaje del día es muy largo - máximo de {} caracteres, se recibieron {}.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Comando desconocido {}", # message
|
||||
|
||||
@ -502,6 +502,8 @@ fr = {
|
||||
"server-messed-up-motd-too-long": "Le message du jour est trop long: {}caractères maximum, {} donnés.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Commande inconnue {}", # message
|
||||
|
||||
@ -501,6 +501,8 @@ it = {
|
||||
"server-messed-up-motd-too-long": "Il messaggio del giorno è troppo lungo - numero massimo di caratteri è {}, {} trovati.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Comando non riconosciuto {}", # message
|
||||
|
||||
@ -502,6 +502,8 @@ pt_BR = {
|
||||
"server-messed-up-motd-too-long": "A Mensagem do Dia é muito longa - máximo de {} caracteres, {} foram dados.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Comando desconhecido: {}", # message
|
||||
|
||||
@ -501,6 +501,8 @@ pt_PT = {
|
||||
"server-messed-up-motd-too-long": "A Mensagem do Dia é muito longa - máximo de {} caracteres, {} foram dados.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Comando desconhecido: {}", # message
|
||||
|
||||
@ -498,6 +498,8 @@ ru = {
|
||||
"server-messed-up-motd-too-long": "MOTD-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Неизвестная команда: {}", # message
|
||||
|
||||
@ -502,6 +502,8 @@ tr = {
|
||||
"server-messed-up-motd-too-long": "Günün Mesajı çok uzun - maksimum {} karakter olmalı, {} verildi.",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "Bilinmeyen komut {}", # message
|
||||
|
||||
@ -502,6 +502,8 @@ zh_CN = {
|
||||
"server-messed-up-motd-too-long": "每日信息过长 - 最大{}个chars, 给出的长度{}",
|
||||
"server-listen-only-on-ipv4": "Listen only on IPv4 when starting the server.",
|
||||
"server-listen-only-on-ipv6": "Listen only on IPv6 when starting the server.",
|
||||
"server-interface-ipv4": "The IP address to bind to for IPv4. Leaving it empty defaults to using all.",
|
||||
"server-interface-ipv6": "The IP address to bind to for IPv6. Leaving it empty defaults to using all.",
|
||||
|
||||
# Server errors
|
||||
"unknown-command-server-error": "未知命令 {}", # message
|
||||
|
||||
@ -891,3 +891,5 @@ class ConfigurationGetter(object):
|
||||
self._argparser.add_argument('--tls', metavar='path', type=str, nargs='?', help=getMessage("server-startTLS-argument"))
|
||||
self._argparser.add_argument('--ipv4-only', action='store_true', help=getMessage("server-listen-only-on-ipv4"))
|
||||
self._argparser.add_argument('--ipv6-only', action='store_true', help=getMessage("server-listen-only-on-ipv6"))
|
||||
self._argparser.add_argument('--interface-ipv4', metavar='interfaceIPv4', type=str, nargs='?', help=getMessage("server-interface-ipv4"), default='')
|
||||
self._argparser.add_argument('--interface-ipv6', metavar='interfaceIPv6', type=str, nargs='?', help=getMessage("server-interface-ipv6"), default='')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user