1
+ import 'dart:convert' ;
1
2
import 'dart:io' ;
2
3
import 'package:socks5_proxy/socks_client.dart' ;
3
4
import 'package:tor/tor.dart' ;
@@ -75,7 +76,7 @@ class ProxyWrapper {
75
76
});
76
77
}
77
78
if (body != null ) {
78
- request.write ( body);
79
+ request.add (utf8. encode ( body) );
79
80
}
80
81
await request.flush ();
81
82
return await request.close ();
@@ -94,7 +95,7 @@ class ProxyWrapper {
94
95
});
95
96
}
96
97
if (body != null ) {
97
- request.write ( body);
98
+ request.add (utf8. encode ( body) );
98
99
}
99
100
await request.flush ();
100
101
return await request.close ();
@@ -170,15 +171,26 @@ class ProxyWrapper {
170
171
Uri ? clearnetUri,
171
172
Uri ? onionUri,
172
173
String ? body,
174
+ bool allowMitmMoneroBypassSSLCheck = false ,
173
175
}) async {
174
176
HttpClient ? torClient;
177
+ HttpClient clearnetClient = HttpClient ();
178
+
179
+ if (allowMitmMoneroBypassSSLCheck) {
180
+ clearnetClient.badCertificateCallback =
181
+ ((X509Certificate cert, String host, int port) => true );
182
+ }
183
+
175
184
bool torEnabled = CakeTor .instance.started;
176
185
177
186
if (torEnabled) {
178
187
try {
179
188
torClient = await getProxyHttpClient (portOverride: portOverride);
180
189
} catch (_) {}
181
-
190
+ if (allowMitmMoneroBypassSSLCheck) {
191
+ torClient! .badCertificateCallback =
192
+ ((X509Certificate cert, String host, int port) => true );
193
+ }
182
194
if (onionUri != null ) {
183
195
try {
184
196
return await makePost (
@@ -207,7 +219,7 @@ class ProxyWrapper {
207
219
return HttpOverrides .runZoned (
208
220
() async {
209
221
return await makePost (
210
- client: HttpClient () ,
222
+ client: clearnetClient ,
211
223
uri: clearnetUri,
212
224
headers: headers,
213
225
body: body,
0 commit comments