The product is Voelin (app id io.github.faumaray.Voelin), everywhere: - crates tsc-* -> voelin-* (and voelin-fuzz), the desktop binary tsc-desktop -> voelin, the development CLI tsctl -> voelinctl; - the Android app: applicationId, Kotlin package io.github.faumaray.voelin, VoelinApp, libvoelin_android.so (JNI class names follow); - TSC_* environment variables -> VOELIN_*, Gradle properties tsc.* -> voelin.*, signing secrets VOELIN_SIGNING_*; - the data/config/cache/state folder tsc -> voelin, the keyring service, thread names, the dev compose project; - desktop file, metainfo, icon, Flatpak manifest, NSIS installer, docs. The gateway keeps its name: bin tsgw (crate voelin-gateway), TSGW_* env vars, the tsgw.v1+json protocol, the tsgw image. The window title and the About page show "Voelin <version>" from voelin_platform::APP_NAME. Packages (scripts/package.sh): the app only (voelin, voelin.exe, APKs, Flatpak). voelinctl is a development tool and in no package. tsgw is for servers and now its own Linux package, tsgw_<v>_amd64.deb and tsgw-<v>-linux-x86_64.tar.gz, with a sandboxed systemd unit (packaging/linux/tsgw.service; /etc/tsgw config, /var/lib/tsgw state) and dependencies of its own (no GUI libraries). docs/gateway-admin.md has an Install section. Fixes: - package-windows: makensis on Windows found no file through "D:/a/..." paths; pass Windows paths (cygpath -w). - StartupWMClass is the app id, which the app sets as its X11 WM_CLASS (it was the binary name, so desktops could not match the window). - Gradle wrapper download timeout 10 s -> 60 s (slow proxies). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
91 lines
2.8 KiB
Rust
91 lines
2.8 KiB
Rust
//! The query source: own ServerQuery credentials, in-process observer and relays.
|
|
|
|
use tokio::sync::{broadcast, mpsc};
|
|
use voelin_model::{ChatMessage, ChatTarget, Presence};
|
|
use voelin_observer::{
|
|
Observer, ObserverConfig, ObserverEvent, RelayConfig, RelayEvent, RelayPool,
|
|
};
|
|
|
|
pub(crate) enum QueryCmd {
|
|
OpenChat(ChatTarget),
|
|
CloseChat(ChatTarget),
|
|
SendChat { target: ChatTarget, nick: String, text: String },
|
|
Stop,
|
|
}
|
|
|
|
pub(crate) enum QueryEvent {
|
|
Presence(Presence),
|
|
Chat(ChatMessage),
|
|
Error(String),
|
|
Disconnected,
|
|
}
|
|
|
|
pub(crate) async fn run(
|
|
connect: voelin_query::Connect,
|
|
mut commands: mpsc::UnboundedReceiver<QueryCmd>,
|
|
events: mpsc::UnboundedSender<QueryEvent>,
|
|
) {
|
|
let observer = Observer::spawn(ObserverConfig::new(connect.clone()));
|
|
let relays = RelayPool::new(RelayConfig::new(connect));
|
|
let mut observed = observer.subscribe();
|
|
let mut relayed = relays.subscribe();
|
|
let mut open = std::collections::HashSet::new();
|
|
loop {
|
|
tokio::select! {
|
|
e = observed.recv() => match e {
|
|
Ok(ObserverEvent::Snapshot(_)) | Ok(ObserverEvent::Delta(_)) | Err(broadcast::error::RecvError::Lagged(_)) => {
|
|
let presence = observer.presence().read().unwrap().clone();
|
|
let _ = events.send(QueryEvent::Presence(presence));
|
|
}
|
|
Ok(ObserverEvent::Chat(msg)) => {
|
|
if open.contains(&msg.target) {
|
|
let _ = events.send(QueryEvent::Chat(msg));
|
|
}
|
|
}
|
|
Ok(ObserverEvent::Disconnected(reason)) => {
|
|
let _ = events.send(QueryEvent::Error(format!("query connection lost: {reason}")));
|
|
}
|
|
Err(broadcast::error::RecvError::Closed) => break,
|
|
},
|
|
e = relayed.recv() => match e {
|
|
Ok(RelayEvent::Message(msg)) => {
|
|
let _ = events.send(QueryEvent::Chat(msg));
|
|
}
|
|
Ok(RelayEvent::Closed { channel, reason }) => {
|
|
let _ = events.send(QueryEvent::Error(format!("relay for channel {channel} closed: {reason}")));
|
|
}
|
|
Err(_) => {}
|
|
},
|
|
cmd = commands.recv() => match cmd {
|
|
None | Some(QueryCmd::Stop) => break,
|
|
Some(QueryCmd::OpenChat(target)) => {
|
|
if let ChatTarget::Channel(cid) = target
|
|
&& let Err(e) = relays.open(cid).await
|
|
{
|
|
let _ = events.send(QueryEvent::Error(e.to_string()));
|
|
continue;
|
|
}
|
|
open.insert(target);
|
|
}
|
|
Some(QueryCmd::CloseChat(target)) => {
|
|
if let ChatTarget::Channel(cid) = target {
|
|
relays.close(cid).await;
|
|
}
|
|
open.remove(&target);
|
|
}
|
|
Some(QueryCmd::SendChat { target, nick, text }) => {
|
|
let result = match &target {
|
|
ChatTarget::Channel(cid) => relays.send(*cid, &nick, &text).await,
|
|
_ => Err(voelin_query::Error::Unsupported("only channel chat is relayed with own credentials")),
|
|
};
|
|
if let Err(e) = result {
|
|
let _ = events.send(QueryEvent::Error(e.to_string()));
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|
|
relays.close_all().await;
|
|
let _ = events.send(QueryEvent::Disconnected);
|
|
}
|