Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can reinvite yourself to the admin room through the following methods:
argument once to invite yourslf to the admin room on startup
- Use the Tuwunel console/CLI to run the `users make_user_admin` command
- Or specify the `emergency_password` config option to allow you to temporarily
log into the server account (`@conduit`) from a web client
log into the server account (`@conduit` or `@tuwunel`) from a web client

## General potential issues

Expand Down
38 changes: 36 additions & 2 deletions src/core/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
path::{Path, PathBuf},
};

use either::{
Either,
Either::{Left, Right},
Expand Down Expand Up @@ -1208,8 +1207,23 @@ pub struct Config {
#[serde(default = "default_rocksdb_stats_level")]
pub rocksdb_stats_level: u8,


/// The server bot is automatically created when the database is created.
/// Originally the account was `conduit`; this is also why it is still default.
/// When creating a new database, it is suggested to be done with `tuwunel`; when
/// using an existing database, then the default `conduit` must be used.
///
/// There are only the values `conduit` or `tuwunel`accepted, anything else or
/// `@` as a prefix will raise an error when starting up.
///
/// default: conduit
#[serde(default = "default_server_user")]
#[serde(deserialize_with = "validate_server_user")]
pub server_user: String,


/// This is a password that can be configured that will let you login to the
/// server bot account (currently `@conduit`) for emergency troubleshooting
/// server bot account (`@tuwunel` or `@conduit`) for emergency troubleshooting
/// purposes such as recovering/recreating your admin room, or inviting
/// yourself back.
///
Expand Down Expand Up @@ -2577,6 +2591,26 @@ fn default_rocksdb_bottommost_compression_level() -> i32 { 32767 }

fn default_rocksdb_stats_level() -> u8 { 1 }


fn default_server_user() -> String {
"conduit".to_string()
}

// This ensures that only "tuwunel" or "conduit" are accepted.
fn validate_server_user<'de, D>(deserializer: D) -> Result<String, D::Error>
where
D: serde::Deserializer<'de>,
{
let s: String = String::deserialize(deserializer)?;
match s.as_str() {
"tuwunel" | "conduit" => Ok(s),
_ => Err(serde::de::Error::custom(
"server_user must be either 'tuwunel' or 'conduit'"
))
}
}


// I know, it's a great name
#[must_use]
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions src/service/globals/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ impl crate::Service for Service {
admin_alias: OwnedRoomAliasId::try_from(format!("#admins:{}", &args.server.name))
.expect("#admins:server_name is valid alias name"),
server_user: UserId::parse_with_server_name(
String::from("conduit"),
&config.server_user,
&args.server.name,
)
.expect("@conduit:server_name is valid"),
.expect("server user is valid"),
turn_secret,
registration_token,
}))
Expand Down
Loading