mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-22 19:53:43 +08:00
feat: rust/rsHttp Option with_custom_dns
This commit is contained in:
parent
7e1e96707c
commit
0c03050f5c
@ -14,49 +14,73 @@ class RSHttp {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<RustHttpResponse> get(String url,
|
static Future<RustHttpResponse> get(
|
||||||
{Map<String, String>? headers, String? withIpAddress}) async {
|
String url, {
|
||||||
|
Map<String, String>? headers,
|
||||||
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns,
|
||||||
|
}) async {
|
||||||
final r = await rust_http.fetch(
|
final r = await rust_http.fetch(
|
||||||
method: MyMethod.gets,
|
method: MyMethod.gets,
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
withIpAddress: withIpAddress);
|
withIpAddress: withIpAddress,
|
||||||
|
withCustomDns: withCustomDns,
|
||||||
|
);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> getText(String url,
|
static Future<String> getText(
|
||||||
{Map<String, String>? headers, String? withIpAddress}) async {
|
String url, {
|
||||||
final r = await get(url, headers: headers, withIpAddress: withIpAddress);
|
Map<String, String>? headers,
|
||||||
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns,
|
||||||
|
}) async {
|
||||||
|
final r = await get(url,
|
||||||
|
headers: headers,
|
||||||
|
withIpAddress: withIpAddress,
|
||||||
|
withCustomDns: withCustomDns);
|
||||||
if (r.data == null) return "";
|
if (r.data == null) return "";
|
||||||
final str = utf8.decode(r.data!);
|
final str = utf8.decode(r.data!);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<RustHttpResponse> postData(String url,
|
static Future<RustHttpResponse> postData(
|
||||||
{Map<String, String>? headers,
|
String url, {
|
||||||
String? contentType,
|
Map<String, String>? headers,
|
||||||
Uint8List? data,
|
String? contentType,
|
||||||
String? withIpAddress}) async {
|
Uint8List? data,
|
||||||
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns,
|
||||||
|
}) async {
|
||||||
if (contentType != null) {
|
if (contentType != null) {
|
||||||
headers ??= {};
|
headers ??= {};
|
||||||
headers["Content-Type"] = contentType;
|
headers["Content-Type"] = contentType;
|
||||||
}
|
}
|
||||||
final r = await rust_http.fetch(
|
final r = await rust_http.fetch(
|
||||||
method: MyMethod.post,
|
method: MyMethod.post,
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
inputData: data,
|
inputData: data,
|
||||||
withIpAddress: withIpAddress);
|
withIpAddress: withIpAddress,
|
||||||
|
withCustomDns: withCustomDns,
|
||||||
|
);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<RustHttpResponse> head(String url,
|
static Future<RustHttpResponse> head(
|
||||||
{Map<String, String>? headers, String? withIpAddress}) async {
|
String url, {
|
||||||
|
Map<String, String>? headers,
|
||||||
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns,
|
||||||
|
}) async {
|
||||||
final r = await rust_http.fetch(
|
final r = await rust_http.fetch(
|
||||||
method: MyMethod.head,
|
method: MyMethod.head,
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
withIpAddress: withIpAddress);
|
withIpAddress: withIpAddress,
|
||||||
|
withCustomDns: withCustomDns,
|
||||||
|
);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,13 +17,15 @@ Future<RustHttpResponse> fetch(
|
|||||||
required String url,
|
required String url,
|
||||||
Map<String, String>? headers,
|
Map<String, String>? headers,
|
||||||
Uint8List? inputData,
|
Uint8List? inputData,
|
||||||
String? withIpAddress}) =>
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns}) =>
|
||||||
RustLib.instance.api.crateApiHttpApiFetch(
|
RustLib.instance.api.crateApiHttpApiFetch(
|
||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
inputData: inputData,
|
inputData: inputData,
|
||||||
withIpAddress: withIpAddress);
|
withIpAddress: withIpAddress,
|
||||||
|
withCustomDns: withCustomDns);
|
||||||
|
|
||||||
Future<List<String>> dnsLookupTxt({required String host}) =>
|
Future<List<String>> dnsLookupTxt({required String host}) =>
|
||||||
RustLib.instance.api.crateApiHttpApiDnsLookupTxt(host: host);
|
RustLib.instance.api.crateApiHttpApiDnsLookupTxt(host: host);
|
||||||
|
@ -96,7 +96,8 @@ abstract class RustLibApi extends BaseApi {
|
|||||||
required String url,
|
required String url,
|
||||||
Map<String, String>? headers,
|
Map<String, String>? headers,
|
||||||
Uint8List? inputData,
|
Uint8List? inputData,
|
||||||
String? withIpAddress});
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns});
|
||||||
|
|
||||||
Future<void> crateApiHttpApiSetDefaultHeader(
|
Future<void> crateApiHttpApiSetDefaultHeader(
|
||||||
{required Map<String, String> headers});
|
{required Map<String, String> headers});
|
||||||
@ -228,7 +229,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
required String url,
|
required String url,
|
||||||
Map<String, String>? headers,
|
Map<String, String>? headers,
|
||||||
Uint8List? inputData,
|
Uint8List? inputData,
|
||||||
String? withIpAddress}) {
|
String? withIpAddress,
|
||||||
|
bool? withCustomDns}) {
|
||||||
return handler.executeNormal(NormalTask(
|
return handler.executeNormal(NormalTask(
|
||||||
callFfi: (port_) {
|
callFfi: (port_) {
|
||||||
var arg0 = cst_encode_my_method(method);
|
var arg0 = cst_encode_my_method(method);
|
||||||
@ -236,22 +238,37 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
var arg2 = cst_encode_opt_Map_String_String(headers);
|
var arg2 = cst_encode_opt_Map_String_String(headers);
|
||||||
var arg3 = cst_encode_opt_list_prim_u_8_strict(inputData);
|
var arg3 = cst_encode_opt_list_prim_u_8_strict(inputData);
|
||||||
var arg4 = cst_encode_opt_String(withIpAddress);
|
var arg4 = cst_encode_opt_String(withIpAddress);
|
||||||
|
var arg5 = cst_encode_opt_box_autoadd_bool(withCustomDns);
|
||||||
return wire.wire__crate__api__http_api__fetch(
|
return wire.wire__crate__api__http_api__fetch(
|
||||||
port_, arg0, arg1, arg2, arg3, arg4);
|
port_, arg0, arg1, arg2, arg3, arg4, arg5);
|
||||||
},
|
},
|
||||||
codec: DcoCodec(
|
codec: DcoCodec(
|
||||||
decodeSuccessData: dco_decode_rust_http_response,
|
decodeSuccessData: dco_decode_rust_http_response,
|
||||||
decodeErrorData: dco_decode_AnyhowException,
|
decodeErrorData: dco_decode_AnyhowException,
|
||||||
),
|
),
|
||||||
constMeta: kCrateApiHttpApiFetchConstMeta,
|
constMeta: kCrateApiHttpApiFetchConstMeta,
|
||||||
argValues: [method, url, headers, inputData, withIpAddress],
|
argValues: [
|
||||||
|
method,
|
||||||
|
url,
|
||||||
|
headers,
|
||||||
|
inputData,
|
||||||
|
withIpAddress,
|
||||||
|
withCustomDns
|
||||||
|
],
|
||||||
apiImpl: this,
|
apiImpl: this,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskConstMeta get kCrateApiHttpApiFetchConstMeta => const TaskConstMeta(
|
TaskConstMeta get kCrateApiHttpApiFetchConstMeta => const TaskConstMeta(
|
||||||
debugName: "fetch",
|
debugName: "fetch",
|
||||||
argNames: ["method", "url", "headers", "inputData", "withIpAddress"],
|
argNames: [
|
||||||
|
"method",
|
||||||
|
"url",
|
||||||
|
"headers",
|
||||||
|
"inputData",
|
||||||
|
"withIpAddress",
|
||||||
|
"withCustomDns"
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -417,6 +434,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
return raw as bool;
|
return raw as bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool dco_decode_box_autoadd_bool(dynamic raw) {
|
||||||
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
return raw as bool;
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RsiLauncherAsarData dco_decode_box_autoadd_rsi_launcher_asar_data(
|
RsiLauncherAsarData dco_decode_box_autoadd_rsi_launcher_asar_data(
|
||||||
dynamic raw) {
|
dynamic raw) {
|
||||||
@ -484,6 +507,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
return raw == null ? null : dco_decode_String(raw);
|
return raw == null ? null : dco_decode_String(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool? dco_decode_opt_box_autoadd_bool(dynamic raw) {
|
||||||
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
|
return raw == null ? null : dco_decode_box_autoadd_bool(raw);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw) {
|
BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw) {
|
||||||
// Codec=Dco (DartCObject based), see doc to use other codecs
|
// Codec=Dco (DartCObject based), see doc to use other codecs
|
||||||
@ -624,6 +653,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
return deserializer.buffer.getUint8() != 0;
|
return deserializer.buffer.getUint8() != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool sse_decode_box_autoadd_bool(SseDeserializer deserializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
return (sse_decode_bool(deserializer));
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RsiLauncherAsarData sse_decode_box_autoadd_rsi_launcher_asar_data(
|
RsiLauncherAsarData sse_decode_box_autoadd_rsi_launcher_asar_data(
|
||||||
SseDeserializer deserializer) {
|
SseDeserializer deserializer) {
|
||||||
@ -719,6 +754,17 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool? sse_decode_opt_box_autoadd_bool(SseDeserializer deserializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
|
||||||
|
if (sse_decode_bool(deserializer)) {
|
||||||
|
return (sse_decode_box_autoadd_bool(deserializer));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) {
|
BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
@ -925,6 +971,12 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
serializer.buffer.putUint8(self ? 1 : 0);
|
serializer.buffer.putUint8(self ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_box_autoadd_bool(bool self, SseSerializer serializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
sse_encode_bool(self, serializer);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_rsi_launcher_asar_data(
|
void sse_encode_box_autoadd_rsi_launcher_asar_data(
|
||||||
RsiLauncherAsarData self, SseSerializer serializer) {
|
RsiLauncherAsarData self, SseSerializer serializer) {
|
||||||
@ -1014,6 +1066,16 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_opt_box_autoadd_bool(bool? self, SseSerializer serializer) {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
|
||||||
|
sse_encode_bool(self != null, serializer);
|
||||||
|
if (self != null) {
|
||||||
|
sse_encode_box_autoadd_bool(self, serializer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer) {
|
void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer) {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
@ -38,6 +38,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
bool dco_decode_bool(dynamic raw);
|
bool dco_decode_bool(dynamic raw);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool dco_decode_box_autoadd_bool(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RsiLauncherAsarData dco_decode_box_autoadd_rsi_launcher_asar_data(
|
RsiLauncherAsarData dco_decode_box_autoadd_rsi_launcher_asar_data(
|
||||||
dynamic raw);
|
dynamic raw);
|
||||||
@ -72,6 +75,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
String? dco_decode_opt_String(dynamic raw);
|
String? dco_decode_opt_String(dynamic raw);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool? dco_decode_opt_box_autoadd_bool(dynamic raw);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw);
|
BigInt? dco_decode_opt_box_autoadd_u_64(dynamic raw);
|
||||||
|
|
||||||
@ -126,6 +132,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
bool sse_decode_bool(SseDeserializer deserializer);
|
bool sse_decode_bool(SseDeserializer deserializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool sse_decode_box_autoadd_bool(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
RsiLauncherAsarData sse_decode_box_autoadd_rsi_launcher_asar_data(
|
RsiLauncherAsarData sse_decode_box_autoadd_rsi_launcher_asar_data(
|
||||||
SseDeserializer deserializer);
|
SseDeserializer deserializer);
|
||||||
@ -162,6 +171,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
String? sse_decode_opt_String(SseDeserializer deserializer);
|
String? sse_decode_opt_String(SseDeserializer deserializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
bool? sse_decode_opt_box_autoadd_bool(SseDeserializer deserializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer);
|
BigInt? sse_decode_opt_box_autoadd_u_64(SseDeserializer deserializer);
|
||||||
|
|
||||||
@ -235,6 +247,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw));
|
return cst_encode_list_prim_u_8_strict(utf8.encoder.convert(raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ffi.Pointer<ffi.Bool> cst_encode_box_autoadd_bool(bool raw) {
|
||||||
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
|
return wire.cst_new_box_autoadd_bool(cst_encode_bool(raw));
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ffi.Pointer<wire_cst_rsi_launcher_asar_data>
|
ffi.Pointer<wire_cst_rsi_launcher_asar_data>
|
||||||
cst_encode_box_autoadd_rsi_launcher_asar_data(RsiLauncherAsarData raw) {
|
cst_encode_box_autoadd_rsi_launcher_asar_data(RsiLauncherAsarData raw) {
|
||||||
@ -303,6 +321,12 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
return raw == null ? ffi.nullptr : cst_encode_String(raw);
|
return raw == null ? ffi.nullptr : cst_encode_String(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@protected
|
||||||
|
ffi.Pointer<ffi.Bool> cst_encode_opt_box_autoadd_bool(bool? raw) {
|
||||||
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
|
return raw == null ? ffi.nullptr : cst_encode_box_autoadd_bool(raw);
|
||||||
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
ffi.Pointer<ffi.Uint64> cst_encode_opt_box_autoadd_u_64(BigInt? raw) {
|
ffi.Pointer<ffi.Uint64> cst_encode_opt_box_autoadd_u_64(BigInt? raw) {
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
@ -411,6 +435,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
void sse_encode_bool(bool self, SseSerializer serializer);
|
void sse_encode_bool(bool self, SseSerializer serializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_box_autoadd_bool(bool self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_box_autoadd_rsi_launcher_asar_data(
|
void sse_encode_box_autoadd_rsi_launcher_asar_data(
|
||||||
RsiLauncherAsarData self, SseSerializer serializer);
|
RsiLauncherAsarData self, SseSerializer serializer);
|
||||||
@ -448,6 +475,9 @@ abstract class RustLibApiImplPlatform extends BaseApiImpl<RustLibWire> {
|
|||||||
@protected
|
@protected
|
||||||
void sse_encode_opt_String(String? self, SseSerializer serializer);
|
void sse_encode_opt_String(String? self, SseSerializer serializer);
|
||||||
|
|
||||||
|
@protected
|
||||||
|
void sse_encode_opt_box_autoadd_bool(bool? self, SseSerializer serializer);
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer);
|
void sse_encode_opt_box_autoadd_u_64(BigInt? self, SseSerializer serializer);
|
||||||
|
|
||||||
@ -622,6 +652,7 @@ class RustLibWire implements BaseWire {
|
|||||||
ffi.Pointer<wire_cst_list_record_string_string> headers,
|
ffi.Pointer<wire_cst_list_record_string_string> headers,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> input_data,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> input_data,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict> with_ip_address,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict> with_ip_address,
|
||||||
|
ffi.Pointer<ffi.Bool> with_custom_dns,
|
||||||
) {
|
) {
|
||||||
return _wire__crate__api__http_api__fetch(
|
return _wire__crate__api__http_api__fetch(
|
||||||
port_,
|
port_,
|
||||||
@ -630,6 +661,7 @@ class RustLibWire implements BaseWire {
|
|||||||
headers,
|
headers,
|
||||||
input_data,
|
input_data,
|
||||||
with_ip_address,
|
with_ip_address,
|
||||||
|
with_custom_dns,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,7 +673,8 @@ class RustLibWire implements BaseWire {
|
|||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
ffi.Pointer<wire_cst_list_record_string_string>,
|
ffi.Pointer<wire_cst_list_record_string_string>,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>>(
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
ffi.Pointer<ffi.Bool>)>>(
|
||||||
'frbgen_starcitizen_doctor_wire__crate__api__http_api__fetch');
|
'frbgen_starcitizen_doctor_wire__crate__api__http_api__fetch');
|
||||||
late final _wire__crate__api__http_api__fetch =
|
late final _wire__crate__api__http_api__fetch =
|
||||||
_wire__crate__api__http_api__fetchPtr.asFunction<
|
_wire__crate__api__http_api__fetchPtr.asFunction<
|
||||||
@ -651,7 +684,8 @@ class RustLibWire implements BaseWire {
|
|||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
ffi.Pointer<wire_cst_list_record_string_string>,
|
ffi.Pointer<wire_cst_list_record_string_string>,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
ffi.Pointer<wire_cst_list_prim_u_8_strict>,
|
||||||
|
ffi.Pointer<ffi.Bool>)>();
|
||||||
|
|
||||||
void wire__crate__api__http_api__set_default_header(
|
void wire__crate__api__http_api__set_default_header(
|
||||||
int port_,
|
int port_,
|
||||||
@ -782,6 +816,20 @@ class RustLibWire implements BaseWire {
|
|||||||
_wire__crate__api__win32_api__set_foreground_windowPtr.asFunction<
|
_wire__crate__api__win32_api__set_foreground_windowPtr.asFunction<
|
||||||
void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
void Function(int, ffi.Pointer<wire_cst_list_prim_u_8_strict>)>();
|
||||||
|
|
||||||
|
ffi.Pointer<ffi.Bool> cst_new_box_autoadd_bool(
|
||||||
|
bool value,
|
||||||
|
) {
|
||||||
|
return _cst_new_box_autoadd_bool(
|
||||||
|
value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
late final _cst_new_box_autoadd_boolPtr =
|
||||||
|
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Bool> Function(ffi.Bool)>>(
|
||||||
|
'frbgen_starcitizen_doctor_cst_new_box_autoadd_bool');
|
||||||
|
late final _cst_new_box_autoadd_bool = _cst_new_box_autoadd_boolPtr
|
||||||
|
.asFunction<ffi.Pointer<ffi.Bool> Function(bool)>();
|
||||||
|
|
||||||
ffi.Pointer<wire_cst_rsi_launcher_asar_data>
|
ffi.Pointer<wire_cst_rsi_launcher_asar_data>
|
||||||
cst_new_box_autoadd_rsi_launcher_asar_data() {
|
cst_new_box_autoadd_rsi_launcher_asar_data() {
|
||||||
return _cst_new_box_autoadd_rsi_launcher_asar_data();
|
return _cst_new_box_autoadd_rsi_launcher_asar_data();
|
||||||
|
@ -16,7 +16,7 @@ pub enum MyMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn _my_method_to_hyper_method(m: MyMethod) -> Method {
|
fn _my_method_to_hyper_method(m: MyMethod) -> Method {
|
||||||
return match m {
|
match m {
|
||||||
MyMethod::Options => Method::OPTIONS,
|
MyMethod::Options => Method::OPTIONS,
|
||||||
MyMethod::Gets => Method::GET,
|
MyMethod::Gets => Method::GET,
|
||||||
MyMethod::Post => Method::POST,
|
MyMethod::Post => Method::POST,
|
||||||
@ -26,7 +26,7 @@ fn _my_method_to_hyper_method(m: MyMethod) -> Method {
|
|||||||
MyMethod::Trace => Method::TRACE,
|
MyMethod::Trace => Method::TRACE,
|
||||||
MyMethod::Connect => Method::CONNECT,
|
MyMethod::Connect => Method::CONNECT,
|
||||||
MyMethod::Patch => Method::PATCH,
|
MyMethod::Patch => Method::PATCH,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_default_header(headers: HashMap<String, String>) {
|
pub fn set_default_header(headers: HashMap<String, String>) {
|
||||||
@ -39,6 +39,7 @@ pub async fn fetch(
|
|||||||
headers: Option<HashMap<String, String>>,
|
headers: Option<HashMap<String, String>>,
|
||||||
input_data: Option<Vec<u8>>,
|
input_data: Option<Vec<u8>>,
|
||||||
with_ip_address: Option<String>,
|
with_ip_address: Option<String>,
|
||||||
|
with_custom_dns: Option<bool>,
|
||||||
) -> anyhow::Result<RustHttpResponse> {
|
) -> anyhow::Result<RustHttpResponse> {
|
||||||
http_package::fetch(
|
http_package::fetch(
|
||||||
_my_method_to_hyper_method(method),
|
_my_method_to_hyper_method(method),
|
||||||
@ -46,6 +47,7 @@ pub async fn fetch(
|
|||||||
headers,
|
headers,
|
||||||
input_data,
|
input_data,
|
||||||
with_ip_address,
|
with_ip_address,
|
||||||
|
with_custom_dns
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,7 @@ fn wire__crate__api__http_api__fetch_impl(
|
|||||||
headers: impl CstDecode<Option<std::collections::HashMap<String, String>>>,
|
headers: impl CstDecode<Option<std::collections::HashMap<String, String>>>,
|
||||||
input_data: impl CstDecode<Option<Vec<u8>>>,
|
input_data: impl CstDecode<Option<Vec<u8>>>,
|
||||||
with_ip_address: impl CstDecode<Option<String>>,
|
with_ip_address: impl CstDecode<Option<String>>,
|
||||||
|
with_custom_dns: impl CstDecode<Option<bool>>,
|
||||||
) {
|
) {
|
||||||
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
|
||||||
flutter_rust_bridge::for_generated::TaskInfo {
|
flutter_rust_bridge::for_generated::TaskInfo {
|
||||||
@ -169,6 +170,7 @@ fn wire__crate__api__http_api__fetch_impl(
|
|||||||
let api_headers = headers.cst_decode();
|
let api_headers = headers.cst_decode();
|
||||||
let api_input_data = input_data.cst_decode();
|
let api_input_data = input_data.cst_decode();
|
||||||
let api_with_ip_address = with_ip_address.cst_decode();
|
let api_with_ip_address = with_ip_address.cst_decode();
|
||||||
|
let api_with_custom_dns = with_custom_dns.cst_decode();
|
||||||
move |context| async move {
|
move |context| async move {
|
||||||
transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>(
|
transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>(
|
||||||
(move || async move {
|
(move || async move {
|
||||||
@ -178,6 +180,7 @@ fn wire__crate__api__http_api__fetch_impl(
|
|||||||
api_headers,
|
api_headers,
|
||||||
api_input_data,
|
api_input_data,
|
||||||
api_with_ip_address,
|
api_with_ip_address,
|
||||||
|
api_with_custom_dns,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(output_ok)
|
Ok(output_ok)
|
||||||
@ -567,6 +570,17 @@ impl SseDecode for Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseDecode for Option<bool> {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
|
if (<bool>::sse_decode(deserializer)) {
|
||||||
|
return Some(<bool>::sse_decode(deserializer));
|
||||||
|
} else {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseDecode for Option<u64> {
|
impl SseDecode for Option<u64> {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
fn sse_decode(deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer) -> Self {
|
||||||
@ -1008,6 +1022,16 @@ impl SseEncode for Option<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SseEncode for Option<bool> {
|
||||||
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
|
<bool>::sse_encode(self.is_some(), serializer);
|
||||||
|
if let Some(value) = self {
|
||||||
|
<bool>::sse_encode(value, serializer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SseEncode for Option<u64> {
|
impl SseEncode for Option<u64> {
|
||||||
// Codec=Sse (Serialization based), see doc to use other codecs
|
// Codec=Sse (Serialization based), see doc to use other codecs
|
||||||
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
fn sse_encode(self, serializer: &mut flutter_rust_bridge::for_generated::SseSerializer) {
|
||||||
@ -1180,6 +1204,12 @@ mod io {
|
|||||||
String::from_utf8(vec).unwrap()
|
String::from_utf8(vec).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl CstDecode<bool> for *mut bool {
|
||||||
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
|
fn cst_decode(self) -> bool {
|
||||||
|
unsafe { *flutter_rust_bridge::for_generated::box_from_leak_ptr(self) }
|
||||||
|
}
|
||||||
|
}
|
||||||
impl CstDecode<crate::api::asar_api::RsiLauncherAsarData> for *mut wire_cst_rsi_launcher_asar_data {
|
impl CstDecode<crate::api::asar_api::RsiLauncherAsarData> for *mut wire_cst_rsi_launcher_asar_data {
|
||||||
// Codec=Cst (C-struct based), see doc to use other codecs
|
// Codec=Cst (C-struct based), see doc to use other codecs
|
||||||
fn cst_decode(self) -> crate::api::asar_api::RsiLauncherAsarData {
|
fn cst_decode(self) -> crate::api::asar_api::RsiLauncherAsarData {
|
||||||
@ -1372,6 +1402,7 @@ mod io {
|
|||||||
headers: *mut wire_cst_list_record_string_string,
|
headers: *mut wire_cst_list_record_string_string,
|
||||||
input_data: *mut wire_cst_list_prim_u_8_strict,
|
input_data: *mut wire_cst_list_prim_u_8_strict,
|
||||||
with_ip_address: *mut wire_cst_list_prim_u_8_strict,
|
with_ip_address: *mut wire_cst_list_prim_u_8_strict,
|
||||||
|
with_custom_dns: *mut bool,
|
||||||
) {
|
) {
|
||||||
wire__crate__api__http_api__fetch_impl(
|
wire__crate__api__http_api__fetch_impl(
|
||||||
port_,
|
port_,
|
||||||
@ -1380,6 +1411,7 @@ mod io {
|
|||||||
headers,
|
headers,
|
||||||
input_data,
|
input_data,
|
||||||
with_ip_address,
|
with_ip_address,
|
||||||
|
with_custom_dns,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1436,6 +1468,11 @@ mod io {
|
|||||||
wire__crate__api__win32_api__set_foreground_window_impl(port_, window_name)
|
wire__crate__api__win32_api__set_foreground_window_impl(port_, window_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_bool(value: bool) -> *mut bool {
|
||||||
|
flutter_rust_bridge::for_generated::new_leak_box_ptr(value)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_rsi_launcher_asar_data(
|
pub extern "C" fn frbgen_starcitizen_doctor_cst_new_box_autoadd_rsi_launcher_asar_data(
|
||||||
) -> *mut wire_cst_rsi_launcher_asar_data {
|
) -> *mut wire_cst_rsi_launcher_asar_data {
|
||||||
|
@ -48,15 +48,19 @@ static DEFAULT_HEADER: Lazy<RwLock<HeaderMap>> = Lazy::new(|| RwLock::from(Heade
|
|||||||
static DNS_CLIENT: Lazy<Arc<dns::MyHickoryDnsResolver>> =
|
static DNS_CLIENT: Lazy<Arc<dns::MyHickoryDnsResolver>> =
|
||||||
Lazy::new(|| Arc::from(dns::MyHickoryDnsResolver::default()));
|
Lazy::new(|| Arc::from(dns::MyHickoryDnsResolver::default()));
|
||||||
|
|
||||||
static HTTP_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| new_http_client(true));
|
static HTTP_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| new_http_client(true,true));
|
||||||
|
|
||||||
fn new_http_client(keep_alive: bool) -> reqwest::Client {
|
static HTTP_CLIENT_NO_CUSTOM_DNS: Lazy<reqwest::Client> = Lazy::new(|| new_http_client(true,false));
|
||||||
|
|
||||||
|
fn new_http_client(keep_alive: bool,with_custom_dns: bool) -> reqwest::Client {
|
||||||
let mut c = reqwest::Client::builder()
|
let mut c = reqwest::Client::builder()
|
||||||
.dns_resolver(DNS_CLIENT.clone())
|
|
||||||
.use_rustls_tls()
|
.use_rustls_tls()
|
||||||
.connect_timeout(Duration::from_secs(10))
|
.connect_timeout(Duration::from_secs(10))
|
||||||
.gzip(true)
|
.gzip(true)
|
||||||
.no_proxy();
|
.no_proxy();
|
||||||
|
if with_custom_dns {
|
||||||
|
c = c.dns_resolver(DNS_CLIENT.clone());
|
||||||
|
}
|
||||||
if !keep_alive {
|
if !keep_alive {
|
||||||
c = c.tcp_keepalive(None);
|
c = c.tcp_keepalive(None);
|
||||||
} else {
|
} else {
|
||||||
@ -82,15 +86,15 @@ pub async fn fetch(
|
|||||||
headers: Option<HashMap<String, String>>,
|
headers: Option<HashMap<String, String>>,
|
||||||
input_data: Option<Vec<u8>>,
|
input_data: Option<Vec<u8>>,
|
||||||
with_ip_address: Option<String>,
|
with_ip_address: Option<String>,
|
||||||
|
with_custom_dns: Option<bool>,
|
||||||
) -> anyhow::Result<RustHttpResponse> {
|
) -> anyhow::Result<RustHttpResponse> {
|
||||||
let address_clone = with_ip_address.clone();
|
let address_clone = with_ip_address.clone();
|
||||||
let url_clone = url.clone();
|
let url_clone = url.clone();
|
||||||
|
|
||||||
if address_clone.is_some() {
|
if address_clone.is_some() {
|
||||||
let addr = std::net::IpAddr::from_str(with_ip_address.unwrap().as_str()).unwrap();
|
let addr = std::net::IpAddr::from_str(with_ip_address.unwrap().as_str())?;
|
||||||
let mut hosts = dns::MY_HOSTS_MAP.write().unwrap();
|
let mut hosts = dns::MY_HOSTS_MAP.write().unwrap();
|
||||||
let url_host = Url::from_str(url.as_str())
|
let url_host = Url::from_str(url.as_str())?
|
||||||
.unwrap()
|
|
||||||
.host()
|
.host()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string();
|
.to_string();
|
||||||
@ -105,9 +109,13 @@ pub async fn fetch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut req = if address_clone.is_some() {
|
let mut req = if address_clone.is_some() {
|
||||||
_mix_header(new_http_client(false).request(method, url_clone), headers)
|
_mix_header(new_http_client(false,with_custom_dns.unwrap_or(false)).request(method, url_clone), headers)
|
||||||
} else {
|
} else {
|
||||||
_mix_header(HTTP_CLIENT.request(method, url_clone), headers)
|
if with_custom_dns.unwrap_or(false) {
|
||||||
|
_mix_header(HTTP_CLIENT.request(method, url_clone), headers)
|
||||||
|
}else {
|
||||||
|
_mix_header(HTTP_CLIENT_NO_CUSTOM_DNS.request(method, url_clone), headers)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if input_data.is_some() {
|
if input_data.is_some() {
|
||||||
req = req.body(input_data.unwrap());
|
req = req.body(input_data.unwrap());
|
||||||
|
Loading…
Reference in New Issue
Block a user