Skip to content

Commit

Permalink
Add subscription mod; userinfo parse
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbai committed Feb 12, 2024
1 parent 8118a47 commit fb69377
Show file tree
Hide file tree
Showing 38 changed files with 252 additions and 86 deletions.
3 changes: 0 additions & 3 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
[build]
rustflags = ["--cfg", "windows_raw_dylib"]

[unstable]
bindeps = true
34 changes: 34 additions & 0 deletions .github/workflows/build-arm-uwp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Build and Tests

on:
push:
branches: [ main, ci-scratch ]
pull_request:
branches: [ main ]

env:
CARGO_TERM_COLOR: always

jobs:
build-uwp:

runs-on: windows-latest
env:
VCPKGRS_TRIPLET: arm-uwp
UWP_CROSS_TARGET_TRIPLET: thumbv7a-uwp-windows-msvc
UWP_NATIVE_TARGET_TRIPLET: x86_64-uwp-windows-msvc
BUILD_STD_ARGS: build-std=std,panic_abort
THUMBV7A_UWP_WINDOWS_MSVC_OPENSSL_DIR: 'C:\vcpkg\installed\arm-uwp'
RUSTFLAGS: "--cfg windows_raw_dylib"

steps:
- uses: actions/checkout@v2
- name: Prepare toolchain
run: rustup show
- uses: Swatinem/rust-cache@v1

- name: Install OpenSSL
run: vcpkg install openssl:arm-uwp

- name: Build ARMv7
run: cargo build -p ytflow-uwp-plugin -Z $env:BUILD_STD_ARGS --target $env:UWP_CROSS_TARGET_TRIPLET --release
22 changes: 0 additions & 22 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,3 @@ jobs:
run: cargo build
- name: Run tests
run: cargo test

build-uwp:

runs-on: windows-latest
env:
VCPKGRS_TRIPLET: arm-uwp
UWP_CROSS_TARGET_TRIPLET: thumbv7a-uwp-windows-msvc
UWP_NATIVE_TARGET_TRIPLET: x86_64-uwp-windows-msvc
BUILD_STD_ARGS: build-std=std,panic_abort
THUMBV7A_UWP_WINDOWS_MSVC_OPENSSL_DIR: 'C:\vcpkg\installed\arm-uwp'

steps:
- uses: actions/checkout@v2
- name: Prepare toolchain
run: rustup show
- uses: Swatinem/rust-cache@v1

- name: Install OpenSSL
run: vcpkg install openssl:arm-uwp

- name: Build ARMv7
run: cargo build -p ytflow-uwp-plugin -Z $env:BUILD_STD_ARGS --target $env:UWP_CROSS_TARGET_TRIPLET --release
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ members = [
"ytflow-bin-shared",
"ytflow-uwp-plugin",
]
resolver = "1"
resolver = "2"

[patch.crates-io]
mio = { git = "https://github.com/YtFlow/mio-noafd", branch = "noafd-v0.7-nobind" }
Expand Down
4 changes: 4 additions & 0 deletions ytflow-app-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
ffi = []

[build-dependencies]
cbindgen = { version = "0.26", default-features = false }

Expand All @@ -17,5 +20,6 @@ cbor4ii = { version = "0.3", features = ["use_std", "serde1"] }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["alloc"] }
serde_bytes = "0.11"
chrono = { version = "*", features = ["serde"] }
uuid = { version = "1", features = ["serde"] }
ytflow = { path = "../ytflow" }
4 changes: 3 additions & 1 deletion ytflow-app-util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![feature(ptr_metadata)]
#![cfg_attr(feature = "ffi", feature(ptr_metadata))]

#[cfg(feature = "ffi")]
pub mod ffi;
pub mod proxy;
pub mod share_link;
pub mod subscription;
6 changes: 4 additions & 2 deletions ytflow-app-util/src/proxy.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use serde::{Deserialize, Serialize};

use ytflow::flow::DestinationAddr;

pub mod obfs;
pub mod protocol;
pub mod tls;

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Proxy {
pub name: String,
pub legs: Vec<ProxyLeg>,
pub udp_supported: bool,
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProxyLeg {
pub protocol: protocol::ProxyProtocolType,
pub dest: DestinationAddr,
Expand Down
14 changes: 10 additions & 4 deletions ytflow-app-util/src/proxy/obfs.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub mod http_obfs;
pub mod tls_obfs;
pub mod ws;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq)]
mod http_obfs;
mod tls_obfs;
mod ws;

pub use http_obfs::HttpObfsObfs;
pub use tls_obfs::TlsObfsObfs;
pub use ws::WebSocketObfs;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ProxyObfsType {
HttpObfs(http_obfs::HttpObfsObfs),
TlsObfs(tls_obfs::TlsObfsObfs),
Expand Down
4 changes: 3 additions & 1 deletion ytflow-app-util/src/proxy/obfs/http_obfs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Debug, Clone, PartialEq, Eq)]
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpObfsObfs {
pub host: String,
pub path: String,
Expand Down
4 changes: 3 additions & 1 deletion ytflow-app-util/src/proxy/obfs/tls_obfs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Debug, Clone, PartialEq, Eq)]
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TlsObfsObfs {
pub host: String,
}
4 changes: 3 additions & 1 deletion ytflow-app-util/src/proxy/obfs/ws.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Debug, Clone, PartialEq, Eq)]
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WebSocketObfs {
pub host: Option<String>,
pub path: String,
Expand Down
20 changes: 14 additions & 6 deletions ytflow-app-util/src/proxy/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
pub mod http;
pub mod shadowsocks;
pub mod socks5;
pub mod trojan;
pub mod vmess;
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, PartialEq, Eq)]
mod http;
mod shadowsocks;
mod socks5;
mod trojan;
mod vmess;

pub use http::HttpProxy;
pub use shadowsocks::ShadowsocksProxy;
pub use socks5::Socks5Proxy;
pub use trojan::TrojanProxy;
pub use vmess::VMessProxy;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ProxyProtocolType {
Shadowsocks(shadowsocks::ShadowsocksProxy),
Trojan(trojan::TrojanProxy),
Expand Down
3 changes: 2 additions & 1 deletion ytflow-app-util/src/proxy/protocol/http.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;

#[derive(Debug, Default, Clone, PartialEq, Eq)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpProxy {
pub username: ByteBuf,
pub password: ByteBuf,
Expand Down
3 changes: 2 additions & 1 deletion ytflow-app-util/src/proxy/protocol/shadowsocks.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;

use ytflow::plugin::shadowsocks::SupportedCipher;

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ShadowsocksProxy {
pub cipher: SupportedCipher,
pub password: ByteBuf,
Expand Down
3 changes: 2 additions & 1 deletion ytflow-app-util/src/proxy/protocol/socks5.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;

#[derive(Debug, Default, Clone, PartialEq, Eq)]
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Socks5Proxy {
pub username: ByteBuf,
pub password: ByteBuf,
Expand Down
3 changes: 2 additions & 1 deletion ytflow-app-util/src/proxy/protocol/trojan.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TrojanProxy {
pub password: ByteBuf,
}
3 changes: 2 additions & 1 deletion ytflow-app-util/src/proxy/protocol/vmess.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde::{Deserialize, Serialize};
use ytflow::plugin::vmess::SupportedSecurity;

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct VMessProxy {
pub user_id: uuid::Uuid,
pub alter_id: u16,
Expand Down
4 changes: 3 additions & 1 deletion ytflow-app-util/src/proxy/tls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Debug, Default, Clone, PartialEq, Eq)]
use serde::{Deserialize, Serialize};

#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ProxyTlsLayer {
pub alpn: Vec<String>,
pub sni: Option<String>,
Expand Down
5 changes: 1 addition & 4 deletions ytflow-app-util/src/share_link/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ use url::{Host, Url};

use ytflow::flow::{DestinationAddr, HostName};

use crate::proxy::protocol::{
http::HttpProxy, shadowsocks::ShadowsocksProxy, socks5::Socks5Proxy, trojan::TrojanProxy,
vmess::VMessProxy,
};
use crate::proxy::protocol::{HttpProxy, ShadowsocksProxy, Socks5Proxy, TrojanProxy, VMessProxy};
use crate::proxy::Proxy;

pub static BASE64_ENGINE: base64::engine::GeneralPurpose = base64::engine::GeneralPurpose::new(
Expand Down
3 changes: 1 addition & 2 deletions ytflow-app-util/src/share_link/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ mod tests {
use ytflow::plugin::vmess::SupportedSecurity;

use crate::proxy::protocol::{
http::HttpProxy, shadowsocks::ShadowsocksProxy, socks5::Socks5Proxy, trojan::TrojanProxy,
vmess::VMessProxy,
HttpProxy, ShadowsocksProxy, Socks5Proxy, TrojanProxy, VMessProxy,
};
use crate::proxy::tls::ProxyTlsLayer;
use crate::proxy::ProxyLeg;
Expand Down
3 changes: 1 addition & 2 deletions ytflow-app-util/src/share_link/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use ytflow::flow::DestinationAddr;

use super::decode::{extract_name_from_frag, map_host_name, DecodeError, DecodeResult, QueryMap};
use super::encode::{url_encode_host, EncodeError, EncodeResult};
use crate::proxy::protocol::http::HttpProxy;
use crate::proxy::protocol::ProxyProtocolType;
use crate::proxy::protocol::{HttpProxy, ProxyProtocolType};
use crate::proxy::tls::ProxyTlsLayer;
use crate::proxy::{Proxy, ProxyLeg};

Expand Down
2 changes: 1 addition & 1 deletion ytflow-app-util/src/share_link/shadowsocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod decode_sip002;
mod encode;

use super::decode::{extract_name_from_frag, DecodeResult, QueryMap};
use crate::proxy::protocol::shadowsocks::ShadowsocksProxy;
use crate::proxy::protocol::ShadowsocksProxy;
use crate::proxy::Proxy;

impl ShadowsocksProxy {
Expand Down
5 changes: 3 additions & 2 deletions ytflow-app-util/src/share_link/shadowsocks/decode_legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use url::{Host, Url};

use ytflow::{config::plugin::parse_supported_cipher, flow::DestinationAddr};

use crate::proxy::protocol::{shadowsocks::ShadowsocksProxy, ProxyProtocolType};
use crate::proxy::protocol::{ProxyProtocolType, ShadowsocksProxy};
use crate::proxy::ProxyLeg;
use crate::share_link::decode::{
map_host_name, DecodeError, DecodeResult, QueryMap, BASE64_ENGINE,
Expand Down Expand Up @@ -55,7 +55,8 @@ mod tests {
use base64::engine::general_purpose::STANDARD;
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};

use ytflow::{flow::HostName, plugin::shadowsocks::SupportedCipher};
use ytflow::flow::HostName;
use ytflow::plugin::shadowsocks::SupportedCipher;

use super::*;

Expand Down
7 changes: 4 additions & 3 deletions ytflow-app-util/src/share_link/shadowsocks/decode_sip002.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use url::Url;

use ytflow::{config::plugin::parse_supported_cipher, flow::DestinationAddr};

use crate::proxy::obfs::{http_obfs::HttpObfsObfs, tls_obfs::TlsObfsObfs, ProxyObfsType};
use crate::proxy::protocol::{shadowsocks::ShadowsocksProxy, ProxyProtocolType};
use crate::proxy::obfs::{HttpObfsObfs, ProxyObfsType, TlsObfsObfs};
use crate::proxy::protocol::{ProxyProtocolType, ShadowsocksProxy};
use crate::proxy::ProxyLeg;
use crate::share_link::decode::parse_host_transparent;
use crate::share_link::decode::{DecodeError, DecodeResult, QueryMap, BASE64_ENGINE};
Expand Down Expand Up @@ -93,7 +93,8 @@ mod tests {
use base64::engine::general_purpose::STANDARD;
use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC};

use ytflow::{flow::HostName, plugin::shadowsocks::SupportedCipher};
use ytflow::flow::HostName;
use ytflow::plugin::shadowsocks::SupportedCipher;

use super::*;

Expand Down
4 changes: 2 additions & 2 deletions ytflow-app-util/src/share_link/shadowsocks/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
use url::Url;

use crate::proxy::obfs::ProxyObfsType;
use crate::proxy::protocol::shadowsocks::ShadowsocksProxy;
use crate::proxy::protocol::ShadowsocksProxy;
use crate::proxy::{Proxy, ProxyLeg};
use crate::share_link::encode::{url_encode_host, EncodeError, EncodeResult};

Expand Down Expand Up @@ -67,7 +67,7 @@ mod tests {
use ytflow::flow::{DestinationAddr, HostName};
use ytflow::plugin::shadowsocks::SupportedCipher;

use crate::proxy::obfs::{http_obfs::HttpObfsObfs, tls_obfs::TlsObfsObfs, ws::WebSocketObfs};
use crate::proxy::obfs::{HttpObfsObfs, TlsObfsObfs, WebSocketObfs};
use crate::proxy::protocol::ProxyProtocolType;

use super::*;
Expand Down
3 changes: 1 addition & 2 deletions ytflow-app-util/src/share_link/socks5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use super::decode::{
extract_name_from_frag, parse_host_transparent, DecodeError, DecodeResult, QueryMap,
};
use super::encode::{url_encode_host, EncodeError, EncodeResult};
use crate::proxy::protocol::socks5::Socks5Proxy;
use crate::proxy::protocol::ProxyProtocolType;
use crate::proxy::protocol::{ProxyProtocolType, Socks5Proxy};
use crate::proxy::{Proxy, ProxyLeg};

impl Socks5Proxy {
Expand Down
3 changes: 1 addition & 2 deletions ytflow-app-util/src/share_link/trojan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use super::decode::{
extract_name_from_frag, parse_host_transparent, DecodeError, DecodeResult, QueryMap,
};
use super::encode::{url_encode_host, EncodeError, EncodeResult};
use crate::proxy::protocol::trojan::TrojanProxy;
use crate::proxy::protocol::ProxyProtocolType;
use crate::proxy::protocol::{ProxyProtocolType, TrojanProxy};
use crate::proxy::tls::ProxyTlsLayer;
use crate::proxy::{Proxy, ProxyLeg};

Expand Down
2 changes: 1 addition & 1 deletion ytflow-app-util/src/share_link/vmess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod v2rayn;

use super::decode::{DecodeResult, QueryMap};
use super::encode::EncodeResult;
use crate::proxy::protocol::vmess::VMessProxy;
use crate::proxy::protocol::VMessProxy;
use crate::proxy::{Proxy, ProxyLeg};

impl VMessProxy {
Expand Down
Loading

0 comments on commit fb69377

Please sign in to comment.