Skip to content

Commit

Permalink
修复在android中分片大于4M时下载失败的问题、应用启动时获取XIU2/TrackersListCollection最新Tracker服务器
Browse files Browse the repository at this point in the history
  • Loading branch information
roomanl committed Jul 16, 2024
1 parent 0c39462 commit 6a0d4c0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/resources/aria2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ always-resume=true
auto-file-renaming=true
max-overall-download-limit=0
max-overall-upload-limit=50K
max-upload-limit=20
max-upload-limit=50K
connect-timeout=120
lowest-speed-limit=10K
max-connection-per-server=16
Expand All @@ -31,7 +31,7 @@ rpc-secure=false
daemon=true
disable-ipv6=true
enable-mmap=true
file-allocation=falloc
file-allocation=none
max-download-result=120
force-sequential=true
parameterized-uri=true
Expand Down
4 changes: 4 additions & 0 deletions lib/src/common/const.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const String SETTING_DOWN_PATH_KEY = 'downPath';
const String SETTING_THEME_COLOR_KEY = 'themeColor';

//Tracker服务器
const String ARIA2_Tracker_List =
'https://bitbucket.org/xiu2/trackerslistcollection/raw/master/best_aria2.txt';

const String ARIA2_URL_VALUE = 'http://127.0.0.1:{port}/jsonrpc';
const String FAMD_GITHUB_URL = 'https://github.com/roomanl/famd';
const String HOME_PAGE = 'https://rootvip.cn';
Expand Down
10 changes: 9 additions & 1 deletion lib/src/utils/aria2_conf_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
import '../common/const.dart';
import 'file_utils.dart';
import 'native_channel_utils.dart';
import 'package:http/http.dart' as http;

getAria2rootPath() async {
return await getPlugAssetsDir('aria2');
Expand Down Expand Up @@ -40,6 +41,11 @@ Future<String> getAria2UrlConf() async {
}

initAria2Conf() async {
String? trackerList;
var res = await http.get(Uri.parse(ARIA2_Tracker_List));
if (res.statusCode == 200) {
trackerList = res.body;
}
String rootPath = await getAria2rootPath();
String confPath = await getAria2ConfPath();
List<String> aria2ConfLines = await readDefAria2Conf();
Expand All @@ -58,7 +64,9 @@ initAria2Conf() async {
confLines.add('input-file=$sessionFile');
confLines.add('save-session=$sessionFile');
for (String line in aria2ConfLines) {
if (!line.startsWith('dir=') &&
if (line.startsWith('bt-tracker') && trackerList != null) {
confLines.add('bt-tracker=$trackerList');
} else if (!line.startsWith('dir=') &&
!line.startsWith('log=') &&
!line.startsWith('input-file=') &&
!line.startsWith('save-session=')) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 2.6.3+263
version: 2.6.4+264

environment:
sdk: '>=3.1.0 <4.0.0'
Expand Down
Binary file modified windows/bin/plugin/aria2/m3u8aria2c.exe
Binary file not shown.

0 comments on commit 6a0d4c0

Please sign in to comment.