Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e63c834f5 | ||
|
|
b5e0484d03 |
@@ -0,0 +1,182 @@
|
||||
name: build-test
|
||||
|
||||
# ------------- NOTE
|
||||
# please setup some secrets before running this workflow:
|
||||
# DOCKER_IMAGE should be the target image name on docker hub (e.g. "rustdesk/rustdesk-server-s6" )
|
||||
# DOCKER_IMAGE_CLASSIC should be the target image name on docker hub for the old build (e.g. "rustdesk/rustdesk-server" )
|
||||
# DOCKER_USERNAME is the username you normally use to login at https://hub.docker.com/
|
||||
# DOCKER_PASSWORD is a token you should create under "account settings / security" with read/write access
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- 'test.*'
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
LATEST_TAG: latest
|
||||
|
||||
jobs:
|
||||
|
||||
# binary build
|
||||
build:
|
||||
|
||||
name: Build - ${{ matrix.job.name }}
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { name: "amd64", target: "x86_64-unknown-linux-musl" }
|
||||
- { name: "arm64v8", target: "aarch64-unknown-linux-musl" }
|
||||
- { name: "armv7", target: "armv7-unknown-linux-musleabihf" }
|
||||
- { name: "i386", target: "i686-unknown-linux-musl" }
|
||||
#- { name: "amd64fb", target: "x86_64-unknown-freebsd" }
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
default: true
|
||||
components: rustfmt
|
||||
profile: minimal
|
||||
target: ${{ matrix.job.target }}
|
||||
|
||||
- name: Build
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --all-features --target=${{ matrix.job.target }}
|
||||
use-cross: true
|
||||
|
||||
- name: Exec chmod
|
||||
run: chmod -v a+x target/${{ matrix.job.target }}/release/*
|
||||
|
||||
- name: Publish Artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: binaries-linux-${{ matrix.job.name }}
|
||||
path: |
|
||||
target/${{ matrix.job.target }}/release/hbbr
|
||||
target/${{ matrix.job.target }}/release/hbbs
|
||||
target/${{ matrix.job.target }}/release/rustdesk-utils
|
||||
if-no-files-found: error
|
||||
|
||||
|
||||
# docker build and push of single-arch images
|
||||
docker:
|
||||
|
||||
name: Docker push - ${{ matrix.job.name }}
|
||||
needs: build
|
||||
runs-on: ubuntu-24.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
job:
|
||||
- { name: "amd64", docker_platform: "linux/amd64", s6_platform: "x86_64" }
|
||||
- { name: "arm64v8", docker_platform: "linux/arm64", s6_platform: "aarch64" }
|
||||
- { name: "armv7", docker_platform: "linux/arm/v7", s6_platform: "armhf" }
|
||||
# - { name: "i386", docker_platform: "linux/386", s6_platform: "i686" }
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Download binaries
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: binaries-linux-${{ matrix.job.name }}
|
||||
path: docker/rootfs/usr/bin
|
||||
|
||||
- name: Make binaries executable
|
||||
run: chmod -v a+x docker/rootfs/usr/bin/*
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: registry.hub.docker.com/${{ secrets.DOCKER_IMAGE }}
|
||||
|
||||
- name: Get git tag
|
||||
id: vars
|
||||
run: |
|
||||
T=${GITHUB_REF#refs/*/}
|
||||
M=${T%%.*}
|
||||
echo "GIT_TAG=$T" >> $GITHUB_ENV
|
||||
echo "MAJOR_TAG=$M" >> $GITHUB_ENV
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: "./docker"
|
||||
platforms: ${{ matrix.job.docker_platform }}
|
||||
push: true
|
||||
provenance: false
|
||||
build-args: |
|
||||
S6_ARCH=${{ matrix.job.s6_platform }}
|
||||
tags: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-${{ matrix.job.name }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
# docker build and push of multiarch images
|
||||
docker-manifest:
|
||||
|
||||
name: Docker manifest s6
|
||||
needs: docker
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
|
||||
- name: Log in to Docker Hub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Get git tag
|
||||
id: vars
|
||||
run: |
|
||||
T=${GITHUB_REF#refs/*/}
|
||||
M=${T%%.*}
|
||||
echo "GIT_TAG=$T" >> $GITHUB_ENV
|
||||
echo "MAJOR_TAG=$M" >> $GITHUB_ENV
|
||||
|
||||
# manifest for :1.2.3 tag
|
||||
# this has to run only if invoked by a new tag
|
||||
- name: Create and push manifest (:ve.rs.ion)
|
||||
uses: Noelware/docker-manifest-action@master
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
with:
|
||||
tags: ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}
|
||||
inputs: |
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-amd64,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-arm64v8,
|
||||
${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-armv7,
|
||||
# ${{ secrets.DOCKER_IMAGE }}:${{ env.GIT_TAG }}-i386
|
||||
push: true
|
||||
+27
-54
@@ -39,6 +39,8 @@ use hbb_common::{
|
||||
};
|
||||
use ipnetwork::Ipv4Network;
|
||||
|
||||
use crate::jwt;
|
||||
use std::io::Error;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr},
|
||||
@@ -46,7 +48,6 @@ use std::{
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
};
|
||||
use crate::jwt;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum Data {
|
||||
@@ -62,6 +63,7 @@ struct SafeWsSink {
|
||||
sink: WsSink,
|
||||
encrypt: Option<Encrypt>,
|
||||
}
|
||||
|
||||
struct SafeTcpStreamSink {
|
||||
sink: TcpStreamSink,
|
||||
encrypt: Option<Encrypt>,
|
||||
@@ -124,7 +126,7 @@ pub struct RendezvousServer {
|
||||
relay_servers0: Arc<RelayServers>,
|
||||
rendezvous_servers: Arc<Vec<String>>,
|
||||
inner: Arc<Inner>,
|
||||
ws_map: Arc<Mutex<HashMap<SocketAddr, Sink>>>
|
||||
ws_map: Arc<Mutex<HashMap<SocketAddr, Sink>>>,
|
||||
}
|
||||
|
||||
enum LoopFailure {
|
||||
@@ -183,7 +185,7 @@ impl RendezvousServer {
|
||||
secure_tcp_pk_b,
|
||||
secure_tcp_sk_b,
|
||||
}),
|
||||
ws_map: Arc::new(Mutex::new(HashMap::new()))
|
||||
ws_map: Arc::new(Mutex::new(HashMap::new())),
|
||||
};
|
||||
log::info!("mask: {:?}", rs.inner.mask);
|
||||
log::info!("local-ip: {:?}", rs.inner.local_ip);
|
||||
@@ -211,11 +213,13 @@ impl RendezvousServer {
|
||||
|
||||
let must_login = get_arg("must-login");
|
||||
log::debug!("must_login={}", must_login);
|
||||
if must_login.to_uppercase() == "Y" ||
|
||||
(must_login == "" && std::env::var("MUST_LOGIN")
|
||||
.unwrap_or_default()
|
||||
.to_uppercase()
|
||||
== "Y") {
|
||||
if must_login.to_uppercase() == "Y"
|
||||
|| (must_login == ""
|
||||
&& std::env::var("MUST_LOGIN")
|
||||
.unwrap_or_default()
|
||||
.to_uppercase()
|
||||
== "Y")
|
||||
{
|
||||
MUST_LOGIN.store(true, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
@@ -498,7 +502,7 @@ impl RendezvousServer {
|
||||
// B registered
|
||||
if !rp.id.is_empty() {
|
||||
log::trace!("New peer registered: {:?} {:?}", &rp.id, &addr);
|
||||
let request_pk = self.update_addr(rp.id, addr).await;
|
||||
let request_pk = self.update_addr(rp.id, addr).await;
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_register_peer_response(RegisterPeerResponse {
|
||||
request_pk,
|
||||
@@ -772,11 +776,7 @@ impl RendezvousServer {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
async fn update_addr(
|
||||
&mut self,
|
||||
id: String,
|
||||
socket_addr: SocketAddr,
|
||||
) -> bool {
|
||||
async fn update_addr(&mut self, id: String, socket_addr: SocketAddr) -> bool {
|
||||
let (request_pk, ip_change) = if let Some(old) = self.pm.get_in_memory(&id).await {
|
||||
let mut old = old.write().await;
|
||||
let ip = socket_addr.ip();
|
||||
@@ -888,7 +888,7 @@ impl RendezvousServer {
|
||||
ph: PunchHoleRequest,
|
||||
key: &str,
|
||||
ws: bool,
|
||||
) -> ResultType<(RendezvousMessage, Option<(SocketAddr)>)> {
|
||||
) -> ResultType<(RendezvousMessage, Option<SocketAddr>)> {
|
||||
let mut ph = ph;
|
||||
if !key.is_empty() && ph.licence_key != key {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
@@ -987,7 +987,7 @@ impl RendezvousServer {
|
||||
});
|
||||
}
|
||||
//
|
||||
Ok((msg_out, Some((peer_addr))))
|
||||
Ok((msg_out, Some(peer_addr)))
|
||||
} else {
|
||||
let mut msg_out = RendezvousMessage::new();
|
||||
msg_out.set_punch_hole_response(PunchHoleResponse {
|
||||
@@ -1064,38 +1064,6 @@ impl RendezvousServer {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/**
|
||||
async fn handle_tcp_punch_hole_request(
|
||||
&mut self,
|
||||
addr: SocketAddr,
|
||||
ph: PunchHoleRequest,
|
||||
key: &str,
|
||||
ws: bool,
|
||||
) -> ResultType<()> {
|
||||
let (msg, to_addr) = self.handle_punch_hole_request(addr, ph, key, ws).await?;
|
||||
log::debug!(
|
||||
"handle_tcp_punch_hole_request: {:?} to {:?}",
|
||||
&msg, &to_addr
|
||||
);
|
||||
//
|
||||
|
||||
if let Some(addr) = to_addr {
|
||||
// self.send_to_tcp_sync(msg, addr).await?;
|
||||
//这里无法判断目标addr是否是ws,请求无法发送到目标peer
|
||||
if self.tcp_punch.lock().await.contains_key(&try_into_v4(addr)) {
|
||||
self.send_to_tcp_sync(msg, addr).await?; //这里如果client使用ws,可以,但如果不用ws就必须用下面的,怎么判断呢
|
||||
//这样判断还是不行,如果client从ws切换回udp,tcp_punch中还是有残留,会导致发送失败,应该做个新的hashmap存??
|
||||
} else {
|
||||
self.tx.send(Data::Msg(msg.into(), addr))?;
|
||||
}
|
||||
// self.tx.send(Data::Msg(msg.into(), addr))?;
|
||||
|
||||
} else {
|
||||
self.send_to_tcp_sync(msg, addr).await?;
|
||||
}
|
||||
Ok(())
|
||||
}**/
|
||||
|
||||
#[inline]
|
||||
async fn handle_udp_punch_hole_request(
|
||||
&mut self,
|
||||
@@ -1310,11 +1278,7 @@ impl RendezvousServer {
|
||||
MUST_LOGIN.store(false, Ordering::SeqCst);
|
||||
}
|
||||
} else {
|
||||
let _ = writeln!(
|
||||
res,
|
||||
"MUST_LOGIN: {:?}",
|
||||
MUST_LOGIN.load(Ordering::SeqCst)
|
||||
);
|
||||
let _ = writeln!(res, "MUST_LOGIN: {:?}", MUST_LOGIN.load(Ordering::SeqCst));
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
@@ -1420,7 +1384,16 @@ impl RendezvousServer {
|
||||
if !key.is_empty() {
|
||||
self.key_exchange_phase1(addr, &mut sink).await;
|
||||
}
|
||||
while let Ok(Some(Ok(bytes))) = timeout(30_000, b.next()).await {
|
||||
while let Ok(Some(Ok(mut bytes))) = timeout(30_000, b.next()).await {
|
||||
// log::debug!("receive tcp data from {:?} {:?}", addr, bytes);
|
||||
if let Some(Sink::Tss(s)) = sink.as_mut() {
|
||||
if let Some(key) = s.encrypt.as_mut() {
|
||||
if let Err(err) = key.dec(&mut bytes) {
|
||||
log::error!("dec tcp data from {:?} err: {:?}", addr, err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.handle_tcp(&bytes, &mut sink, addr, key, ws).await {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user