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) {
|
} catch (e) {
|
||||||
if (spi.alterUrl == null) rethrow;
|
if (spi.alterUrl == null) rethrow;
|
||||||
try {
|
try {
|
||||||
spi.fromStringUrl();
|
final ipPort = spi.fromStringUrl();
|
||||||
socket = await SSHSocket.connect(
|
socket = await SSHSocket.connect(
|
||||||
spi.ip,
|
ipPort.ip,
|
||||||
spi.port,
|
ipPort.port,
|
||||||
timeout: const Duration(seconds: 5),
|
timeout: const Duration(seconds: 5),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class ServerPrivateInfo {
|
|||||||
alterUrl != old.alterUrl;
|
alterUrl != old.alterUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fromStringUrl() {
|
_IpPort fromStringUrl() {
|
||||||
if (alterUrl == null) {
|
if (alterUrl == null) {
|
||||||
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl is null');
|
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl is null');
|
||||||
}
|
}
|
||||||
@@ -76,16 +76,16 @@ class ServerPrivateInfo {
|
|||||||
if (splited.length != 2) {
|
if (splited.length != 2) {
|
||||||
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl no @');
|
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl no @');
|
||||||
}
|
}
|
||||||
user = splited[0];
|
|
||||||
final splited2 = splited[1].split(':');
|
final splited2 = splited[1].split(':');
|
||||||
if (splited2.length != 2) {
|
if (splited2.length != 2) {
|
||||||
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl no :');
|
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl no :');
|
||||||
}
|
}
|
||||||
ip = splited2[0];
|
final ip_ = splited2[0];
|
||||||
port = int.tryParse(splited2[1]) ?? 22;
|
final port_ = int.tryParse(splited2[1]) ?? 22;
|
||||||
if (port <= 0 || port > 65535) {
|
if (port <= 0 || port > 65535) {
|
||||||
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl port error');
|
throw SSHErr(type: SSHErrType.connect, message: 'alterUrl port error');
|
||||||
}
|
}
|
||||||
|
return _IpPort(ip_, port_);
|
||||||
|
|
||||||
// Do not update [id]
|
// Do not update [id]
|
||||||
// Because [id] is the identity which is used to find the [SSHClient]
|
// Because [id] is the identity which is used to find the [SSHClient]
|
||||||
@@ -97,3 +97,10 @@ class ServerPrivateInfo {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _IpPort {
|
||||||
|
final String ip;
|
||||||
|
final int port;
|
||||||
|
|
||||||
|
_IpPort(this.ip, this.port);
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,4 +39,4 @@ SPEC CHECKSUMS:
|
|||||||
|
|
||||||
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
|
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
|
||||||
|
|
||||||
COCOAPODS: 1.11.1
|
COCOAPODS: 1.12.1
|
||||||
|
|||||||
Reference in New Issue
Block a user