mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-05 16:15:43 +00:00
fix: andriod unix socket
This commit is contained in:
1 parent
9659176752
commit
c1545adeb2
3 files changed
+18
-23
No files matched your search
+11
-11
@@ -23,23 +23,23 @@ class _Client {
|
||||
if (_instance == null) {
|
||||
_instance = _Client._internal();
|
||||
var dio = Dio();
|
||||
dio.options.baseUrl = "http://${LibgopeedBoot.instance.config.address}";
|
||||
final isUnixSocket = LibgopeedBoot.instance.config.network == 'unix';
|
||||
dio.options.baseUrl = isUnixSocket
|
||||
? 'http://127.0.0.1'
|
||||
: 'http://${LibgopeedBoot.instance.config.address}';
|
||||
_instance!.dio = dio;
|
||||
if(_instance!.dio.httpClientAdapter is DefaultHttpClientAdapter){
|
||||
if (isUnixSocket) {
|
||||
(_instance!.dio.httpClientAdapter as DefaultHttpClientAdapter)
|
||||
.onHttpClientCreate = (client) {
|
||||
if (LibgopeedBoot.instance.config.network == "unix") {
|
||||
client.connectionFactory =
|
||||
(Uri uri, String? proxyHost, int? proxyPort) {
|
||||
var address = InternetAddress(LibgopeedBoot.instance.config.address,
|
||||
type: InternetAddressType.unix);
|
||||
return Socket.startConnect(address, 0);
|
||||
};
|
||||
}
|
||||
client.connectionFactory =
|
||||
(Uri uri, String? proxyHost, int? proxyPort) {
|
||||
var address = InternetAddress(LibgopeedBoot.instance.config.address,
|
||||
type: InternetAddressType.unix);
|
||||
return Socket.startConnect(address, 0);
|
||||
};
|
||||
return client;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,6 @@ class LibgopeedBootNative implements LibgopeedBoot {
|
||||
|
||||
@override
|
||||
Future<void> start() async {
|
||||
// if is debug mode,use local http server
|
||||
if (kDebugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
var storageDir = "./";
|
||||
if (!Util.isUnix()) {
|
||||
// not support unix socket, use tcp
|
||||
|
||||
@@ -7,11 +7,11 @@ import '../api/model/server_config.dart';
|
||||
import '../util/util.dart';
|
||||
|
||||
class Setting {
|
||||
late String host;
|
||||
late int port;
|
||||
late int connections;
|
||||
late String downloadDir;
|
||||
late ThemeMode themeMode;
|
||||
String host = "127.0.0.1";
|
||||
int port = 0;
|
||||
int connections = 0;
|
||||
String downloadDir = "";
|
||||
ThemeMode themeMode = ThemeMode.system;
|
||||
|
||||
Setting({
|
||||
required this.host,
|
||||
@@ -44,13 +44,13 @@ class Setting {
|
||||
this.themeMode = ThemeMode.values.byName(themeMode);
|
||||
}
|
||||
|
||||
if(Util.isWeb()){
|
||||
if (Util.isWeb()) {
|
||||
downloadDir = "./";
|
||||
return;
|
||||
}
|
||||
if (Util.isAndroid()) {
|
||||
downloadDir =
|
||||
'${await ExternalPath.getExternalStoragePublicDirectory(ExternalPath.DIRECTORY_DOWNLOADS)}/com.gopeed';
|
||||
'${await ExternalPath.getExternalStoragePublicDirectory(ExternalPath.DIRECTORY_DOWNLOADS)}/com.gopeed';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user