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

116 Commits

Author SHA1 Message Date
James Lu
b0b9138720 Merge branch 'master' into devel 2015-09-14 17:56:53 -07:00
James Lu
2e0a5e52e2 utils.parseModes: fix IndexError on empty query 2015-09-14 17:56:33 -07:00
James Lu
9cd176b846 utils.reverseModes: don't reverse prefix/list modes that were never set
Charybdis/TS6 doesn't check this IRCd-side, so we don't want people to abuse this by say, overriding -b *!*@* in a relay channel and having the PyLink client set +b *!*@* in response,
2015-09-13 14:05:07 -07:00
James Lu
9a139212dd relay/utils: make mode reversals work with mode changes that affect op statuses. 2015-09-13 13:48:14 -07:00
James Lu
dab29cfc19 utils: add a proper reverseModes() with tests
Closes #107.
2015-09-12 22:31:20 -07:00
James Lu
f23cff845c utils: Documentation and cleanup 2015-09-12 22:31:19 -07:00
James Lu
62e7cc4fca move utils.msg() => classes.Irc.msg()
New function gets an extra (optional) "source" argument for specifying a sender UID. It's also shorter since no IRC object has to be passed to utils.
2015-09-06 22:23:44 -07:00
James Lu
57da0aa3b3 Classify all our protocol modules - why didn't I do this earlier 2015-09-05 18:00:57 -07:00
James Lu
0b590d6ab3 relay/protocols: use utils.toLower() for channel names, respecting IRCd casemappings
Closes #102.
2015-09-01 22:01:22 -07:00
James Lu
e1e31f64ad Allow multiple plugins to bind to one command name!
They will get called in a list, one after the other. The "help" command is able to distinguish with this too.
2015-08-29 19:25:07 -07:00
James Lu
973aba6de7 Move utils' global variables to world.py 2015-08-29 09:39:33 -07:00
James Lu
ad5fc97e21 Many fixes to test API, utils.reverseModes stub 2015-08-28 19:28:06 -07:00
James Lu
3d621b00df Move checkAuthenticated() to utils, and give it and isOper() toggles for allowing oper/PyLink logins 2015-08-25 20:47:21 -07:00
James Lu
579838e1ba utils.applyModes: be more error tolerant? 2015-08-15 20:02:07 -07:00
James Lu
880b59c2c1 utils.isOper: check for both umode +o and login status
Also, make commands.status show this isOper result.
2015-08-02 19:41:40 -07:00
James Lu
0977268070 utils.parseModes: don't error if prefix isn't given, assume + 2015-07-23 15:04:57 -07:00
James Lu
a8b16d9724 utils.parseModes: fix handling of mode "-k *" on TS6
Charybdis allows unsetting +k without actually knowing the key by faking the argument when unsetting as a single "*". We'd need to know the real argument of the +k being removed, in order to remove the mode pair from the mode list.
2015-07-23 13:24:18 -07:00
James Lu
254ccea0a3 remove some debugging cruft and unused imports 2015-07-23 11:46:45 -07:00
James Lu
a7f977aa3b Add whois handlers for channel lists, user modes, and signon time, and relay user information
New API: utils.whois_handlers allows one to add functions taking (irc, target) and returning (irc numeric, reply text)

Closes #72.
2015-07-23 00:01:51 -07:00
James Lu
35cdfbf7e6 Declare IRCd casemapping in protocol modules, and respect these in utils.nickToUid
This adds a new utils.toLower(irc, text) function which returns the lowercased version of <text> based on <irc>'s declared case mapping.

Closes #75.
2015-07-22 20:31:45 -07:00
James Lu
e2738e3909 utils.applyModes: fix prefixmodes lists not being updated... 2015-07-21 19:57:22 -07:00
James Lu
8cde2ddce7 utils.applyModes: don't crash if existing modelist is a list, not a set 2015-07-19 22:42:04 -07:00
James Lu
0540e10d50 relay: don't add bans that don't match nick!user@host
Closes #55.
2015-07-19 16:53:51 -07:00
James Lu
1b09a00ea9 utils: add getHostmask 2015-07-19 15:01:49 -07:00
James Lu
67f5bbba4b add a utils.started threaded trigger, so plugins can ACTUALLY wait until all Irc objects have been initialized to do their work 2015-07-13 16:07:55 -07:00
James Lu
45cef19eaa Make plugins global, not per IRC instance 2015-07-12 23:28:34 -07:00
James Lu
450584b963 relay: hack in utils.schedulers so that exportDB only gets queued once globally
Previously, exportDB would be queued once by every IRC object, which was the wrong behavior!
2015-07-12 13:09:35 -07:00
James Lu
e250409b46 utils: add a new TS6SIDGenerator() class, for generating SIDs based on ranges 2015-07-11 20:21:10 -07:00
James Lu
7a6c32e0c4 utils: add isOper() function 2015-07-10 16:43:16 -07:00
James Lu
eec024bf9a Second attempt at multinet support, by wrapping threading.Thread around Irc.run()
Closes #15.
2015-07-09 18:29:00 -07:00
James Lu
c8f12f2ab1 move messaging functions to protocol (#35)
Closes #36.
2015-07-09 16:23:20 -07:00
James Lu
1c7f2f6a83 utils.applyModes: fix logging output; only remove delete modes with args if new args are different
Previously, you'd get interesting messages where in sequential FJOINs, PyLink would remove param-modes like ('f', '6:5') and then add it right back, thinking that it was a duplicate.
2015-07-08 23:13:23 -07:00
James Lu
b27fcc7f8f utils.applyModes: operate on a copy of the original modelist
This prevents bugs where mode changes are applied to the wrong users (possibly due to the scope not clearing).
2015-07-08 23:11:44 -07:00
James Lu
35f8a0e25f utils.parseModes: be a bit more fault-tolerant
- Log "mode requires an argument but none was found" errors to warning, and skip the mode instead of failing completely.
- Assign a fallback value for 'prefix', checking to make sure it exists and raising ValueError (not UnboundLocalError) when it doesn't.
2015-07-08 22:42:04 -07:00
James Lu
7a37f50a1a utils.joinModes: support joining modes with prefixes 2015-07-08 16:58:59 -07:00
James Lu
098b29ae2d Correction: it is legal for a server name to end with '.', but it can't start with it 2015-07-07 14:31:47 -07:00
James Lu
74339d1038 Fix joinModes, and use it in protocol/inspircd's joinClient
In short, PyLink should be sending FJOINs to channels with the modes that it already has (or what we believe it has). This prevents clearing mode lists when PyLink's channel TS is slightly earlier than the IRCd's.
2015-07-06 12:28:10 -07:00
James Lu
170620c410 applyModes: remove old modepairs when setting non-list modes that require params
Closes #30.
2015-07-05 23:15:17 -07:00
James Lu
48c3b4b2e9 applyModes: chop off the +/- part of each mode tuple when storing mode lists
Also update these tests accordingly.
2015-07-05 23:00:14 -07:00
James Lu
2cbd6fd851 Tests for FMODE/FJOIN, and bugfixes 2015-07-05 19:19:49 -07:00
James Lu
87781abc82 Logging format tweaks 2015-07-05 16:46:57 -07:00
James Lu
211decd2aa everything: Improve logging 2015-07-05 13:44:48 -07:00
James Lu
bd03e00c74 applyModes: ignore unsupported prefix modes (e.g. InspIRCd's +yY) 2015-07-05 12:53:53 -07:00
James Lu
b22f674785 Support prefix modes (+qaohv); refactor applyModes to apply in place; add removeuser() to IrcChannel
Closes #16.
2015-07-05 12:48:39 -07:00
James Lu
dafeff6324 Add channel mode handling (more testing needed)
Closes #28.
2015-07-05 00:20:45 -07:00
James Lu
8b93b78d13 Support modes with arguments in our modestring parsers
Closes #27.
2015-07-04 23:49:28 -07:00
James Lu
d23d34e316 Refactor hooks to send parsed arguments instead of raw args
ref #18.

- Command handlers that support hooks will now return parsed args, which are then sent to the hooks
- Hook commands are now stored in uppercase letters, consistent with the IRC spec
2015-07-04 19:00:29 -07:00
James Lu
991e86a8cb unittests! wow! 2015-07-03 17:05:44 -07:00
James Lu
072cc72602 defaultdict for channels, fix user tracking in {join|part}Client, isInternal* to utils
- collections.defaultdict for simpler channel handling
- proto/inspircd: fix join/partClient not updating the channel's user list
- move isInternal* to utils
2015-06-23 19:29:53 -07:00
James Lu
6370ad492f Add basic command hooks (ref #18) 2015-06-23 19:08:43 -07:00
James Lu
28e7b52ef4 utils.TS6UIDGenerator: initialize SID variable once per instance 2015-06-22 16:51:42 -07:00
James Lu
f37af68e3f utils: tweak TS6UIDGenerator again
Only increment the UID table after we fetch the UID, so that the initial value (AAAAAA) gets used too.
2015-06-21 18:11:17 -07:00
James Lu
c686523a6e Add pseudoserver spawning, adapting _sendFromServer and spawnClient accordingly.
Now you can spawn multiple servers for a multi-server botnet!

Also, create proto.isInternalServer() / utils.isServerName() checkers.

Closes #22.
2015-06-21 15:03:58 -07:00
James Lu
ce249dfe33 uhhh.... let's clear our variables properly 2015-06-20 21:06:45 -07:00
James Lu
aeb53a14e3 Make IrcUser.modes a set 2015-06-20 20:58:25 -07:00
James Lu
d3257f9314 Don't hardcode client usermodes in spawnClient
Still a bit of a WIP here...
2015-06-20 20:54:01 -07:00
James Lu
379f442a14 Add basic user mode tracking (Closes #10) 2015-06-20 20:36:35 -07:00
James Lu
55a5d08378 Use a WORKING TS6 UID generator, adapted from InspIRCd source
Closes #21.
2015-06-19 10:43:42 -07:00
James Lu
93b1a11651 How on earth does this uid generator even work? It badly needs a rewrite... 2015-06-16 21:02:38 -07:00
James Lu
f7244ee6b7 Add basic nick and channel checking (ref #20) 2015-06-16 20:46:01 -07:00
James Lu
f40cb7954a Allow dynamic protocol loading again, and make proto an attribute of Irc()
This should remove the need for plugins, etc. to import proto directly,
which wouldn't work because of dynamic naming.
2015-06-16 20:05:41 -07:00
James Lu
4d763288e5 rename utils._nicktoUid to utils.nickToUid
Consistency in function capitalization is a good thing!!
2015-06-07 19:36:21 -07:00
James Lu
43a46d3d99 Many fixes
- Move _nicktoUid to utils.py
- Make _sendFromUser arguments more consistent (irc, sendfrom, message) instead of (irc, message, sendfrom=None)
- Add admin only kickclient, partclient, and nickclient commands
- proto.joinClient: take UIDs instead of an IrcUser object, in order to be more consistent

Closes #4, Closes #12.
2015-06-07 19:31:56 -07:00
James Lu
d9db7e1b9e It's almost June! Updates:
- Move config handling into separate module
- Implement identify and status commands, currently only supporting the admin account defined in the config. Closes #1.
- Move proto.add_cmd to utils.py, rename _msg() to msg()
- Allow sending the command name as an optional argument in add_cmd
- Add catch-all exception handling in plugins to prevent them from crashing the program!
2015-05-31 12:20:09 -07:00
James Lu
0fcf5ead04 utils.py: Make _msg a shared function (Closes #3) 2015-05-30 23:00:39 -07:00
James Lu
9b4fb50f25 Today's code dump, featuring:
- PLUGIN SUPPORT and COMMAND HANDLING, wow!!!!!!!
- Restructuring of files so that there's only one protocol module (anything else is too much to maintain for now)
- Split protocol things into utils.py
- Bugfixes: don't go into an endless loop of text spamming when the remote host closes the connection!
2015-04-24 22:37:07 -07:00