# leaf **Repository Path**: suzg-net/leaf ## Basic Information - **Project Name**: leaf - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-08-27 - **Last Updated**: 2024-08-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LEAF 鸿蒙适配 https://github.com/eycorsican/leaf 适配鸿蒙环境项目。 ## 目录结构 相对原始项目变更: * 原始 README.md 更名为 README.leaf.md * 原始 README.zh.md 更名为 README.leaf.zh.md * config.json: leaf cli使用配置文件 * 添加目录cpp: C语言接口 * 添加目录ctest: Linux下命令行测试程序 * 添加目录rust-tun: 基于 https://github.com/eycorsican/rust-tun.git * 添加目录netstack-lwip: 基于 https://github.com/eycorsican/netstack-lwip.git ## 依赖环境 * Ubuntu 20.04 * OpenHarmony Rust,环境配置: https://gitee.com/belanLu/build/blob/master/RUST-BUILD-GUIDE.md * C++编译环境 ## 编译 此工程支持编译Linux X86库和鸿蒙库。其中Linux库提供测试程序,供调试、验证使用。 ### Linux下调试 测试运行: 1. 准备socks5服务:可以使用任何支持socks5协议的服务器,默认地址为127.0.0.1,端口3456,可以在`ctest/main.cpp`中修改 ```C start_socks(write_packet, "127.0.0.1", 3456); ``` 2. 编译: 最上层目录执行`make testall`,输出文件在 `ctest/test` 3. 运行: `sudo ctest/test` 4. 测试: 访问位于代理后侧服务进行测试 ### Linux下静态库编译 ```shell make lib ``` 输出文件 `target/x86/debug/libleaf.a` ### 鸿蒙下静态库编译 #### 32位 ```shell make ohos32 ``` 输出文件 `target/armv7-unknown-linux-ohos/release/libleaf.a` #### 64位 ```shell make ohos64 ``` 输出文件 `target/aarch64-unknown-linux-ohos/release/libleaf.a` ## 鸿蒙下静态库使用 上一步编译出的`libleaf.a`文件,可以在鸿蒙NDK工程中使用。NDK开发详见 https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ndk-development-overview-V5 参考使用方式见 * [cpp/leaf.h](cpp/leaf.h) * [cpp/leaf.cpp](cpp/leaf.cpp) * [ctest/main.cpp](ctest/main.cpp)