1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-01 23:26:37 +02:00
Commit Graph

8320 Commits

Author SHA1 Message Date
Bram Matthys 4ad7d02ffa Changes to unrl_utf8_make_valid():
1) No longer impose a static maximum length
2) Caller must provide a work buffer and maximum length
3) Add a strict length check option
2021-08-09 08:49:01 +02:00
Bram Matthys 91a3c71d60 We now (try to) kill the "old" server when a server links in with the same
name, handy when the old server is a zombie waiting for ping timeout.

NOTE: atm this only works if someone links directly to us and there is
an existing server local or remote.
There is no code yet for a remote & remote scenario, which requires (or
at least prefers) having a creationtime for server connects, requiring
a SID command change.
2021-08-08 20:15:22 +02:00
Bram Matthys 2c8ef11004 Newlog: finished server.c conversion, yay. 2021-08-08 19:34:46 +02:00
Bram Matthys 93facdcdf4 Newlog: re-add syslog support 2021-08-08 17:39:37 +02:00
Bram Matthys 65e97e4140 Fix crash in set::server-linking::autoconnect-strategy sequential-fallback
when a remote server links to another server.
2021-08-08 15:57:33 +02:00
Bram Matthys a198d99850 Newlog: SLOG: actually use the JSON "msg" instead of parv[4]
And document SLOG command.
2021-08-08 15:27:04 +02:00
Bram Matthys f501772cbe Whoops... remove multi-line logging test code :D 2021-08-08 15:11:34 +02:00
Bram Matthys 53e283082f For IRCOps with unrealircd.org/json-log: in case of a multi-line message
we will now only send the JSON in the first message.

Also fix log file timestamp missing with multiline.

And rename do_unreal_log_ircops() to do_unreal_log_opers()

Add safe_free_message_tags()
2021-08-08 15:10:04 +02:00
Bram Matthys bc9e17aeb0 Add multiline support to unreal_log()
Any \n's will be expanded to multiple lines.
* For JSON disk logging there is no change.
* For text disk logging it will show as:
  [time] facility subsys.CODE+
  [time] facility subsys.CODE+
  [time] facility subsys.CODE
  So a plus sign is added if another message is to follow.
* For notices to opers/snomasks exactly the same (plus sign if needed).

Untested. More changes to follow eg to notice dropping the json
in the followup msgs.

This also changes the logging format for text disk to match
the output on server notices, we no longer log as:
[TS] facility subsystem event_code: msg....
But as:
[TS] facility subsystem.event_code: msg....
2021-08-08 12:04:41 +02:00
Bram Matthys 01542cdf77 Add line2multiline() which takes a string with \n's and returns a MultiLine
linked list.
2021-08-08 11:28:54 +02:00
Bram Matthys 2eb1f97d25 Newlog: server.c: Use SERVER_LINKED_REMOTE for remote links as
they use a slightly different format and you may want to exclude
these from certain logging. Also mention the correct uplink there.
2021-08-08 11:18:51 +02:00
Bram Matthys bac8b297c7 Newlog: more server.c conversions (all local server connect rejects done) 2021-08-08 11:02:44 +02:00
Bram Matthys 12adca5817 Set client->name early to provided servername and drop the servername
argument from verify_link() since now you can just use client->name.

Also more newlog for server.c (more to follow)
2021-08-08 10:15:59 +02:00
Bram Matthys a339efad2a Add exit_client_fmt() which accepts formatting characters. 2021-08-08 10:14:48 +02:00
Bram Matthys f843fc6d23 Serialize json with JSON_COMPACT.
Saves a bit of room, especially when the JSON travels over network this
maybe save some "crucial" bytes (and in that case it looks better too,
since the \s's in message tags only make it less readable).
2021-08-07 18:14:38 +02:00
Bram Matthys d17db626b3 Add some notes for the release notes (:D) 2021-08-07 17:49:33 +02:00
Bram Matthys fbe3d6124b Add unrealircd.org/json-log CAP, which sends JSON logs to IRCOps.
This basically enhances the regular snomask/ircop notices with
JSON logs, the same logs that are logged to disk (with type 'json').
This allows bots/machines to much more easily parse server notices
such as connect notices or.. anything.

Note that JSON logs are quite large, so make sure the ircop has
a BIG class::sendq!

Also, everyone can set the cap but it is only effective for IRCOps.
2021-08-07 17:32:54 +02:00
Bram Matthys ab180b086c Rename recently added mtag: s2s/json -> unrealircd.org/json-log 2021-08-07 17:17:37 +02:00
Bram Matthys adfa81ee07 Get rid of >1024 msg length check in sendbufto_one. 2021-08-07 17:16:34 +02:00
Bram Matthys fb9af08e83 Add coloring to snomask/ircop messages based on log level.
This will later be configurable, of course.
2021-08-07 16:15:29 +02:00
Bram Matthys 9885af1486 Validate and rewrite remotely received JSON via SLOG cmd.
This makes it use OUR timestamp, so timestamps in logs are properly
sequential. The originial timestamp is saved in "original_timestamp".
Finally, we (over)write "log_source" with the remote server name.
2021-08-07 15:49:29 +02:00
Bram Matthys b75f6b4086 Newlog: add "log_source" 2021-08-07 15:49:12 +02:00
Bram Matthys 64180d8a2c Send and receive json as well in SLOG server to server message.
TODO: validate JSON
2021-08-07 15:22:06 +02:00
Bram Matthys bac38926a6 Make compiling with -O0 work again 2021-08-07 15:21:48 +02:00
Bram Matthys 654a88a53a Easy message tags sending restrictions to permit full 4094 bytes.
Needed for next commits.
2021-08-07 15:20:53 +02:00
Bram Matthys 659b553351 Add slog.c, initial version of S2S logging. 2021-08-07 14:40:08 +02:00
Bram Matthys 0739af0812 Add initial remote logging support via SLOG (S2S cmd).
Also call the log::destination "remote" instead of "global".
2021-08-07 14:38:06 +02:00
Bram Matthys 39e45c2be3 Add newlog TODO item 2021-08-07 14:14:19 +02:00
Bram Matthys f4af4acb16 Newlog: fix rehash and memory leak 2021-08-07 14:01:44 +02:00
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 2aff2727ed Re-order matching in log_sources_match() for performance. 2021-08-07 09:14:32 +02:00
Bram Matthys 839367272a Rename $client.nuh to $client.details as it is generic detailed
client information and not necessarily nick!user@host in all cases.
2021-08-06 20:59:54 +02:00
Bram Matthys 33a9b745a8 Support client.a.b.c.d etc with "infinite" depth (as long as the
variable is max 255 characters).
This fixes the client connecting notice that previous commit
knowingly broke.
2021-08-06 20:55:57 +02:00
Bram Matthys f38a43434e Newlog: expand client.server more, and also move some stuff to client.user
This means we now have $client.user.username but the expansion system
does not allow items more than 2 deep atm (only $client.something
but not $client.something.other). Will fix later. (TODO)
In the meantime the connection notice will look weird :D
2021-08-06 20:32:35 +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
Bram Matthys 3eef42c385 Let's log everything except ULOG_DEBUG on the console when booting.
Better than missing an important message.
2021-08-06 16:24:44 +02:00
Bram Matthys 6d216c3a90 Validate set::logging better. 2021-08-06 15:47:51 +02:00
Bram Matthys 1b00ea9137 Fix module not loading using config_status() instead of config_error()
which wasn't logged on the console.
2021-08-06 15:47:24 +02:00
Bram Matthys 9c210ba3fa Merge branch 'unreal60_dev' of github.com:syzop/unrealircd-next into unreal60_dev 2021-08-06 15:27:46 +02:00
Bram Matthys e75ea8d00e Temporarily send to all opers if there is no matching set::logging::snomask
nor set::logging::all-opers configuration.

This so you at least have logging for now ;D
2021-08-06 15:27:03 +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 4c3fa999a7 use 'all-opers' (not 'all-ircops') to be consistent. 2021-08-06 15:23:17 +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 e9ffeb2d33 Newlog: validate log level, event id and subsystem now. We crash immediately
when any of these are wrong. Obviously this should probably be changed to
only do it in DEBUGMODE in a final stable release :D

We also crash if 'msg' contains a percent sign ('%'). This is to avoid
mistakes where someone uses eg '%s' in there, which is not supported.
Unfortunately it also prevents stuff like '100%' so this should probably
be removed too at some point.
2021-08-06 11:50:28 +02:00
Bram Matthys bfe9fc49e4 Fix non-JSON logging (set type 'text' by default) 2021-08-06 11:29:49 +02:00
Bram Matthys 065d24e248 In register_user() use client->user->XXX instead of user->XXX.
Has always been annoying me.. :D
2021-08-06 11:11:09 +02:00
Bram Matthys 92757f6d9f Newlog: convert local client connects and disconnects.
Also makes the connect message and the standard log message consistent.
2021-08-06 11:05:59 +02:00
Bram Matthys f3035a49f8 Newlog (JSON): enrich client object with 'reputation' and 'security-groups'.
The former is an integer and may not always be available (eg: very early
before the user is connected). The latter is an array.

TODO: opt-in/out of all these expansions as they come at a performance penalty
2021-08-06 11:04:22 +02:00