initial
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
library flutter_tor;
|
||||
|
||||
export 'src/tor_api.g.dart'
|
||||
show
|
||||
TransportType,
|
||||
TorConfiguration,
|
||||
TorStartResult,
|
||||
TorStatus,
|
||||
TorLogMessage,
|
||||
IPtProxyController;
|
||||
|
||||
export 'src/flutter_tor.dart';
|
||||
@@ -0,0 +1,92 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tor/src/tor_api.g.dart';
|
||||
|
||||
/// Flutter Tor implementation
|
||||
/// Provides a clean Dart API over the Pigeon-generated code
|
||||
class FlutterTor {
|
||||
FlutterTor() {
|
||||
_torLogApi = _TorLogApiImpl(
|
||||
onLog: _logController.add,
|
||||
onStatus: _statusController.add,
|
||||
onBootstrap: _bootstrapController.add,
|
||||
);
|
||||
|
||||
// Register the Flutter API handler so native can call us
|
||||
TorLogApi.setUp(_torLogApi);
|
||||
}
|
||||
|
||||
final _torApi = TorApi();
|
||||
late final _TorLogApiImpl _torLogApi;
|
||||
|
||||
final _logController = StreamController<TorLogMessage>.broadcast();
|
||||
final _statusController = StreamController<TorStatus>.broadcast();
|
||||
final _bootstrapController = StreamController<int>.broadcast();
|
||||
|
||||
/// Stream of log messages from Tor
|
||||
Stream<TorLogMessage> get logStream => _logController.stream;
|
||||
|
||||
/// Stream of status changes
|
||||
Stream<TorStatus> get statusStream => _statusController.stream;
|
||||
|
||||
/// Stream of bootstrap progress updates (0-100)
|
||||
Stream<int> get bootstrapProgressStream => _bootstrapController.stream;
|
||||
|
||||
/// Start Tor with the given configuration
|
||||
Future<int> start(TorConfiguration config) async {
|
||||
return await _torApi.startTor(config);
|
||||
}
|
||||
|
||||
/// Stop Tor
|
||||
Future<void> stop() async {
|
||||
await _torApi.stopTor();
|
||||
}
|
||||
|
||||
/// Get current Tor status
|
||||
Future<TorStatus> getStatus() async {
|
||||
return await _torApi.getStatus();
|
||||
}
|
||||
|
||||
/// Request a new Tor identity (new circuit)
|
||||
Future<void> requestNewIdentity() async {
|
||||
await _torApi.requestNewIdentity();
|
||||
}
|
||||
|
||||
/// Dispose resources
|
||||
void dispose() {
|
||||
// Unregister the Flutter API handler
|
||||
TorLogApi.setUp(null);
|
||||
|
||||
_logController.close();
|
||||
_statusController.close();
|
||||
_bootstrapController.close();
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation of TorLogApi for receiving callbacks from native
|
||||
class _TorLogApiImpl extends TorLogApi {
|
||||
_TorLogApiImpl({
|
||||
required this.onLog,
|
||||
required this.onStatus,
|
||||
required this.onBootstrap,
|
||||
});
|
||||
|
||||
final void Function(TorLogMessage) onLog;
|
||||
final void Function(TorStatus) onStatus;
|
||||
final void Function(int) onBootstrap;
|
||||
|
||||
@override
|
||||
void onLogMessage(TorLogMessage log) {
|
||||
onLog(log);
|
||||
}
|
||||
|
||||
@override
|
||||
void onStatusChanged(TorStatus status) {
|
||||
onStatus(status);
|
||||
}
|
||||
|
||||
@override
|
||||
void onBootstrapProgress(int progress) {
|
||||
onBootstrap(progress);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,538 @@
|
||||
// Autogenerated from Pigeon (v26.1.5), do not edit directly.
|
||||
// See also: https://pub.dev/packages/pigeon
|
||||
// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
|
||||
|
||||
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
PlatformException _createConnectionError(String channelName) {
|
||||
return PlatformException(
|
||||
code: 'channel-error',
|
||||
message: 'Unable to establish connection on channel: "$channelName".',
|
||||
);
|
||||
}
|
||||
|
||||
List<Object?> wrapResponse({Object? result, PlatformException? error, bool empty = false}) {
|
||||
if (empty) {
|
||||
return <Object?>[];
|
||||
}
|
||||
if (error == null) {
|
||||
return <Object?>[result];
|
||||
}
|
||||
return <Object?>[error.code, error.message, error.details];
|
||||
}
|
||||
bool _deepEquals(Object? a, Object? b) {
|
||||
if (a is List && b is List) {
|
||||
return a.length == b.length &&
|
||||
a.indexed
|
||||
.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]));
|
||||
}
|
||||
if (a is Map && b is Map) {
|
||||
return a.length == b.length && a.entries.every((MapEntry<Object?, Object?> entry) =>
|
||||
(b as Map<Object?, Object?>).containsKey(entry.key) &&
|
||||
_deepEquals(entry.value, b[entry.key]));
|
||||
}
|
||||
return a == b;
|
||||
}
|
||||
|
||||
|
||||
/// Transport types for Tor connections
|
||||
enum TransportType {
|
||||
/// Direct Tor connection (no bridges)
|
||||
none,
|
||||
/// obfs4 pluggable transport
|
||||
obfs4,
|
||||
/// Snowflake pluggable transport (default broker)
|
||||
snowflake,
|
||||
/// Snowflake via AMP cache
|
||||
snowflakeAmp,
|
||||
/// Meek pluggable transport
|
||||
meek,
|
||||
/// Meek via Azure CDN
|
||||
meekAzure,
|
||||
/// WebTunnel pluggable transport
|
||||
webtunnel,
|
||||
/// Custom bridge lines (passthrough)
|
||||
custom,
|
||||
}
|
||||
|
||||
/// Configuration for starting Tor
|
||||
class TorConfiguration {
|
||||
TorConfiguration({
|
||||
required this.transport,
|
||||
required this.bridgeLines,
|
||||
this.entryNodeCountries,
|
||||
this.exitNodeCountries,
|
||||
this.strictNodes,
|
||||
});
|
||||
|
||||
/// Transport type to use
|
||||
TransportType transport;
|
||||
|
||||
/// Bridge lines for the transport (empty for direct connection)
|
||||
List<String> bridgeLines;
|
||||
|
||||
/// Entry node countries (ISO 3166-1 alpha-2, comma-separated, e.g., "de,fr,nl")
|
||||
String? entryNodeCountries;
|
||||
|
||||
/// Exit node countries (ISO 3166-1 alpha-2, comma-separated, e.g., "ch,is,se")
|
||||
String? exitNodeCountries;
|
||||
|
||||
/// If true, never use nodes outside specified countries
|
||||
bool? strictNodes;
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
transport,
|
||||
bridgeLines,
|
||||
entryNodeCountries,
|
||||
exitNodeCountries,
|
||||
strictNodes,
|
||||
];
|
||||
}
|
||||
|
||||
Object encode() {
|
||||
return _toList(); }
|
||||
|
||||
static TorConfiguration decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return TorConfiguration(
|
||||
transport: result[0]! as TransportType,
|
||||
bridgeLines: (result[1] as List<Object?>?)!.cast<String>(),
|
||||
entryNodeCountries: result[2] as String?,
|
||||
exitNodeCountries: result[3] as String?,
|
||||
strictNodes: result[4] as bool?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
bool operator ==(Object other) {
|
||||
if (other is! TorConfiguration || other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return _deepEquals(encode(), other.encode());
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
int get hashCode => Object.hashAll(_toList())
|
||||
;
|
||||
}
|
||||
|
||||
/// Current Tor status
|
||||
class TorStatus {
|
||||
TorStatus({
|
||||
required this.isRunning,
|
||||
this.socksPort,
|
||||
required this.bootstrapProgress,
|
||||
this.currentCircuit,
|
||||
this.exitNodeCountry,
|
||||
});
|
||||
|
||||
/// Whether Tor is running
|
||||
bool isRunning;
|
||||
|
||||
/// SOCKS proxy port (if running)
|
||||
int? socksPort;
|
||||
|
||||
/// Bootstrap progress (0-100)
|
||||
int bootstrapProgress;
|
||||
|
||||
/// Current circuit ID
|
||||
String? currentCircuit;
|
||||
|
||||
/// Exit node country code
|
||||
String? exitNodeCountry;
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
isRunning,
|
||||
socksPort,
|
||||
bootstrapProgress,
|
||||
currentCircuit,
|
||||
exitNodeCountry,
|
||||
];
|
||||
}
|
||||
|
||||
Object encode() {
|
||||
return _toList(); }
|
||||
|
||||
static TorStatus decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return TorStatus(
|
||||
isRunning: result[0]! as bool,
|
||||
socksPort: result[1] as int?,
|
||||
bootstrapProgress: result[2]! as int,
|
||||
currentCircuit: result[3] as String?,
|
||||
exitNodeCountry: result[4] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
bool operator ==(Object other) {
|
||||
if (other is! TorStatus || other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return _deepEquals(encode(), other.encode());
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
int get hashCode => Object.hashAll(_toList())
|
||||
;
|
||||
}
|
||||
|
||||
/// Log message from Tor
|
||||
class TorLogMessage {
|
||||
TorLogMessage({
|
||||
required this.severity,
|
||||
required this.message,
|
||||
required this.timestamp,
|
||||
});
|
||||
|
||||
/// Log severity (NOTICE, WARN, ERR, DEBUG)
|
||||
String severity;
|
||||
|
||||
/// Log message
|
||||
String message;
|
||||
|
||||
/// Timestamp (milliseconds since epoch)
|
||||
int timestamp;
|
||||
|
||||
List<Object?> _toList() {
|
||||
return <Object?>[
|
||||
severity,
|
||||
message,
|
||||
timestamp,
|
||||
];
|
||||
}
|
||||
|
||||
Object encode() {
|
||||
return _toList(); }
|
||||
|
||||
static TorLogMessage decode(Object result) {
|
||||
result as List<Object?>;
|
||||
return TorLogMessage(
|
||||
severity: result[0]! as String,
|
||||
message: result[1]! as String,
|
||||
timestamp: result[2]! as int,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
bool operator ==(Object other) {
|
||||
if (other is! TorLogMessage || other.runtimeType != runtimeType) {
|
||||
return false;
|
||||
}
|
||||
if (identical(this, other)) {
|
||||
return true;
|
||||
}
|
||||
return _deepEquals(encode(), other.encode());
|
||||
}
|
||||
|
||||
@override
|
||||
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
||||
int get hashCode => Object.hashAll(_toList())
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
class _PigeonCodec extends StandardMessageCodec {
|
||||
const _PigeonCodec();
|
||||
@override
|
||||
void writeValue(WriteBuffer buffer, Object? value) {
|
||||
if (value is int) {
|
||||
buffer.putUint8(4);
|
||||
buffer.putInt64(value);
|
||||
} else if (value is TransportType) {
|
||||
buffer.putUint8(129);
|
||||
writeValue(buffer, value.index);
|
||||
} else if (value is TorConfiguration) {
|
||||
buffer.putUint8(130);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is TorStatus) {
|
||||
buffer.putUint8(131);
|
||||
writeValue(buffer, value.encode());
|
||||
} else if (value is TorLogMessage) {
|
||||
buffer.putUint8(132);
|
||||
writeValue(buffer, value.encode());
|
||||
} else {
|
||||
super.writeValue(buffer, value);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Object? readValueOfType(int type, ReadBuffer buffer) {
|
||||
switch (type) {
|
||||
case 129:
|
||||
final value = readValue(buffer) as int?;
|
||||
return value == null ? null : TransportType.values[value];
|
||||
case 130:
|
||||
return TorConfiguration.decode(readValue(buffer)!);
|
||||
case 131:
|
||||
return TorStatus.decode(readValue(buffer)!);
|
||||
case 132:
|
||||
return TorLogMessage.decode(readValue(buffer)!);
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Host API (Flutter -> Native)
|
||||
class TorApi {
|
||||
/// Constructor for [TorApi]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
TorApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
/// Start Tor with the given configuration
|
||||
/// Returns a Future to avoid blocking the main thread
|
||||
Future<int> startTor(TorConfiguration config) async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_tor.TorApi.startTor$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[config]);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as int?)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// Stop Tor
|
||||
Future<void> stopTor() async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_tor.TorApi.stopTor$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// Get current status
|
||||
Future<TorStatus> getStatus() async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_tor.TorApi.getStatus$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as TorStatus?)!;
|
||||
}
|
||||
}
|
||||
|
||||
/// Request a new Tor identity (new circuit)
|
||||
Future<void> requestNewIdentity() async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_tor.TorApi.requestNewIdentity$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Flutter API (Native -> Flutter)
|
||||
abstract class TorLogApi {
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
/// Called when a log message is received
|
||||
void onLogMessage(TorLogMessage log);
|
||||
|
||||
/// Called when status changes
|
||||
void onStatusChanged(TorStatus status);
|
||||
|
||||
static void setUp(TorLogApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
|
||||
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
{
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_tor.TorLogApi.onLogMessage$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_tor.TorLogApi.onLogMessage was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final TorLogMessage? arg_log = (args[0] as TorLogMessage?);
|
||||
assert(arg_log != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_tor.TorLogApi.onLogMessage was null, expected non-null TorLogMessage.');
|
||||
try {
|
||||
api.onLogMessage(arg_log!);
|
||||
return wrapResponse(empty: true);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
{
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
'dev.flutter.pigeon.flutter_tor.TorLogApi.onStatusChanged$messageChannelSuffix', pigeonChannelCodec,
|
||||
binaryMessenger: binaryMessenger);
|
||||
if (api == null) {
|
||||
pigeonVar_channel.setMessageHandler(null);
|
||||
} else {
|
||||
pigeonVar_channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_tor.TorLogApi.onStatusChanged was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final TorStatus? arg_status = (args[0] as TorStatus?);
|
||||
assert(arg_status != null,
|
||||
'Argument for dev.flutter.pigeon.flutter_tor.TorLogApi.onStatusChanged was null, expected non-null TorStatus.');
|
||||
try {
|
||||
api.onStatusChanged(arg_status!);
|
||||
return wrapResponse(empty: true);
|
||||
} on PlatformException catch (e) {
|
||||
return wrapResponse(error: e);
|
||||
} catch (e) {
|
||||
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class IPtProxyController {
|
||||
/// Constructor for [IPtProxyController]. The [binaryMessenger] named argument is
|
||||
/// available for dependency injection. If it is left null, the default
|
||||
/// BinaryMessenger will be used which routes to the host platform.
|
||||
IPtProxyController({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
||||
: pigeonVar_binaryMessenger = binaryMessenger,
|
||||
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
||||
final BinaryMessenger? pigeonVar_binaryMessenger;
|
||||
|
||||
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
||||
|
||||
final String pigeonVar_messageChannelSuffix;
|
||||
|
||||
Future<int> start(TransportType proxyType, String proxy) async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_tor.IPtProxyController.start$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[proxyType, proxy]);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else if (pigeonVar_replyList[0] == null) {
|
||||
throw PlatformException(
|
||||
code: 'null-error',
|
||||
message: 'Host platform returned null value for non-null return value.',
|
||||
);
|
||||
} else {
|
||||
return (pigeonVar_replyList[0] as int?)!;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> stop(TransportType proxyType) async {
|
||||
final pigeonVar_channelName = 'dev.flutter.pigeon.flutter_tor.IPtProxyController.stop$pigeonVar_messageChannelSuffix';
|
||||
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
||||
pigeonVar_channelName,
|
||||
pigeonChannelCodec,
|
||||
binaryMessenger: pigeonVar_binaryMessenger,
|
||||
);
|
||||
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[proxyType]);
|
||||
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
||||
if (pigeonVar_replyList == null) {
|
||||
throw _createConnectionError(pigeonVar_channelName);
|
||||
} else if (pigeonVar_replyList.length > 1) {
|
||||
throw PlatformException(
|
||||
code: pigeonVar_replyList[0]! as String,
|
||||
message: pigeonVar_replyList[1] as String?,
|
||||
details: pigeonVar_replyList[2],
|
||||
);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user