mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-15 04:43:41 +00:00
feat: ed2k protocol support (#1316)
This commit is contained in:
35 files changed
+1129
-35
No files matched your search
@@ -31,6 +31,7 @@ class DownloaderConfig {
|
||||
class ProtocolConfig {
|
||||
HttpConfig http = HttpConfig();
|
||||
BtConfig bt = BtConfig();
|
||||
Ed2kConfig ed2k = Ed2kConfig();
|
||||
|
||||
ProtocolConfig();
|
||||
|
||||
@@ -80,6 +81,28 @@ class BtConfig {
|
||||
Map<String, dynamic> toJson() => _$BtConfigToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Ed2kConfig {
|
||||
int listenPort;
|
||||
int udpPort;
|
||||
String serverAddr;
|
||||
String serverMet;
|
||||
String nodesDat;
|
||||
|
||||
Ed2kConfig({
|
||||
this.listenPort = 0,
|
||||
this.udpPort = 0,
|
||||
this.serverAddr = '',
|
||||
this.serverMet = '',
|
||||
this.nodesDat = '',
|
||||
});
|
||||
|
||||
factory Ed2kConfig.fromJson(Map<String, dynamic> json) =>
|
||||
_$Ed2kConfigFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$Ed2kConfigToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class ExtraConfig {
|
||||
String themeMode;
|
||||
|
||||
@@ -42,12 +42,15 @@ Map<String, dynamic> _$DownloaderConfigToJson(DownloaderConfig instance) =>
|
||||
ProtocolConfig _$ProtocolConfigFromJson(Map<String, dynamic> json) =>
|
||||
ProtocolConfig()
|
||||
..http = HttpConfig.fromJson(json['http'] as Map<String, dynamic>)
|
||||
..bt = BtConfig.fromJson(json['bt'] as Map<String, dynamic>);
|
||||
..bt = BtConfig.fromJson(json['bt'] as Map<String, dynamic>)
|
||||
..ed2k = Ed2kConfig.fromJson(
|
||||
json['ed2k'] as Map<String, dynamic>? ?? <String, dynamic>{});
|
||||
|
||||
Map<String, dynamic> _$ProtocolConfigToJson(ProtocolConfig instance) =>
|
||||
<String, dynamic>{
|
||||
'http': instance.http.toJson(),
|
||||
'bt': instance.bt.toJson(),
|
||||
'ed2k': instance.ed2k.toJson(),
|
||||
};
|
||||
|
||||
HttpConfig _$HttpConfigFromJson(Map<String, dynamic> json) => HttpConfig(
|
||||
@@ -82,6 +85,23 @@ Map<String, dynamic> _$BtConfigToJson(BtConfig instance) => <String, dynamic>{
|
||||
'seedTime': instance.seedTime,
|
||||
};
|
||||
|
||||
Ed2kConfig _$Ed2kConfigFromJson(Map<String, dynamic> json) => Ed2kConfig(
|
||||
listenPort: (json['listenPort'] as num?)?.toInt() ?? 0,
|
||||
udpPort: (json['udpPort'] as num?)?.toInt() ?? 0,
|
||||
serverAddr: json['serverAddr'] as String? ?? '',
|
||||
serverMet: json['serverMet'] as String? ?? '',
|
||||
nodesDat: json['nodesDat'] as String? ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$Ed2kConfigToJson(Ed2kConfig instance) =>
|
||||
<String, dynamic>{
|
||||
'listenPort': instance.listenPort,
|
||||
'udpPort': instance.udpPort,
|
||||
'serverAddr': instance.serverAddr,
|
||||
'serverMet': instance.serverMet,
|
||||
'nodesDat': instance.nodesDat,
|
||||
};
|
||||
|
||||
ExtraConfig _$ExtraConfigFromJson(Map<String, dynamic> json) => ExtraConfig(
|
||||
themeMode: json['themeMode'] as String? ?? '',
|
||||
locale: json['locale'] as String? ?? '',
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'task.g.dart';
|
||||
|
||||
enum Status { ready, running, pause, wait, error, done }
|
||||
|
||||
enum Protocol { http, bt }
|
||||
enum Protocol { http, bt, ed2k }
|
||||
|
||||
// ExtractStatus enum matching Go backend
|
||||
enum ExtractStatus {
|
||||
|
||||
@@ -51,6 +51,7 @@ const _$StatusEnumMap = {
|
||||
const _$ProtocolEnumMap = {
|
||||
Protocol.http: 'http',
|
||||
Protocol.bt: 'bt',
|
||||
Protocol.ed2k: 'ed2k',
|
||||
};
|
||||
|
||||
Progress _$ProgressFromJson(Map<String, dynamic> json) => Progress(
|
||||
|
||||
Reference in new issue
Block a user