4 Commits

Author SHA1 Message Date
c8a34ee760 Set rust toolchain
Some checks failed
Build and deploy / Build container and manifests (push) Has been cancelled
2025-04-18 15:23:40 +02:00
a0b742b0b1 Changed syntax used in build.yaml 2025-04-18 15:08:07 +02:00
d4bd0ef1ca Use store instead of fetch_add for atomics
All checks were successful
Build and deploy / Build container and manifests (push) Successful in 2m48s
2025-04-18 14:58:15 +02:00
95e47c708c Highlight port in red if tunnel failed to open 2025-04-18 14:57:31 +02:00
7 changed files with 34 additions and 10 deletions

2
.cargo/config.toml Normal file
View File

@@ -0,0 +1,2 @@
[env]
RUSTC_BOOTSTRAP = "1"

View File

@@ -79,11 +79,11 @@ jobs:
- name: Push manifests
run: |
flux push artifact oci://$OCI_REPO/manifests:${{ gitea.head_ref || gitea.ref_name }} \
flux push artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
--path="./manifests.yaml" \
--source="$(git config --get remote.origin.url)" \
--revision="$(git rev-parse HEAD)" \
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
flux tag artifact oci://$OCI_REPO/manifests:${{ gitea.head_ref || gitea.ref_name }} \
flux tag artifact oci://${{ env.OCI_REPO }}/manifests:${{ gitea.head_ref || gitea.ref_name }} \
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /')

View File

@@ -16,8 +16,6 @@ RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
ARG RELEASE_VERSION
ENV RELEASE_VERSION=${RELEASE_VERSION}
# HACK: Enable the use of features on stable
ENV RUSTC_BOOTSTRAP=1
RUN cargo auditable build --release
FROM gcr.io/distroless/cc-debian12:nonroot AS runtime

4
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,4 @@
[toolchain]
channel = "1.85"
profile = "default"
components = ["rust-analyzer"]

View File

@@ -1,6 +1,6 @@
use std::pin::Pin;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::task::{Context, Poll};
use pin_project_lite::pin_project;
@@ -14,25 +14,34 @@ pub struct Stats {
connections: AtomicUsize,
rx: AtomicUsize,
tx: AtomicUsize,
failed: AtomicBool,
}
impl Stats {
pub fn add_connection(&self) {
self.connections.fetch_add(1, Ordering::Relaxed);
self.connections.store(1, Ordering::Relaxed);
}
pub fn add_rx_bytes(&self, n: usize) {
self.rx.fetch_add(n, Ordering::Relaxed);
self.rx.store(n, Ordering::Relaxed);
}
pub fn add_tx_bytes(&self, n: usize) {
self.tx.fetch_add(n, Ordering::Relaxed);
self.tx.store(n, Ordering::Relaxed);
}
pub fn connections(&self) -> usize {
self.connections.load(Ordering::Relaxed)
}
pub fn failed(&self) -> bool {
self.failed.load(Ordering::Relaxed)
}
pub fn set_failed(&self, failed: bool) {
self.failed.store(failed, Ordering::Relaxed);
}
pub fn rx(&self) -> Unit {
Unit::new(self.rx.load(Ordering::Relaxed), "B")
}

View File

@@ -40,7 +40,12 @@ impl TunnelInner {
&self.internal_address,
self.port,
)
.await?;
.await
.inspect_err(|_| {
self.stats.set_failed(true);
})?;
self.stats.set_failed(false);
Ok(TrackStats::new(channel.into_stream(), self.stats.clone()))
}

View File

@@ -17,9 +17,15 @@ pub struct TunnelRow {
impl From<&TunnelRow> for Vec<Span<'static>> {
fn from(row: &TunnelRow) -> Self {
let port = if row.stats.failed() {
row.port.clone().red()
} else {
row.port.clone()
};
vec![
row.name.clone(),
row.port.clone(),
port,
row.access.clone(),
row.address.clone(),
row.stats.connections().to_string().into(),