default connection port to 27520

This commit is contained in:
2026-09-03 01:19:08 +08:00
parent 9607a66cf3
commit 2e37cadb36
7 changed files with 44 additions and 14 deletions
+2 -2
View File
@@ -20,6 +20,6 @@ RUN mkdir /app
COPY --from=builder /app/target/release/friendolls-server /app/friendolls-server
USER friendolls
ENV BIND_ADDR=0.0.0.0:3000
EXPOSE 3000
ENV BIND_ADDR=0.0.0.0:27520
EXPOSE 27520
ENTRYPOINT ["/app/friendolls-server"]
+1
View File
@@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
use specta::Type;
pub const VERSION: u8 = 4;
pub const DEFAULT_SERVER_PORT: u16 = 27_520;
pub const MAX_INTERACTION_PAYLOAD_BYTES: usize = 160 * 1024;
pub const MAX_IMAGE_B64_SIZE: usize = 150 * 1024;
pub const MAX_SKIN_B64_SIZE: usize = 96 * 1024;
+3 -1
View File
@@ -1,10 +1,12 @@
use axum::{Router, http::StatusCode, routing::get};
use friendolls_common::DEFAULT_SERVER_PORT;
mod network;
#[tokio::main]
async fn main() -> std::io::Result<()> {
let bind_addr = std::env::var("BIND_ADDR").unwrap_or_else(|_| "127.0.0.1:3000".to_string());
let bind_addr =
std::env::var("BIND_ADDR").unwrap_or_else(|_| format!("127.0.0.1:{DEFAULT_SERVER_PORT}"));
let listener = tokio::net::TcpListener::bind(&bind_addr).await?;
let app = Router::new()
.route("/", get("ok"))
+35 -7
View File
@@ -2,8 +2,8 @@ use std::collections::HashMap;
use std::time::Duration;
use friendolls_common::{
ClientMessage, InteractionDeliveryStatus, Profile, ServerMessage, friends_bytes,
interaction_bytes, message_bytes, profile_bytes, register_bytes,
ClientMessage, DEFAULT_SERVER_PORT, InteractionDeliveryStatus, Profile, ServerMessage,
friends_bytes, interaction_bytes, message_bytes, profile_bytes, register_bytes,
};
use futures_util::{SinkExt, StreamExt};
use tauri::{AppHandle, Manager};
@@ -402,9 +402,37 @@ fn url(remote: &Remote) -> String {
} else {
"ws"
};
let port = remote
.port
.map(|port| format!(":{port}"))
.unwrap_or_default();
format!("{scheme}://{address}{port}/v1/ws")
let port = remote.port.unwrap_or(DEFAULT_SERVER_PORT);
format!("{scheme}://{address}:{port}/v1/ws")
}
#[cfg(test)]
mod tests {
use super::*;
fn remote(address: &str, port: Option<u16>) -> Remote {
Remote {
id: "remote-id".to_owned(),
address: address.to_owned(),
name: None,
port,
priority: 0,
}
}
#[test]
fn url_uses_default_server_port_when_unspecified() {
assert_eq!(
url(&remote("example.net", None)),
"ws://example.net:27520/v1/ws"
);
}
#[test]
fn url_preserves_explicit_port() {
assert_eq!(
url(&remote("https://example.net", Some(443))),
"wss://example.net:443/v1/ws"
);
}
}
@@ -94,7 +94,7 @@
min="1"
max="65535"
inputmode="numeric"
placeholder="Default"
placeholder="27520"
/>
</fieldset>
</div>
@@ -150,9 +150,8 @@
min="1"
max="65535"
inputmode="numeric"
placeholder="Default"
placeholder="27520"
/>
<p class="fieldset-label">Leave port blank to use the server default.</p>
</fieldset>
</div>
@@ -49,7 +49,7 @@
min="1"
max="65535"
inputmode="numeric"
placeholder="Default"
placeholder="27520"
disabled={busy}
/>
</fieldset>