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

2184 Commits

Author SHA1 Message Date
Bram Matthys e59cd278cd log { } now uses the new log system and is used for logging to disk,
snomasks, opers, global (remote), ..

For disk logs we currently ignore the sources and log everything.

NOTE: REHASH is untested and will memory leak for sure.
2021-08-07 13:04:07 +02:00
Bram Matthys b8837844fb Newlog: new config plan, ditch set::logging and use log blocks soon.
In this commit it is still called logx { }. Will merge them soon
into one log { } block.
2021-08-07 10:39:54 +02:00
Bram Matthys c22207c4ca Drop cf_ prefix from ConfigFile and ce_ prefix from ConfigEntry structs.
Also rename them to describe better what they do.

ConfigFile:
cf_filename -> filename
cf_next -> next
cf_entries -> items

ConfigEntry:
ce_fileptr -> file
ce_varlinenum -> line_number
ce_fileposstart -> file_position_start
ce_fileposend -> file_position_end
ce_sectlinenum -> section_linenumber
ce_varname -> name
ce_vardata -> value
ce_cond -> conditional_config
ce_entries -> items
ce_next -> next
ce_prevlevel -> parent

Also add doxygen docs for both structs.
2021-08-06 17:50:45 +02:00
k4be 50eaee19a7 Merge branch 'unreal60_dev' into unreal60_dev+watch 2021-08-06 15:25:13 +02:00
k4be 55a5574a4b Merge branch 'unreal60_dev' into unreal60_dev+watch 2021-08-06 15:23:37 +02:00
Bram Matthys f34d3bd861 Add set::logging block and the logging to snomask mapping.
Note that without such a block nothing will be sent to ircops at all
(anything that comes from unreal_log anyway).
In a later commit either a snomasks.default.conf will be added and/or
an internal default mapping.

This also moves the recursion trap to earlier in the logging code,
which has the side effect that debug traffic regarding snomasks is
no longer logged.
2021-08-06 15:19:36 +02:00
Bram Matthys 5b44baab1f ULOG_WARN -> ULOG_WARNING. Better be consistent. This was the only
ULOG_* level that used an abbreviated term.
2021-08-06 08:50:45 +02:00
Bram Matthys 4115eaf483 Use memory pool for channels 2021-08-05 17:20:24 +02:00
Bram Matthys 3c7112469b Drop 2nd argument to find_channel which was always NULL everywhere anyway. 2021-08-05 17:02:39 +02:00
Bram Matthys 8dd6640bf5 Rename get_channel() to make_channel() to match make_user() and
change some more calls to make_channel() to use find_channel().
Also make it take 1 argument instead of 3.

Needed to be careful in sjoin code since the previous code set
channel->creationtime to 0 if client was a remote. Now merged
a few if's into one. Should be correct :D.
2021-08-05 16:55:28 +02:00
Bram Matthys da07fbf28f Make Channel struct fixed-size rather than the name[1] trick.
Also, do some more validations on remote names now that it is fixed.
2021-08-05 16:40:26 +02:00
Bram Matthys 6bad375ad7 Rename channel->chname to channel->name. 2021-08-05 16:34:45 +02:00
Bram Matthys bda671fa14 Newlog: Add ULOG_DEBUG log level, and update reputation.c to use newlog. 2021-08-05 14:17:39 +02:00
Bram Matthys a19135d2a2 Guard against ULOG_INFO / LOG_INFO mixups :D
No such mistakes have been made yet, but.. bound to happen.
2021-08-05 12:15:55 +02:00
Bram Matthys f5852ce534 Newlog: add log_data_timestamp() and use ISO8601 timestamps in JSON
logging. We already did so for the "timestamp" of the log message,
but now also do it in other log messages that have a timestamp,
such as "set_at" and "expire_at" in TKL entries.
2021-08-05 11:11:21 +02:00
Bram Matthys dbdfb7c656 Update TKL code to use new logging system. Make the TKL add/del/expiry
messages more consistent at the same time.
2021-08-05 10:19:05 +02:00
Bram Matthys b23f7e77c7 Add unreal_log_raw() if you want to log a buffer directly without expanding
the $stuff in it. This is unusual, but possible in some cases.
Generally people should use unreal_log(), though.
2021-08-05 07:54:22 +02:00
Bram Matthys 413def178c Add early loglevel to snomask code. Hardcoded atm. 2021-08-05 07:34:03 +02:00
k4be 5c9b7cf15f Add MONITOR command and fix numerous problems with WATCH. 2021-07-21 20:23:07 +02:00
k4be 4ec455bf06 Add selective watch removal.
Clean up linked list item deleting.
2021-07-21 18:04:01 +02:00
k4be 7fab97d364 Add watch notification hook.
This will likely reduce performance, but this should not matter in modern times.
Also added flags to let modules know which one the entry belongs to, and what
to do with it.
Now modules should be able to add their own WATCH methods (like IRCv3 MONITOR),
or extend functionality to notify about other changes than the default log on,
log off and away statuses (like SETNAMEs).
2021-07-20 20:59:36 +02:00
k4be 6ec6c37839 Add watch calls to efunctions.
(Doing nothing useful at this point.)
Also bump MAXEFUNCTIONS.
2021-07-19 21:28:29 +02:00
k4be bcbcc10b9d Move watch code from core to module 2021-07-19 18:16:28 +02:00
k4be 3a9e4f98ac Add option for notifying chanops about invitations by normal users.
Normally, channel operators are only notified when another chanop
invites someone to their channel - as this would allow the user to
join the channel later if it becomes invite-only. This is still
the default behaviour. But now, it can be configured to notify
operators about any invitation done to their channel, eitner by
another op or by normal user. This will allow them to see whether
someone floods others with invitations to their channels.
Enable the option with set::normal-user-invite-notification yes;
2021-07-17 18:07:02 +02:00
k4be 3ede47c7fa Remove invite moddata access from core (without breaking the api) 2021-07-15 16:13:02 +02:00
k4be c97b9bb494 Move invites from core to module 2021-07-14 20:20:56 +02:00
Bram Matthys d7fcc90014 Change lost_server_link() prototype and log errors properly for both TLS and non-TLS.
Not really satisfied with the way the TLS socket error is logged yet, but ok..
2021-07-14 14:13:02 +02:00
Bram Matthys 49fe200243 unreal_log(), connect_server and report_error() / report_baderror():
* Converted 90% of the socket and linking errors to use unreal_log()
* Add log_data_socket_error(fd) and $socket_error
* This also makes connect_server() 'void' and removes all of the error
  reporting from the callers (there was 3x code duplication due to that)
* Don't use report_error and report_baderror anymore in socket.c
* More to follow...
2021-07-14 13:33:18 +02:00
Bram Matthys 1068960b9a We now compile with -Wformat-nonliteral by default.
This adds __attribute__((format(printf,X,Y))) to several functions.
It also adds checking only for the non-literal case to some functions
such as unreal_log/unreal_do_log.

This so we can more easily detect format string issues. Especially now with
the recoding of the logger and with possible future mistakes in this area
in UnrealIRCd 6 itself or in third party modules.

The check is currently disabled in these files, which are TODO items:
* src/send.c: still much work to do
* src/socket.c: due to report_error and report_baderror().
  I want to get rid of these functions and integrate them
  in the new logger anyway.
* src/serv.c: only disable for hunt_server()
2021-07-14 11:15:49 +02:00
Bram Matthys 05aeba9ba9 Get rid of Debug(()) function calls. I never use it anyway. 2021-07-12 18:54:38 +02:00
Bram Matthys a57bdba220 Move CONFIG_TEST/CONFIG_RUN stuff for logging from conf.c to log.c
Still some other stuff to move too eg rehash/freeing stuff etc.
2021-07-12 18:00:41 +02:00
Bram Matthys b871d2a177 Add log::type for 'json' (work in progress) 2021-07-12 17:24:16 +02:00
Bram Matthys f89348d26c Add JSON logger - initial work 2021-07-12 14:37:25 +02:00
Bram Matthys 757adc76dd Bump version to 6.0.0-git and start release notes with a clean slate. 2021-07-12 14:17:46 +02:00
Bram Matthys d3c98c73c2 Fix issue where saslmechlist could not be set by services server.
This broke SASL services autodetection and also sasl=x,y,z in CAP.
Reported by Valware in https://bugs.unrealircd.org/view.php?id=5960

Of course the easiest solution would be just to set .remote_write=1
for this, which is what I've just done for the 5.2.1.1 release.
But there seems to be a pattern here. When a server wants to write
its own object (irc1.example.net writing to the MD object of
irc1.example.net) we have the problem that that object is both
"our client" and from the other server POV it is "themselves".
On one hand you may want to allow that (eg for 'saslmechlist'), on
the other hand a server writing its own 'certfp' sounds like a bad
idea in principle.
So we now add a new option for the 'self' case and make some MD
objects use it. In fact, in the core we now have zero MD objects
using remote_write. We keep the option available though, for example
for k4be's geoip modules and possibly future features.

Module API change:
* .self_write added which allows a server to write to its own object
  (irc1.example.net writing to the MD object of irc1.example.net)
* .remote_write still exists too if you want to allow remote servers
  to write to your own objects
* Note that in all cases, servers can always write to their own
  (child) client objects.

Changes:
* The link-security MD changed from .remote_write=1 to .self_write=1
* The salmechslist MD now has .self_write=1, this fixes the actual bug
2021-07-10 09:14:18 +02:00
Bram Matthys 8322a48026 ** UnrealIRCd 5.2.1 ** 2021-07-08 17:42:52 +02:00
Bram Matthys 94993a03ca ** UnrealIRCd 5.2.1-rc1 ** 2021-07-03 14:42:34 +02:00
Bram Matthys 696d5f05fb Last argument in fd_open() is now used to indicate what should be done on a
later fd_close() call. This also removes fd_map() since fd_open w/FDCLOSE_NONE
now does that.

* If you use fd_socket() or fd_accept(), then no change.
  When fd_close() is called we call close() on *NIX and closesocket() on Win.
* If you use fd_fileopen(), then no change.
  When fd_close() is called we will call close() on both *NIX and Win.
* If you used fd_open() and then fd_unmap() because you didn't want us
  to close the socket, then use fd_open() with FDCLOSE_NONE and
  just call fd_close() instead of fd_unmap().
  We will not actually close the fd in fd_close() (FDCLOSE_NONE).
* If you called fd_open() with other intentions then either specify a
  FDCLOSE_SOCKET / FDCLOSE_FILE as the last argument, or more likely:
  don't use fd_open() at all and use fd_socket() or fd_fileopen() instead.

For reasons on this change, see previous patch. This way is more sane and
makes it harder to make mistakes even beyond Windows-specific issues.
2021-06-30 11:33:46 +02:00
Bram Matthys 329f48334c I/O engine: track if a fd is a file or socket, needed for Windows.
This fixes a file descriptor leak in Windows that happened in the
logging code. The most visible effect of this was if you had a
log::maxsize set then on Windows you would see:
"Max file size reached, starting new log file"
Every other line, forever (and not actually starting a new log).

fd_close() previously did not close the file descriptor of a file
on Windows because on Windows it needs to call close() for a file
and closesocket() for a socket, and it always did the latter.
On *NIX it's more easy and you can just always close() any fd.
2021-06-30 11:06:44 +02:00
Bram Matthys 79740c4a38 Make "REHASH" and ./unrealircd rehash also run the same code as "REHASH -tls",
if on OpenSSL 1.1.1 or later.

We trust OpenSSL 1.1.1 and later to be good enough to handle all
the reference counting and freeing nowadays, which is something that
was not done correctly in (much) older OpenSSL versions, leading
to crashes on one hand and on memory leaks on the other hand.

In OpenSSL 1.1.0 and earlier we do not rehash tls on simple "REHASH",
since that code has not been vetted. However, nobody should be
running those old OpenSSL versions anyway, since they are out of
official OpenSSL support.
2021-06-27 15:38:40 +02:00
Bram Matthys 68d172854d Remove IsARegNick() as we already have IsRegNick() 2021-06-26 11:19:47 +02:00
Bram Matthys 06c0a34ab1 Assume all services use account names (SVID), and drop suport for services
that only set +r on people. To my knowledge, practically no services are
out there anymore that do not use proper SVIDs (and that can link with
UnrealIRCd 5).
2021-06-26 11:14:52 +02:00
Bram Matthys 114d54ac61 Allow larger IDLEN for incoming, but keep sending current length.
I would like a bit more room for this in the future,
but until then we will keep sending UIDs of length 9 in
server to server traffic, so no change at all.
2021-06-25 12:17:33 +02:00
Bram Matthys 26a3444f4e Validate the UID in cmd_uid(). Reported by Valware in
https://bugs.unrealircd.org/view.php?id=5925

This does two things in cmd_uid() now:
* It checks if parameter 6 in UID is a valid UID, using valid_uid()
* It checks if the first 3 characters of the UID match the SID
2021-06-25 11:47:23 +02:00
Bram Matthys e9e2504bf4 Don't allow remote servers to write to our MD client objects by default.
Modules can still opt-in via mreq.remote_write=1 to allow it for
certain moddata.
For example, k4be may want to do this for his geoip-base module which
allows a single server to set moddata "geoip" for all connecting clients,
including remote clients.
If you are a moddata provider then you can enable it like this:
 ModDataInfo mreq;
 [..]
 #if UNREAL_VERSION_TIME >= 202125
 mreq.remote_write = 1;
 #endif
 [..]

See discussion on https://github.com/unrealircd/unrealircd/pull/142
2021-06-25 11:28:32 +02:00
Bram Matthys e80c7b5b65 Add set::anti-flood options lag-penalty and lag-penalty-sec.
This also allows known-users to execute slightly more commands per second.

For people who want their trusted users/bots to allow even more commands
per second (eg 20cmds/sec) we now have a nice FAQ item that uses this:
https://www.unrealircd.org/docs/FAQ#high-command-rate
2021-06-23 16:21:06 +02:00
Bram Matthys 3fabc1ef5f New security-group::include-mask item so you can put clients into
security-groups based on masks too.
2021-06-23 13:22:17 +02:00
Bram Matthys 52297e24b6 Don't send "local" channel modes to remote servers.
They were already ignored in MODE by remote UnrealIRCd servers,
but this makes it so local modes (+Z and +d at the moment)
are not sent across the wire.

This also changes the channel_modes() function to have an additional
'hide_local_modes' argument. Set this to 1 if you are building a
buffer that will be sent to remote servers, otherwise use 0,
which is far more common.

Also, this will skip saving of local channel modes to channeldb
since all of these are temporary, or at the moment anyway.

Thanks to alice for reporting this bug and providing a good test
case to help fix this issue and the previous ones.
2021-06-19 17:25:26 +02:00
Bram Matthys a541b8f4ad Add support for OpenSSL 3.0.0 (based on -beta1)
Now compiles fine without any warnings.

Note that certificate_quality_check() is an outstanding TODO item.
2021-06-19 13:10:52 +02:00
Bram Matthys 905850a825 Bump version to 5.2.1-git and indicate this is bleeding edge 2021-06-19 10:21:46 +02:00