1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-28 00:26:38 +02:00
Commit Graph

8518 Commits

Author SHA1 Message Date
Bram Matthys 4e53bf874a Make remote includes caching work again. Both on-boot and on-rehash. 2021-08-19 09:33:46 +02:00
Bram Matthys 7b3c1165f8 Make tld::mask use the generic masks that we use everywhere
(and hence support multiple masks and server bans matching etc)
2021-08-18 18:45:23 +02:00
Bram Matthys e503ad4fd5 Reorder members in ConfigEntry struct a bit (optimize for L1/L2 cache)
Obviously name, value and next should be at the top.
2021-08-18 18:32:05 +02:00
Bram Matthys cdff69db7a Allow people to include the same file multiple times. This will no
longer raise an error and we will simply load the include only once.

I left some tracing code in case we have a bug in the code that
handles this, but testing shows it works well both for files and
URLs.
2021-08-18 17:04:45 +02:00
Bram Matthys a60b9f3176 Handle duplicate URLs/downloads (only download once) 2021-08-18 16:43:42 +02:00
Bram Matthys ce3e23a5d2 Get rid of unnecessary included_from and included_from_line
members in ConfigResource (previously ConfigItem_include).
2021-08-18 16:31:48 +02:00
Bram Matthys 0b5fab1617 Some cleanups in src/url.c and added error message for the very unusual
case where curl may fail to create a handle.
2021-08-18 15:19:51 +02:00
Bram Matthys d8c3da7698 Get rid of download_file(), the synchronous version, is no longer used. 2021-08-18 15:14:14 +02:00
Bram Matthys 6d56145f60 Remove URL support from staff module now that main conf.c already does this.
And re-enable the module, as it was #if'd out.
2021-08-18 15:11:37 +02:00
Bram Matthys e296464b97 Get rid of update_config_resource() and just set the appropriate
values at the four places that used it.
2021-08-18 15:02:18 +02:00
Bram Matthys 756fee58cb Rename ConfigItem_include to ConfigResource and also use it for non-includes
such as other items in the configuration file that are URLs.
2021-08-18 14:54:41 +02:00
Bram Matthys d897ecbc86 Get rid of some if (need_34_upgrade) upgrade_conf_to_34(); stuff
We probably want to get rid of that at all?
Maybe defer until we know whether we want/need it for U5->U6...
2021-08-18 13:36:55 +02:00
Bram Matthys b74d15595b Change int rehash() to void request_rehash(), which is a better name
as it REQUESTS to rehash the server, but it may not be done immediately.
And making it void makes sure nobody relies on some sort of return
value which will differ between with vs without remote includes.

Also get rid of sig and loop.rehash_save_sig, as a NULL client
already indicates the same (or at least does so now).
2021-08-18 13:28:56 +02:00
Bram Matthys 675c1cab55 Rename loop struct members:
* loop.ircd_rehashing -> loop.rehashing
* loop.ircd_terminating -> loop.terminating
* loop.ircd_booted -> loop.booted
* loop.ircd_forked -> loop.forked
2021-08-18 13:08:42 +02:00
Bram Matthys f184472781 Get rid of argument to config_test(), as we have loop.ircd_rehashing for that. 2021-08-18 13:03:31 +02:00
Bram Matthys fe2c834080 Rename lots of config functions (internally used ones, most likely
not used by 3rd party authors):
* conf_start() -> config_read_start()
* conf_check_complete() -> is_config_read_finished()
* load_conf() -> config_read_file()
* config_test() -> config_test_blocks()
* config_run() -> config_run_blocks()
* init_conf() -> config_test()
* run_configuration() -> config_run()

This so things look like:

if (config_read_start() < 0)
        exit(-1);
while (!is_config_read_finished())
	; // do something
if (config_test(1) == 0)
        config_run();
2021-08-18 12:57:38 +02:00
Bram Matthys 7321a66196 Make failed include loading fatal again. And fix a crash related to that. 2021-08-18 12:46:11 +02:00
Bram Matthys 685e0ee073 In ConfigItem_include include->url now always exists, and src/url.c is now
always compiled in, both regardless of cURL support or not.
Obviously the cURL functions are not available without cURL and there
are now some #ifdef USE_LIBCURL in url.c

This also fixes the current build to work without cURL
2021-08-18 12:27:13 +02:00
Bram Matthys f85615518e Make rehashing work again 2021-08-18 12:05:15 +02:00
Bram Matthys 03423a2eb7 Get rid of INCLUDE_NOTLOADED and INCLUDE_USED which AFAICT are
unnecessary. Get rid of load_includes() which did the marking
and unload_notloaded_includes() and unload_loaded_includes()
accordingly. There's now one single free_all_includes().
2021-08-18 11:52:53 +02:00
Bram Matthys 9e887ea4e9 Start with remote includes makeover. First objective is making them
asynchronous on start, which is achieved by this 1st commit.

For this to work, the init_conf() stuff has been split to an
earlier call to conf_start() and then a loop where you can
check for conf_check_complete().
This means init_conf() no longer calls load_conf, as that
is moved to conf_start() and conf_check_complete().
Thus, init_conf() is now only called when all includes are in the
linked list 'conf_include'.

This is work in progress and breaks:
1) rehashes
2) compiling without curl
3) possibly cached remote includes
2021-08-18 11:31:46 +02:00
Bram Matthys 5154038d59 Code cleanup: replace "if(" with "if (" 2021-08-18 09:54:43 +02:00
Bram Matthys 6058090435 Use GeoIPResult * everywhere. Any modules who want to fetch it for
a client can use geoip_client(client).
2021-08-17 17:16:14 +02:00
Bram Matthys 58abc0da5b Add moddata_client_get_raw() to get the ModData *.
This probably should not be used much as normally you
should not rely on structures created by modules in
other modules / other code.
2021-08-17 17:03:00 +02:00
Bram Matthys 796cac7a63 geoip: migrate from simple string to returning a GeoIPResult struct.
(work in progress, 1/2)

This also add supports for callbacks which return pointers (pvoidfunc),
we already had that for efuncs but not in callbacks.
2021-08-17 16:39:39 +02:00
Bram Matthys fe3c86b128 Support ~country:* for unknown country (fix) 2021-08-17 16:14:59 +02:00
Bram Matthys fc6c52db93 Add extbans/country: +b ~country:UK 2021-08-17 16:12:06 +02:00
Bram Matthys a9434d13c7 Add RPL_WHOISCOUNTRY info in /WHOIS requests from IRCOps 2021-08-17 15:53:17 +02:00
Bram Matthys d7561d6b23 Show [country: XX] in connect notice and sync geoip info with other servers. 2021-08-17 15:35:14 +02:00
Bram Matthys 2ea75dfbdb Add geoip_base module, which sets "geo_country" if a geo provider
module is able to lookup the IP and return a country.

Also consistently use geoip_ and GEOIP_ prefixes.
2021-08-17 15:26:29 +02:00
Bram Matthys 0bbad85f84 Add geo_lookup() function. Make geoip_classic do something useful.
NOTE: everything hardcoded atm, just temporarily.
Add CALLBACKTYPE_GEO_LOOKUP which is called from geo_lookup().
2021-08-17 15:11:40 +02:00
Bram Matthys 8cdbc3ae86 Don't build geoip_classic without --enable-geoip-classic=yes.
([I... hate... M4!])
2021-08-17 14:37:48 +02:00
Bram Matthys ed7bf1daf5 Bundle with GeoIP classic library and add geoip_classic placeholder.
This library we can safely bundle because it is GPLv2.
2021-08-17 14:11:36 +02:00
Bram Matthys 9ff56089ad Show TLS cipher in [secure: xyz] in far connects too (+s +F).
This requires both servers to be using UnrealIRCd 6 and there
should be no UnrealIRCd 5 server in-between (eg an old hub).

This also changes tls_cipher() to expect a Client * argument.
And tls_get_cipher() can now safely be called on any client,
including remote clients, and it will return the cipherstring
if it is known via moddata.
2021-08-16 14:30:21 +02:00
Bram Matthys 76da8714a7 Fix using the wrong variable in moddata_extract_s2s_mtags() 2021-08-16 14:26:49 +02:00
Bram Matthys 11167924df Add tls_cipher module which stores/retrieves the TLS cipher of all users. 2021-08-16 14:16:13 +02:00
Bram Matthys f75a9c8544 Sync ModData in UID command if mdata.sync = MODDATA_SYNC_EARLY.
This way we should be able to show certfp and webirc status
in far connect notices, and later various other details too.
2021-08-16 14:01:45 +02:00
Bram Matthys 7500de1060 Permit unknown message tags from trusted servers. 2021-08-16 13:48:09 +02:00
Bram Matthys 48e3901f27 It's probably a good idea to send the channel name in SJOIN
(fix for commit from yesterday, 99d2870870)
2021-08-15 08:59:32 +02:00
Bram Matthys 6134452b82 Fix crash on connect due to wrong reputation logging
(accessing e->ip when e is NULL) in DEBUGMODE.
2021-08-14 21:08:25 +02:00
Bram Matthys 99d2870870 For SJOIN, send the shorter nomode&nopara version when possible.
We used to always send the long version:
SJOIN ts #channel +sntkl key 999 :xxx
From now on we only send that for the first SJOIN for a channel
when syncing. For any subsequent SJOINs (so for larger channels or
with lots of bans/exempts/invexes) we will use the short version:
SJOIN ts #channel :xxx

We now do it that way because the remote side already received
all the modes the first time, so they are redundant in the
subsequent SJOINs for the same channel.
Especially if you have a channel with a large mode string, such as
+lLfH 99 #redirectchan [30j#i10,40m#m10,7c#C15,10n#N15,30k#K10]:15 100:1d
it was previously 1) wasting bandwidth and 2) unnecessary CPU
trying to merge channel modes that were already the same.
2021-08-14 21:03:49 +02:00
Bram Matthys 428c301a94 unreal_server_compat: convert named extbans in SJOIN as well. 2021-08-14 20:05:00 +02:00
Bram Matthys eac417d66a Fix memory leak on +beI 2021-08-14 18:36:01 +02:00
Bram Matthys a43637d55d Add extban->is_banned_events which you need to set to indicate to
which BANCHK_* events you want to listen, eg BANCHK_JOIN, BANCHK_MSG.
You can use BANCHK_ALL to watch on all events.
Only BANCHK_TKL is not included there and needs an explicit
BANCHK_ALL|BANCHK_TKL.

The caller will now take care of BANCHK_* filtering so we won't
waste any CPU on calling an is_banned() function that isn't
interested at all in the event that we have.

Also, no longer require an extban->is_banned function, since some
extbans don't use it. This too saves useless calls.
2021-08-14 18:25:36 +02:00
Bram Matthys 03d78bf95d Fix looking up the wrong extban in some cases.
~T => ~text => starts with ~t => ~time... fun.
2021-08-14 17:57:22 +02:00
Bram Matthys 75dbd99614 I think the code already handles all these "can't stack these" cases.
If I'm wrong we have a regression :D
2021-08-14 17:46:44 +02:00
Bram Matthys 0acc9eef49 Add parameter to clean_ban_mask() that will be put in b->conv_options.
Currently only supported option is:
BCTX_CONV_OPTION_WRITE_LETTER_BANS: always write letter bans

This removes the NULL pointer magic that i was not happy about.
2021-08-14 17:36:49 +02:00
Bram Matthys ca4f4c2575 Add PROTOCTL NEXTBANS. This indicates support for named extended bans.
If you don't indicate NEXTBANS support then we will send old fashioned
extended bans to you.
Note that eventually we will likely require named extended bans support,
but that will be UnrealIRCd 7 / 8.... ;)
2021-08-14 17:28:15 +02:00
Bram Matthys 5f31f7a5cc Add unreal_server_compat module which rewrites named extbans in
server to server traffic to be letter extbans.
Yeah this is a tad ugly, but the alternative was worse, see
header of the file for the full story.

Module is loaded by default (obviously).

Still to do: only do this for non-U6 servers (add some PROTOCTL)

And probably alter clean_ban_mask because I don't like the
magic on NULL client at the moment.
2021-08-14 16:45:18 +02:00
Bram Matthys f6704cfd1c Add empty_mode(modebuf) to check for "", "+" or "-" modes, that is:
modes that are empty/useless. Previously this check was done at
several places in their own way. Ugly and duplicate code.
2021-08-14 15:18:34 +02:00