mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-09-19 10:51:01 +03:00
support wss:// for web client
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -352,6 +352,9 @@ void changeIdWhiteList({Function()? callback}) async {
|
|||||||
msg = "";
|
msg = "";
|
||||||
isInProgress = true;
|
isInProgress = true;
|
||||||
});
|
});
|
||||||
|
debugPrint(
|
||||||
|
'[id-whitelist] raw=${controller.text.replaceAll(' ', '␠').replaceAll('\n', r'\n')}',
|
||||||
|
);
|
||||||
newIdWhiteListField = controller.text.trim();
|
newIdWhiteListField = controller.text.trim();
|
||||||
var newIdWhiteList = "";
|
var newIdWhiteList = "";
|
||||||
if (newIdWhiteListField.isEmpty) {
|
if (newIdWhiteListField.isEmpty) {
|
||||||
@@ -362,9 +365,10 @@ void changeIdWhiteList({Function()? callback}) async {
|
|||||||
.split(RegExp(r"[\s,;\n]+"))
|
.split(RegExp(r"[\s,;\n]+"))
|
||||||
.where((e) => e.isNotEmpty)
|
.where((e) => e.isNotEmpty)
|
||||||
.toList();
|
.toList();
|
||||||
|
debugPrint('[id-whitelist] ids=$ids');
|
||||||
// test id, wildcards '*' and '?' are allowed;
|
// test id, wildcards '*' and '?' are allowed;
|
||||||
// '@' '.' ':' occur in cross-server IDs like "123456789@server:port"
|
// '@' '.' ':' '/' '[' ']' occur in cross-server IDs and WebSocket URIs
|
||||||
final idMatch = RegExp(r"^[a-zA-Z0-9_*?@.:-]+$");
|
final idMatch = RegExp(r"^[a-zA-Z0-9_*?@.:/\[\]-]+$");
|
||||||
for (final id in ids) {
|
for (final id in ids) {
|
||||||
if (!idMatch.hasMatch(id)) {
|
if (!idMatch.hasMatch(id)) {
|
||||||
msg = "${translate("Invalid ID")} $id";
|
msg = "${translate("Invalid ID")} $id";
|
||||||
@@ -379,6 +383,7 @@ void changeIdWhiteList({Function()? callback}) async {
|
|||||||
if (newIdWhiteList.trim().isEmpty) {
|
if (newIdWhiteList.trim().isEmpty) {
|
||||||
newIdWhiteList = defaultOptionWhitelist;
|
newIdWhiteList = defaultOptionWhitelist;
|
||||||
}
|
}
|
||||||
|
debugPrint('[id-whitelist] normalized=$newIdWhiteList');
|
||||||
await bind.mainSetOption(
|
await bind.mainSetOption(
|
||||||
key: kOptionIdWhitelist, value: newIdWhiteList);
|
key: kOptionIdWhitelist, value: newIdWhiteList);
|
||||||
callback?.call();
|
callback?.call();
|
||||||
|
|||||||
@@ -6812,7 +6812,7 @@ mod test {
|
|||||||
// Cross server from web, whose server is a WebSocket URI.
|
// Cross server from web, whose server is a WebSocket URI.
|
||||||
assert!(id_whitelist_allows(
|
assert!(id_whitelist_allows(
|
||||||
&list(&["123456789"]),
|
&list(&["123456789"]),
|
||||||
"123456789@ws://example.com:21118"
|
"123456789@wss://example.com:21118/ws/id"
|
||||||
));
|
));
|
||||||
// A different id is still rejected, suffix or not.
|
// A different id is still rejected, suffix or not.
|
||||||
assert!(!id_whitelist_allows(
|
assert!(!id_whitelist_allows(
|
||||||
|
|||||||
Reference in New Issue
Block a user