3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 11:39:25 +01:00
Commit Graph

314 Commits

Author SHA1 Message Date
James Lu
1ff027152a Irc: remove outdated cert/keyfile comment 2017-05-28 20:09:26 -07:00
James Lu
2737b6bbfc Irc: simplify _send() code and replace unencodable characters 2017-05-27 02:21:12 -07:00
James Lu
1246edaf2c Irc: initial work on encoding support (#101) 2017-05-27 01:27:09 -07:00
James Lu
ead20f5be9 Irc: log full tracebacks when disconnecting due to an error 2017-05-16 16:30:03 -07:00
James Lu
fd3236ddb7 Irc: fix another CPU loop on 'disconnect' 2017-05-12 19:52:40 -07:00
James Lu
daa6593534 Irc: block when the queue is empty instead of needlessly polling it
Rework Irc.processQueue() to block when the queue is full, and abort if the item "None" is sent to it.
To make sure that the None isn't caught by a full queue or pushed back by other elements, this modifies queue.Queue's underlying deque instance directly.

Closes #459.
2017-05-12 17:55:24 -07:00
James Lu
06d49f4433 Revert "Irc: only disconnect the write portion of the socket"
This reverts commit f4babc6f28.
2017-05-12 17:19:16 -07:00
James Lu
7daef0000b Irc: break out of processQueue properly when a network disconnects 2017-05-09 23:31:20 -07:00
James Lu
701f01fa4f Irc: reword error message from last commit to be more concise 2017-05-09 18:19:35 -07:00
James Lu
bac6dc36b4 Irc: log socket.send() errors with a proper traceback 2017-05-09 18:06:51 -07:00
James Lu
4ca8667669 Irc: fix 62aea23879 (lowercase queue) 2017-05-07 17:34:04 -07:00
James Lu
62aea23879 Irc: fix throttle_time not actually blocking for the defined amount of time
Passing the timeout to queue.Queue.get is invalid because it'll only block if there ISN'T any text to send.
2017-05-07 17:31:31 -07:00
James Lu
15ed251ed7 Irc: refuse to queue send data if aborted is set 2017-05-07 13:46:25 -07:00
James Lu
de67fe0d37 Irc: log socket shutdown errors to debug 2017-05-07 13:46:15 -07:00
James Lu
f4babc6f28 Irc: only disconnect the write portion of the socket
Per https://docs.python.org/3/howto/sockets.html#disconnecting
2017-05-07 13:46:06 -07:00
James Lu
5d629f7331 matchHost: extend negation via "!" to regular hostmasks as well as exttargets 2017-05-04 19:04:03 -07:00
James Lu
6d96dd21ac updateTS: remove usage of mutable as function default argument
This may subtly break things: https://docs.quantifiedcode.com/python-anti-patterns/correctness/mutable_default_value_as_argument.html
2017-04-09 14:45:12 -07:00
James Lu
348572bcb6 Irc: rewrite sendq to use queue.Queue, and add an upper bound (maxsendq)
Closes #430. Closes #442.
2017-03-31 17:41:56 -07:00
James Lu
9d9b01839c Split Irc.reply() into _reply() to make 'networks.remote' actually thread-safe
Previously, the Irc.reply_lock check was in the reply() function itself: replacing it with another function checking for the same lock would delay execution,
but then run the wrong reply() code if another module used irc.reply() while 'remote' was executing.
2017-03-31 16:25:28 -07:00
James Lu
ae6c68018b core: half the default throttle time (from 0.01 to 0.005) 2017-03-28 22:38:54 -07:00
James Lu
938a1fb9d7 Irc: reorder comments from last commit 2017-03-26 14:25:02 -07:00
James Lu
397df48efd Irc: simplify runloop error catching, adding RuntimeError and SystemExit (closes #438)
socket.error is aliased to OSError since Python 3.3, and ConnectionError is actually a subclass of OSError.
So, it makes more sense to just catch the more generic type here.

Also, make ProtocolError derive from RuntimeError instead of Exception.
2017-03-26 14:17:37 -07:00
James Lu
e3c0bf6a1b Irc: break out of processQueue as soon as self.aborted is set 2017-03-24 18:40:02 -07:00
James Lu
99d3780773 Irc: add locking for reply() calls (#437) 2017-03-24 00:57:21 -07:00
James Lu
ff6d961922 Protocol: add missing self in hasCap() 2017-03-23 22:41:12 -07:00
James Lu
f512ae1b33 Protocol: add a hasCap() wrapper function (#337) 2017-03-15 23:46:13 -07:00
James Lu
2ca0cf05a0 Start work on protocol capabilities (#337) 2017-03-15 23:32:47 -07:00
James Lu
afc5cc26fa Irc: more compact __repr__ for IrcChannel/IrcServer/IrcUser 2017-03-11 22:49:48 -08:00
James Lu
2028cab04c core: Grow autoconnect delays by a configurable factor whenever connections fail
Closes #348.
2017-03-11 00:21:30 -08:00
James Lu
9e50c5e69a Irc: try to make breaking out of autoconnect loops faster 2017-03-10 23:57:37 -08:00
James Lu
3096c54bb8 Irc: return in msg() if the main client is missing and no explicit source is set 2017-03-10 23:47:07 -08:00
James Lu
9a9e0b2c20 Irc: deprecate the botdata field as well (#273) 2017-03-05 00:14:43 -08:00
James Lu
b4f70bdece Irc: remove duplicate botdata assignment 2017-03-05 00:06:49 -08:00
James Lu
4284853a4a Irc: remove internal use of 'conf' and 'botdata' (#273) 2017-03-05 00:06:44 -08:00
James Lu
7f070448b7 utils, Irc: add abstraction to warn on deprecated attribute usage (#273) 2017-03-05 00:00:26 -08:00
James Lu
5fe277f90d Irc: mention CIDR matching (#411) and casemappings in matchHost() desc. 2017-02-25 22:26:37 -08:00
James Lu
4df8567fa6 Irc: move PYLINK_DISCONNECT firing and connected.clear() into disconnect() (#421)
This may prevent extra irc.connected.clear() calls from messing with the was_connected state.
2017-02-25 22:06:43 -08:00
James Lu
7c0cb92696 Irc: hack in CIDR support in matchHost() (#411) 2017-02-24 22:27:26 -08:00
James Lu
04fa0520a6 Irc: make was_successful check the last Irc.connected state 2017-02-24 22:09:41 -08:00
James Lu
b30d696e3a Irc: add "was_successful" data key to PYLINK_DISCONNECT
This stores whether the network was actually connected before this disconnect message fired (i.e. the disconnect wasn't caused by a configuration error, etc.)
2017-02-24 21:42:44 -08:00
James Lu
3d9f69dba7 Irc: deprecate checkAuthenticated() 2017-02-24 18:42:58 -08:00
James Lu
21cbcb8cf6 Irc: fix / simplify defaults in msg(), reply, error() 2017-02-24 16:28:23 -08:00
James Lu
12bb59d257 Irc: more parseArgs tweaks
- Make parsePrefixedArgs() a class method
- Split the input if parseArgs() is given a raw string instead of a list
2017-02-18 19:58:24 -08:00
James Lu
03fc16dd5a Irc: rewrite parseArgs to be more efficient 2017-02-18 19:47:36 -08:00
James Lu
b3161d6d5d Irc: add a getFullNetworkName() function 2017-02-18 13:32:48 -08:00
James Lu
2f968aca80 Irc: allow defaulting to private command replies (Closes #409)
Squashed commit of the following:

commit c168500235b65f833b1d7fe49ebde674159683ee
Author: James Lu <GLolol@overdrivenetworks.com>
Date:   Thu Feb 16 17:33:36 2017 -0800

    ServiceBot: default notice and private to None

    This is so that it respects the changes from the last commit.

commit f685f3ef522f7f0ee356082c3c1b8b5a4e34b211
Author: James Lu <GLolol@overdrivenetworks.com>
Date:   Thu Feb 16 15:10:33 2017 -0800

    Irc: implement a prefer_private_replies option (#409)
2017-02-16 17:41:07 -08:00
James Lu
7bbe77fe4a Irc: remove unused "bot_clients" attribute
Thanks to @IotaSpencer for pointing this out!
2017-01-21 11:08:37 -08:00
James Lu
e2c0877e9b wrapModes: optionally check for max. modes per line (#253) 2017-01-08 21:19:26 -08:00
James Lu
7594933550 parseModes: reorder logic so that -k * workarounds work again
Thanks @cooper for noticing this.
2017-01-08 17:31:50 -08:00
James Lu
d4b4cfb32e wrap* funcs: convert input args to a list, so that pop(0) always works 2017-01-06 22:13:27 -08:00
James Lu
ba330bbfac updateTS: don't save any broken TS values lower than 750000
Workaround for #385, and other related timestamp issues caused by the TS value getting cut off in mode messages (#283)
2017-01-06 21:56:22 -08:00
James Lu
a3ff32c22e core: implement bind host support
Closes #379.
2017-01-02 12:30:24 -08:00
James Lu
d1d3c3ef15 Irc: oops, wrapModes() needs to be a classmethod 2017-01-02 12:15:44 -08:00
James Lu
5843eebba2 Irc: add wrapModes() abstraction 2017-01-02 12:08:22 -08:00
James Lu
1a1dff7609 IrcChannel: don't assume +nt on new channels
Revert "classes.IrcChannel: default modes to +nt on join"

This reverts commit 1062e47b72.
2017-01-01 00:37:12 -08:00
James Lu
a6b889c469 Irc: fix whitespace 2016-12-17 16:18:11 -08:00
James Lu
cbc7f438d2 clientbot: implement preliminary message tags parsing
Untested so far...
2016-12-16 22:28:22 -08:00
James Lu
e7e2f2c98e core: update "missing dependencies" errors
Closes #363.
2016-12-09 17:15:53 -08:00
James Lu
f9e798cf93 Irc: fix matchHost not using realhost [rp[er;y 2016-11-20 12:29:51 -08:00
Ken Spencer
02dfe5aeab classes: pass force_privmsg_in_private and private booleans to irc.reply() in irc.error() 2016-11-18 23:10:45 -08:00
Ken Spencer
c450d71f84 classes: add irc.error() for easier error replies 2016-11-18 23:10:45 -08:00
James Lu
377df413ed Irc: s/isServiceBot/getServiceBot/g (#355)
This function is renamed to better reflect its return value (ServiceBot object instead of boolean True).
2016-11-09 19:09:59 -08:00
James Lu
08fa64c3cc Irc, services_support: store service name in IrcUser objects (#355) 2016-11-09 19:07:01 -08:00
James Lu
0815df1bca Irc: rewrite isInternalClient to use getServer & return a boolean (#355) 2016-11-09 18:55:53 -08:00
James Lu
ddd0436937 Irc: rewrite getServer() to look for IrcUser.server attribute (#355)
The relevant attribute was introduced in c57fabc9ef.
2016-11-09 18:55:08 -08:00
James Lu
c57fabc9ef core, protocols: add server argument to IrcUser (#355) 2016-11-09 18:40:16 -08:00
James Lu
6ad40c91b4 Irc: explicitly kill connect loop threads after an Irc object has been removed
Possible fix for #351.
2016-11-02 22:34:02 -07:00
James Lu
72ca41df33 Irc, clientbot: disallow unsetting bans that don't exist
This fixes an infinite loop when:
- Clientbot modesync is enabled
- 2 or more clientbot linked networks show unsetting modes that weren't enabled (e.g. charybdis)
- A user removes a ban

The workaround in clientbot prevents this process from triggering an infinite loop when a mode change acknowledgement is received for unsetting a non-existant ban,
though multiple -b mode changes may still be seen due to race conditions in updating the various networks' states.
2016-10-07 20:54:52 -07:00
James Lu
ec4e71c8cf Irc: demote unknown user errors in parseModes() to DEBUG
Some ancient services like Anope 1.8 set SVS2MODE +d on users when they connect, even if the user quits right after. Due to lag we may receive the MODE after the QUIT instead of before.
2016-10-02 22:09:33 -07:00
James Lu
4dd0709f66 protocols, core: remove unused imports 2016-10-01 12:43:12 -07:00
James Lu
0a436cdf4c Irc: make loopback hook in msg() optional 2016-08-31 18:28:13 -07:00
James Lu
87757a60a3 Irc: rename 'chandata' in SQUIT payload to 'channeldata' 2016-08-27 17:42:07 -07:00
James Lu
c68c941c1d Irc.msg: break on empty text strings
Closes #306.
2016-08-27 09:52:01 -07:00
James Lu
5908776a86 API CHANGE: Rename NotAuthenticatedError -> NotAuthorizedError 2016-08-25 00:43:44 -07:00
James Lu
a546bae341 Irc: make throttle time configurable per server (defaults to 0.01s) 2016-08-21 17:25:09 -07:00
James Lu
7a5b64bdc9 Irc: implement basic message queueing (1 message sent per X seconds)
Ref #293.
2016-08-21 17:12:51 -07:00
James Lu
a76bd8c5b2 core: make hostmask fetching a shared function 2016-08-12 19:18:56 -07:00
James Lu
6828d032b4 Irc: RFC-standard umode +s does not take an argument 2016-08-11 18:14:35 -07:00
James Lu
ffdc313376 Irc: make hostname field optional in version()
Reported by Rascle via IRC.
2016-08-10 13:23:24 -07:00
James Lu
3633a41e4f Protocol: return a mapping of channels->lists of nicks in SQUIT payloads 2016-08-08 20:58:34 -07:00
James Lu
12e1a0edff Move handle_error() to the generic protocol 2016-08-08 18:12:07 -07:00
James Lu
9448bc86fd Protocol: abort when receiving SQUIT to our own server 2016-08-04 12:55:24 -07:00
James Lu
b36ce36451 protocols: send old IrcServer object (serverdata) in SQUIT hooks 2016-08-04 12:50:04 -07:00
James Lu
4b27ebbee4 Irc: make sorting in joinModes() an option, and explicitly enable it in WHOIS output
This prevents mode lists from being sorted when they really shouldn't be, such as when relaying mode changes ("+qo nick nick" became +oq nick nick").
2016-07-31 21:45:38 -07:00
James Lu
d911045dca Merge branch 'devel' of github.com:GLolol/PyLink into devel 2016-07-31 20:11:06 -07:00
James Lu
168f9f972d classes: more tweaks to updateTS()
Really fixes #295. Closes #298.
2016-07-30 21:25:28 -07:00
James Lu
1ef89560e2 core: rename IrcUser.identified attribute to IrcUser.account 2016-07-29 20:16:05 -07:00
James Lu
891039dba2 Merge branch 'master' into devel 2016-07-29 14:44:54 -07:00
James Lu
2326f8b818 Irc: fix TS handling comparing against the wrong TS on outgoing sjoin()
Closes #295.
2016-07-29 14:44:25 -07:00
James Lu
13c0e50358 Irc: make certfile/keyfile optional
This was never required for S2S links to work... Why did I think that?
2016-07-28 22:49:05 -07:00
James Lu
f4922743fc core: SID and hostname options are now optional (#282)
Hostname defaults to a fallback hardcoded in world.fallback_hostname, while SID defaults to None (protocol modules have to deal with this themselves)
2016-07-28 22:23:59 -07:00
James Lu
f45cb3a583 classes: Drop FakeIRC, FakeProto 2016-07-28 22:03:44 -07:00
James Lu
852bd74c3b core: enumerate our server after calling proto.connect()
This gives protocol modules a chance to manipulate their SID before it's added to the internal server list, replacing hacks previously used by the Nefarious and Clientbot modules.

This is the first step to sid-less servers :)
2016-07-28 21:50:51 -07:00
James Lu
c410de2fad Make server config validation protocol specific
Closes #282.
2016-07-28 21:34:00 -07:00
James Lu
4e3d209831 Irc: rework TS handling again
(cherry picked from commit 0e535a916c)
2016-07-28 20:20:35 -07:00
James Lu
0e535a916c Irc: rework TS handling again 2016-07-26 23:30:55 -07:00
James Lu
795c163a69 Irc: use int values for ircmatch casemapping
The ircmatch version with casemapping variables hasn't been released on pip yet.

(cherry picked from commit 39675e15e8)
2016-07-23 21:52:23 -07:00
James Lu
39675e15e8 Irc: use int values for ircmatch casemapping
The ircmatch version with casemapping variables hasn't been released on pip yet.
2016-07-23 21:51:26 -07:00
James Lu
c6fcdd854c parseModes: give prefix modes precedence over mode types 2016-07-21 19:11:19 -07:00
James Lu
eef54cd77d classes: Move ISUPPORT-style PREFIX and capabilities handling to Protocol 2016-07-20 23:59:22 -07:00