更新最新的Leaf 动态库
更新最新的Leaf 动态库
This commit is contained in:
@@ -1 +0,0 @@
|
||||
Run the `misc/download_leaf.sh` script to download library files.
|
||||
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
module LeafFFI {
|
||||
umbrella header "leaf.h"
|
||||
link "leaf"
|
||||
export *
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1273FB482B1EBC5E005B78AF /* leaf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1273FB472B1EBC5E005B78AF /* leaf.xcframework */; };
|
||||
1273FB492B1EBCA4005B78AF /* leaf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1273FB472B1EBC5E005B78AF /* leaf.xcframework */; };
|
||||
1273FB4A2B1EBCA4005B78AF /* leaf.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1273FB472B1EBC5E005B78AF /* leaf.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
2FD21F1125A363E300F556E0 /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FD21F1025A363E300F556E0 /* PacketTunnelProvider.swift */; };
|
||||
2FD21F1625A363E300F556E0 /* PacketTunnel.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 2FD21F0D25A363E300F556E0 /* PacketTunnel.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -14,7 +17,6 @@
|
||||
31DA31B2DE002F172285FB1C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A9C0075B77637136AF52D8B /* Pods_Runner.framework */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3E06F985293FACBB00E04D92 /* PacketTunnelProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FD21F1025A363E300F556E0 /* PacketTunnelProvider.swift */; };
|
||||
3E06F986293FAD1C00E04D92 /* libleaf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA6B288293FA83000B2BABC /* libleaf.a */; };
|
||||
3E06F989293FAFC600E04D92 /* LeafAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E06F988293FAFC600E04D92 /* LeafAdapter.swift */; };
|
||||
3E06F98A293FAFC600E04D92 /* LeafAdapter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E06F988293FAFC600E04D92 /* LeafAdapter.swift */; };
|
||||
3E06F98C293FB8F600E04D92 /* TunnelConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E06F98B293FB8F600E04D92 /* TunnelConfiguration.swift */; };
|
||||
@@ -29,7 +31,6 @@
|
||||
3EA6B280293F6AB900B2BABC /* URL+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EA6B277293F1D1600B2BABC /* URL+Helpers.swift */; };
|
||||
3EA6B281293F6AF800B2BABC /* template.conf in Resources */ = {isa = PBXBuildFile; fileRef = 3EA6B275293F1AC500B2BABC /* template.conf */; };
|
||||
3EA6B282293F6BA500B2BABC /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EA6B279293F1FAD00B2BABC /* Logger.swift */; };
|
||||
3EA6B289293FA83E00B2BABC /* libleaf.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EA6B288293FA83000B2BABC /* libleaf.a */; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
7A31DD8228420C0B00E82EE1 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FD21EF825A363AA00F556E0 /* NetworkExtension.framework */; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
@@ -49,6 +50,17 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
1273FB4B2B1EBCA4005B78AF /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
1273FB4A2B1EBCA4005B78AF /* leaf.xcframework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
2FD21F0625A363AA00F556E0 /* Embed App Extensions */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -73,6 +85,7 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1273FB472B1EBC5E005B78AF /* leaf.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = leaf.xcframework; sourceTree = "<group>"; };
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
2F50954A25A36FD0001A32D5 /* VPNManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNManager.swift; sourceTree = "<group>"; };
|
||||
@@ -90,7 +103,6 @@
|
||||
3EA6B277293F1D1600B2BABC /* URL+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Helpers.swift"; sourceTree = "<group>"; };
|
||||
3EA6B279293F1FAD00B2BABC /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
|
||||
3EA6B287293FA53500B2BABC /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
|
||||
3EA6B288293FA83000B2BABC /* libleaf.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libleaf.a; path = LeafFFI/libleaf.a; sourceTree = "<group>"; };
|
||||
4A9C0075B77637136AF52D8B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@@ -113,7 +125,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7A31DD8228420C0B00E82EE1 /* NetworkExtension.framework in Frameworks */,
|
||||
3EA6B289293FA83E00B2BABC /* libleaf.a in Frameworks */,
|
||||
1273FB492B1EBCA4005B78AF /* leaf.xcframework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -121,10 +133,10 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3E06F986293FAD1C00E04D92 /* libleaf.a in Frameworks */,
|
||||
2FD21F2425A364B700F556E0 /* NetworkExtension.framework in Frameworks */,
|
||||
DBC6F25A26C78B1D91884CE1 /* Pods_Runner.framework in Frameworks */,
|
||||
31DA31B2DE002F172285FB1C /* Pods_Runner.framework in Frameworks */,
|
||||
1273FB482B1EBC5E005B78AF /* leaf.xcframework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -234,7 +246,7 @@
|
||||
F6BCB37E43B89DAB5A76B9D0 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3EA6B288293FA83000B2BABC /* libleaf.a */,
|
||||
1273FB472B1EBC5E005B78AF /* leaf.xcframework */,
|
||||
2FD21EF825A363AA00F556E0 /* NetworkExtension.framework */,
|
||||
4A9C0075B77637136AF52D8B /* Pods_Runner.framework */,
|
||||
);
|
||||
@@ -251,6 +263,7 @@
|
||||
2FD21F0925A363E300F556E0 /* Sources */,
|
||||
2FD21F0A25A363E300F556E0 /* Frameworks */,
|
||||
2FD21F0B25A363E300F556E0 /* Resources */,
|
||||
1273FB4B2B1EBCA4005B78AF /* Embed Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -559,7 +572,6 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
"$(PROJECT_DIR)/LeafFFI",
|
||||
);
|
||||
MODULEMAP_FILE = "${PROJECT_DIR}/LeafFFI/module.modulemap";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.sail-tunnel.zeus1";
|
||||
@@ -568,7 +580,7 @@
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/LeafFFI";
|
||||
SWIFT_INCLUDE_PATHS = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
@@ -604,10 +616,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/LeafFFI",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
MARKETING_VERSION = 1.0.6;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
@@ -615,7 +624,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/LeafFFI";
|
||||
SWIFT_INCLUDE_PATHS = "";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
@@ -650,16 +659,13 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/LeafFFI",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
MARKETING_VERSION = 1.0.6;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.sail-tunnel.zeus1.PacketTunnel1";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/LeafFFI";
|
||||
SWIFT_INCLUDE_PATHS = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
@@ -693,16 +699,13 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/LeafFFI",
|
||||
);
|
||||
LIBRARY_SEARCH_PATHS = "$(inherited)";
|
||||
MARKETING_VERSION = 1.0.6;
|
||||
MTL_FAST_MATH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.sail-tunnel.zeus1.PacketTunnel1";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/LeafFFI";
|
||||
SWIFT_INCLUDE_PATHS = "";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
@@ -847,7 +850,6 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
"$(PROJECT_DIR)/LeafFFI",
|
||||
);
|
||||
MODULEMAP_FILE = "${PROJECT_DIR}/LeafFFI/module.modulemap";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.sail-tunnel.zeus1";
|
||||
@@ -856,7 +858,7 @@
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/LeafFFI";
|
||||
SWIFT_INCLUDE_PATHS = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_VERSION = 5.0;
|
||||
@@ -891,7 +893,6 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Flutter",
|
||||
"$(PROJECT_DIR)/LeafFFI",
|
||||
);
|
||||
MODULEMAP_FILE = "${PROJECT_DIR}/LeafFFI/module.modulemap";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.sail-tunnel.zeus1";
|
||||
@@ -900,7 +901,7 @@
|
||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||
SUPPORTS_MACCATALYST = NO;
|
||||
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = YES;
|
||||
SWIFT_INCLUDE_PATHS = "$(PROJECT_DIR)/LeafFFI";
|
||||
SWIFT_INCLUDE_PATHS = "";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = 1;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
import Foundation
|
||||
import NetworkExtension
|
||||
import LeafFFI
|
||||
//import LeafFFI
|
||||
import leaf
|
||||
|
||||
public enum LeafAdapterError: Error {
|
||||
/// Failure to locate tunnel file descriptor.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import NetworkExtension
|
||||
import LeafFFI
|
||||
|
||||
//import LeafFFI
|
||||
import leaf
|
||||
class PacketTunnelProvider: NEPacketTunnelProvider {
|
||||
|
||||
private lazy var adapter: LeafAdapater = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
import NetworkExtension
|
||||
import LeafFFI
|
||||
//import LeafFFI
|
||||
import leaf
|
||||
|
||||
extension NEVPNStatus: CustomStringConvertible {
|
||||
public var description: String {
|
||||
|
||||
@@ -4,6 +4,8 @@ logoutput = {{leafLogFile}}
|
||||
dns-server = 223.5.5.5, 114.114.114.114
|
||||
tun-fd = {{tunFd}}
|
||||
routing-domain-resolve = true
|
||||
socks-interface = 127.0.0.1
|
||||
socks-port = 1080
|
||||
|
||||
[Proxy]
|
||||
Direct = direct
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>macos-arm64_x86_64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libleaf.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>macos</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libleaf.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64_x86_64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libleaf.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
<string>x86_64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,4 @@
|
||||
module leaf {
|
||||
header "leaf.h"
|
||||
export *
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* No error.
|
||||
*/
|
||||
#define ERR_OK 0
|
||||
|
||||
/**
|
||||
* Config path error.
|
||||
*/
|
||||
#define ERR_CONFIG_PATH 1
|
||||
|
||||
/**
|
||||
* Config parsing error.
|
||||
*/
|
||||
#define ERR_CONFIG 2
|
||||
|
||||
/**
|
||||
* IO error.
|
||||
*/
|
||||
#define ERR_IO 3
|
||||
|
||||
/**
|
||||
* Config file watcher error.
|
||||
*/
|
||||
#define ERR_WATCHER 4
|
||||
|
||||
/**
|
||||
* Async channel send error.
|
||||
*/
|
||||
#define ERR_ASYNC_CHANNEL_SEND 5
|
||||
|
||||
/**
|
||||
* Sync channel receive error.
|
||||
*/
|
||||
#define ERR_SYNC_CHANNEL_RECV 6
|
||||
|
||||
/**
|
||||
* Runtime manager error.
|
||||
*/
|
||||
#define ERR_RUNTIME_MANAGER 7
|
||||
|
||||
/**
|
||||
* No associated config file.
|
||||
*/
|
||||
#define ERR_NO_CONFIG_FILE 8
|
||||
|
||||
/**
|
||||
* Starts leaf with options, on a successful start this function blocks the current
|
||||
* thread.
|
||||
*
|
||||
* @note This is not a stable API, parameters will change from time to time.
|
||||
*
|
||||
* @param rt_id A unique ID to associate this leaf instance, this is required when
|
||||
* calling subsequent FFI functions, e.g. reload, shutdown.
|
||||
* @param config_path The path of the config file, must be a file with suffix .conf
|
||||
* or .json, according to the enabled features.
|
||||
* @param auto_reload Enabls auto reloading when config file changes are detected,
|
||||
* takes effect only when the "auto-reload" feature is enabled.
|
||||
* @param multi_thread Whether to use a multi-threaded runtime.
|
||||
* @param auto_threads Sets the number of runtime worker threads automatically,
|
||||
* takes effect only when multi_thread is true.
|
||||
* @param threads Sets the number of runtime worker threads, takes effect when
|
||||
* multi_thread is true, but can be overridden by auto_threads.
|
||||
* @param stack_size Sets stack size of the runtime worker threads, takes effect when
|
||||
* multi_thread is true.
|
||||
* @return ERR_OK on finish running, any other errors means a startup failure.
|
||||
*/
|
||||
int32_t leaf_run_with_options(uint16_t rt_id,
|
||||
const char *config_path,
|
||||
bool auto_reload,
|
||||
bool multi_thread,
|
||||
bool auto_threads,
|
||||
int32_t threads,
|
||||
int32_t stack_size);
|
||||
|
||||
/**
|
||||
* Starts leaf with a single-threaded runtime, on a successful start this function
|
||||
* blocks the current thread.
|
||||
*
|
||||
* @param rt_id A unique ID to associate this leaf instance, this is required when
|
||||
* calling subsequent FFI functions, e.g. reload, shutdown.
|
||||
* @param config_path The path of the config file, must be a file with suffix .conf
|
||||
* or .json, according to the enabled features.
|
||||
* @return ERR_OK on finish running, any other errors means a startup failure.
|
||||
*/
|
||||
int32_t leaf_run(uint16_t rt_id, const char *config_path);
|
||||
|
||||
int32_t leaf_run_with_config_string(uint16_t rt_id, const char *config);
|
||||
|
||||
/**
|
||||
* Reloads DNS servers, outbounds and routing rules from the config file.
|
||||
*
|
||||
* @param rt_id The ID of the leaf instance to reload.
|
||||
*
|
||||
* @return Returns ERR_OK on success.
|
||||
*/
|
||||
int32_t leaf_reload(uint16_t rt_id);
|
||||
|
||||
/**
|
||||
* Shuts down leaf.
|
||||
*
|
||||
* @param rt_id The ID of the leaf instance to reload.
|
||||
*
|
||||
* @return Returns true on success, false otherwise.
|
||||
*/
|
||||
bool leaf_shutdown(uint16_t rt_id);
|
||||
|
||||
/**
|
||||
* Tests the configuration.
|
||||
*
|
||||
* @param config_path The path of the config file, must be a file with suffix .conf
|
||||
* or .json, according to the enabled features.
|
||||
* @return Returns ERR_OK on success, i.e no syntax error.
|
||||
*/
|
||||
int32_t leaf_test_config(const char *config_path);
|
||||
@@ -0,0 +1,4 @@
|
||||
module leaf {
|
||||
header "leaf.h"
|
||||
export *
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* No error.
|
||||
*/
|
||||
#define ERR_OK 0
|
||||
|
||||
/**
|
||||
* Config path error.
|
||||
*/
|
||||
#define ERR_CONFIG_PATH 1
|
||||
|
||||
/**
|
||||
* Config parsing error.
|
||||
*/
|
||||
#define ERR_CONFIG 2
|
||||
|
||||
/**
|
||||
* IO error.
|
||||
*/
|
||||
#define ERR_IO 3
|
||||
|
||||
/**
|
||||
* Config file watcher error.
|
||||
*/
|
||||
#define ERR_WATCHER 4
|
||||
|
||||
/**
|
||||
* Async channel send error.
|
||||
*/
|
||||
#define ERR_ASYNC_CHANNEL_SEND 5
|
||||
|
||||
/**
|
||||
* Sync channel receive error.
|
||||
*/
|
||||
#define ERR_SYNC_CHANNEL_RECV 6
|
||||
|
||||
/**
|
||||
* Runtime manager error.
|
||||
*/
|
||||
#define ERR_RUNTIME_MANAGER 7
|
||||
|
||||
/**
|
||||
* No associated config file.
|
||||
*/
|
||||
#define ERR_NO_CONFIG_FILE 8
|
||||
|
||||
/**
|
||||
* Starts leaf with options, on a successful start this function blocks the current
|
||||
* thread.
|
||||
*
|
||||
* @note This is not a stable API, parameters will change from time to time.
|
||||
*
|
||||
* @param rt_id A unique ID to associate this leaf instance, this is required when
|
||||
* calling subsequent FFI functions, e.g. reload, shutdown.
|
||||
* @param config_path The path of the config file, must be a file with suffix .conf
|
||||
* or .json, according to the enabled features.
|
||||
* @param auto_reload Enabls auto reloading when config file changes are detected,
|
||||
* takes effect only when the "auto-reload" feature is enabled.
|
||||
* @param multi_thread Whether to use a multi-threaded runtime.
|
||||
* @param auto_threads Sets the number of runtime worker threads automatically,
|
||||
* takes effect only when multi_thread is true.
|
||||
* @param threads Sets the number of runtime worker threads, takes effect when
|
||||
* multi_thread is true, but can be overridden by auto_threads.
|
||||
* @param stack_size Sets stack size of the runtime worker threads, takes effect when
|
||||
* multi_thread is true.
|
||||
* @return ERR_OK on finish running, any other errors means a startup failure.
|
||||
*/
|
||||
int32_t leaf_run_with_options(uint16_t rt_id,
|
||||
const char *config_path,
|
||||
bool auto_reload,
|
||||
bool multi_thread,
|
||||
bool auto_threads,
|
||||
int32_t threads,
|
||||
int32_t stack_size);
|
||||
|
||||
/**
|
||||
* Starts leaf with a single-threaded runtime, on a successful start this function
|
||||
* blocks the current thread.
|
||||
*
|
||||
* @param rt_id A unique ID to associate this leaf instance, this is required when
|
||||
* calling subsequent FFI functions, e.g. reload, shutdown.
|
||||
* @param config_path The path of the config file, must be a file with suffix .conf
|
||||
* or .json, according to the enabled features.
|
||||
* @return ERR_OK on finish running, any other errors means a startup failure.
|
||||
*/
|
||||
int32_t leaf_run(uint16_t rt_id, const char *config_path);
|
||||
|
||||
int32_t leaf_run_with_config_string(uint16_t rt_id, const char *config);
|
||||
|
||||
/**
|
||||
* Reloads DNS servers, outbounds and routing rules from the config file.
|
||||
*
|
||||
* @param rt_id The ID of the leaf instance to reload.
|
||||
*
|
||||
* @return Returns ERR_OK on success.
|
||||
*/
|
||||
int32_t leaf_reload(uint16_t rt_id);
|
||||
|
||||
/**
|
||||
* Shuts down leaf.
|
||||
*
|
||||
* @param rt_id The ID of the leaf instance to reload.
|
||||
*
|
||||
* @return Returns true on success, false otherwise.
|
||||
*/
|
||||
bool leaf_shutdown(uint16_t rt_id);
|
||||
|
||||
/**
|
||||
* Tests the configuration.
|
||||
*
|
||||
* @param config_path The path of the config file, must be a file with suffix .conf
|
||||
* or .json, according to the enabled features.
|
||||
* @return Returns ERR_OK on success, i.e no syntax error.
|
||||
*/
|
||||
int32_t leaf_test_config(const char *config_path);
|
||||
@@ -0,0 +1,4 @@
|
||||
module leaf {
|
||||
header "leaf.h"
|
||||
export *
|
||||
}
|
||||
Reference in New Issue
Block a user