# coolink_ohos_sdk **Repository Path**: coocaa-coolink/coolink_ohos_sdk ## Basic Information - **Project Name**: coolink_ohos_sdk - **Description**: 可用于开源鸿蒙操作系统(https://gitee.com/openharmony)系统的酷连跨屏联动库。基于RUST开发。 (本项目处于WIP中,正在加紧开发)。 功能: 1、支持P2P点到点快速连接及通信(采用websoket交换信令); 2、支持对称型NAT; 3、支持RTM实时文件传输; 4、支持RTC实时流媒体传输。 - **Primary Language**: Rust - **License**: MIT - **Default Branch**: master - **Homepage**: https://coolink.coocaa.com - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2023-01-13 - **Last Updated**: 2024-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # coolink_ohos_sdk coolink protocol sdk implementation for openharmony operation system ## 开始 ### openharmony 开源社区地址: - https://gitee.com/openharmony/docs ### rust程序支持: - 1、 OpenHarmony切换到master分支; - 2、 确认源码工程/build/路径下的的代码支持如下rust 编译模板: - build/template/rust/ohos_cargo_crate.gni - build/template/rust/rust_template.gni - build/template/rust/rust_target_lints.gni - build/template/rust/ohos_rust_library.gni - 3、 确认源码工程/prebuilts/rustc/linux-x86_64/current/lib/rustlib下的工具链有 : - arm-linux-ohos eabi的目标库 - 4、确认源码工程/third_party/rust目录存在,并cd到该路径下,下载库代码 ~~~bash git clone xxx ~~~ - 5、添加一个新工程的rust目录到buid/rust/test目录下,修改rust/tests/BUILD.gn,将工程添加进编译系统: ~~~bash group("coolink_test") { deps = [ "//third_party/rust/coolink_ohos_sdk:coolink_ohos_sdk", ] } ~~~ - 6、./build.sh --product-name rk3568 --build-target build/rust/tests:coolink_test - 7、要确认编译出来的可执行程序运行,需要注意可能需要将编译时libstd.dylib.so(arm平台)库拷贝到rk3568板子上。否则可能会发生link失败的问题。根据/build/rust/BUILD.gn当中的内容,可以/out目录下的对应cpu架构中找到。 ~~~bash 动态库位于: /out/(target)/clang_x64/obj/build/rust/ 中。 ohos_prebuilt_shared_library("libstd.dylib.so") { if (current_cpu == "arm64") { source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/aarch64-linux-ohos/lib/libstd-37747be394d9d22c.so" } else if (current_cpu == "arm") { source = "//prebuilts/rustc/linux-x86_64/current/lib/rustlib/arm-linux-ohos/lib/libstd-a4ed09c4b860e683.so" } else if (current_cpu == "x86_64" || current_cpu == "x64") { source = "//prebuilts/rustc/linux-x86_64/current/lib/libstd-c244726431624c96.so" } else { source = "" } # enable_strip = true install_images = [ "system", "uptater", ] output = "libstd.dylib.so" part_name = "common" } ~~~ ### 编译与运行 通过上述的修改,执行: ~~~bash ./build.sh --product-name rk3568 --build-target build/rust/tests:coolink_test ~~~ 会编译代码通过,并且在/out/rk3568/common/common中生成32位的库: ~~~bash readelf -h coolink_ohos_bin ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: DYN (Shared object file) Machine: ARM Version: 0x1 Entry point address: 0xf0d60 Start of program headers: 52 (bytes into file) Start of section headers: 4668216 (bytes into file) Flags: 0x5000200, Version5 EABI, soft-float ABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 13 Size of section headers: 40 (bytes) Number of section headers: 32 Section header string table index: 30 ~~~ 在rk3568平台上,将/out/rk3568/package/phone/system/lib/libstd_dylib.so(找到对应target平台的rust-std动态库)和/common/common/coolink_ohos_bin 拷贝到u盘中,并且用串口接入rk3568的平台板子,remont系统挂载路径: ~~~bash - 1、 mount -o remount -w / - 2、 copy /mnt/xxx(挂载路径)/libstd_dylib.so to /system/lib - 3、 执行./coolink_ohos_bin & 程序可以运行在后台,并且有打印信息,同时采用netstat -ntulp 命令看到12345,8000端口绑定,接入网线,reqwest会返回ip打印请求: 结果符合预期。 ~~~ ### 测试方法: - 1、按照上面工程编译可执行程序之后,启动后会利用uinput在/dev/input创建event4和event5节点,在linux系统上可以支持标准键盘的按键输入,在ohos系统上暂时还无法dispatch分发给到应用。可以通过打印。 - 2、连接依赖的是每个终端唯一独立的ID,可以通过打印抓取: ~~~bash INFO coolink_ohos_bin:msgtunnel on_p2p_rpc_service_ready,client_id = "xxxxx" ~~~ 这个client_id作为连接ID输入到手机端应用程序的【连接ID】编辑框当中。可以在手机端中保存避免下次还需要输入。下一次的连接只需要在列表中点击【选中】会自动填入编辑框,然后可以直接点击连接。完成通道建立。 ## API接口说明 - 例子详见:coolink_ohos_sdk/v0_0_2/main.rs - 主要通信接口类:coolink_ohos_sdk/v0_0_2/coolink_easy_api.rs - 主要虚拟键鼠接口类:coolink_ohos_sdk/v0_0_2/coolink_easy_api.rs ### 通信接口类: 该API是针对酷连协议设计的,提供了一系列方法以便于使用该协议进行设备之间的通信。 #### 接口列表 ##### pre_init_sdk_log - 日志打印可以前置初始化 ~~~rust fn pre_init_sdk_log(log_init: LogIntArgs); 参数 log_init:日志初始化参数 ~~~ ##### init_easy_sdk - 初始化SDK ~~~rust fn init_easy_sdk( log_init: LogIntArgs, // 日志初始化参数 server_init: ServerQueryInitArgs, // 服务请求初始化参数 httpd_init: HttpdInitArgs, // httpd服务请求初始化参数 ); 参数 log_init:日志初始化参数 server_init:服务请求初始化参数 httpd_init:httpd服务请求初始化参数 ~~~ ##### set_message_type_tunnel_listener - 设置消息通道的回调 ~~~rust fn set_message_type_tunnel_listener(listener: Box); 参数 listener:实现了IUniqueMessageTunnelListener trait的回调对象 ~~~ ##### set_sensor_type_tunnel_listener - 设置传感通道的回调 ~~~rust fn set_sensor_type_tunnel_listener(listener: Box); 参数 listener:实现了ISensorTunnelListener trait的回调对象 ~~~ ##### set_bytebuf_type_tunnel_listener - 设置字节数组通道的回调 ~~~rust fn set_bytebuf_type_tunnel_listener(listener: Box); 参数 listener:实现了IByteBufListener trait的回调对象 ~~~ ##### re_init_user_id - 重新设置用户,比如在切换账号之后 ~~~rust fn re_init_user_id(user_id: String); 参数 user_id:新的用户id ~~~ ##### re_init_device_id - 重新设置设备ID,比如在设备重新初始化之后 ~~~rust fn re_init_device_id(device_id: String); 参数 device_id:新的设备id ~~~ ##### connect_peer_as_controlling - 主动向对端设备发起消息通道的连接 ~~~rust fn connect_peer_as_controlling(remote_client_id: String) -> i32; 参数 remote_client_id:对端ID 返回值 1:代表连接已经存在,默认是成功的 0:表示此次成功 -1:代表有错误发生 ~~~ ##### open_sensor_as_controlling - 主动向对端设备发起sensor通道的连接 ~~~rust fn open_sensor_as_controlling(remote_client_id: String) -> i32; 参数 remote_client_id:对端ID 返回值 1:代表连接已经存在,默认是成功的 0:表示此次成功 -1:代表有错误发生 ~~~ ##### start_byte_buf_channel_as_controlling - 主动向对端设备发起bytebuf通道的连接 ~~~rust fn start_byte_buf_channel_as_controlling(remote_client_id: String) -> i32; 参数 remote_client_id:对端ID 返回值 1:代表连接已经存在,默认是成功的 0:表示此次成功 -1:代表有错误发生 ~~~ ##### is_message_tunnel_ready - 判断消息通道是否已经准备完成 ~~~rust fn is_message_tunnel_ready(remote_client_id: String) -> bool; 参数 remote_client_id:对端ID 返回值 true:通道已经准备好 false:通道未准备好 ~~~ ##### is_sensor_tunnel_ready - 判断sensor通道是否已经准备完成 ~~~rust fn is_sensor_tunnel_ready(remote_client_id: String) -> bool; 参数 remote_client_id:对端ID 返回值 true:通道已经准备好 false:通道未准备好 ~~~ ##### is_bytebuf_tunnel_ready - 判断buffer通道是否已经准备完成 ~~~rust fn is_bytebuf_tunnel_ready(remote_client_id: String) -> bool; 参数 remote_client_id:对端ID 返回值 true:通道已经准备好 false:通道未准备好 ~~~ ##### destroy_tunnel - 主动端开与对端的连接 ~~~rust fn destroy_tunnel(remote_client_id: String) -> bool; 参数 remote_client_id:对端ID 返回值 true:销毁成功 false:销毁失败 ~~~ ##### get_connected_devices - 获得当前创建了P2P通道的连接设备列表 ~~~rust fn get_connected_devices() -> Option>>; 返回值 Vec>:当前创建了P2P通道的连接设备列表 ~~~ ##### send_message - 通过连接通道发送消息 ~~~rust fn send_message( send_result: Box, // 回调指针 remote_client_id: String, // 对端设备ID message_event: String, // 消息名 message: String, // 消息 ) -> Result; 参数 send_result:回调对象,实现了ISendMessageResult trait remote_client_id:对端设备ID message_event:消息名称 message:消息内容 返回值 Ok(String):成功返回message_id Err(anyhow::Error):失败原因 ~~~ ##### broadcast_message - 通过连接通道发送广播消息,不需要带上remote_client_id参数 ~~~rust fn broadcast_message( send_result: Box, //结果回调 message_event: String, //消息名称 message: String, // 消息内容 ) -> Vec>; 参数 send_result:回调对象,实现了ISendMessageResult trait message_event:消息名称 message:消息内容 返回值 Vec>:成功或者错误,成功返回(remote_client_id,message_id)消息列表 ~~~ ##### send_sensor - 通过sensor通道发送消息 ~~~rust fn send_sensor( send_result: Box, //回调结果 remote_client_id: String, // 对端设备ID sensor_event: String, // sensor消息名称 sensor_data: String, // sensor消息 ) -> Result; 参数 send_result:回调对象,实现了ISendSensorResult trait remote_client_id:对端设备ID sensor_event:sensor消息名称 sensor_data:sensor消息内容 返回值 Ok(String):成功返回message_id Err(anyhow::Error):失败原因 ~~~ ##### send_bytebuf - 通过流数组通道发送消息 ~~~rust fn send_bytebuf( send_result: Box, //结果回调 remote_client_id: String, // 对端设备ID can_lost: bool, // 能否丢包 video_buf: Option>, // 视频数据 audio_buf: Option>, // 音频数据 ) -> Result; 参数 send_result:回调对象,实现了ISendByteBufResult trait remote_client_id:对端设备ID can_lost:是否允许丢包 video_buf:视频数据 audio_buf:音频数据 返回值 Ok(String):成功返回message_id Err(anyhow::Error):失败原因 ~~~ ##### generate_p2prpc_file_mapping - 将本地文件添加到P2P的mapping中 ~~~rust fn generate_p2prpc_file_mapping(file_path: String) -> Result; 参数 file_path:本地文件的绝对路径 返回值 Ok(String):成功返回mapping ID Err(anyhow::Error):失败原因 ~~~ ##### get_p2prpc_file_mapping_to_http - 获取到对端发来的mapping文件,生成url ~~~ rust fn get_p2prpc_file_mapping_to_http( remote_client_id: String, // 对方的设备id mapping_url: String, // 映射的url名字 ) -> Result; 参数 remote_client_id:对方的设备id mapping_url:映射的url名字 返回值 Ok(String):成功返回http ID Err(anyhow::Error):失败原因 ~~~ ##### query_online_from_gateway - 从网关处请求判断client_id是否是在线状态 ~~~rust fn query_online_from_gateway( client_id: String, // 接入的client_id query_callback: Box, // 接口请求回调 ) -> Result<(), anyhow::Error>; 参数 client_id:接入的client_id query_callback:接口请求回调对象,实现了IQueryOnline trait 返回值 Ok(()):请求成功 Err(anyhow::Error):请求失败原因 ~~~ ##### is_in_same_host - 判断是否在同一个host下 ~~~rust fn is_in_same_host(remote_client_id: String) -> bool; 参数 remote_client_id:远端client_id 返回值 true:在同一个host下 false:不在同一个host下 ~~~ ### 虚拟键值接口类: 该API是针对酷连协议设计的,提供了一系列方法以便于使用该协议进行设备之间的通信。 #### 接口列表 ##### loop_block_on_u_keyboard - 使用uinput创建一个keyboard虚拟键盘,并等待接受键值 ~~~rust async fn loop_block_on_u_keyboard( mut rx: UnboundedReceiver, ) -> Result<(), anyhow::Error> 参数 rx: 接收外部键值发送的channel rx 返回值 Result<(), anyhow::Error> 启动结果 ~~~ #### 接口列表 ##### loop_block_on_u_keyboard - 使用uinput创建一个keyboard虚拟键盘,并等待接受键值,需要使用异步运行时调用 ~~~rust async fn loop_block_on_u_keyboard( mut rx: UnboundedReceiver, ) -> Result<(), anyhow::Error> 参数 rx: 接收外部键值发送的channel rx 返回值 Result<(), anyhow::Error> 启动结果 ~~~ ##### loop_block_on_u_mouse - 使用uinput创建一个mouse虚拟鼠标,并等待接受鼠标事件,需要使用异步运行时调用 ~~~rust async fn loop_block_on_u_mouse( mut rx: UnboundedReceiver, ) -> Result<(), anyhow::Error> 参数 rx: 接收外部鼠标发送的channel rx 返回值 Result<(), anyhow::Error> 启动结果 ~~~ ## 移植经验分享 - 1、toolchain中含有如下的sys_root库,可以在/prebuilts/rustc/linux-x86_64/current/lib/rustlib找到: ~~~bash --extern 'noprelude:alloc=$stdlib_path/liballoc-3b52b93c4ca8a5bd.rlib' --extern 'noprelude:compiler_builtins=$stdlib_path/libcompiler_builtins-b9ee818e172f8741.rlib' --extern 'noprelude:core=$stdlib_path/libcore-7286fdc02c41072a.rlib' --extern 'noprelude:cfg_if=$stdlib_path/libcfg_if-3035f6fd06fe6ec9.rlib' --extern 'noprelude:proc_macro=$stdlib_path/libproc_macro-4684c24756a7fd30.rlib' --extern 'noprelude:getopts=$stdlib_path/libgetopts-d95f4426b4470457.rlib' --extern 'noprelude:panic_unwind=$stdlib_path/libpanic_unwind-6bf3d049ede235ab.rlib' --extern 'noprelude:hashbrown=$stdlib_path/libhashbrown-a0e8c87c5c49d8ae.rlib' --extern 'noprelude:libc=$stdlib_path/liblibc-46a258016f0c70b0.rlib' --extern 'noprelude:panic_abort=$stdlib_path/libpanic_abort-5e632aaeca04e386.rlib' --extern 'noprelude:rustc_demangle=$stdlib_path/librustc_demangle-aff4ef91724960ce.rlib' --extern 'noprelude:std_detect=$stdlib_path/libstd_detect-a83355b65181d20c.rlib' --extern 'noprelude:unwind=$stdlib_path/libunwind-f36b85fd9f3a6350.rlib' --extern 'noprelude:std=$stdlib_path/libstd-a4ed09c4b860e683.rlib' --extern 'std=$std_dylib_path/libstd.dylib.so' --extern 'test=$stdlib_path/libtest-7a70af01540caacc.rlib' ~~~ - 含: ~~~bash liballoc libcompiler_builtins libcore libcfg_if libproc_macro libgetopts libpanic_unwind libhashbrown liblibc libpanic_abort librustc_demangle libstd_detect libunwind libstd libtest ~~~ - 如果编译的工程代码中依赖这些库的代码,可以在GN编译文件中删除依赖,代码中只需要增加如下内容(以libc为例): ~~~bash ## 放在第一行 #![feature(rustc_private)] ## 内部依赖 #[cfg(unix)] extern crate libc; ~~~ - 2、socket2库报错修改: ~~~bash failed to resolve: use of undeclared type `IovLen` ~~~ 这是由于在开源鸿蒙中,target-env被设置成了ohos(采用的是musl-libc),rust代码中的所以在sys/unix.rs中作出如下修改: ~~~bash all( target_os = "linux", any( target_env = "musl", target_env = "ohos", //add ohos here! all(target_env = "uclibc", target_pointer_width = "32") ) ), ~~~ - 3、ring (加解密算法rust纯实现)库,从boringssl中移植,在openharmony中不太容易移植(需要perl/asm等一系列的工具),不建议使用。在其他库中涉及rust_tls相关features代码(用于支持SSL),需要设置为native_tls。 - 4、openssl依赖,可以直接采用ohos的openssl源码进行依赖: 在openssl-sys中的编译脚本增加: ~~~bash public_configs = [ "//third_party/openssl:ssl_config_public" ] deps = [ # "//third_party/rust/coolink_ohos_sdk/libc/v0_2_138:lib", "//third_party/openssl:crypto_source", "//third_party/openssl:ssl_source", ] ~~~ 另外,由于openssl采用的是ffi的crate-name,所以在BUILD.gn需要将包名改掉: ~~~bash crate_name = "ffi" ~~~ 同时,在lib.rs中增加: ~~~bash extern crate ffi; ~~~ 参考//third_party/openssl当中的配置,在openssl/openssl_sys的BUILD.gn中增加: ~~~bash rustflags = [ "--cfg", "ossl101", "--cfg", "ossl102", "--cfg", "ossl110", "--cfg", "ossl110g", "--cfg", "ossl110h", "--cfg", "ossl111", "--cfg=osslconf=\"OPENSSL_USE_NODELETE\"", "--cfg=osslconf=\"OPENSSL_PIC\"", "--cfg=osslconf=\"OPENSSL_NO_MD2\"", "--cfg=osslconf=\"OPENSSL_NO_RC5\"", "--cfg=osslconf=\"OPENSSL_NO_RIPEMD\"", "--cfg=osslconf=\"OPENSSL_NO_ASM\"", "--cfg=osslconf=\"OPENSSL_ARM_PLATFORM\"", "--cfg=osslconf=\"OPENSSL_NO_STATIC_ENGINE\"", "--cfg=osslconf=\"OPENSSL_NO_BF\"", "--cfg=osslconf=\"OPENSSL_NO_CAMELLIA\"", "--cfg=osslconf=\"OPENSSL_NO_CAST\"", "--cfg=osslconf=\"OPENSSL_NO_CT\"", "--cfg=osslconf=\"OPENSSL_NO_RC2\"", "--cfg=osslconf=\"OPENSSL_NO_RMD160\"", "--cfg=osslconf=\"OPENSSL_NO_SSL2\"", "--cfg=osslconf=\"OPENSSL_NO_SSL3\"", "--cfg=osslconf=\"OPENSSL_NO_SSL3_METHOD\"", ] ~~~ - 5、tungstenite依赖的sha1采用了cpufeatures用于判断是否存target-feature的情况,这里面由于我们编译的目标是arm,所以此处可以取消依赖,采用:https://doc.rust-lang.org/core/arch/index.html rust自带的target-feature cfg来进行判断处理,修改:sha1的src/compress/aarch64.rs以及x86.rs文件,改为采用if cfg!(target_feature = "sha2") 判断的方法。 - 6、tungstenite 和tokio-tungstenite依赖的native_tls采用了native_tls_crate的重命名,但是tokio-native-tls采用了原来的包名,所以要在两个工程中找到使用了native_tls_crate的代码,并修改代码完成如下重命名的方法: ~~~bash #[cfg(feature = "native-tls")] extern crate native_tls as native_tls_crate; ... mod encryption { pub mod native_tls { use super::super::native_tls_crate:: ... ~~~ - 7、indexmap修改: h2库依赖了indexmap库,indexmap库又依赖了hashbrown,hashbrown已经被默认集成进toolchain中,系统默认的hashbrown并没有设置features = ["raw"]编译选项,所以在编译过程中会有报错信息。 可以将hashbrown的依赖重命名为hashbrown_raw,并且在indexmap 的lib中增加: ~~~bash extern crate hashbrown_raw as hashbrown; ~~~ - 8、reqwest 也使用了native_tls_crate的命名,需要同6点修改,另外,tungstenite和reqwest使用的base64的版本号不同,需要在reqwest的库中,增加如下extern来解决问题: ~~~bash extern crate base64_v2 as base64; ~~~ 使用reqwest库请求返回本机IP地址:http(https)://httpbin.org/ip,其中使用http返回成功,请求https返回失败。错误原因如下: ~~~bash "unable to get local issuer certificate" ~~~ 开发板子上的/ect/ssl/certs下有证书,说明openssl代码编译的时候可能路径配置不正确,编写测试代码,运行: ~~~bash openssl_probe::probe(); ~~~ 查看获取到的CA根证书路径,发现cert_file为空,需要修改openssl_probe源码,lib.rs中的line127,确保在找到cert_dir后,判断cert_file是否为空,重新赋值: ~~~rust if cert_dir.exists() { let some_cert_dir = cert_dir.clone(); result.cert_dir = Some(cert_dir); if result.cert_file.is_none() { result.cert_file = cert_filenames .iter() .map(|fname| some_cert_dir.join(fname)) .find(|p| p.exists()); } } ~~~ 也可以在BUILD.gn中配置rustenv,设置好ssl的CA路径。 另外,如果开发板上的ntp时钟同步错误,openssl的请求会发生报错: ~~~bash "not yet valid" ~~~ 所以在使用https的时候要可以根据报错提示,检查开发板上的时钟,重启开发板同步ntp时间戳。 - 9、tonic-inf:用于Http代理处理端到端的请求路由时,转发给底层P2P的RPC实现,需要主机系统中安装了protoc,请在host机上执行: ~~~bash sudo apt-get install protobuf-compiler ~~~ 并在rustenv中设置: ~~~bash rustenv = ["PROTOC=/usr/local/bin/protoc"] ~~~ 其中请用whereis protoc查询正确的路径并替换上述路径,另外,根据安装的protoc版本的不同,对于optional的支持有不同的编译参数,可能需要在build.rs中增加: ~~~bash tonic_build::configure().protoc_arg("--experimental_allow_proto3_optional") ~~~ issue: https://github.com/hyperium/tonic/issues/1047 参考该问题,在host主机上可能需要从源码编译protc避免出现experimental_allow_proto3_optional flag不识别问题。 - 10、tonic cargo 改名报错修改: ~~~bash extern crate prost as prost1; ~~~ - 11、nix 是 Rust 语言的一个系统编程库,提供了访问系统底层功能的能力,例如文件系统、网络、进程等。它是一个高级的、操作系统无关的库,并且比 libc 提供了更多的功能。由于该库涉及平台兼容特性,需要作出类似socket2库一样的兼容适配修改,用于适配openharmony的环境。涉及的修改众多,需要注意查找所有target_env = "musl"的地方,全部改为any(target_env = "musl",target_env = "ohos")用于满足鸿蒙操作系统的环境变量要求。另外,nix依赖的libc需要支持extra_trait的feature,鸿蒙系统预编译的rust-libc没有开放该feature,所以不能简单的直接使用系统编译的libc,而是应该使用自行编译的libc(修改了target_env="ohos")的静态库(重命名为libc_c)并且依赖到nix中,然后在lib.rs中修改: ~~~rust extern libc_c as libc; ~~~ 同时,在webrtc-util中也采用本仓库编译的libc,而不使用系统预置的libc,也是在webrtc-util的lib.rs中增加如下extern: ~~~rust extern libc_c as libc; ~~~ - 12、stun 和turn库依赖了ring,需要修改new_hmac方法 ~~~rust // use ring::hmac; use openssl::pkey::PKey; use openssl::sign::Signer; use openssl::hash::MessageDigest; ... fn new_hmac(key: &[u8], message: &[u8]) -> Vec { // let mac = hmac::Key::new(hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY, key); // hmac::sign(&mac, message).as_ref().to_vec() // FIXME: unwrap may crash, warp {if let } let mac = PKey::hmac(key).unwrap(); let mut signer = Signer::new(MessageDigest::sha1(), &mac).unwrap(); signer.update(message).unwrap(); signer.sign_to_vec().unwrap() } ... ~~~ stun的依赖有重命名的变化,需要代码中修改: ~~~rust extern crate webrtc_util as util; extern crate md_5 as md5; ~~~ - 13、webrtc系列库需要注意调整一下针对mdns、util等库重命名,在源码中修改头文件库的依赖; - 14、uinput-tokio依赖libdev_sys,libdev_sys则依赖了系统内置的udev库,需要在编译脚本中增加如下依赖: ~~~bash public_configs = [ "//third_party/eudev:libudev_public_config" ] deps = [ "//third_party/eudev:libudev", ] ~~~ 另外,在build.rs中,发现无法生成rs文件,需要修改build.rs文件,直接将函数名称和命令执行的函数进行调整,注释掉writeln方法。 ~~~rust let out_dir = env::var_os("OUT_DIR").unwrap(); let test_file_name = Path::new(&out_dir).join(format!("check_{}.rs", function_name)); std::fs::write(test_file_name, CHCEKCODE).ok()?; ~~~ ## 项目参与方法: ~~~bash - [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files - [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: ``` cd existing_repo git remote add origin http://gitlab.skysri.com/open_best_rtm_rtc/openharmony/coolink_ohos_sdk.git git branch -M main git push -uf origin main ``` ~~~ ## 项目描述 开源鸿蒙系统是国产优秀的操作系统,封装了国产方舟编译器,国产Ark开发语言等,"酷连协议"是一套稳定可靠实现的全网域环境下的端到端连接、传输的能力库,将贡献到开源鸿蒙操作系统中。 ## 知识 本项目需要具备计算机领域方向专业知识,包括Unix类簇操作系统、Gn编译工具、C/C++开发语言、RUST开发语言等。 ## 开源协议 本项目基于MIT协议基础上,采用的第三方库采用的开源协议如下: ~~~bash addr2line: LICENSE-MIT adler: LICENSE-MIT ahash: LICENSE-MIT,LICENSE-APACHE aho_corasick: LICENSE-MIT anyhow: LICENSE-MIT,LICENSE-APACHE app_dirs2: LICENSE-MIT arc_swap: LICENSE-MIT,LICENSE-APACHE async_compression: LICENSE-MIT,LICENSE-APACHE async_stream: LICENSE-MIT async_stream_impl: LICENSE-MIT async_trait: LICENSE-MIT,LICENSE-APACHE atomic_waker: LICENSE-MIT,LICENSE-APACHE,LICENSE-THIRD-PARTY autocfg: LICENSE-MIT,LICENSE-APACHE axum: LICENSE-MIT axum_core: LICENSE-MIT backtrace: LICENSE-MIT,LICENSE-APACHE base64: LICENSE-MIT,LICENSE-APACHE bitflags: LICENSE-MIT,LICENSE-APACHE block_buffer: LICENSE-MIT,LICENSE-APACHE buf_redux: LICENSE-MIT,LICENSE-APACHE build_time: UNLICENSE byteorder: LICENSE-MIT bytes: LICENSE-MIT cache_padded: LICENSE-MIT,LICENSE-APACHE cc: LICENSE-MIT,LICENSE-APACHE cfg_if: LICENSE-MIT,LICENSE-APACHE chrono: LICENSE-MIT coolink_ohos_sdk: UNLICENSE cpufeatures: LICENSE-MIT,LICENSE-APACHE crc: LICENSE-MIT,LICENSE-APACHE crc32fast: LICENSE-MIT,LICENSE-APACHE crc_catalog: LICENSE-MIT,LICENSE-APACHE crypto_common: LICENSE-MIT,LICENSE-APACHE custom_derive: LICENSE-MIT,LICENSE-APACHE darling: LICENSE-MIT darling_core: LICENSE-MIT darling_macro: LICENSE-MIT derivative: LICENSE-MIT,LICENSE-APACHE digest: LICENSE-MIT,LICENSE-APACHE dirs: LICENSE-MIT,LICENSE-APACHE dirs_sys: LICENSE-MIT,LICENSE-APACHE either: LICENSE-MIT,LICENSE-APACHE ekho: UNLICENSE encoding_rs: LICENSE-MIT,LICENSE-APACHE,LICENSE-MIT,LICENSE-WHATWG enum_derive: UNLICENSE fastrand: LICENSE-MIT,LICENSE-APACHE fixedbitset: LICENSE-MIT,LICENSE-APACHE flate2: LICENSE-MIT,LICENSE-APACHE fnv: LICENSE-MIT,LICENSE-APACHE foreign_types: LICENSE-MIT,LICENSE-APACHE foreign_types_shared: LICENSE-MIT,LICENSE-APACHE form_urlencoded: LICENSE-MIT,LICENSE-APACHE futures: LICENSE-MIT,LICENSE-APACHE futures_channel: LICENSE-MIT,LICENSE-APACHE futures_core: LICENSE-MIT,LICENSE-APACHE futures_executor: LICENSE-MIT,LICENSE-APACHE futures_io: LICENSE-MIT,LICENSE-APACHE futures_macro: LICENSE-MIT,LICENSE-APACHE futures_ringbuf: UNLICENSE futures_sink: LICENSE-MIT,LICENSE-APACHE futures_task: LICENSE-MIT,LICENSE-APACHE futures_util: LICENSE-MIT,LICENSE-APACHE generic_array: LICENSE-MIT getrandom: LICENSE-MIT,LICENSE-APACHE gimli: LICENSE-MIT,LICENSE-APACHE h2: LICENSE-MIT hashbrown: LICENSE-MIT,LICENSE-APACHE headers: LICENSE-MIT headers_core: LICENSE-MIT heck: LICENSE-MIT,LICENSE-APACHE hex: LICENSE-MIT,LICENSE-APACHE http: LICENSE-MIT,LICENSE-APACHE httparse: LICENSE-MIT,LICENSE-APACHE http_body: LICENSE-MIT httpdate: LICENSE-MIT,LICENSE-APACHE http_range_header: LICENSE-MIT hyper: LICENSE-MIT hyper_timeout: LICENSE-MIT,LICENSE-APACHE hyper_tls: LICENSE-MIT,LICENSE-APACHE iana_time_zone: LICENSE-MIT,LICENSE-APACHE ident_case: LICENSE-MIT idna: LICENSE-MIT,LICENSE-APACHE indexmap: LICENSE-MIT,LICENSE-APACHE ioctl_sys: UNLICENSE ipnet: LICENSE-MIT,LICENSE-APACHE itertools: LICENSE-MIT,LICENSE-APACHE itoa: LICENSE-MIT,LICENSE-APACHE lazy_static: LICENSE-MIT,LICENSE-APACHE libc: LICENSE-MIT,LICENSE-APACHE libudev: LICENSE-MIT libudev_sys: LICENSE-MIT lock_api: LICENSE-MIT,LICENSE-APACHE log: LICENSE-MIT,LICENSE-APACHE log_derive: UNLICENSE matchers: LICENSE-MIT matchit: LICENSE-MIT md_5: LICENSE-MIT,LICENSE-APACHE md5: LICENSE-MIT,LICENSE-APACHE memchr: LICENSE-MIT memoffset: LICENSE-MIT mime: LICENSE-MIT,LICENSE-APACHE mime_guess: LICENSE-MIT miniz_oxide: LICENSE-MIT,LICENSE-APACHE,LICENSE-ZLIB mio: LICENSE-MIT multimap: LICENSE-MIT,LICENSE-APACHE multipart: LICENSE-MIT,LICENSE-APACHE native_tls: LICENSE-MIT,LICENSE-APACHE nix: LICENSE-MIT nom8: LICENSE-MIT nu_ansi_term: LICENSE-MIT num_cpus: LICENSE-MIT,LICENSE-APACHE num_enum: LICENSE-MIT,LICENSE-APACHE num_enum_derive: LICENSE-MIT,LICENSE-APACHE, LICENSE-BSD num_integer: LICENSE-MIT,LICENSE-APACHE num_traits: LICENSE-MIT,LICENSE-APACHE object: LICENSE-MIT,LICENSE-APACHE once_cell: LICENSE-MIT,LICENSE-APACHE openssl: LICENSE-APACHE openssl_macros: LICENSE-MIT,LICENSE-APACHE openssl_probe: LICENSE-MIT,LICENSE-APACHE openssl_sys: LICENSE-MIT optional_struct: LICENSE-APACHE optional_struct_internal: UNLICENSE optional_struct_macro_impl: UNLICENSE overload: LICENSE-MIT parking_lot: LICENSE-MIT,LICENSE-APACHE parking_lot_core: LICENSE-MIT,LICENSE-APACHE path_clean: LICENSE-MIT,LICENSE-APACHE percent_encoding: LICENSE-MIT,LICENSE-APACHE petgraph: LICENSE-MIT,LICENSE-APACHE pin_project: LICENSE-MIT,LICENSE-APACHE pin_project_internal: LICENSE-MIT,LICENSE-APACHE pin_project_lite: LICENSE-MIT,LICENSE-APACHE pin_utils: LICENSE-MIT,LICENSE-APACHE pkg_config: LICENSE-MIT,LICENSE-APACHE ppv_lite86: LICENSE-MIT,LICENSE-APACHE prettyplease: LICENSE-MIT,LICENSE-APACHE proc_macro2: LICENSE-MIT,LICENSE-APACHE proc_macro_crate: LICENSE-MIT,LICENSE-APACHE prost: LICENSE-APACHE prost_build: LICENSE-APACHE prost_derive: LICENSE-APACHE prost_types: LICENSE-APACHE quick_error: LICENSE-MIT,LICENSE-APACHE quote: LICENSE-MIT,LICENSE-APACHE rand: LICENSE-MIT,LICENSE-APACHE rand_chacha: LICENSE-MIT,LICENSE-APACHE rand_core: LICENSE-MIT,LICENSE-APACHE regex: LICENSE-MIT,LICENSE-APACHE regex_automata: LICENSE-MIT,UNLICENSE regex_syntax: LICENSE-MIT,LICENSE-APACHE remove_dir_all: LICENSE-MIT,LICENSE-APACHE reqwest: LICENSE-MIT,LICENSE-APACHE ringbuf: LICENSE-MIT,LICENSE-APACHE rustc_demangle: LICENSE-MIT,LICENSE-APACHE rustc_version: LICENSE-MIT,LICENSE-APACHE rustls_pemfile: LICENSE-MIT,LICENSE-APACHE,LICENSE-ISC rustversion: LICENSE-MIT,LICENSE-APACHE ryu: LICENSE-APACHE,LICENSE-BOOST safemem: LICENSE-MIT,LICENSE-APACHE scoped_tls: LICENSE-MIT,LICENSE-APACHE scopeguard: LICENSE-MIT,LICENSE-APACHE semver: LICENSE-MIT,LICENSE-APACHE serde: LICENSE-MIT,LICENSE-APACHE serde_derive: LICENSE-MIT,LICENSE-APACHE serde_json: LICENSE-MIT,LICENSE-APACHE serde_urlencoded: LICENSE-MIT,LICENSE-APACHE sha1: LICENSE-MIT,LICENSE-APACHE sharded_slab: LICENSE-MIT signal_hook_registry: LICENSE-MIT,LICENSE-APACHE slab: LICENSE-MIT smallvec: LICENSE-MIT,LICENSE-APACHE socket2: LICENSE-MIT,LICENSE-APACHE state: LICENSE-MIT,LICENSE-APACHE strsim: LICENSE-MIT stun: LICENSE-MIT,LICENSE-APACHE subtle: LICENSE-BSD symlink: LICENSE-MIT,LICENSE-APACHE syn: LICENSE-MIT,LICENSE-APACHE sync_wrapper: LICENSE-APACHE tempfile: LICENSE-MIT,LICENSE-APACHE thiserror: LICENSE-MIT,LICENSE-APACHE thiserror_impl: LICENSE-MIT,LICENSE-APACHE thread_local: LICENSE-MIT,LICENSE-APACHE time: LICENSE-MIT,LICENSE-APACHE tinyvec: LICENSE-MIT,LICENSE-APACHE,LICENSE-ZLIB tinyvec_macros: LICENSE-MIT tokio: LICENSE-MIT tokio_io_timeout: LICENSE-MIT,LICENSE-APACHE tokio_macros: LICENSE-MIT tokio_native_tls: LICENSE-MIT tokio_stream: LICENSE-MIT tokio_tungstenite: LICENSE-MIT tokio_util: LICENSE-MIT toml_datetime: LICENSE-MIT,LICENSE-APACHE toml_edit: LICENSE-MIT,LICENSE-APACHE tonic: LICENSE-MIT tonic_build: LICENSE-MIT tonic_inf: UNLICENSE tower: LICENSE-MIT tower_http: LICENSE-MIT tower_layer: LICENSE-MIT tower_service: LICENSE-MIT tracing: LICENSE-MIT tracing_attributes: LICENSE-MIT tracing_core: LICENSE-MIT tracing_futures: LICENSE-MIT tracing_log: LICENSE-MIT tracing_subscriber: LICENSE-MIT try_lock: LICENSE-MIT tungstenite: LICENSE-MIT,LICENSE-APACHE turn: LICENSE-MIT,LICENSE-APACHE twoway: LICENSE-MIT,LICENSE-APACHE typenum: LICENSE-MIT,LICENSE-APACHE uinput_sys: UNLICENSE uinput_tokio: UNLICENSE unicase: LICENSE-MIT,LICENSE-APACHE unicode_bidi: LICENSE-MIT,LICENSE-APACHE unicode_ident: LICENSE-MIT,LICENSE-APACHE,LICENSE-UNICODE unicode_normalization: LICENSE-MIT,LICENSE-APACHE url: LICENSE-MIT,LICENSE-APACHE urlencoding: LICENSE-MIT utf_8: LICENSE-MIT,LICENSE-APACHE uuid: LICENSE-MIT,LICENSE-APACHE version: LICENSE-MIT,LICENSE-APACHE version_check: LICENSE-MIT,LICENSE-APACHE waitgroup: LICENSE-APACHE want: LICENSE-MIT warp: LICENSE-MIT webrtc_ice: LICENSE-MIT,LICENSE-APACHE webrtc_mdns: LICENSE-MIT,LICENSE-APACHE webrtc_util: LICENSE-MIT,LICENSE-APACHE which: LICENSE-MIT xdg: LICENSE-MIT,LICENSE-APACHE ~~~ ## 项目状态 本项目处于WIP状态中。