diff --git a/lib/core/utils/server.dart b/lib/core/utils/server.dart index 64cd13f7..d75ce381 100644 --- a/lib/core/utils/server.dart +++ b/lib/core/utils/server.dart @@ -58,10 +58,10 @@ Future genClient( } catch (e) { if (spi.alterUrl == null) rethrow; try { - spi.fromStringUrl(); + final ipPort = spi.fromStringUrl(); socket = await SSHSocket.connect( - spi.ip, - spi.port, + ipPort.ip, + ipPort.port, timeout: const Duration(seconds: 5), ); } catch (e) { diff --git a/lib/data/model/server/server_private_info.dart b/lib/data/model/server/server_private_info.dart index 7cb6a28c..6761e987 100644 --- a/lib/data/model/server/server_private_info.dart +++ b/lib/data/model/server/server_private_info.dart @@ -68,7 +68,7 @@ class ServerPrivateInfo { alterUrl != old.alterUrl; } - void fromStringUrl() { + _IpPort fromStringUrl() { if (alterUrl == null) { throw SSHErr(type: SSHErrType.connect, message: 'alterUrl is null'); } @@ -76,16 +76,16 @@ class ServerPrivateInfo { if (splited.length != 2) { throw SSHErr(type: SSHErrType.connect, message: 'alterUrl no @'); } - user = splited[0]; final splited2 = splited[1].split(':'); if (splited2.length != 2) { throw SSHErr(type: SSHErrType.connect, message: 'alterUrl no :'); } - ip = splited2[0]; - port = int.tryParse(splited2[1]) ?? 22; + final ip_ = splited2[0]; + final port_ = int.tryParse(splited2[1]) ?? 22; if (port <= 0 || port > 65535) { throw SSHErr(type: SSHErrType.connect, message: 'alterUrl port error'); } + return _IpPort(ip_, port_); // Do not update [id] // Because [id] is the identity which is used to find the [SSHClient] @@ -97,3 +97,10 @@ class ServerPrivateInfo { return id; } } + +class _IpPort { + final String ip; + final int port; + + _IpPort(this.ip, this.port); +} diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 7de9a739..97e82977 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -39,4 +39,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367 -COCOAPODS: 1.11.1 +COCOAPODS: 1.12.1