Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched from aws-lc-sys to ring #3

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,56 @@ jobs:
name: artifacts-dist-manifest
path: dist-manifest.json

publish-homebrew-formula:
needs:
- plan
- host
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLAN: ${{ needs.plan.outputs.val }}
GITHUB_USER: "axo bot"
GITHUB_EMAIL: "[email protected]"
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
steps:
- uses: actions/checkout@v4
with:
repository: "manforowicz/homebrew-tap"
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
# So we have access to the formula
- name: Fetch homebrew formulae
uses: actions/download-artifact@v4
with:
pattern: artifacts-*
path: Formula/
merge-multiple: true
# This is extra complex because you can make your Formula name not match your app name
# so we need to find releases with a *.rb file, and publish with that filename.
- name: Commit formula files
run: |
git config --global user.name "${GITHUB_USER}"
git config --global user.email "${GITHUB_EMAIL}"

for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
name=$(echo "$filename" | sed "s/\.rb$//")
version=$(echo "$release" | jq .app_version --raw-output)

git add "Formula/${filename}"
git commit -m "${name} ${version}"
done
git push

# Create a GitHub Release while uploading all files to it
announce:
needs:
- plan
- host
- publish-homebrew-formula
# use "always() && ..." to allow us to wait for all publish jobs while
# still allowing individual publish jobs to skip themselves (for prereleases).
# "host" however must run to completion, no skipping allowed!
if: ${{ always() && needs.host.result == 'success' }}
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Cargo Build & Test

on:
push:
branches:
- main
pull_request:

env:
Expand All @@ -14,9 +16,9 @@ jobs:
strategy:
matrix:
toolchain:
- stable
# - stable
- beta
- nightly
# - nightly
steps:
- uses: actions/checkout@v3

Expand Down
31 changes: 11 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,12 @@ members = [
"gday_file_transfer",
]

# Config for 'cargo dist'
# specifying build dependencies for aws-lc-sys
[workspace.metadata.dist.dependencies.homebrew]
llvm = '*'
cmake = '*'


[workspace.metadata.dist.dependencies.apt]
clang = '*'
build-essential = '*'
cmake = '*'


[workspace.metadata.dist.dependencies.chocolatey]
clang = '*'
cmake = '*'
nasm = '*'
# Keys that workspace packages will inherit
[workspace.package]
authors = ["Marcin Anforowicz"]
edition = "2021"
license = "MIT"
repository = "https://github.com/manforowicz/gday/"

# Config for 'cargo dist'
[workspace.metadata.dist]
Expand All @@ -35,13 +24,15 @@ cargo-dist-version = "0.15.1"
# CI backends to support
ci = "github"
# The installers to generate for each app
installers = []
installers = ["homebrew"]
# A GitHub repo to push Homebrew formulas to
tap = "manforowicz/homebrew-tap"
# Target platforms to build apps for (Rust target-triple syntax)
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
# Publish jobs to run in CI
publish-jobs = ["homebrew"]
# Publish jobs to run in CI
pr-run-mode = "plan"
# Whether to install an updater program
install-updater = false

# The profile that 'cargo dist' will build with
[profile.dist]
Expand Down
18 changes: 8 additions & 10 deletions gday/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[package]
name = "gday"
version = "0.1.1"
authors = ["Marcin Anforowicz"]
edition = "2021"
description = "Command line tool to send files easily, securely, and directly, without a relay or port forwarding."
license = "MIT"
repository = "https://github.com/manforowicz/gday/"
homepage = "https://github.com/manforowicz/gday/gday/"

# Inherit these keys from workspace toml
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

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

Expand All @@ -23,9 +26,4 @@ owo-colors = "4.0.0"
postcard = "1.0.8"
rand = "0.8.5"
serde = { version = "1.0.203", features = ["serde_derive"] }
thiserror = "1.0.61"

[dev-dependencies]
assert_cmd = "2.0.14"
gday_server = { version = "0.1.1", path = "../gday_server" }
tempfile = "3.10.1"
thiserror = "1.0.61"
11 changes: 7 additions & 4 deletions gday_contact_exchange_protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[package]
name = "gday_contact_exchange_protocol"
version = "0.1.1"
authors = ["Marcin Anforowicz"]
edition = "2021"
description = "Protocol that peers can use to exchange their public and private socket addresses via a server."
license = "MIT"
repository = "https://github.com/manforowicz/gday/"
homepage = "https://github.com/manforowicz/gday/gday_contact_exchange_protocol/"

# Inherit these keys from workspace toml
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

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

Expand Down
11 changes: 7 additions & 4 deletions gday_encryption/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[package]
name = "gday_encryption"
version = "0.1.1"
authors = ["Marcin Anforowicz"]
edition = "2021"
description = "A simple ChaCha20Poly1305 encryption wrapper around an IO stream."
license = "MIT"
repository = "https://github.com/manforowicz/gday/"
homepage = "https://github.com/manforowicz/gday/gday_encryption/"

# Inherit these keys from workspace toml
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

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

Expand Down
11 changes: 7 additions & 4 deletions gday_file_transfer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[package]
name = "gday_file_transfer"
version = "0.1.1"
authors = ["Marcin Anforowicz"]
edition = "2021"
description = "A minimal protocol to securely transfer files over an IO stream. Used by gday."
license = "MIT"
repository = "https://github.com/manforowicz/gday/"
homepage = "https://github.com/manforowicz/gday/gday_file_transfer/"

# Inherit these keys from workspace toml
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

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

Expand Down
15 changes: 9 additions & 6 deletions gday_hole_punch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[package]
name = "gday_hole_punch"
version = "0.1.1"
authors = ["Marcin Anforowicz"]
edition = "2021"
description = "Establish an authenticated peer-to-peer internet connection using TCP hole-punching."
license = "MIT"
repository = "https://github.com/manforowicz/gday/"
homepage = "https://github.com/manforowicz/gday/gday_hole_punch/"

# Inherit these keys from workspace toml
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

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

Expand All @@ -14,9 +17,9 @@ blake3 = "1.5.1"
gday_contact_exchange_protocol = { version = "0.1.1", path = "../gday_contact_exchange_protocol" }
log = "0.4.21"
rand = "0.8.5"
rustls = "0.23.9"
rustls = { version = "0.23.9", features = ["ring", "log", "logging", "std", "tls12"], default-features = false }
serde = "1.0.203"
socket2 = "0.5.7"
socket2 = { version = "0.5.7", features = ["all"] }
spake2 = { version = "0.4.0", features = ["std"] }
thiserror = "1.0.61"
tokio = { version = "1.38.0", features = ["net", "rt", "time"] }
Expand Down
8 changes: 5 additions & 3 deletions gday_hole_punch/src/hole_puncher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,14 @@ fn get_local_socket(local_addr: SocketAddr) -> std::io::Result<TcpSocket> {
let sock = SockRef::from(&socket);

let _ = sock.set_reuse_address(true);

// socket2 only supports this method on these systems
#[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))]
let _ = sock.set_reuse_port(true);

let keepalive = TcpKeepalive::new()
.with_time(Duration::from_secs(5))
.with_interval(Duration::from_secs(2))
.with_retries(5);
.with_time(Duration::from_secs(60))
.with_interval(Duration::from_secs(10));
let _ = sock.set_tcp_keepalive(&keepalive);

socket.bind(local_addr)?;
Expand Down
5 changes: 4 additions & 1 deletion gday_hole_punch/src/server_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ impl ServerStream {
/// So that this socket can be reused for
/// hole-punching.
fn enable_reuse(&self) {
let stream = match self {
let stream: &TcpStream = match self {
Self::TCP(stream) => stream,
Self::TLS(stream) => stream.get_ref(),
};

let sock = SockRef::from(stream);
let _ = sock.set_reuse_address(true);

// socket2 only supports this method on these systems
#[cfg(all(unix, not(any(target_os = "solaris", target_os = "illumos"))))]
let _ = sock.set_reuse_port(true);
}
}
Expand Down
15 changes: 9 additions & 6 deletions gday_server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
[package]
name = "gday_server"
version = "0.1.1"
authors = ["Marcin Anforowicz"]
edition = "2021"
description = "A server that lets 2 peers exchange their private and public addresses via the gday contact exchange protocol."
license = "MIT"
repository = "https://github.com/manforowicz/gday/"
homepage = "https://github.com/manforowicz/gday/gday_server/"

# Inherit these keys from workspace toml
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true

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

[dependencies]
clap = { version = "4.5.4", features = ["derive"] }
socket2 = "0.5.7"
socket2 = { version = "0.5.7", features = ["all"] }
tokio = { version = "1.38.0", features = [
"rt-multi-thread",
"macros",
"net",
"time",
"sync",
] }
tokio-rustls = "0.26.0"
tokio-rustls = { version = "0.26.0", features = ["ring", "logging", "tls12"], default-features = false }
gday_contact_exchange_protocol = { path = "../gday_contact_exchange_protocol" }
thiserror = "1.0.61"
log = "0.4.21"
Expand Down
3 changes: 1 addition & 2 deletions gday_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ async fn get_tcp_listener(addr: impl ToSocketAddrs + Display) -> TcpListener {
// sets the keepalive to 10 minutes
let tcp_keepalive = TcpKeepalive::new()
.with_time(Duration::from_secs(600))
.with_interval(Duration::from_secs(10))
.with_retries(3);
.with_interval(Duration::from_secs(10));
let socket = SockRef::from(&listener);
socket
.set_tcp_keepalive(&tcp_keepalive)
Expand Down