default connection port to 27520
This commit is contained in:
+2
-2
@@ -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"]
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user