Public Access
The IRC App edited the live config while the IRC task could be reading it to connect. The App now edits a copy; applyConfig() validates it and swaps it in under the lock, and the task connects from a snapshot. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "key_value_store.h"
|
|
|
|
namespace roro {
|
|
|
|
// 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<std::string> 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;
|
|
|
|
static std::vector<std::string> parseChannels(const std::string& text);
|
|
static std::string formatChannels(const std::vector<std::string>& channels);
|
|
|
|
private:
|
|
KeyValueStore& store_;
|
|
};
|
|
|
|
} // namespace roro
|