23 Commits

Author SHA1 Message Date
TheDaemoness
b2f40896bf Update reg handler to use client state
The handler now, instead of returning Registration,
sets the Client's internal ClientState.
This means useful state info is more readily-available to handlers.

Updated examples to match.
2024-04-28 09:41:23 -07:00
TheDaemoness
965740a9b4 Rework SASL authentication
Rewrites SaslLogic, which now outputs into a SecretBuf and
reports the name of the mechanism in use instead of Sasl.

The Sasl trait now returns a Vec of SaslLogics.

Adds a Password authenticator to auth using PLAIN
(or, in the future, SCRAM).

The SASL handler now processes a whole SaslQueue.

Removes Authenticate and implements MakeHandler on
names::cmd::AUTHENTICATE instead.

Simplifies the registration handler thanks to these changes.
2024-04-27 12:57:43 -07:00
TheDaemoness
04a51463ce Rework handling of secrets
Secrets can now be loaded during deserialization of a struct containing them
(e.g. Options). They are also typed more-strongly.

Adds SecretBuf, a mutable buffer for containing sensitive data
before constructing a Bytes from it.

Sasl::logic is now infallible, as secrets are supposed to have been loaded
earlier.

The password-retrieval function in Register is now infallible.
As such, Register's handler construction now uses the Infallible error type.
RFC 1216 will hopefully be stabilized at some point soon.

Adds CString conversions to NoNul and friends.

Removes zeroize as a feature and optional dependency.
We'll just write_volatile directly.
2024-04-25 12:21:39 -07:00
TheDaemoness
2f170b020f Improve and correct CTCP handling
Now that it's correct, also uses the CTCP handler in the reconnect example.
2024-04-16 12:04:03 -07:00
TheDaemoness
8b54fe74f3 Include ChannelSpec in Client
Oftentimes the channel spec isn't going to change frequently,
so it becomes fairly redundant as a parameter on Client::add.

This alters the Client creation functions to include the channel spec,
as well as adding a type parameter to Client for it.

Also removes new_client as it's basically pointless.
2024-04-16 12:04:03 -07:00
TheDaemoness
060b21a3ba Support reusing Clients on reconnection
Also adds an example of reconnection that also uses handler IDs to determine
when an event has occurred.
2024-04-12 07:42:33 -07:00
TheDaemoness
b9a938b3ab Add Send bounds everywhere, rewrite oneshot
Client is now Send (but not Sync yet).

The new implementation of the oneshot channel has cloneable senders
and is Send for non-Sync values.
Non-consuming read-only access to the contained value via peek
is now behind an explicit T: Sync requirement.

Renames Receiver::recv_nonblocking to Receiver::recv_now to be more accurate.

Moves the modules in channel to their own files.
2024-04-09 16:17:58 -07:00
TheDaemoness
61bee4bf12 Rework channel abstractions, add sync oneshot channels
Adds `oneshot` as essentially wrapped `Arc<OnceLock>`s,
but with a nicer interface and weak references on the sender side.
The senders can be cloned for usecases where one only cares about the first
operation to complete.

Adds `parker` for thread-parking, allowing the oneshot channels to block.
Very untested at the moment.

Changes the receiver type on Sender from `Arc<Self>` to `&mut Self`.
Also changes `ChannelSpec` and `*::make_channel` to match.
`Arc`s are not structural and oneshot-type channels really want to consume
the sender, which is quite clumsy when everything is an `Arc`.
Instead, `Sender` is impl'd for `Option`s containing oneshot senders.
2024-04-06 13:55:54 -07:00
TheDaemoness
f29bd66b40 Change MakeHandler::make_handler to take self by value 2024-04-04 18:10:43 -07:00
TheDaemoness
b9de1e054d Begin adding second-stage message parsing
This is for parsing of messages after they're ClientMsgs/ServerMsgs.

Adds the WIP TargetedMsg for messages that are sent to specific targets.

Implements NameValued for a few message types using TargetedMsg.

Adds the YieldParsed handler for convenient extraction of specific messages.

Adds an example using these features!
2024-04-04 16:20:13 -07:00
TheDaemoness
cf811ec233 Name consts and its contents more sensibly 2024-03-30 08:05:31 -07:00
TheDaemoness
c9d2dbcd4e Add and migrate to TagMaps
TagMaps are a way of mapping Tags to lazily-parsed values.
Additional information can be stored alongside the "natural" value for a tag.
This commit makes changes to FlatMap to support this new type.

Migrates ISUPPORT tokens to the new system,
and removes the serverinfo module (including ISupportParser).

Adds a module for common IRCv3 capabilities.
Also adds a public way to get SASL mechanisms out of the capability string.

Changes capabilities and ISUPPORT in Registration to use TagMaps.
This has particular benefits for capabilities, as now consumers of vinezombie
have access to info about unrequested capabilities.
2024-03-30 01:07:13 -07:00
TheDaemoness
ea9daa127e Add system of typed tags, migrate consts/cmd.rs to it
Tag as in "tagged union", not as in "IRCv3 message".

This lays the foundation for using something like what ISUPPORT handling does,
but for other classes of tags.

Will migrate ISUPPORT to this later.
2024-03-21 13:03:21 -07:00
TheDaemoness
a40879c6f8 Rework connection registration
Completely reworked nick generation AGAIN.

We now parse RPL_ISUPPORT and RPL_BOUNCE (both of them)!
The reg handler also now waits until the MOTD to finish.

The `MakeHandler` that creates a registration handler is now `Features`,
a struct that is used to extract information from an options struct.

Renamed `Register` to `Options` and trimmed it down a little.
Used by the `Features` that replace `ClientDefaults` and `BotDefaults`.

Changed default behaviors for connection registration.

Silly hashing for the Ping handler and elsewhere now uses SipHash.
2024-03-16 20:39:54 -07:00
TheDaemoness
ce18d6096d Rewrite handlers from scratch
Further testing necessary,
but this system should be VASTLY more flexible than what existed prior.

Also adds some cheeky labeled-response support to Queue.

Also removes the logging from ircmsg and moves it to Client.
2024-02-28 16:23:56 -08:00
TheDaemoness
2370e49902 Break TLS support in order to tidy it up
Renames TlsConfig -> TlsConfigOptions.

Adds a type alias for Arc<ClientConfig> named TlsConfg.

connect and connect_tokio now take a function that fallibly returns a
TlsConfg. This allows for lazy TlsConfig construction that previously
wasn't convenient to do.

Fixes deprecation warning due to use of with_single_cert.
2023-07-20 23:27:57 -07:00
TheDaemoness
3feae669cd Restructure Register's nick and cap options
Moved capability options into Register.
This was originally kept seperate due to being especially
application-specific (where most of Register's other options aren't),
but ultimately this way is tidier, and applications can always
change caps before calling handler.

nicks is now a struct containing nickgen (as "gen").
This should make things a bit tidier.

Added an option to skip attempting to use the first nick.
Useful for having the first nick exclusively as a fallback,
or just jumping directly to generated nicks.
2023-07-15 16:04:09 -07:00
TheDaemoness
faebc03273 Add Tokio example usage 2023-06-30 11:00:06 -07:00
TheDaemoness
e321a8ab43 Repurpose vinezombie to be a lower-level IRC lib
The abstractions are nowhere near done,
but vinezombie is useful as a plain IRC library despite that.
This commit removes the WIP state and update modules,
reorganizes some code and feature flags to make more sense,
and updates documentation to match.

The WIP abstractions will get their own library.
2023-06-29 22:58:26 -07:00
TheDaemoness
189976c69c Add nicer ways to create sync connections
Breaking: Removes client::tls::connect.
Use client::conn::ServerAddr::connect instead,
which returns a wrapper that is more-generally-convenient to work with.
2023-06-29 12:26:04 -07:00
TheDaemoness
d1e1c54dd6 Add tracing support 2023-06-26 22:00:06 -07:00
TheDaemoness
9a211c0499 Add Handler trait, make run_handler a function
This is a concession to allow convenient use of a bit of
I/O-related boilerplate without reaching for declarative macros.
2023-06-26 19:45:54 -07:00
TheDaemoness
ff9a0b9235 Improve documentation
Welcome back, hello_libera.rs.
2023-06-26 18:07:28 -07:00