Merge pull request #1714 from shan3275/master

add button for importing server config
This commit is contained in:
RustDesk 2022-10-13 11:49:10 +08:00 committed by GitHub
commit c0b230fd63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 240 additions and 1 deletions

View File

@ -723,8 +723,10 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
AbsorbPointer(
absorbing: locked,
child: Column(children: [
_Card(title: 'Server', children: [
_CardRow(title: 'Server', children: [
_Button('ID/Relay Server', changeServer, enabled: enabled),
_Button('Import Server Conf', importServer,
enabled: enabled),
]),
_Card(title: 'Proxy', children: [
_Button('Socks5 Proxy', changeSocks5Proxy,
@ -894,6 +896,38 @@ Widget _Card({required String title, required List<Widget> children}) {
);
}
Widget _CardRow({required String title, required List<Widget> children}) {
return Row(
children: [
SizedBox(
width: _kCardFixedWidth,
child: Card(
child: Column(
children: [
Row(
children: [
Text(
translate(title),
textAlign: TextAlign.start,
style: const TextStyle(
fontSize: _kTitleFontSize,
),
),
const Spacer(),
],
).marginOnly(left: _kContentHMargin, top: 10, bottom: 10),
Row(children: [
...children
.map((e) => e.marginOnly(top: 4, right: _kContentHMargin)),
]),
],
).marginOnly(bottom: 10),
).marginOnly(left: _kCardLeftMargin, top: 15),
),
],
);
}
Color? _disabledTextColor(BuildContext context, bool enabled) {
return enabled
? null
@ -1377,6 +1411,119 @@ void changeServer() async {
});
}
void importServer() async {
Future<void> importServerShow(String content) async {
gFFI.dialogManager.show((setState, close) {
return CustomAlertDialog(
title: Text(content),
content: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 500),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 4.0,
),
],
),
),
actions: [
TextButton(onPressed: close, child: Text(translate("OK"))),
],
onCancel: close,
);
});
}
Future<bool> submit(
String idServer, String relayServer, String apiServer, String key) async {
Map<String, dynamic> oldOptions = jsonDecode(await bind.mainGetOptions());
var idServerMsg = "";
var relayServerMsg = "";
if (idServer.isNotEmpty) {
idServerMsg =
translate(await bind.mainTestIfValidServer(server: idServer));
if (idServerMsg.isEmpty) {
oldOptions['custom-rendezvous-server'] = idServer;
} else {
debugPrint('ID Server invalid return');
return false;
}
} else {
oldOptions['custom-rendezvous-server'] = "";
}
if (relayServer.isNotEmpty) {
relayServerMsg =
translate(await bind.mainTestIfValidServer(server: relayServer));
if (relayServerMsg.isEmpty) {
oldOptions['relay-server'] = relayServer;
} else {
debugPrint('Relay Server invalid return');
return false;
}
} else {
oldOptions['relay-server'] = "";
}
if (apiServer.isNotEmpty) {
if (apiServer.startsWith('http://') || apiServer.startsWith("https://")) {
oldOptions['api-server'] = apiServer;
return false;
} else {
debugPrint('invalid_http');
return false;
}
} else {
oldOptions['api-server'] = "";
}
// ok
oldOptions['key'] = key;
await bind.mainSetOptions(json: jsonEncode(oldOptions));
debugPrint("set ID/Realy Server Ok");
return true;
}
Clipboard.getData(Clipboard.kTextPlain).then((value) {
TextEditingController mytext = TextEditingController();
String? aNullableString = "";
aNullableString = value?.text;
mytext.text = aNullableString.toString();
if (mytext.text.isNotEmpty) {
debugPrint('Clipboard is not empty');
try {
Map<String, dynamic> config = jsonDecode(mytext.text);
if (config.containsKey('IdServer') &&
config.containsKey('RelayServer')) {
debugPrint('IdServer: ${config['IdServer']}');
debugPrint('RelayServer: ${config['RelayServer']}');
debugPrint('ApiServer: ${config['ApiServer']}');
debugPrint('Key: ${config['Key']}');
Future<bool> success = submit(config['IdServer'],
config['RelayServer'], config['ApiServer'], config['Key']);
success.then((value) {
if (value) {
importServerShow(
translate('Import server configuration successfully'));
} else {
importServerShow(translate('Invalid server configuration'));
}
});
} else {
debugPrint('invalid config info');
importServerShow(translate("Invalid server configuration"));
}
} catch (e) {
debugPrint('invalid config info');
importServerShow(translate("Invalid server configuration"));
}
} else {
debugPrint('Clipboard is empty');
importServerShow(translate("Clipboard is empty"));
}
});
}
void changeSocks5Proxy() async {
var socks = await bind.mainGetSocks();

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "允许建立TCP隧道"),
("IP Whitelisting", "IP白名单"),
("ID/Relay Server", "ID/中继服务器"),
("Import Server Conf", "导入服务器配置"),
("Import server configuration successfully", "导入服务器配置信息成功"),
("Invalid server configuration", "无效服务器配置,请修改后重新拷贝配置信息到剪贴板后点击此按钮"),
("Clipboard is empty", "拷贝配置信息到剪贴板后点击此按钮,可以自动导入配置"),
("Stop service", "停止服务"),
("Change ID", "改变ID"),
("Website", "网站"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Povolit TCP tunelování"),
("IP Whitelisting", "Povolování pouze z daných IP adres)"),
("ID/Relay Server", "Identifikátor / předávací (relay) server"),
("Import Server Conf", "Importovat konfiguraci serveru"),
("Import server configuration successfully", "Konfigurace serveru úspěšně importována"),
("Invalid server configuration", "Neplatná konfigurace serveru"),
("Clipboard is empty", "Schránka je prázdná"),
("Stop service", "Zastavit službu"),
("Change ID", "Změnit identifikátor"),
("Website", "Webové stránky"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Slå TCP-tunneling til"),
("IP Whitelisting", "IP-udgivelsesliste"),
("ID/Relay Server", "ID/forbindelsesserver"),
("Import Server Conf", "Importér serverkonfiguration"),
("Import server configuration successfully", "Importér serverkonfigurationen"),
("Invalid server configuration", "Ugyldig serverkonfiguration"),
("Clipboard is empty", "Udklipsholderen er tom"),
("Stop service", "Sluk for forbindelsesserveren"),
("Change ID", "Ændre ID"),
("Website", "Hjemmeside"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "TCP-Tunnel aktivieren"),
("IP Whitelisting", "IP-Whitelist"),
("ID/Relay Server", "ID/Vermittlungsserver"),
("Import Server Conf", "Serverkonfiguration importieren"),
("Import server configuration successfully", "Serverkonfiguration erfolgreich importiert"),
("Invalid server configuration", "Ungültige Serverkonfiguration"),
("Clipboard is empty", "Zwischenablage ist leer"),
("Stop service", "Vermittlungsdienst deaktivieren"),
("Change ID", "ID ändern"),
("Website", "Webseite"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Ebligi tunelado TCP"),
("IP Whitelisting", "Listo de IP akceptataj"),
("ID/Relay Server", "Identigila/Relajsa servilo"),
("Import Server Conf", "Enporti servilan agordon"),
("Import server configuration successfully", "Importi servilan agordon sukcese"),
("Invalid server configuration", "Nevalida servila agordo"),
("Clipboard is empty", "La poŝo estas malplena"),
("Stop service", "Haltu servon"),
("Change ID", "Ŝanĝi identigilon"),
("Website", "Retejo"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Habilitar tunel TCP"),
("IP Whitelisting", "Lista blanca de IP"),
("ID/Relay Server", "Servidor ID/Relay"),
("Import Server Conf", "Importar configuración de servidor"),
("Import server configuration successfully", "Configuración de servidor importada con éxito"),
("Invalid server configuration", "Configuración de servidor inválida"),
("Clipboard is empty", "El portapapeles está vacío"),
("Stop service", "Parar servicio"),
("Change ID", "Cambiar ID"),
("Website", "Sitio web"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Activer le tunneling TCP"),
("IP Whitelisting", "Liste blanche IP"),
("ID/Relay Server", "ID/Serveur Relais"),
("Import Server Conf", "Importer la configuration du serveur"),
("Import server configuration successfully", "Configuration du serveur importée avec succès"),
("Invalid server configuration", "Configuration du serveur non valide"),
("Clipboard is empty", "Presse-papier vide"),
("Stop service", "Arrêter le service"),
("Change ID", "Changer d'ID"),
("Website", "Site Web"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "TCP Tunneling bekapcsolása"),
("IP Whitelisting", "IP Fehérlista"),
("ID/Relay Server", "ID/Relay Szerver"),
("Import Server Conf", "Szerver Konfiguráció Importálása"),
("Import server configuration successfully", "Szerver konfiguráció sikeresen importálva"),
("Invalid server configuration", "Érvénytelen szerver konfiguráció"),
("Clipboard is empty", "A vágólap üres"),
("Stop service", "Szolgáltatás Kikapcsolása"),
("Change ID", "ID Megváltoztatása"),
("Website", "Weboldal"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Aktifkan TCP Tunneling"),
("IP Whitelisting", "Daftar Putih IP"),
("ID/Relay Server", "ID/Relay Server"),
("Import Server Conf", "Impor Konfigurasi Server"),
("Import server configuration successfully", "Impor konfigurasi server berhasil"),
("Invalid server configuration", "Konfigurasi server tidak valid"),
("Clipboard is empty", "Papan klip kosong"),
("Stop service", "Hentikan Layanan"),
("Change ID", "Ubah ID"),
("Website", "Website"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Abilita tunnel TCP"),
("IP Whitelisting", "IP autorizzati"),
("ID/Relay Server", "Server ID/Relay"),
("Import Server Conf", "Importa configurazione Server"),
("Import server configuration successfully", "Configurazione Server importata con successo"),
("Invalid server configuration", "Configurazione Server non valida"),
("Clipboard is empty", "Gli appunti sono vuoti"),
("Stop service", "Arresta servizio"),
("Change ID", "Cambia ID"),
("Website", "Sito web"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "TCPトンネリングを有効化"),
("IP Whitelisting", "IPホワイトリスト"),
("ID/Relay Server", "認証・中継サーバー"),
("Import Server Conf", "サーバー設定をインポート"),
("Import server configuration successfully", "サーバー設定をインポートしました"),
("Invalid server configuration", "無効なサーバー設定です"),
("Clipboard is empty", "クリップボードは空です"),
("Stop service", "サービスを停止"),
("Change ID", "IDを変更"),
("Website", "公式サイト"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "TCP 터널링 활성화"),
("IP Whitelisting", "IP 화이트리스트"),
("ID/Relay Server", "ID/Relay 서버"),
("Import Server Conf", "서버 설정 가져오기"),
("Import server configuration successfully", "서버 설정 가져오기 성공"),
("Invalid server configuration", "잘못된 서버 설정"),
("Clipboard is empty", "클립보드가 비어있습니다"),
("Stop service", "서비스 중단"),
("Change ID", "ID 변경"),
("Website", "웹사이트"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "TCP тунелдеуді қосу"),
("IP Whitelisting", "IP Ақ-тізімі"),
("ID/Relay Server", "ID/Relay сербері"),
("Import Server Conf", "Серверді импорттау"),
("Import server configuration successfully", "Сервердің конфигурациясы сәтті импортталды"),
("Invalid server configuration", "Жарамсыз сервердің конфигурациясы"),
("Clipboard is empty", "Көшіру-тақта бос"),
("Stop service", "Сербесті тоқтату"),
("Change ID", "ID ауыстыру"),
("Website", "Web-сайт"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Włącz tunelowanie TCP"),
("IP Whitelisting", "Biała lista IP"),
("ID/Relay Server", "Serwer ID/Pośredniczący"),
("Import Server Conf", "Importuj konfigurację serwera"),
("Import server configuration successfully", "Importowanie konfiguracji serwera powiodło się"),
("Invalid server configuration", "Nieprawidłowa konfiguracja serwera"),
("Clipboard is empty", "Schowek jest pusty"),
("Stop service", "Zatrzymaj usługę"),
("Change ID", "Zmień ID"),
("Website", "Strona internetowa"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Activar Túnel TCP"),
("IP Whitelisting", "Whitelist de IP"),
("ID/Relay Server", "Servidor ID/Relay"),
("Import Server Conf", "Importar Configuração do Servidor"),
("Import server configuration successfully", "Configuração do servidor importada com sucesso"),
("Invalid server configuration", "Configuração do servidor inválida"),
("Clipboard is empty", "A área de transferência está vazia"),
("Stop service", "Parar serviço"),
("Change ID", "Alterar ID"),
("Website", "Website"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Habilitar Tunelamento TCP"),
("IP Whitelisting", "Whitelist de IP"),
("ID/Relay Server", "Servidor ID/Relay"),
("Import Server Conf", "Importar Configuração do Servidor"),
("Import server configuration successfully", "Configuração do servidor importada com sucesso"),
("Invalid server configuration", "Configuração do servidor inválida"),
("Clipboard is empty", "A área de transferência está vazia"),
("Stop service", "Parar serviço"),
("Change ID", "Alterar ID"),
("Website", "Website"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Включить туннелирование TCP"),
("IP Whitelisting", "Список разрешенных IP-адресов"),
("ID/Relay Server", "ID/Сервер ретрансляции"),
("Import Server Conf", "Импортировать конфигурацию сервера"),
("Import server configuration successfully", "Конфигурация сервера успешно импортирована"),
("Invalid server configuration", "Недопустимая конфигурация сервера"),
("Clipboard is empty", "Буфер обмена пуст"),
("Stop service", "Остановить службу"),
("Change ID", "Изменить ID"),
("Website", "Веб-сайт"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Povoliť TCP tunelovanie"),
("IP Whitelisting", "Zoznam povolených IP adries"),
("ID/Relay Server", "ID/Prepojovací server"),
("Import Server Conf", "Importovať konfiguráciu servera"),
("Import server configuration successfully", "Konfigurácia servera bola úspešne importovaná"),
("Invalid server configuration", "Neplatná konfigurácia servera"),
("Clipboard is empty", "Schránka je prázdna"),
("Stop service", "Zastaviť službu"),
("Change ID", "Zmeniť ID"),
("Website", "Webová stránka"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", ""),
("IP Whitelisting", ""),
("ID/Relay Server", ""),
("Import server configuration successfully", ""),
("Import Server Conf", ""),
("Invalid server configuration", ""),
("Clipboard is empty", ""),
("Stop service", ""),
("Change ID", ""),
("Website", ""),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "TCP Tüneline izin ver"),
("IP Whitelisting", "İzinli IP listesi"),
("ID/Relay Server", "ID/Relay Sunucusu"),
("Import Server Conf", "Sunucu ayarlarını içe aktar"),
("Import server configuration successfully", "Sunucu ayarları başarıyla içe aktarıldı"),
("Invalid server configuration", "Geçersiz sunucu ayarı"),
("Clipboard is empty", "Kopyalanan geçici veri boş"),
("Stop service", "Servisi Durdur"),
("Change ID", "ID Değiştir"),
("Website", "Website"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "啟用 TCP 通道"),
("IP Whitelisting", "IP 白名單"),
("ID/Relay Server", "ID/轉送伺服器"),
("Import Server Conf", "匯入伺服器設定"),
("Import server configuration successfully", "匯入伺服器設定成功"),
("Invalid server configuration", "無效的伺服器設定"),
("Clipboard is empty", "剪貼簿是空的"),
("Stop service", "停止服務"),
("Change ID", "更改 ID"),
("Website", "網站"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Увімкнути тунелювання TCP"),
("IP Whitelisting", "Список дозволених IP-адрес"),
("ID/Relay Server", "ID/Сервер ретрансляції"),
("Import Server Conf", "Імпортувати конфігурацію сервера"),
("Import server configuration successfully", "Конфігурацію сервера успішно імпортовано"),
("Invalid server configuration", "Недійсна конфігурація сервера"),
("Clipboard is empty", "Буфер обміну порожній"),
("Stop service", "Зупинити службу"),
("Change ID", "Змінити ID"),
("Website", "Веб-сайт"),

View File

@ -29,6 +29,10 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Enable TCP Tunneling", "Cho phép TCP Tunneling"),
("IP Whitelisting", "Cho phép IP"),
("ID/Relay Server", "Máy chủ ID/Relay"),
("Import Server Conf", "Nhập cấu hình máy chủ"),
("Import server configuration successfully", "Nhập cấu hình máy chủ thành công"),
("Invalid server configuration", "Cấu hình máy chủ không hợp lệ"),
("Clipboard is empty", "Khay nhớ tạm trống"),
("Stop service", "Dừng dịch vụ"),
("Change ID", "Thay đổi ID"),
("Website", "Trang web"),