add the options to enable latency first or not

in the old behavior, the flags is not set, and it will be generated as default value in the first read. so the default value for the latency_first will be set to true according to the Default settings to Flag.

so the Vue code init the latency first to true.
This commit is contained in:
Jiangqiu Shen
2024-09-18 15:49:56 -04:00
committed by Sijie.Sun
parent 82f5dfd569
commit 99c47813c3
5 changed files with 18 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ on_text: 点击开启
show_config: 显示配置 show_config: 显示配置
close: 关闭 close: 关闭
use_latency_first: 延迟优先模式
my_node_info: 当前节点信息 my_node_info: 当前节点信息
peer_count: 已连接 peer_count: 已连接
upload: 上传 upload: 上传

View File

@@ -43,7 +43,7 @@ logging_copy_dir: Copy Log Path
disable_auto_launch: Disable Launch on Reboot disable_auto_launch: Disable Launch on Reboot
enable_auto_launch: Enable Launch on Reboot enable_auto_launch: Enable Launch on Reboot
exit: Exit exit: Exit
use_latency_first: Latency First Mode
chips_placeholder: 'e.g: {0}, press Enter to add' chips_placeholder: 'e.g: {0}, press Enter to add'
hostname_placeholder: 'Leave blank and default to host name: {0}' hostname_placeholder: 'Leave blank and default to host name: {0}'
off_text: Press to disable off_text: Press to disable

View File

@@ -7,7 +7,7 @@ use anyhow::Context;
use dashmap::DashMap; use dashmap::DashMap;
use easytier::{ use easytier::{
common::config::{ common::config::{
ConfigLoader, FileLoggerConfig, NetworkIdentity, PeerConfig, TomlConfigLoader, ConfigLoader, FileLoggerConfig, Flags, NetworkIdentity, PeerConfig, TomlConfigLoader,
VpnPortalConfig, VpnPortalConfig,
}, },
launcher::{NetworkInstance, NetworkInstanceRunningInfo}, launcher::{NetworkInstance, NetworkInstanceRunningInfo},
@@ -60,6 +60,7 @@ struct NetworkConfig {
listener_urls: Vec<String>, listener_urls: Vec<String>,
rpc_port: i32, rpc_port: i32,
latency_first: bool,
} }
impl NetworkConfig { impl NetworkConfig {
@@ -160,7 +161,9 @@ impl NetworkConfig {
})?, })?,
}); });
} }
let mut flags = Flags::default();
flags.latency_first = self.latency_first;
cfg.set_flags(flags);
Ok(cfg) Ok(cfg)
} }
} }

View File

@@ -205,6 +205,15 @@ onMounted(async () => {
<Panel :header="t('advanced_settings')" toggleable collapsed> <Panel :header="t('advanced_settings')" toggleable collapsed>
<div class="flex flex-column gap-y-2"> <div class="flex flex-column gap-y-2">
<div class="flex flex-row gap-x-9 flex-wrap">
<div class="flex flex-column gap-2 basis-5/12 grow">
<div class="flex align-items-center">
<Checkbox v-model="curNetwork.latency_first" input-id="use_latency_first" :binary="true" />
<label for="use_latency_first" class="ml-2"> {{ t('use_latency_first') }} </label>
</div>
</div>
</div>
<div class="flex flex-row gap-x-9 flex-wrap"> <div class="flex flex-row gap-x-9 flex-wrap">
<div class="flex flex-column gap-2 basis-5/12 grow"> <div class="flex flex-column gap-2 basis-5/12 grow">
<label for="hostname">{{ t('hostname') }}</label> <label for="hostname">{{ t('hostname') }}</label>

View File

@@ -31,6 +31,7 @@ export interface NetworkConfig {
listener_urls: string[] listener_urls: string[]
rpc_port: number rpc_port: number
latency_first: boolean
} }
export function DEFAULT_NETWORK_CONFIG(): NetworkConfig { export function DEFAULT_NETWORK_CONFIG(): NetworkConfig {
@@ -62,6 +63,7 @@ export function DEFAULT_NETWORK_CONFIG(): NetworkConfig {
'wg://0.0.0.0:11011', 'wg://0.0.0.0:11011',
], ],
rpc_port: 0, rpc_port: 0,
latency_first: true,
} }
} }