Skip to content

Commit

Permalink
Use ring and rustls on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
eycorsican committed Oct 26, 2020
1 parent 71c0144 commit 2f70780
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ jobs:
- name: build
run: |
# OPENSSL_DIR=/tmp/openssl-ios64 cargo lipo --release -p leaf-mobile --targets aarch64-apple-ios
cargo lipo --release -p leaf-mobile --targets aarch64-apple-ios
- name: generate header
run: |
cbindgen leaf-mobile/src/lib.rs -l c > leaf.h
make ios
- name: zip artifacts
run: |
mv target/universal/release/libleaf.a .
mv target/universal/release/leaf.h .
zip libleaf-ios.zip leaf.h libleaf.a
- name: upload assets
Expand Down
11 changes: 2 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,14 @@ jobs:
- name: build
run: |
# OPENSSL_DIR=/tmp/openssl-ios64 cargo lipo --release -p leaf-mobile --targets aarch64-apple-ios
cargo lipo --release -p leaf-mobile --targets aarch64-apple-ios
- name: generate header
run: |
cbindgen leaf-mobile/src/lib.rs -l c > leaf.h
make ios
- name: zip artifacts
run: |
mv target/universal/release/libleaf.a .
mv target/universal/release/leaf.h .
zip libleaf-ios.zip leaf.h libleaf.a
- name: verify zip artifacts
run: |
unzip -l libleaf-ios.zip
- name: upload assets
uses: actions/upload-artifact@v2
with:
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
ios:
cargo lipo -p leaf-mobile --release --targets aarch64-apple-ios && cbindgen leaf-mobile/src/lib.rs -l c > target/universal/release/leaf.h
cargo lipo -p leaf-mobile --release --targets aarch64-apple-ios --manifest-path leaf-mobile/Cargo.toml --no-default-features --features "common config ring-aead rustls-tls"
cbindgen leaf-mobile/src/lib.rs -l c > target/universal/release/leaf.h

ios-dev:
cargo lipo -p leaf-mobile --targets aarch64-apple-ios && cbindgen leaf-mobile/src/lib.rs -l c > target/universal/debug/leaf.h
cargo lipo -p leaf-mobile --targets aarch64-apple-ios --manifest-path leaf-mobile/Cargo.toml --no-default-features --features "common config ring-aead rustls-tls"
cbindgen leaf-mobile/src/lib.rs -l c > target/universal/debug/leaf.h

local:
cargo build -p leaf-bin --release
Expand Down
18 changes: 17 additions & 1 deletion leaf-mobile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,24 @@ name = "leaf"
path = "src/lib.rs"
crate-type = ["staticlib"]

[features]
default = ["common", "config", "ring-aead", "rustls-tls"]

config = ["json-config", "conf-config"]

json-config = ["leaf/json"]
conf-config = ["leaf/conf"]

ring-aead = ["leaf/ring-aead"]
openssl-aead = ["leaf/openssl-aead"]

rustls-tls = ["leaf/rustls-tls"]
openssl-tls = ["leaf/openssl-tls"]

common = ["leaf/endpoint", "leaf/ensemble"]

[dependencies]
leaf = { path = "../leaf" }
leaf = { path = "../leaf", default-features = false, optional = true }
log = "0.4"
fern = { version = "0.5", features = ["colored"] }
memchr = "2.3"
Expand Down
2 changes: 1 addition & 1 deletion leaf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "leaf"
path = "src/lib.rs"

[features]
default = ["config", "endpoint", "ensemble", "openssl-aead", "openssl-tls"]
default = ["config", "endpoint", "ensemble", "ring-aead", "rustls-tls"]

ring-aead = ["ring"]
openssl-aead = ["openssl"]
Expand Down
12 changes: 6 additions & 6 deletions leaf/src/proxy/tun/netstack/tcp_stream_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,12 @@ impl Drop for TcpStreamImpl {
unsafe {
let _g = self.lwip_lock.lock();
if !self.errored {
// tcp_arg(self.pcb, std::ptr::null_mut());
// tcp_recv(self.pcb, None);
// tcp_sent(self.pcb, None);
// tcp_err(self.pcb, None);
// tcp_close(self.pcb);
tcp_abort(self.pcb);
// TODO
tcp_close(self.pcb);
tcp_arg(self.pcb, std::ptr::null_mut());
tcp_recv(self.pcb, None);
tcp_sent(self.pcb, None);
tcp_err(self.pcb, None);
}
}
}
Expand Down

0 comments on commit 2f70780

Please sign in to comment.