fix:调整兼容域名解析
This commit is contained in:
parent
e6b90d9651
commit
f79e5daa47
@ -894,17 +894,16 @@ class StartChartManage {
|
|||||||
|
|
||||||
/// 解析 UDP URL 并提取 IP 地址和端口号
|
/// 解析 UDP URL 并提取 IP 地址和端口号
|
||||||
Map<String, dynamic> _parseUdpUrl(String url) {
|
Map<String, dynamic> _parseUdpUrl(String url) {
|
||||||
// 使用正则表达式匹配 IP 地址和端口号
|
// 修改正则表达式以匹配 IP 地址或域名
|
||||||
final regex = RegExp(r'udp://(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d+)')
|
final regex = RegExp(r'udp://([a-zA-Z0-9.-]+):(\d+)').firstMatch(url);
|
||||||
.firstMatch(url);
|
|
||||||
|
|
||||||
if (regex != null) {
|
if (regex != null) {
|
||||||
final ip = regex.group(1);
|
final host = regex.group(1);
|
||||||
final portStr = regex.group(2);
|
final portStr = regex.group(2);
|
||||||
final port = int.tryParse(portStr ?? '');
|
final port = int.tryParse(portStr ?? '');
|
||||||
|
|
||||||
if (ip != null && port != null) {
|
if (host != null && port != null) {
|
||||||
return {'host': ip, 'port': port};
|
return {'host': host, 'port': port};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw FormatException('无法解析 URL 格式: $url');
|
throw FormatException('无法解析 URL 格式: $url');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user