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