Skip to content
Snippets Groups Projects
Commit 5a9b8b1f authored by Willem Mulder's avatar Willem Mulder Committed by Eric S. Raymond
Browse files

Add option to set socket connection timeout.

parent 2d5963fb
No related branches found
No related tags found
No related merge requests found
irker history
Repostory head:
Add socket connection-timeout option.
2.19: 2020-06-29
Codebase is now fully forward-poerted to Python 3.
......
......@@ -280,7 +280,7 @@ class IRCServerConnection():
LOG.warning(
'cannot check SSL/TLS hostname with Python %s' % sys.version)
def connect(self, target, nickname, username=None, realname=None,
def connect(self, target, nickname, username=None, realname=None, timeout=5.0,
**kwargs):
LOG.debug("connect(server=%r, port=%r, nickname=%r, ...)" % (
target.servername, target.port, nickname))
......@@ -302,7 +302,9 @@ class IRCServerConnection():
self.socket = self._wrap_socket(
socket=self.socket, target=target, **kwargs)
self.socket.bind(('', 0))
self.socket.settimeout(timeout)
self.socket.connect((target.servername, target.port))
self.socket.settimeout(None)
except socket.error as err:
raise IRCServerConnectionError("Couldn't connect to socket: %s" % err)
......@@ -987,6 +989,9 @@ if __name__ == '__main__':
parser.add_argument(
'-p', '--password', metavar='PASSWORD',
help='NickServ password')
parser.add_argument(
'-t', '--timeout', metavar='TIMEOUT', type=float, default=5.0,
help="connection timeout in seconds (default: 5.0)")
parser.add_argument(
'-i', '--immediate', metavar='IRC-URL',
help=(
......@@ -1019,6 +1024,7 @@ if __name__ == '__main__':
password=args.password,
cafile=args.ca_file,
certfile=args.cert_file,
timeout=args.timeout,
)
LOG.info("irkerd version %s" % version)
if args.immediate:
......
......@@ -26,6 +26,7 @@
<arg>-n <replaceable>nick</replaceable></arg>
<arg>-p <replaceable>password</replaceable></arg>
<arg>-i <replaceable>IRC-URL</replaceable></arg>
<arg>-t <replaceable>timeout</replaceable></arg>
<arg>-V</arg>
<arg>-h</arg>
<arg choice='opt'><replaceable>message text</replaceable></arg>
......@@ -184,6 +185,11 @@ password to be used. If given, this password is shipped to
authenticate the nick on receipt of a welcome message.</para></listitem>
</varlistentry>
<varlistentry>
<term>-t</term>
<listitem><para>Takes a following value, setting the connection
timeout for server-socket opens.</para></listitem>
</varlistentry>
<varlistentry>
<term>-i</term>
<listitem><para>Immediate mode, to be run in foreground. Takes a following
following value interpreted as a channel URL. May take a second
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment