Compare commits
1 Commits
v1.2.0
...
4a9dec7e34
| Author | SHA1 | Date | |
|---|---|---|---|
|
4a9dec7e34
|
@@ -17,13 +17,14 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Set timestamp and release version
|
||||
- name: Set git based environment variables
|
||||
run: |
|
||||
echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
|
||||
git fetch --prune --unshallow --tags --force
|
||||
echo "RELEASE_VERSION=$(git describe --always --dirty='--modified')" >> $GITHUB_ENV
|
||||
cat $GITHUB_ENV
|
||||
echo "RELEASE_VERSION=$(git describe --always --dirty='--modified)" >> $GITHUB_ENV
|
||||
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v3
|
||||
|
||||
@@ -15,7 +15,7 @@ RUN cargo chef cook --release --recipe-path recipe.json
|
||||
|
||||
COPY . .
|
||||
ARG RELEASE_VERSION
|
||||
ENV RELEASE_VERSION=${RELEASE_VERSION}
|
||||
ENV RELEASE_VERSION ${RELEASE_VERSION}
|
||||
# HACK: Enable the use of features on stable
|
||||
ENV RUSTC_BOOTSTRAP=1
|
||||
RUN cargo auditable build --release
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use pin_project_lite::pin_project;
|
||||
@@ -14,34 +14,25 @@ pub struct Stats {
|
||||
connections: AtomicUsize,
|
||||
rx: AtomicUsize,
|
||||
tx: AtomicUsize,
|
||||
failed: AtomicBool,
|
||||
}
|
||||
|
||||
impl Stats {
|
||||
pub fn add_connection(&self) {
|
||||
self.connections.store(1, Ordering::Relaxed);
|
||||
self.connections.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn add_rx_bytes(&self, n: usize) {
|
||||
self.rx.store(n, Ordering::Relaxed);
|
||||
self.rx.fetch_add(n, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
pub fn add_tx_bytes(&self, n: usize) {
|
||||
self.tx.store(n, Ordering::Relaxed);
|
||||
self.tx.fetch_add(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")
|
||||
}
|
||||
|
||||
@@ -5,7 +5,10 @@ mod io;
|
||||
pub mod ldap;
|
||||
pub mod ssh;
|
||||
pub mod tunnel;
|
||||
mod version;
|
||||
pub mod web;
|
||||
|
||||
pub use version::VERSION;
|
||||
pub fn get_version() -> &'static str {
|
||||
std::option_env!("RELEASE_VERSION")
|
||||
.filter(|version| !version.is_empty())
|
||||
.unwrap_or(git_version::git_version!())
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use dotenvy::dotenv;
|
||||
use hyper::server::conn::http1::{self};
|
||||
use hyper_util::rt::TokioIo;
|
||||
use rand::rngs::OsRng;
|
||||
use siranga::VERSION;
|
||||
use siranga::get_version;
|
||||
use siranga::ldap::Ldap;
|
||||
use siranga::ssh::Server;
|
||||
use siranga::tunnel::Registry;
|
||||
@@ -38,7 +38,7 @@ async fn main() -> color_eyre::Result<()> {
|
||||
.init();
|
||||
}
|
||||
|
||||
info!(version = VERSION, "Starting",);
|
||||
info!(version = get_version(), "Starting",);
|
||||
|
||||
let key = if let Ok(path) = std::env::var("PRIVATE_KEY_FILE") {
|
||||
russh::keys::PrivateKey::read_openssh_file(Path::new(&path))
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::cmp::min;
|
||||
use std::iter::once;
|
||||
|
||||
use clap::Parser;
|
||||
use git_version::git_version;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::prelude::CrosstermBackend;
|
||||
use ratatui::{Terminal, TerminalOptions, Viewport};
|
||||
@@ -10,14 +11,13 @@ use russh::keys::ssh_key::PublicKey;
|
||||
use russh::server::{Auth, Msg, Session};
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
use crate::VERSION;
|
||||
use crate::io::{Input, TerminalHandle};
|
||||
use crate::ldap::{Ldap, LdapError};
|
||||
use crate::tunnel::{Registry, Tunnel, TunnelAccess};
|
||||
|
||||
/// Quickly create http tunnels for development
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version = VERSION, about, long_about = None)]
|
||||
#[command(version = git_version!(), about, long_about = None)]
|
||||
pub struct Args {
|
||||
/// Make all tunnels public by default instead of private
|
||||
#[arg(long, group = "access")]
|
||||
|
||||
@@ -17,7 +17,7 @@ use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
|
||||
use tracing::error;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::VERSION;
|
||||
use crate::get_version;
|
||||
use crate::io::TerminalHandle;
|
||||
use crate::tunnel::{Tunnel, TunnelRow};
|
||||
|
||||
@@ -165,7 +165,7 @@ impl RendererInner {
|
||||
}
|
||||
|
||||
fn render_title(&self, frame: &mut Frame, rect: Rect) {
|
||||
let title = format!("{} ({})", std::env!("CARGO_PKG_NAME"), VERSION).bold();
|
||||
let title = format!("{} ({})", std::env!("CARGO_PKG_NAME"), get_version()).bold();
|
||||
let title = Line::from(title).centered();
|
||||
frame.render_widget(title, rect);
|
||||
}
|
||||
|
||||
@@ -40,12 +40,7 @@ impl TunnelInner {
|
||||
&self.internal_address,
|
||||
self.port,
|
||||
)
|
||||
.await
|
||||
.inspect_err(|_| {
|
||||
self.stats.set_failed(true);
|
||||
})?;
|
||||
|
||||
self.stats.set_failed(false);
|
||||
.await?;
|
||||
|
||||
Ok(TrackStats::new(channel.into_stream(), self.stats.clone()))
|
||||
}
|
||||
|
||||
@@ -17,15 +17,9 @@ 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(),
|
||||
port,
|
||||
row.port.clone(),
|
||||
row.access.clone(),
|
||||
row.address.clone(),
|
||||
row.stats.connections().to_string().into(),
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
pub const VERSION: &str = get_version();
|
||||
|
||||
const fn get_version() -> &'static str {
|
||||
if let Some(version) = std::option_env!("RELEASE_VERSION")
|
||||
&& !version.is_empty()
|
||||
{
|
||||
version
|
||||
} else {
|
||||
git_version::git_version!(fallback = "unknown")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user