diff options
author | Martin Maney <maney@two14.net> | 2014-06-27 20:41:51 -0500 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2014-07-16 14:01:15 +0200 |
commit | 1c9921b3f85bc82c1af7c75e533445f6dcb4d7e5 (patch) | |
tree | 874248a3c4456c0cb5fdcf327fc5b517445273a1 | |
parent | 3e7fedf0c05e2c36f6176ace36eeaf1d92471ffe (diff) | |
download | miniircd-1c9921b3f85bc82c1af7c75e533445f6dcb4d7e5.tar.gz miniircd-1c9921b3f85bc82c1af7c75e533445f6dcb4d7e5.zip |
Added --listen option to set address to bind to
-rwxr-xr-x | miniircd | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -641,7 +641,13 @@ class Server(object): self.chroot = options.chroot self.setuid = options.setuid self.statedir = options.statedir - self.name = socket.getfqdn()[:63] # Server name limit from the RFC. + + if options.listen: + self.address = socket.gethostbyname(options.listen) + else: + self.address = "" + self.name = socket.getfqdn(self.address)[:63] # Server name limit from the RFC. + self.channels = {} # irc_lower(Channel name) --> Channel instance. self.clients = {} # Socket --> Client instance. self.nicknames = {} # irc_lower(Nickname) --> Client instance. @@ -737,7 +743,7 @@ class Server(object): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: - s.bind(("", port)) + s.bind((self.address, port)) except socket.error as e: self.print_error("Could not bind port %s: %s." % (port, e)) sys.exit(1) @@ -816,6 +822,10 @@ def main(argv): action="store_true", help="print debug messages to stdout") op.add_option( + "--listen", + metavar = "X", + help = "listen on specific IP address") + op.add_option( "--logdir", metavar="X", help="store channel log in directory X") |