-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d680c65
commit 29ec7a9
Showing
28 changed files
with
597 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# .github/workflows/build_and_upload.yml | ||
name: Build and Upload | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install musl-tools | ||
run: sudo apt-get install -y musl-tools | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: stable | ||
override: true | ||
target: x86_64-unknown-linux-musl | ||
|
||
- name: Build geph5-bridge | ||
run: cargo build --locked --release --target x86_64-unknown-linux-musl --manifest-path binaries/geph5-bridge/Cargo.toml | ||
|
||
- name: Build geph5-exit | ||
run: cargo build --locked --release --target x86_64-unknown-linux-musl --manifest-path binaries/geph5-exit/Cargo.toml | ||
|
||
# - name: Upload to S3 | ||
# uses: jakejarvis/s3-sync-action@master | ||
# with: | ||
# args: --acl public-read --follow-symlinks --delete | ||
# env: | ||
# AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | ||
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
# AWS_REGION: "us-west-1" | ||
# SOURCE_DIR: "target/x86_64-unknown-linux-musl/release" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use std::{ | ||
net::SocketAddr, | ||
time::{Duration, SystemTime}, | ||
}; | ||
|
||
use geph5_broker_protocol::{BridgeDescriptor, RouteDescriptor}; | ||
use geph5_misc_rpc::bridge::{B2eMetadata, BridgeControlClient, ObfsProtocol}; | ||
use moka::future::Cache; | ||
use nanorpc_sillad::DialerTransport; | ||
use once_cell::sync::Lazy; | ||
use sillad::tcp::TcpDialer; | ||
use sillad_sosistab3::{dialer::SosistabDialer, Cookie}; | ||
|
||
pub async fn bridge_to_leaf_route( | ||
bridge: &BridgeDescriptor, | ||
exit_b2e: SocketAddr, | ||
) -> anyhow::Result<RouteDescriptor> { | ||
static CACHE: Lazy<Cache<(SocketAddr, SocketAddr), RouteDescriptor>> = Lazy::new(|| { | ||
Cache::builder() | ||
.time_to_live(Duration::from_secs(60)) | ||
.build() | ||
}); | ||
|
||
let cookie = Cookie::new(&bridge.control_cookie); | ||
|
||
CACHE | ||
.try_get_with((bridge.control_listen, exit_b2e), async { | ||
let dialer = SosistabDialer { | ||
inner: TcpDialer { | ||
dest_addr: bridge.control_listen, | ||
}, | ||
cookie, | ||
}; | ||
let cookie = format!("exit-cookie-{}", rand::random::<u128>()); | ||
let control_client = BridgeControlClient(DialerTransport(dialer)); | ||
let forwarded_listen = control_client | ||
.tcp_forward( | ||
exit_b2e, | ||
B2eMetadata { | ||
protocol: ObfsProtocol::Sosistab3(cookie.clone()), | ||
expiry: SystemTime::now() + Duration::from_secs(86400), | ||
}, | ||
) | ||
.await?; | ||
anyhow::Ok(RouteDescriptor::Sosistab3 { | ||
cookie, | ||
lower: RouteDescriptor::Tcp(forwarded_listen).into(), | ||
}) | ||
}) | ||
.await | ||
.map_err(|err| anyhow::anyhow!("bridge comms failed: {:?}", err)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.