mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
fix: alterUrl will change spi's props
This commit is contained in:
@@ -58,10 +58,10 @@ Future<SSHClient> 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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,4 @@ SPEC CHECKSUMS:
|
||||
|
||||
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
|
||||
|
||||
COCOAPODS: 1.11.1
|
||||
COCOAPODS: 1.12.1
|
||||
|
||||
Reference in New Issue
Block a user