mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
#78 new: alter host
This commit is contained in:
@@ -17,6 +17,7 @@ abstract class Err<T> {
|
||||
|
||||
enum SSHErrType {
|
||||
unknown,
|
||||
connect,
|
||||
noPrivateKey;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ class ServerPrivateInfo {
|
||||
String? pubKeyId;
|
||||
@HiveField(6)
|
||||
List<String>? tags;
|
||||
@HiveField(7)
|
||||
String? alterHost;
|
||||
|
||||
late String id;
|
||||
|
||||
@@ -29,6 +31,7 @@ class ServerPrivateInfo {
|
||||
required this.pwd,
|
||||
this.pubKeyId,
|
||||
this.tags,
|
||||
this.alterHost,
|
||||
}) : id = '$user@$ip:$port';
|
||||
|
||||
ServerPrivateInfo.fromJson(Map<String, dynamic> json) {
|
||||
@@ -40,6 +43,7 @@ class ServerPrivateInfo {
|
||||
pubKeyId = json["pubKeyId"]?.toString();
|
||||
id = '$user@$ip:$port';
|
||||
tags = json["tags"]?.cast<String>();
|
||||
alterHost = json["alterHost"]?.toString();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
@@ -51,11 +55,15 @@ class ServerPrivateInfo {
|
||||
data["authorization"] = pwd;
|
||||
data["pubKeyId"] = pubKeyId;
|
||||
data["tags"] = tags;
|
||||
data["alterHost"] = alterHost;
|
||||
return data;
|
||||
}
|
||||
|
||||
bool shouldReconnect(ServerPrivateInfo old) {
|
||||
return id != old.id || pwd != old.pwd || pubKeyId != old.pubKeyId;
|
||||
return id != old.id ||
|
||||
pwd != old.pwd ||
|
||||
pubKeyId != old.pubKeyId ||
|
||||
alterHost != old.alterHost;
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -24,13 +24,14 @@ class ServerPrivateInfoAdapter extends TypeAdapter<ServerPrivateInfo> {
|
||||
pwd: fields[4] as String,
|
||||
pubKeyId: fields[5] as String?,
|
||||
tags: (fields[6] as List?)?.cast<String>(),
|
||||
alterHost: fields[7] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, ServerPrivateInfo obj) {
|
||||
writer
|
||||
..writeByte(7)
|
||||
..writeByte(8)
|
||||
..writeByte(0)
|
||||
..write(obj.name)
|
||||
..writeByte(1)
|
||||
@@ -44,7 +45,9 @@ class ServerPrivateInfoAdapter extends TypeAdapter<ServerPrivateInfo> {
|
||||
..writeByte(5)
|
||||
..write(obj.pubKeyId)
|
||||
..writeByte(6)
|
||||
..write(obj.tags);
|
||||
..write(obj.tags)
|
||||
..writeByte(7)
|
||||
..write(obj.alterHost);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user