James Lu
fefd5a1f6b
IRCNetwork: raise ssl.CertificateError instead of an in house exception if certfp is mismatched
...
Also, fix the expected and real fingerprints being logged in the wrong order.
2018-06-15 15:48:09 -07:00
James Lu
76c0db15c4
core: merge TLS validation code into IRCNetwork ( #592 )
...
Certificate verification is now enabled for all Clientbot networks, but not yet for S2S links (self-signed certs are common here and direct IP links even more so)
2018-06-15 15:29:15 -07:00
James Lu
4524aebbac
clientbot: initial pass of TLS cert validation ( #592 )
...
This works OK, but we should make the validation options built-in instead of clientbot-specific.
2018-06-15 02:47:12 -07:00
James Lu
d3125d9a8f
core: automatically detect between IPv4 / IPv6 addresses on connect
...
Closes #212 .
2018-06-15 02:43:33 -07:00
James Lu
56c035a1f5
IRCNetwork: fix broken ping timeout handling
...
Check for ping outs in the ping scheduler instead of the listener... If the connection is dead, the listener won't ever be called.
2018-06-14 01:18:33 -07:00
James Lu
b2421f5e15
IRCNetwork: simplify connection error handling
2018-06-14 01:18:33 -07:00
James Lu
579b5ce93f
IRCNetwork: split SSL connection setup into separate functions
...
* _make_ssl_context(): returns the SSLContext to use on he network (with options set)
* _setup_ssl(): sets up TLS by loading certfile / keyfile and calling wrap_socket()
* _verify_ssl(): implements certificate fingerprint verification, raising TLSVerificationError (a new subclass of ConnectionError) if this fails
This is a prerequisite for #592 .
2018-06-14 01:17:39 -07:00
James Lu
deff6d077d
match_host: remove deprecation notice for non-host globs
...
This is too flaky with commands taking arbitrary user inputs (e.g. opercmds/checkban)
2018-06-12 00:02:18 -07:00
James Lu
2ca9de2ea8
PyLinkNCWUtils: make the allowAuthed, allowOper options to is_oper no-ops
2018-06-11 23:55:19 -07:00
James Lu
18f108c328
PyLinkNCWUtils: remove check_authenticated() ( #422 )
2018-06-11 23:54:48 -07:00
James Lu
ed5d46e28a
utils: remove deprecated is* functions
2018-06-11 23:48:12 -07:00
James Lu
3bea214cb0
classes: remove irc.botdata ( #422 )
2018-06-11 23:43:57 -07:00
James Lu
f9d21c2b10
UserMapping: fix wrong args to __copy__
2018-06-09 10:44:36 -07:00
James Lu
31a0d36990
clientbot: ignore missing args in 324 / RPL_CHANNELMODEIS
...
Fixes #537 .
2018-06-08 18:45:20 -07:00
James Lu
f4de604b7d
classes: split match_host() into match_host() and match_text()
2018-06-08 18:25:23 -07:00
James Lu
b0188dab92
get_friendly_name: strip STATUSMSG prefixes before checking is_channel
2018-06-08 17:26:25 -07:00
James Lu
6f3813d3a4
UserMapping: add in missing reference to the parent irc instance
2018-06-08 15:54:06 -07:00
James Lu
e3a935d0b7
classes: make User, Channel TS a property for type-safety ( #594 )
2018-05-26 02:30:25 -07:00
James Lu
f20fa5e995
Add User.get_fields(), and rework plugins to fix $nick broken expansions
...
User.nick is no longer a writable attribute since a085aed924
, so it won't show up in __dict__ now.
get_fields() replaces the User.__dict__ hack various plugins used and also provides some new expansion variables:
- $sid and $server expand to the server ID and name respectively
- $modes and $channels are now preformatted strings
- $netname expands to the network name
$manipulatable and $_irc were removed since their values aren't quite meaningful as strings
2018-05-26 02:12:38 -07:00
James Lu
b72420a8aa
Revert "NetworkCore: return the server in get_server if the arg was a server"
...
The complete implementation of is_privileged_service() in ec3a94c4ca
explicitly checks the entity ID type, so this strange hack is not needed.
This reverts commit 9113b34b46
.
2018-05-26 01:14:32 -07:00
James Lu
ec3a94c4ca
Move U:line checking into core as PyLinkNCWUtils.is_privileged_server()
...
Closes #604 .
2018-05-26 00:14:04 -07:00
James Lu
a66a9b6336
core: demote KeyError logging in _remove_client to DEBUG
...
This is needed for #607 .
2018-05-21 00:28:16 -07:00
James Lu
20bbf531e6
wrap_message: fall back to bufsize=510 on protocols declaring S2S_BUFSIZE to be 0 (unlimited)
2018-05-18 19:09:06 -07:00
James Lu
559b262db8
core: break attempts to read from a socket if no data is available
2018-05-18 19:08:37 -07:00
James Lu
f87e646f35
core: use the most recent UID if we have an unresolved nick collision / desync
...
This is the one most likely to be correct, assuming IRCds deals with nick collisions properly on their own.
2018-05-18 18:17:04 -07:00
James Lu
73322bd9ba
wrap_message: expand UID targets into nicks before processing ( #153 )
2018-05-11 14:47:27 -07:00
James Lu
244c4fe0eb
classes: return valid channels as-is in get_friendly_name()
...
This makes it safe to use when processing message targets. (ref #153 )
2018-05-11 14:47:18 -07:00
James Lu
0ac5d424d8
core: implement text wrapping in irc.msg()
...
Closes #153 .
2018-05-11 14:38:21 -07:00
James Lu
b46ab844fe
classes: really fix KeyError crashes on duplicate QUIT
2018-04-30 11:11:14 -07:00
James Lu
e96081aa6e
PyLinkNetworkCore: make deletion from self.users non-fatal
2018-04-20 19:39:35 -07:00
James Lu
25d24e9bb2
Use non-blocking sockets again, since Linux select() doesn't guarantee that recv() won't block
2018-04-12 10:58:09 -07:00
James Lu
6bcf7d325f
PyLinkNetworkCore: add get_service_option()
...
Closes #574 .
2018-04-07 22:20:35 -07:00
James Lu
138a52611e
classes: oops, actually tell the queue thread to abort before we wait for it to stop
2018-04-07 22:12:17 -07:00
James Lu
80cbd7a257
classes: make disconnections more synchronized
...
- Make ping timer abort instantly if the network is dead
- Shut down the read and write parts of the socket separately, and only close the socket once both parts are done.
2018-04-07 21:56:10 -07:00
James Lu
84dbca4bda
classes: thread socket connects once more since they block
2018-04-07 21:56:06 -07:00
James Lu
7586989763
classes: really quash duplicate disconnect calls as much as possible
2018-03-31 11:53:50 -07:00
James Lu
f274088ea0
classes: more checks on _aborted to (hopefully) prevent duplicate disconnects triggered by _send
2018-03-30 10:47:34 -07:00
James Lu
93d590fdea
UserMapping: check for lower_nick rather than isinstance(userobj, User)
...
This makes classes reload-safe again.
2018-03-30 10:46:49 -07:00
James Lu
335fb352ec
classes: ignore errors on duplicate selector.unregister()
...
This should really be fixed more thoroughly: there are still some remaining issues after the port to select, with disconnect / reconnect being triggered twice.
2018-03-29 14:04:58 -07:00
James Lu
a085aed924
Rework irc.users and User() to transparently create a store of nicks -> UIDs
...
- This turns IRCNetwork.users into a new UserMapping class, which stores User objects by UID (str) and provides a 'bynick' dict storing case-normalized nicks to lists of UIDs.
- Turn User.nick into a property, where the setter implicitly updates the 'bynick' index and computes a case-normalized version of the nick (User.lower_nick)
2018-03-24 00:12:19 -07:00
James Lu
815535d76b
IRCNetwork: fix autoconnect not applying when socket.connect() fails
2018-03-23 20:21:49 -07:00
James Lu
814dd9a3c5
IRCNetwork: only register a socket with selectdriver after connecting
2018-03-23 20:16:59 -07:00
James Lu
bb1334696c
classes: cache more of to_lower()
2018-03-22 22:03:08 -07:00
James Lu
b522967760
Fix duplicate calls to _run_autoconnect
2018-03-22 17:42:28 -07:00
James Lu
91b86ce0e4
Remove structures.DeprecatedAttributesObject, it's vastly inefficient for what it accomplishes
2018-03-17 15:49:48 -07:00
James Lu
8100a4cea6
IRCNetwork: run _run_autoconnect in a thread so it doesn't block whatever calls disconnect()
2018-03-17 15:26:36 -07:00
James Lu
0151f77f7b
Don't clear the read buffer with every _run_irc call
2018-03-17 12:18:16 -07:00
James Lu
10d2fb93ed
classes: fix syntaxerror from merge
2018-03-17 11:06:02 -07:00
James Lu
0033612fa3
Merge branch 'devel' into engine-rework
...
Conflicts:
classes.py
2018-03-17 11:03:58 -07:00
James Lu
f7ab2564fe
Rework inbound connection handling to use select
...
Closes #588 .
2018-03-17 11:01:32 -07:00
James Lu
92460716d1
IRCNetwork: bump SOCKET_REPOLL_WAIT to 1 sec
2018-03-07 18:32:20 -08:00
James Lu
ccc9f8e5c8
IRCNetwork: also catch ssl.SSLWantReadError and ssl.SSLWantWriteError
2018-03-07 18:31:43 -08:00
James Lu
8f9b56e9d9
IRCNetwork: abort when _send() fails to avoid deadlocks
2018-03-07 18:30:14 -08:00
James Lu
0ca185fada
classes: fix some prefixmodes list vs. state confusion
2018-03-02 21:07:47 -08:00
James Lu
5a00454a8d
_parse_modes: apply modes to a temporary mode list as we parse them
...
Fixes #573 .
Old, broken behaviour:
irc.parse_modes('#test', '+b-bb *!*@new.ban *!*@nonexistent.ban *!*@new.ban')
=> [('+b', '*!*@new.ban')]
Fixed:
irc.parse_modes('#test', '+b-bb *!*@new.ban *!*@nonexistent.ban *!*@new.ban')
=> [('+b', '*!*@new.ban'), ('-b', '*!*@new.ban')]
2018-03-02 20:57:16 -08:00
James Lu
f12318b5dc
classes: add an is_channel argument to _parse_modes
...
This is required for the following commit.
2018-03-02 20:56:59 -08:00
James Lu
1413aa6042
_apply_modes: don't add prefix modes to mode sets even when prefixmodes=None
2018-03-02 20:47:41 -08:00
James Lu
054680c806
classes: split apply_modes into two functions
2018-03-02 20:43:25 -08:00
James Lu
9cca695d14
classes: split parse_modes into core and wrapper functions
2018-03-02 20:43:25 -08:00
James Lu
6a90e99de4
IRCNetwork: do not break on socket BlockingIOError
...
On non-blocking sockets, recv() raises BlockingIOError instead of blocking when there's no data to be read.
The correct behaviour is to wait and try again instead of breaking the connection.
2018-03-01 12:52:41 -05:00
James Lu
50f8cde694
classes: make _to_lower_core and _expandPUID type-safe
2018-02-24 14:19:57 -05:00
James Lu
2e66b9bde6
classes: allow hook functions to block further execution by returning False
...
Closes #547 .
2018-02-18 22:42:39 -08:00
James Lu
67dea6f748
classes: add docstrings to _pre_connect, _pre_disconnect, _post_disconnect
2018-01-21 13:20:42 -08:00
James Lu
6c65d5523e
IRCNetwork: potentially fix queue thread shutdowns ( #558 )
...
Replace unreliable appendleft() usage with replacing the first element (or adding None if the queue is empty).
2017-12-17 01:01:21 -08:00
James Lu
9dfa0a478e
classes: fix inverted order in get_prefix_modes() description
...
No, no, no. Nobody sorts modes that way!
2017-12-07 12:07:08 -08:00
James Lu
2fc5d32e3f
NetworkCore: don't clear state on disconnect
...
This is already reset on connect, so doing it here too is a bit pointless.
2017-12-03 18:56:39 -08:00
James Lu
bebdf2e4ff
IRCNetwork: avoid sending multiple disconnect hooks for one disconnection
2017-12-03 17:46:45 -08:00
James Lu
62cef5c3f5
classes: clarify comments on mode-related functions
2017-11-03 23:40:11 -07:00
James Lu
472b73cf65
classes.Channel: clarify the intended behaviour of sort_prefixes() and get_prefix_modes()
2017-10-15 02:16:18 -07:00
James Lu
aa44bc15a3
classes: fix backwards sorting in Channel.sort_prefixes()
...
Also remove various workaround code added to address this.
2017-10-15 01:29:42 -07:00
James Lu
a9916a74f2
Revert "NetworkCoreWUtils: strip off leading and trailing quotes from parse_modes"
...
This was a band-aid fix not ready to be committed - we should work on this in IRCParser and opercmds instead.
This reverts commit aeaee491f3
.
2017-10-10 22:33:24 -07:00
James Lu
aeaee491f3
NetworkCoreWUtils: strip off leading and trailing quotes from parse_modes
2017-10-10 22:25:06 -07:00
James Lu
663bfe462c
classes: track hopcount in Server
2017-09-23 22:35:55 -07:00
James Lu
113bfcba9d
PyLinkNetworkCore: copy world.hooks before iterating
...
This fixes a race condition where the order of PRIVMSG handlers could be changed as 'load <plugin>' runs, causing the load command to be processed multiple times.
2017-09-23 13:39:43 -07:00
James Lu
0c50091d11
Merge branch 'master' into devel
2017-09-08 19:12:17 -07:00
James Lu
49136d5abd
core: raise better errors on common logging block syntax mistakes
...
These are commonly reported and include:
- Commenting out the contents of logging:channels without commenting out the "channels:" heading, causing that block to become None.
- Commenting out headers like "filerotation:", causing its body to become pairs in logging:files or something similar.
- Leaving logging:channels:<netname> empty: this causes it to become None, so using get() on it fails.
2017-09-08 19:07:03 -07:00
James Lu
f3e82cc15b
Concisify match_host CIDR logging again
...
We're replacing the glob, not the target's host.
(cherry picked from commit 7aa836efa6
)
2017-09-05 19:03:18 -07:00
James Lu
d1f8358159
Fix wrong logging for CIDR ranges in match_host
...
(cherry picked from commit 761d3ef500
)
2017-09-05 19:03:18 -07:00
James Lu
5e92aefcd4
Implement priorities in utils.add_hook()
...
This changes world.hooks to store lists of tuples indicating (priority, hook_func).
2017-09-02 21:17:50 -07:00
James Lu
5c981c83b1
core: abort autoconnect and socket connectons when the daemon is shutting down
2017-08-31 13:40:11 -07:00
James Lu
82a7b914b6
Move control.tried_shutdown to world.shutting_down
2017-08-31 13:36:50 -07:00
James Lu
bc48709595
PyLinkNetworkCore: fix extraneous warnings in get_service_bot
2017-08-30 19:48:46 -07:00
James Lu
cad55097f1
core: reuse existing service client UIDs for all service bots
...
This prevents nick collision wars caused by spawn_service when an ENDBURST hook for the uplink is received multiple times.
2017-08-30 19:29:46 -07:00
James Lu
87639ddeb2
classes: add a has_eob attribute to each server object
2017-08-30 19:16:54 -07:00
James Lu
46e9975bd5
Continue rewriting the protocol module spec ( #478 )
2017-08-30 01:26:35 -07:00
James Lu
4a363aee50
Move _expandPUID into PyLinkNetworkCoreWithUtils
2017-08-30 00:56:18 -07:00
James Lu
d79f1766b6
classes, coremods: migrate to irc.is_*
2017-08-28 20:13:25 -07:00
James Lu
e39b4e9c69
Move utils.is* methods into PyLinkNetworkCoreWithUtils ( #476 )
2017-08-28 20:07:31 -07:00
James Lu
2a7594e56e
Move PUIDGenerator->classes, IncrementalUIDGenerator->ircs2s_common ( #476 )
2017-08-28 19:42:24 -07:00
James Lu
b1159400f1
Move DeprecatedAttributesObject, CamelCaseToSnakeCase to structures ( #476 )
2017-08-28 19:36:55 -07:00
James Lu
0907f05296
Condense (deep)copy definitions into structures.CopyWrapper
2017-08-25 17:05:53 -07:00
James Lu
8c0f19422f
core: Add irc argument to User and Server classes
...
Also, add a __deepcopy__ override to channel because we cannot clone IRCNetwork objects (locks cannot be pickled).
2017-08-25 13:53:45 -07:00
James Lu
96a202acce
core: make User.channels use IRCCaseInsensitiveSet
...
Closes #515 . This is an API breaking change!
2017-08-25 13:26:34 -07:00
James Lu
80766e051e
core: define two (joined) versions of the channels index
...
Closes #509 .
PyLinkNetworkCore.channels is split into the following:
- irc._channels which implicitly creates channels on access (mostly used in protocol modules)
- irc.channels which does not (recommended for use by plugins)
2017-08-25 02:12:08 -07:00
James Lu
c6ca89b48a
Fill in the rest of the extbans list for inspircd & unreal ( #498 )
2017-08-23 21:47:43 -07:00
James Lu
de1a6379df
Add (experimental) support for matching extbans ( #498 )
2017-08-23 21:18:57 -07:00
James Lu
d28006ae62
Move ProtocolError to utils, and link the copy in classes to it
2017-08-21 22:21:09 -07:00
James Lu
3e150d8514
Break up classes.ChannelState into structures.(IRC)CaseInsensitiveDict
2017-08-21 21:50:44 -07:00
James Lu
7aa836efa6
Concisify match_host CIDR logging again
...
We're replacing the glob, not the target's host.
2017-08-16 00:03:57 -07:00
James Lu
761d3ef500
Fix wrong logging for CIDR ranges in match_host
2017-08-15 21:26:18 -07:00