singbox_ffi 0.1.3 copy "singbox_ffi: ^0.1.3" to clipboard
singbox_ffi: ^0.1.3 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');
    print('service state: ${service.state().state.name}');
    for (final event in service.drainLogs()) {
      if (event.isReset) {
        print('logs reset');
      } else {
        print('[${event.levelName}] ${event.message}');
      }
    }
    service.reload(configJson);
  } finally {
    service.close();
  }
}
0
likes
150
points
250
downloads

Documentation

API reference

Publisher

verified publisherloafman.top

Weekly Downloads

Flutter FFI bindings and platform packaging for embedding the sing-box libbox core from Dart.

Repository (GitHub)
View/report issues

Topics

#ffi #flutter-ffi #sing-box #proxy #networking

License

unknown (license)

Dependencies

ffi, flutter

More

Packages that depend on singbox_ffi

Packages that implement singbox_ffi