Public Access
- With NickServ, auto-join waits for the logged-in reply (900) or 2 s
at most, so registered-only IRC channels let us in
- A failed SASL login falls back to NickServ (its own password, or the
SASL account and password)
- IDENTIFY names the account explicitly, and once logged in on a
fallback nick, REGAIN takes ours back from a stale session
- Auto-join entries take keys ("#private key, #public"); keys from
/join are reused when rejoining; keyed channels go first in JOIN
- Serial irc dump: whole Buffers, and which login is configured
(never the secrets)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
59 lines
1.9 KiB
C++
59 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "key_value_store.h"
|
|
|
|
namespace roro {
|
|
|
|
struct IrcChannel {
|
|
std::string channel; // "#roro"
|
|
std::string key; // empty when the IRC channel has none
|
|
};
|
|
|
|
// The one IRC server the IRC Service connects to, persisted in internal flash.
|
|
class IrcConfig {
|
|
public:
|
|
explicit IrcConfig(KeyValueStore& store) : store_(store) {}
|
|
|
|
std::string host = "irc.libera.chat";
|
|
int port = 6697;
|
|
bool tls = true;
|
|
bool allowSelfSigned = false; // pin the certificate on first use instead of checking a CA
|
|
std::string pinnedSha256; // hex fingerprint once pinned
|
|
std::string nick;
|
|
std::string saslUser, saslPassword; // SASL PLAIN when both are set
|
|
std::string nickservPassword; // otherwise IDENTIFY with NickServ, if set
|
|
std::vector<IrcChannel> autojoin;
|
|
|
|
// A copy is a draft the UI can edit freely; copySettingsFrom() applies one.
|
|
IrcConfig(const IrcConfig&) = default;
|
|
void copySettingsFrom(const IrcConfig& other) {
|
|
host = other.host;
|
|
port = other.port;
|
|
tls = other.tls;
|
|
allowSelfSigned = other.allowSelfSigned;
|
|
pinnedSha256 = other.pinnedSha256;
|
|
nick = other.nick;
|
|
saslUser = other.saslUser;
|
|
saslPassword = other.saslPassword;
|
|
nickservPassword = other.nickservPassword;
|
|
autojoin = other.autojoin;
|
|
}
|
|
|
|
void load(const std::string& defaultNick);
|
|
std::string save(); // empty on success, otherwise why it was refused
|
|
std::string validate() const;
|
|
|
|
// "#private key, #public": a word starting with # or & is an IRC channel, the word after it
|
|
// (if it doesn't) its key. Spaces or commas separate entries, so "#a #b" also reads.
|
|
static std::vector<IrcChannel> parseChannels(const std::string& text);
|
|
static std::string formatChannels(const std::vector<IrcChannel>& channels);
|
|
|
|
private:
|
|
KeyValueStore& store_;
|
|
};
|
|
|
|
} // namespace roro
|