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

55 Commits

Author SHA1 Message Date
James Lu
ce822061d2 Irc: catch UnicodeDecodeError when parsing lines
TODO: respect other encodings too?
2015-07-29 04:02:03 -07:00
James Lu
5eee8000dd Irc: catch OSError (bad file descriptor) errors; they usually mean we're disconnected 2015-07-25 22:51:00 -07:00
James Lu
ddefd38591 ts6: fix the broken mess of a JOIN handler, and 'parse_as' handling in irc.callHooks... 2015-07-25 20:43:26 -07:00
James Lu
f85fbd934b main: write a PID file to pylink.pid 2015-07-25 16:57:21 -07:00
James Lu
3804e5e4f8 main: shut down immediately when handle_events errors
This is to prevent accidents from frying a server's CPU. For example, a nick collision loop due to a desync!
2015-07-25 16:11:41 -07:00
James Lu
024cf9d878 main: better INFO logging... 2015-07-23 14:19:12 -07:00
James Lu
1efc9018f3 main: raise fallback ping frequency to 30 2015-07-23 10:28:28 -07:00
James Lu
8a1f965303 Consistently use applyModes in spawnClient, so user modes are stored like ('o', None) instead of ('+o', None)
Drop the 'modes' argument in IrcUser, for this is incorrect.
2015-07-22 21:14:22 -07:00
James Lu
badbcf0507 Irc.callHooks: allow handlers to specify which hook to call via a special 'parse_as' key
For special cases such as "/join 0", where the PART handler has to be called instead of JOIN.
2015-07-20 21:19:15 -07:00
James Lu
6efb59b8b7 Irc: strip off \r from lines 2015-07-20 21:19:01 -07:00
James Lu
a10a18d9cc Irc: make prefixmodes a dict mapping chars to their prefixes
This is needed by TS6 support (#40), which send the characters (@+) instead of modes
2015-07-20 16:48:59 -07:00
James Lu
06d17d578b Irc: prevent rare UnicodeDecodeError by decoding individual lines, not the entire socket.recv() output
Such an error is rare, but it did occur twice since I've started developing this :)
2015-07-19 23:46:31 -07:00
James Lu
536366de99 main/coreplugin: use log.exception() instead of traceback.print_exc()
This fixes tracebacks only being sent to console, and not the log file.
2015-07-18 20:12:13 -07:00
James Lu
b6275130e1 Irc: catch AttributeError when self.socket doesn't exist (failed to establish initial connection) 2015-07-18 20:10:33 -07:00
James Lu
a51cfcb7b2 Fix fakeirc and tests for relay (#56) 2015-07-17 22:52:55 -07:00
James Lu
3f6f78be9a relay + Irc: keep track of network disconnects
This introduces a new PYLINK_DISCONNECT meta-hook that is called when a network disconnects. Also, reset the state variables (i.e. servers, users, etc.) on disconnect! (this was missed before)

Closes #60.
2015-07-17 16:57:08 -07:00
James Lu
bc9863d9e0 Make reconnecting a bit less... broken 2015-07-17 16:20:41 -07:00
James Lu
fdea348cbe move hook calling out of pr/insp and into Irc 2015-07-17 16:09:50 -07:00
James Lu
df595c65a1 fix SQUIT not respecting autoconnect delay 2015-07-17 16:01:51 -07:00
James Lu
f41e1a2eb5 Fixes for connection handling?
XXX: using SQUIT on the PyLink server doesn't respect autoconnect delays; why?
2015-07-17 15:08:24 -07:00
James Lu
836d0e9701 Irc: wrap (re)connecting in a while loop instead of calling it recursively
Also, remove unnecessary comments / ENDBURST hook from relay.

Ping handling seems to work fine now! Closes #57. Closes #42.
2015-07-17 14:37:07 -07:00
James Lu
9bef93c341 More stuff for PINGing uplink and autoreconnect (#42 #59 #57)
Doesn't quite work yet; still blocks everything on disconnect for some reason...
2015-07-17 13:41:14 -07:00
James Lu
0aa2f98705 Move client spawning, command / KILL / KICK handling outside the protocol module
New plugin 'coreplugin' takes care of command/KILL/KICK handling, while client spawning is moved into Irc.spawnMain() and is used by the former.

Closes #33.
2015-07-16 21:52:44 -07:00
James Lu
c6c24c242c Irc: fixes in timeout detection 2015-07-16 19:34:05 -07:00
James Lu
f1ef6f9e15 Irc: catch ConnectionError in both run() and send()
Part of #42.
2015-07-16 16:49:16 -07:00
James Lu
2106b8da3a main: add a note about irc.connected.wait() and maxnicklen being set 2015-07-15 14:00:40 -07:00
James Lu
6e37e1c05d make Irc.connected a threaded event object, setting it to True ONLY when we receive server capabilities from our uplink
The previous behavior set this to True as soon as we ran connect(), but this caused problems because the default capabilities (i.e. nicklen)
that Irc() initializes won't match the real value of the network.
2015-07-15 13:49:12 -07:00
James Lu
293bfff813 main: thread Irc.connect() and begin work on autoreconnection 2015-07-15 11:52:36 -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
0dc0770d6d relay: add LINK and DELINK commands; many fixes to checkers (WIP) 2015-07-12 17:59:09 -07:00
James Lu
5d5f556ee3 main: load plugins in a separate loop, and call the main() of loaded plugins if present 2015-07-11 20:21:10 -07:00
James Lu
149921ac47 main: remove incorrect usage of socket.shutdown, and raise socket timeout to something more reasonable 2015-07-11 20:21:10 -07:00
James Lu
11e27b9f36 main.Irc: only load plugins after the IRC object is initialized in utils.networkobjects
PyLink-Relay (#37) needs this in order to fetch the IRC objects of various networks at start.
2015-07-10 20:24:08 -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
e54e17a0ea Irc.send: safeguard against newlines in input! 2015-07-09 17:25:10 -07:00
James Lu
8576778ddc Make the 'bot' conf block available in Irc() as irc.botdata
Protocol modules shouldn't read conf directly, so that we can override the config in testing.
2015-07-08 13:56:17 -07:00
James Lu
2cbd6fd851 Tests for FMODE/FJOIN, and bugfixes 2015-07-05 19:19:49 -07:00
James Lu
211decd2aa everything: Improve logging 2015-07-05 13:44:48 -07:00
James Lu
54dff7a15a Convert print() calls to log calls, Round 1 2015-07-05 13:29:18 -07:00
James Lu
f06bcc7928 Merge commit 'bd755e137ffa034007a77d75fbd00d21e759163e' into wip/logger-module
Conflicts:
	proto.py
2015-07-05 13:22:17 -07:00
James Lu
3e86cbdd33 Better protocol capability negotiation
Respect our uplink's supported c/umodes, NICKLEN, and max channel name lengths.
2015-07-04 23:12:00 -07:00
James Lu
fed107b12b main.py: don't assign self.socket twice 2015-07-03 18:07:32 -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
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
38df372471 main.py: catch ImportError nicely 2015-06-07 17:04:23 -07:00
James Lu
38bd58f7ff Actually check recvpass field (Closes #9) 2015-06-02 16:55:04 -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
4ead81a66f remove unneeded imports 2015-05-30 22:35:31 -07:00
James Lu
17fc05cc9a WIP: use a proper logging module 2015-05-30 22:35:00 -07:00