Skip to content

Commit

Permalink
fix ffi subscription format mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbai committed Mar 15, 2024
1 parent b10b311 commit 54c8cc2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ytflow-app-util/src/ffi/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub unsafe extern "C" fn ytflow_app_subscription_decode_with_format(
) -> ytflow_result {
ytflow_result::catch_result_unwind(AssertUnwindSafe(move || {
let subscription = std::slice::from_raw_parts(subscription, subscription_len);
let format = SubscriptionFormat(CStr::from_ptr(format).to_bytes());
let format = SubscriptionFormat(CStr::from_ptr(format).to_bytes_with_nul());
decode_subscription_with_format(subscription, format).map(|s| serialize_buffer(&s))
}))
}
2 changes: 1 addition & 1 deletion ytflow-app-util/src/proxy/data/compose_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ fn encode_protocol(
plugin: "shadowsocks-client".into(),
plugin_version: 0,
param: to_cbor(cbor!({
"cipher" => ss.cipher,
"method" => ss.cipher,
"password" => &ss.password,
"tcp_next" => tcp_next,
"udp_next" => udp_next,
Expand Down
14 changes: 7 additions & 7 deletions ytflow-app-util/src/proxy/data/v1/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,15 @@ impl<'p> Analyzer<'p> {
"shadowsocks-client" => {
#[derive(Deserialize)]
struct ShadowsocksConfig<'a> {
cipher: SupportedCipher,
method: SupportedCipher,
password: ByteBuf,
tcp_next: &'a str,
udp_next: &'a str,
}
let ss: ShadowsocksConfig = deserialize_plugin_param(plugin)?;
(
ProxyProtocolType::Shadowsocks(ShadowsocksProxy {
cipher: ss.cipher,
cipher: ss.method,
password: ss.password,
}),
ss.tcp_next,
Expand Down Expand Up @@ -623,7 +623,7 @@ mod tests {
plugin: "shadowsocks-client".into(),
plugin_version: 0,
param: to_cbor(cbor!({
"cipher" => SupportedCipher::Aes128Gcm,
"method" => SupportedCipher::Aes128Gcm,
"password" => ByteBuf::new(),
"tcp_next" => "b.tcp",
"udp_next" => "c.udp",
Expand Down Expand Up @@ -696,7 +696,7 @@ mod tests {
plugin: "shadowsocks-client".into(),
plugin_version: 0,
param: to_cbor(cbor!({
"cipher" => SupportedCipher::Aes128Gcm,
"method" => SupportedCipher::Aes128Gcm,
"password" => ByteBuf::new(),
"tcp_next" => "b.tcp",
"udp_next" => "b.udp",
Expand All @@ -720,7 +720,7 @@ mod tests {
plugin: "shadowsocks-client".into(),
plugin_version: 0,
param: to_cbor(cbor!({
"cipher" => SupportedCipher::Aes128Gcm,
"method" => SupportedCipher::Aes128Gcm,
"password" => ByteBuf::new(),
"tcp_next" => "d.tcp",
"udp_next" => "d.udp",
Expand Down Expand Up @@ -760,7 +760,7 @@ mod tests {
plugin: "shadowsocks-client".into(),
plugin_version: 0,
param: to_cbor(cbor!({
"cipher" => SupportedCipher::Aes128Gcm,
"method" => SupportedCipher::Aes128Gcm,
"password" => ByteBuf::new(),
"tcp_next" => "b.tcp",
"udp_next" => "b.udp",
Expand All @@ -784,7 +784,7 @@ mod tests {
plugin: "shadowsocks-client".into(),
plugin_version: 0,
param: to_cbor(cbor!({
"cipher" => SupportedCipher::Aes128Gcm,
"method" => SupportedCipher::Aes128Gcm,
"password" => ByteBuf::new(),
"tcp_next" => "$out.tcp",
"udp_next" => "$out.udp",
Expand Down

0 comments on commit 54c8cc2

Please sign in to comment.