1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-25 21:06:37 +02:00
Commit Graph

2278 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 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 d8c3da7698 Get rid of download_file(), the synchronous version, is no longer used. 2021-08-18 15:14:14 +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 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 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 a9434d13c7 Add RPL_WHOISCOUNTRY info in /WHOIS requests from IRCOps 2021-08-17 15:53:17 +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 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 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 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 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
Bram Matthys 9e0357ad71 Get rid of all the bounce stuff in MODE.
The only stuff we still have is if a bounce servermode is detected
(incoming) then we just ignore it.

All this bounce stuff wasn't used much, and didn't even work
(was always sending empty bounce string). It was only complicating
the code everywhere with stupid stuff like:
*x++ = bounce ? '+' : '-';
what = MODE_DEL;
2021-08-14 14:56:53 +02:00
Bram Matthys a70580cc86 Enable sending of named extended bans. This can be changed via the
configuration file via set::named-extended-bans <yes|no>; and now
defaults to yes.
Still to do:
* explicitly set names instead of using stupid module names
* update test suite to check for these new names (other git tree)
* backwards compatible sending to U5 and lower using ugly shit
2021-08-14 10:12:43 +02:00
Bram Matthys a6b5587666 Use prefix_with_extban() at the 3 places, needed for next... 2021-08-14 09:49:22 +02:00
Bram Matthys 34b034ab36 Add named extban support. This only deals with the incoming parsing,
it is not visible outgoing yet. So: ~account:name becomes ~a:name.
2021-08-14 09:27:39 +02:00
Bram Matthys 5a387f9c0b Rename extban.flag to extban.letter.
TODO: Should probably do this for umode/cmode as well ;)
2021-08-14 09:07:22 +02:00
Bram Matthys f23546b27c More conv_param() changes, the +3 rule changed, and matches the rest.
The .conv_param() now receives the ban minus the ~own-extban.
And it should also return the part minus the ~own-extban.

Changes to findmod_by_bantype():
1) Takes a string now, rather than a single char value,
   so it is ready for named extbans.
2) Second parameter added so you can easily jump to the remainder.
   Eg:
   extban = findmod_by_bantype(b->banstr, &nextbanstr);
   [..check if extban is non-NULL and then..]
   b->banstr = nextbanstr;
2021-08-14 08:57:33 +02:00
Bram Matthys 5269b647d5 Round three of extban API overhaul, this changes extban->conv_param().
More changes will follow related to that...
2021-08-13 17:59:45 +02:00
Bram Matthys b5d948c09c Round two of extban API overhaul, this changes extban->is_ok()
Also cleanup big blob op duplicate code in +beI handling in MODE.
2021-08-13 16:03:15 +02:00
Bram Matthys bff6fdde6f Start of extban API recode. I created the current API in 2003 and..
well.. let's hope I have gained some good insights since then.. :D
2021-08-13 14:17:07 +02:00
Bram Matthys a0a95f6cee Get rid of unnecessary check_init() stuff (and the hook) 2021-08-13 13:06:35 +02:00
Bram Matthys eb171c8e22 Add strtolower(). Note: we already hade strtolower_safe(). 2021-08-13 12:22:49 +02:00
Bram Matthys 9310fd3b4b Move check for valid hostname out of register_user(), we already
have that in dns.c. Also remove verify_hostname() from dns.c and
integrate it in valid_host() which now takes a second argument
named 'strict'. Call valid_host() with strict set to 1 if the
hostname should be checked to be a valid DNS hostname, eg the
host may not contain stuff like ':' or '/'. Use 0 otherwise
for the loose check, eg if you are not sure if the passed host
is an IP address or a host, or if it is for a vhost.
2021-08-13 12:17:24 +02:00
Bram Matthys fa875d6fd4 Cleanup: register_user() now takes only 1 argument (client) instead of 5 arguments.
The last 3 were always NULL after the remote/local split from a few commits ago.
And nick and username were useless as well as client->name and
client->user->username were always already set.
2021-08-13 11:06:30 +02:00
Bram Matthys 9a2e8613ae For remotely received log messages (via SLOG) show the original server name
as sender in the NOTICE, just like we used to do in the past.
2021-08-12 17:07:12 +02:00
Bram Matthys 445b47391f Do an #undef on LOG_DEBUG, LOG_INFO, etc.. so they cannot be confused
anymore with the ULOG_DEBUG, ULOG_INFO, etc levels.
2021-08-12 15:27:27 +02:00
Bram Matthys a94017c731 Remove sendto_ops_and_log(), use unreal_log() instead! 2021-08-11 19:10:30 +02:00
Bram Matthys 609a6600aa Remove ircd_log(), use unreal_log() instead! 2021-08-11 18:01:00 +02:00
Bram Matthys 4968bf84fe Newlog: convert those in include/*.h too 2021-08-11 17:59:40 +02:00
Bram Matthys fe21fd6024 Remove sendto_realops_and_log() and map some remaining temporary
to sendto_ops_and_log() which will soon disappear too.
2021-08-11 15:47:00 +02:00
Bram Matthys 9308e5b8a0 Change maximum chanmode +l value to 1 million and "coincidentally" also
change the IsInvalidChannelTS() macro to check for this value or lower.
2021-08-11 15:39:15 +02:00
Bram Matthys 9efe590a8e Newlog and fishy timestamp handling:
* New macro IsInvalidChannelTS() which evaluates to ts < 750000
* Check for faulty creation time ("fishy timestamp") at ALL places
  where channel->creationtime is set.
* Also, important, changed behavior:
  if !IsInvalidChannelTS then:
  1) We print our warning
  2) We pretend ts is our channel creationtime (which may be
     TStime() if the channel did not previously exist)
  3) We allow the command through and allow it to merge (in case of SJOIN)

This makes it so we still log the error (noisy) but on the other hand
we won't get "infected" by fishy timestamps since we will never set
them, no matter what happens.
2021-08-11 15:29:45 +02:00