singbox_ffi 0.1.1
singbox_ffi: ^0.1.1 copied to clipboard
Flutter FFI bindings and platform packaging for embedding the sing-box libbox core from Dart.
example/main.dart
import 'package:singbox_ffi/singbox_ffi.dart';
const configJson = '''
{
"log": {"level": "info"},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080
}
],
"outbounds": [
{"type": "direct", "tag": "direct"}
],
"route": {"final": "direct"}
}
''';
void main(List<String> args) {
final libraryPath = args.isEmpty ? null : args.first;
final singbox = SingboxFfi.openBundled(libraryPath);
print('sing-box version: ${singbox.version()}');
print('Go version: ${singbox.goVersion()}');
singbox.init();
singbox.checkConfig(configJson);
final service = singbox.start(configJson);
try {
print('mixed proxy listening on 127.0.0.1:2080');
service.reload(configJson);
} finally {
service.close();
}
}