Skip to content

Commit

Permalink
disable signal listening for windows and add build action for windows
Browse files Browse the repository at this point in the history
bump version to 0.3.4
  • Loading branch information
neevek committed Mar 23, 2023
1 parent cdc8224 commit 7dbe33e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 18 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,32 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

windows-x86_64:
name: Windows x86_64
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
override: true
- run: cargo build --all-features --release && mkdir -p rstun-windows-x86_64
&& mv target/release/rstunc.exe ./rstun-windows-x86_64/
&& mv target/release/rstund.exe ./rstun-windows-x86_64/
&& 7z a rstun-windows-x86_64.zip ./rstun-windows-x86_64/*
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
rstun-windows-x86_64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

darwin-x86_64:
name: Darwin x86_64
runs-on: macos-latest
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rstun"
version = "0.3.3"
version = "0.3.4"
edition = "2021"

[lib]
Expand Down
36 changes: 20 additions & 16 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::net::{IpAddr, SocketAddr};
use std::sync::{Arc, Mutex, RwLock};
use std::time::SystemTime;
use tokio::net::TcpStream;
#[cfg(not(target_os = "windows"))]
use tokio::signal::unix::{signal, SignalKind};
use tokio::sync::mpsc::Receiver;
use tokio::time::Duration;
Expand Down Expand Up @@ -346,26 +347,29 @@ impl Client {
}

async fn observe_terminate_signals(&mut self) -> Result<()> {
let mut quic_send = self.ctrl_stream.take().unwrap().quic_send;
#[cfg(not(target_os = "windows"))]
{
let mut quic_send = self.ctrl_stream.take().unwrap().quic_send;

let is_terminated_flag = self.is_terminated.clone();
let is_terminated_flag = self.is_terminated.clone();

tokio::spawn(async move {
let mut ctrlc = signal(SignalKind::interrupt()).unwrap();
let mut terminate = signal(SignalKind::terminate()).unwrap();
tokio::select! {
_ = ctrlc.recv() => debug!("received SIGINT"),
_ = terminate.recv() => debug!("received SIGTERM"),
}
*is_terminated_flag.lock().unwrap() = true;
tokio::spawn(async move {
let mut ctrlc = signal(SignalKind::interrupt()).unwrap();
let mut terminate = signal(SignalKind::terminate()).unwrap();
tokio::select! {
_ = ctrlc.recv() => debug!("received SIGINT"),
_ = terminate.recv() => debug!("received SIGTERM"),
}
*is_terminated_flag.lock().unwrap() = true;

TunnelMessage::send(&mut quic_send, &TunnelMessage::ReqTerminate)
.await
.ok();
TunnelMessage::send(&mut quic_send, &TunnelMessage::ReqTerminate)
.await
.ok();

tokio::time::sleep(Duration::from_millis(1000)).await;
std::process::exit(0);
});
tokio::time::sleep(Duration::from_millis(1000)).await;
std::process::exit(0);
});
}

Ok(())
}
Expand Down

0 comments on commit 7dbe33e

Please sign in to comment.