Many big updates, most notably and recently all conduwuit settings are now loaded from conduwuit.env. Oh and we mysteriously now have warrant canary

This commit is contained in:
Sangye Ince-Johannsen 2025-03-30 07:55:43 +00:00
parent 30f1d2aad7
commit 90242a495e
8 changed files with 263 additions and 210 deletions

1
.gitignore vendored
View file

@ -34,7 +34,6 @@ config.yaml
registrations.json
banned_ips.txt
refresh_token.sh
canary.txt
testbench/
# Backup directories

View file

@ -2,7 +2,7 @@
Hash: SHA512
We2.ee Warrant Canary
Date: 2025-03-27
Date: 2025-03-30
1. We have not received any National Security Letters.
2. We have not received any court orders under the Foreign Intelligence Surveillance Act.
@ -11,24 +11,24 @@ Date: 2025-03-27
5. We have not been subject to any searches or seizures of our servers.
Proofs:
NIST time: 2025-03-27T00:32:57.229589 UTC
Democracy Now! headline: "1,400+ Arrested in Turkey as Erdoğan Jails Istanbul Mayor & Intensifies Authoritarian Crackdown"
Bitcoin block #889596 hash: 000000000000000000018c38ea9043fd8710fa40d1cf90d5e541d050cd22b89d
Bitcoin block time: 2025-03-26 23:49:42 UTC
NIST time: 2025-03-30T03:15:24.5369625 UTC
Democracy Now! headline: ""The Encampments": New Film on Mahmoud Khalil & Columbia Students Who Sparked Gaza Campus Protests"
Bitcoin block #890061 hash: 000000000000000000022c41b8bf19607d604f9b77d0403439bbf6ee60215332
Bitcoin block time: 2025-03-30 03:10:49 UTC
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCgAdFiEEMjqKLEezdiJLNhO3U1smWu2+W0QFAmfknNcACgkQU1smWu2+
W0RrlxAAinoE3ZsIKAEpt/qzKygQyUx06VozLL82wzLPQrICia+jOkzo6UHuYGmY
to4sj4SIOBaEyrdIhLvPG7Q6QRnrbn7NVasawRD484KsiO1+caPrnROFKJWyW/II
UNlAnmOCxGttu14SlKYPpgp/a6LnLQtciNTHEsj6A0i/JgP1kAPRjqOiM0UCXTKf
2MnNgwHHdjJt3f7AVJewzw5EPsW9ouh7VcIiIu9kZeuGotf0Gux5R8iTg9j2Cpum
F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3QROl44bo/jx1krfCtzZj8YQkFQQnwdj3cWXMk
Pkz9bMMZ6IbyDEKy/y/8GHblvNBzcuSfSY8aoEc2mdESh7uURKQBkpkDpFg6dYS3
b0lkabVcMXUj8nVJEtnAXcjkVWblGM0OYNSg+EpxGhvGQ25Gy8w=
=ElP1
-----END PGP SIGNATURE-----

37
conduwuit.env Normal file
View file

@ -0,0 +1,37 @@
# conduwuit.env
CONDUWUIT_SERVER_NAME=we2.ee
CONDUWUIT_DATABASE_PATH=/var/lib/conduwuit/conduwuit.db
CONDUWUIT_DATABASE_BACKEND=rocksdb
CONDUWUIT_DATABASE_BACKUP_PATH=/backup
CONDUWUIT_ALLOW_REGISTRATION=true
CONDUWUIT_REGISTRATION_TOKEN_FILE=/.registration_token
CONDUWUIT_ADDRESS=["0.0.0.0", "::"]
CONDUWUIT_PORT=8008
CONDUWUIT_NEW_USER_DISPLAYNAME_SUFFIX=
CONDUWUIT_AUTO_JOIN_ROOMS=["#Home:we2.ee", "#Announcements:we2.ee"]
CONDUWUIT_FORGET_FORCED_UPON_LEAVE=true
CONDUWUIT_DB_CACHE_CAPACITY_MB=1024
CONDUWUIT_DB_WRITE_BUFFER_CAPACITY_MB=256
CONDUWUIT_DB_POOL_WORKERS=64
CONDUWUIT_DB_POOL_WORKERS_LIMIT=128
CONDUWUIT_STREAM_AMPLIFICATION=8192
CONDUWUIT_MAX_REQUEST_SIZE=33554432
CONDUWUIT_CACHE_CAPACITY_MODIFIER=1.5
CONDUWUIT_ALLOW_FEDERATION=true
CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_OVER_FEDERATION=true
CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_WITHOUT_AUTH=true
CONDUWUIT_WELL_KNOWN_CONN_TIMEOUT=30
CONDUWUIT_FEDERATION_TIMEOUT=600
CONDUWUIT_FEDERATION_IDLE_TIMEOUT=60
CONDUWUIT_SENDER_TIMEOUT=600
CONDUWUIT_SENDER_IDLE_TIMEOUT=360
CONDUWUIT_SENDER_SHUTDOWN_TIMEOUT=30
CONDUWUIT_DNS_CACHE_ENTRIES=0
CONDUWUIT_DNS_MIN_TTL=0
CONDUWUIT_DNS_MIN_TTL_NXDOMAIN=60
CONDUWUIT_DNS_ATTEMPTS=3
CONDUWUIT_DNS_TIMEOUT=3
CONDUWUIT_DNS_TCP_FALLBACK=true
CONDUWUIT_QUERY_ALL_NAMESERVERS=false
CONDUWUIT_QUERY_OVER_TCP_ONLY=false
CONDUWUIT_IP_LOOKUP_STRATEGY=3

207
launch_conduwuit.sh Executable file
View file

@ -0,0 +1,207 @@
#!/bin/bash
# File paths
BASE_PATH="/home/sij/hand_of_morpheus"
TOKEN_FILE="$BASE_PATH/.registration_token"
LOG_FILE="$BASE_PATH/token_refresh.log"
BACKUP_PATH="/home/sij/conduwuit_backup"
ENV_FILE="$BASE_PATH/conduwuit.env"
REPO_PATH="$HOME/workshop/conduwuit"
# Static container settings
CONTAINER_NAME="conduwuit"
CONTAINER_IMAGE="conduwuit:custom"
# Flags
REFRESH_TOKEN=false
SUPER_ADMIN=false
UPDATE=false
# Function to log with timestamp to both file and terminal
log() {
local message="$(date --iso-8601=seconds) $1"
echo "$message" >> "$LOG_FILE" # Write to log file
echo "$message" # Print to terminal
}
# Function to refresh the registration token
refresh_token() {
NEW_TOKEN=$(openssl rand -hex 3)
echo -n "$NEW_TOKEN" > "$TOKEN_FILE"
if [ $? -ne 0 ]; then
log "ERROR: Failed to write new token to $TOKEN_FILE"
exit 1
fi
log "Generated new registration token: $NEW_TOKEN"
}
# Function to update the Docker image
update_docker_image() {
log "Updating Conduwuit Docker image..."
# Navigate to the repository directory
cd "$REPO_PATH" || {
log "ERROR: Failed to cd into $REPO_PATH"
exit 1
}
# Pull the latest changes
git pull origin main || {
log "ERROR: git pull failed"
exit 1
}
# Build the Docker image using Nix
nix build -L --extra-experimental-features "nix-command flakes" .#oci-image-x86_64-linux-musl-all-features || {
log "ERROR: nix build failed"
exit 1
}
# Use the result symlink to find the image tarball
IMAGE_TAR_PATH=$(readlink -f result)
if [ ! -f "$IMAGE_TAR_PATH" ]; then
log "ERROR: No image tarball found at $IMAGE_TAR_PATH"
exit 1
fi
# Load the image into Docker and tag it
docker load < "$IMAGE_TAR_PATH" | awk '/Loaded image:/ { print $3 }' | xargs -I {} docker tag {} "$CONTAINER_IMAGE"
if [ $? -ne 0 ]; then
log "ERROR: Failed to load and tag Docker image"
exit 1
fi
log "Docker image tagged as $CONTAINER_IMAGE"
}
# Function to restart the container
restart_container() {
# Stop and remove existing container
docker stop "$CONTAINER_NAME" 2>/dev/null
docker rm "$CONTAINER_NAME" 2>/dev/null
# Base docker run command
DOCKER_CMD=(docker run -d
-v "db:/var/lib/conduwuit/"
-v "${TOKEN_FILE}:/.registration_token:ro"
-v "${BACKUP_PATH}:/backup"
--network host
--name "$CONTAINER_NAME"
--restart unless-stopped
)
# Read the .env file and append CONDUWUIT_ variables as -e options
if [ -f "$ENV_FILE" ]; then
while IFS='=' read -r key value; do
# Skip empty lines and comments
[[ -z "$key" || "$key" =~ ^# ]] && continue
# Trim whitespace
key=$(echo "$key" | xargs)
value=$(echo "$value" | xargs)
if [[ "$key" =~ ^CONDUWUIT_ ]]; then
log "Adding env var: $key=$value"
DOCKER_CMD+=(-e "$key=$value")
fi
done < "$ENV_FILE"
else
log "ERROR: Environment file $ENV_FILE not found"
exit 1
fi
# Add RUST_LOG explicitly (since its not CONDUWUIT_ prefixed)
DOCKER_CMD+=(-e RUST_LOG="conduwuit=trace,reqwest=trace,hickory_proto=trace")
# Add emergency password if --super-admin is set
if [ "$SUPER_ADMIN" = true ]; then
EMERGENCY_PASSWORD=$(openssl rand -hex 8)
log "Setting emergency password to: $EMERGENCY_PASSWORD"
DOCKER_CMD+=(-e CONDUWUIT_EMERGENCY_PASSWORD="$EMERGENCY_PASSWORD")
fi
# Add the image as the last argument
DOCKER_CMD+=("$CONTAINER_IMAGE")
# Log the full command for debugging
log "Docker command: ${DOCKER_CMD[*]}"
# Execute the docker command
"${DOCKER_CMD[@]}"
if [ $? -ne 0 ]; then
log "ERROR: Failed to create new conduwuit container"
exit 1
fi
log "Successfully recreated container \"$CONTAINER_NAME\" with image \"$CONTAINER_IMAGE\"."
log " - Configuration loaded from $ENV_FILE"
# Log super-admin credentials if applicable
if [ "$SUPER_ADMIN" = true ]; then
log "Use the following credentials to log in as the @conduit server user:"
log " Username: @conduit:we2.ee"
log " Password: $EMERGENCY_PASSWORD"
log "Once logged in as @conduit:we2.ee, you can invite yourself to the admin room or run admin commands."
fi
}
# Function to start the Python registration service
start_registration_service() {
local python_script="$BASE_PATH/registration.py" # Adjust name if different
local pid_file="$BASE_PATH/registration.pid"
local log_file="$BASE_PATH/registration.log"
if [ ! -f "$python_script" ]; then
log "ERROR: Python script $python_script not found"
exit 1
fi
# Check if it's already running
if [ -f "$pid_file" ] && ps -p "$(cat "$pid_file")" > /dev/null 2>&1; then
log "Registration service already running with PID $(cat "$pid_file")"
else
# Start it in the background, redirecting output to a log file
python3 "$python_script" >> "$log_file" 2>&1 &
local pid=$!
echo "$pid" > "$pid_file"
log "Started registration service with PID $pid"
fi
}
# Parse command-line flags
while [[ $# -gt 0 ]]; do
case "$1" in
--refresh-token)
REFRESH_TOKEN=true
shift
;;
--super-admin)
SUPER_ADMIN=true
shift
;;
--update)
UPDATE=true
shift
;;
--start-service)
START_SERVICE=true
shift
;;
*)
log "ERROR: Unknown option: $1"
echo "Usage: $0 [--refresh-token] [--super-admin] [--update]"
exit 1
;;
esac
done
# Execute based on flags
if [ "$UPDATE" = true ]; then
update_docker_image
fi
if [ "$REFRESH_TOKEN" = true ]; then
refresh_token
fi
restart_container
if [ "$START_SERVICE" = true ] || [ "$1" = "@reboot" ]; then # Run on explicit flag or cron @reboot
start_registration_service
fi
exit 0

View file

@ -1,92 +0,0 @@
#!/bin/bash
# File paths
BASE_PATH="/home/sij/hand_of_morpheus"
TOKEN_FILE="$BASE_PATH/.registration_token"
LOG_FILE="$BASE_PATH/token_refresh.log"
BACKUP_PATH="/home/sij/conduwuit_backup"
# Server/domain info
SERVER_DOMAIN="we2.ee"
CONTAINER_NAME="conduwuit"
CONTAINER_IMAGE="conduwuit:custom"
ADDRESS='["0.0.0.0", "::"]'
PORT=8008
# Auto-join room configuration
AUTO_JOIN_ROOMS='["#home:we2.ee","#server:we2.ee"]'
# Function to log with timestamp to both file and terminal
log() {
local message="$(date --iso-8601=seconds) $1"
echo "$message" >> "$LOG_FILE" # Write to log file
echo "$message" # Print to terminal
}
# Generate new token (6 random hex characters)
NEW_TOKEN=$(openssl rand -hex 3)
# Write new token to file without newline
echo -n "$NEW_TOKEN" > "$TOKEN_FILE"
if [ $? -ne 0 ]; then
log "ERROR: Failed to write new token to $TOKEN_FILE"
exit 1
fi
log "Generated new registration token"
# Stop and remove existing container
docker stop "$CONTAINER_NAME" 2>/dev/null
docker rm "$CONTAINER_NAME" 2>/dev/null
# Launch new container
docker run -d \
-v "db:/var/lib/conduwuit/" \
-v "${TOKEN_FILE}:/.registration_token:ro" \
-v "${BACKUP_PATH}:/backup" \
-e CONDUWUIT_SERVER_NAME="$SERVER_DOMAIN" \
-e CONDUWUIT_DATABASE_PATH="/var/lib/conduwuit/conduwuit.db" \
-e CONDUWUIT_DATABASE_BACKUP_PATH="/backup" \
-e CONDUWUIT_ALLOW_REGISTRATION=true \
-e CONDUWUIT_REGISTRATION_TOKEN_FILE="/.registration_token" \
-e CONDUWUIT_ADDRESS="$ADDRESS" \
-e CONDUWUIT_PORT="$PORT" \
-e CONDUWUIT_NEW_USER_DISPLAYNAME_SUFFIX="" \
-e CONDUWUIT_AUTO_JOIN_ROOMS="$AUTO_JOIN_ROOMS" \
-e CONDUWUIT_FORGET_FORCED_UPON_LEAVE=true \
-e CONDUWUIT_DB_CACHE_CAPACITY_MB=1024 \
-e CONDUWUIT_DB_WRITE_BUFFER_CAPACITY_MB=256 \
-e CONDUWUIT_DB_POOL_WORKERS=64 \
-e CONDUWUIT_DB_POOL_WORKERS_LIMIT=128 \
-e CONDUWUIT_STREAM_AMPLIFICATION=8192 \
-e CONDUWUIT_MAX_REQUEST_SIZE=33554432 \
-e CONDUWUIT_CACHE_CAPACITY_MODIFIER=1.5 \
-e CONDUWUIT_ALLOW_FEDERATION=true \
-e CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_OVER_FEDERATION=true \
-e CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_WITHOUT_AUTH=true \
-e CONDUWUIT_WELL_KNOWN_CONN_TIMEOUT=30 \
-e CONDUWUIT_FEDERATION_TIMEOUT=600 \
-e CONDUWUIT_FEDERATION_IDLE_TIMEOUT=60 \
-e CONDUWUIT_SENDER_TIMEOUT=600 \
-e CONDUWUIT_SENDER_IDLE_TIMEOUT=360 \
-e CONDUWUIT_SENDER_SHUTDOWN_TIMEOUT=30 \
-e CONDUWUIT_DNS_CACHE_ENTRIES=1000 \
-e CONDUWUIT_DNS_MIN_TTL=300 \
-e CONDUWUIT_DNS_MIN_TTL_NXDOMAIN=600 \
-e CONDUWUIT_DNS_TCP_FALLBACK=true \
-e CONDUWUIT_IP_LOOKUP_STRATEGY=3 \
-e RUST_LOG="conduwuit=trace,reqwest=trace,hickory_proto=trace" \
--network host \
--name "$CONTAINER_NAME" \
--restart unless-stopped \
"$CONTAINER_IMAGE"
if [ $? -ne 0 ]; then
log "ERROR: Failed to create new conduwuit container"
exit 1
fi
log "Successfully recreated container \"$CONTAINER_NAME\" with image \"$CONTAINER_IMAGE\" and these parameters:"
log " - domain: $SERVER_DOMAIN"
log " - address: $ADDRESS"
log " - port: $PORT"
log " - auto-join rooms: $AUTO_JOIN_ROOMS"

1
registration.pid Normal file
View file

@ -0,0 +1 @@
749006

View file

@ -1,80 +0,0 @@
#!/bin/bash
# File paths
BASE_PATH="/home/sij/hand_of_morpheus"
TOKEN_FILE="$BASE_PATH/.registration_token"
LOG_FILE="$BASE_PATH/token_refresh.log"
BACKUP_PATH="/home/sij/conduwuit_backup"
# Server/domain info
SERVER_DOMAIN="we2.ee"
CONTAINER_NAME="conduwuit"
CONTAINER_IMAGE="conduwuit:custom"
ADDRESS='["0.0.0.0", "::"]'
PORT=8008
# Auto-join room configuration
AUTO_JOIN_ROOMS='["#home:we2.ee","#server:we2.ee"]'
# Function to log with timestamp to both file and terminal
log() {
local message="$(date --iso-8601=seconds) $1"
echo "$message" >> "$LOG_FILE" # Write to log file
echo "$message" # Print to terminal
}
# Stop and remove existing container
docker stop "$CONTAINER_NAME" 2>/dev/null
docker rm "$CONTAINER_NAME" 2>/dev/null
# Launch new container
docker run -d \
-v "db:/var/lib/conduwuit/" \
-v "${TOKEN_FILE}:/.registration_token:ro" \
-v "${BACKUP_PATH}:/backup" \
-e CONDUWUIT_SERVER_NAME="$SERVER_DOMAIN" \
-e CONDUWUIT_DATABASE_PATH="/var/lib/conduwuit/conduwuit.db" \
-e CONDUWUIT_DATABASE_BACKUP_PATH="/backup" \
-e CONDUWUIT_ALLOW_REGISTRATION=true \
-e CONDUWUIT_REGISTRATION_TOKEN_FILE="/.registration_token" \
-e CONDUWUIT_ADDRESS="$ADDRESS" \
-e CONDUWUIT_PORT="$PORT" \
-e CONDUWUIT_NEW_USER_DISPLAYNAME_SUFFIX="" \
-e CONDUWUIT_AUTO_JOIN_ROOMS="$AUTO_JOIN_ROOMS" \
-e CONDUWUIT_FORGET_FORCED_UPON_LEAVE=true \
-e CONDUWUIT_DB_CACHE_CAPACITY_MB=1024 \
-e CONDUWUIT_DB_WRITE_BUFFER_CAPACITY_MB=256 \
-e CONDUWUIT_DB_POOL_WORKERS=64 \
-e CONDUWUIT_DB_POOL_WORKERS_LIMIT=128 \
-e CONDUWUIT_STREAM_AMPLIFICATION=8192 \
-e CONDUWUIT_MAX_REQUEST_SIZE=33554432 \
-e CONDUWUIT_CACHE_CAPACITY_MODIFIER=1.5 \
-e CONDUWUIT_ALLOW_FEDERATION=true \
-e CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_OVER_FEDERATION=true \
-e CONDUWUIT_ALLOW_PUBLIC_ROOM_DIRECTORY_WITHOUT_AUTH=true \
-e CONDUWUIT_WELL_KNOWN_CONN_TIMEOUT=30 \
-e CONDUWUIT_FEDERATION_TIMEOUT=600 \
-e CONDUWUIT_FEDERATION_IDLE_TIMEOUT=60 \
-e CONDUWUIT_SENDER_TIMEOUT=600 \
-e CONDUWUIT_SENDER_IDLE_TIMEOUT=360 \
-e CONDUWUIT_SENDER_SHUTDOWN_TIMEOUT=30 \
-e CONDUWUIT_DNS_CACHE_ENTRIES=1000 \
-e CONDUWUIT_DNS_MIN_TTL=300 \
-e CONDUWUIT_DNS_MIN_TTL_NXDOMAIN=600 \
-e CONDUWUIT_DNS_TCP_FALLBACK=true \
-e CONDUWUIT_IP_LOOKUP_STRATEGY=3 \
-e RUST_LOG="conduwuit=trace,reqwest=trace,hickory_proto=trace" \
--network host \
--name "$CONTAINER_NAME" \
--restart unless-stopped \
"$CONTAINER_IMAGE"
if [ $? -ne 0 ]; then
log "ERROR: Failed to create new conduwuit container"
exit 1
fi
log "Successfully recreated container \"$CONTAINER_NAME\" with image \"$CONTAINER_IMAGE\" and these parameters:"
log " - domain: $SERVER_DOMAIN"
log " - address: $ADDRESS"
log " - port: $PORT"
log " - auto-join rooms: $AUTO_JOIN_ROOMS"

View file

@ -1,19 +0,0 @@
#!/bin/bash
# Navigate to the repository directory
cd "$HOME/workshop/conduwuit" || exit
# Pull the latest changes
git pull
# Build the Docker image using Nix
nix build -L --extra-experimental-features "nix-command flakes" .#oci-image-x86_64-linux-musl-all-features
# Use the result symlink to find the image tarball
IMAGE_TAR_PATH=$(readlink -f result)
# Load the image into Docker and tag it
docker load < "$IMAGE_TAR_PATH" | awk '/Loaded image:/ { print $3 }' | xargs -I {} docker tag {} conduwuit:custom
# Confirm tagging
echo "Docker image tagged as conduwuit:custom"