fix: test if valid server, control if try test with proxy (#7858)

* fix: test if valid server, control if try test with proxy

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* fix: build

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-04-28 14:22:21 +08:00
committed by GitHub
parent bd717349a7
commit 1dfbaa1e02
9 changed files with 55 additions and 52 deletions

View File

@@ -809,8 +809,8 @@ pub fn main_set_options(json: String) {
}
}
pub fn main_test_if_valid_server(server: String) -> String {
test_if_valid_server(server)
pub fn main_test_if_valid_server(server: String, test_with_proxy: bool) -> String {
test_if_valid_server(server, test_with_proxy)
}
pub fn main_set_socks(proxy: String, username: String, password: String) {
@@ -895,7 +895,7 @@ pub fn main_get_api_server() -> String {
}
pub fn main_http_request(url: String, method: String, body: Option<String>, header: String) {
http_request(url,method, body, header)
http_request(url, method, body, header)
}
pub fn main_get_local_option(key: String) -> SyncReturn<String> {

View File

@@ -272,8 +272,8 @@ impl UI {
m
}
fn test_if_valid_server(&self, host: String) -> String {
test_if_valid_server(host)
fn test_if_valid_server(&self, host: String, test_with_proxy: bool) -> String {
test_if_valid_server(host, test_with_proxy)
}
fn get_sound_inputs(&self) -> Value {
@@ -689,7 +689,7 @@ impl sciter::EventHandler for UI {
fn forget_password(String);
fn set_peer_option(String, String, String);
fn get_license();
fn test_if_valid_server(String);
fn test_if_valid_server(String, bool);
fn get_sound_inputs();
fn set_options(Value);
fn set_option(String, String);

View File

@@ -441,11 +441,11 @@ class MyIdMenu: Reactor.Component {
var key = (res.key || "").trim();
if (id == old_id && relay == old_relay && key == old_key && api == old_api) return;
if (id) {
var err = handler.test_if_valid_server(id);
var err = handler.test_if_valid_server(id, true);
if (err) return translate("ID Server") + ": " + err;
}
if (relay) {
var err = handler.test_if_valid_server(relay);
var err = handler.test_if_valid_server(relay, true);
if (err) return translate("Relay Server") + ": " + err;
}
if (api) {
@@ -476,7 +476,7 @@ class MyIdMenu: Reactor.Component {
var password = (res.password || "").trim();
if (proxy == old_proxy && username == old_username && password == old_password) return;
if (proxy) {
var err = handler.test_if_valid_server(proxy);
var err = handler.test_if_valid_server(proxy, false);
if (err) return translate("Server") + ": " + err;
}
handler.set_socks(proxy, username, password);

View File

@@ -280,8 +280,8 @@ pub fn get_options() -> String {
}
#[inline]
pub fn test_if_valid_server(host: String) -> String {
hbb_common::socket_client::test_if_valid_server(&host)
pub fn test_if_valid_server(host: String, test_with_proxy: bool) -> String {
hbb_common::socket_client::test_if_valid_server(&host, test_with_proxy)
}
#[inline]