mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 16:35:13 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Copyright (C) 2023 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=rustdesk-server
|
||||
PKG_VERSION:=1.1.14
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/rustdesk/rustdesk-server.git
|
||||
PKG_SOURCE_VERSION:=$(PKG_VERSION)
|
||||
PKG_MIRROR_HASH:=skip
|
||||
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
PKG_LICENSE:=AGPL-3.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DEPENDS:=rust/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/rust/rust-package.mk
|
||||
|
||||
define Package/rustdesk-server
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=RustDesk Server Program
|
||||
DEPENDS:=@(aarch64||arm||x86_64) @(!arm||TARGET_bcm53xx||HAS_FPU)
|
||||
URL:=https://rustdesk.com/server
|
||||
USERID:=rustdesk-server:rustdesk-server
|
||||
endef
|
||||
|
||||
define Package/rustdesk-server/description
|
||||
Self-host your own RustDesk server, it is free and open source.
|
||||
endef
|
||||
|
||||
define Package/rustdesk-server/conffiles
|
||||
/etc/config/rustdesk-server
|
||||
/etc/rustdesk-server
|
||||
endef
|
||||
|
||||
define Package/rustdesk-server/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/{hbbr,hbbs} $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/rustdesk-server.conf $(1)/etc/config/rustdesk-server
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/rustdesk-server.init $(1)/etc/init.d/rustdesk-server
|
||||
endef
|
||||
|
||||
$(eval $(call RustBinPackage,rustdesk-server))
|
||||
$(eval $(call BuildPackage,rustdesk-server))
|
||||
@@ -0,0 +1,16 @@
|
||||
config global 'global'
|
||||
option auto_fw '0'
|
||||
option key '_'
|
||||
option port '21116'
|
||||
|
||||
config relay 'hbbr'
|
||||
option enabled '0'
|
||||
option downgrade_start_check ''
|
||||
option downgrade_threshold ''
|
||||
option limit_speed ''
|
||||
option total_bandwidth ''
|
||||
option single_bandwidth ''
|
||||
|
||||
config server 'hbbs'
|
||||
option enabled '0'
|
||||
option always_use_relay ''
|
||||
@@ -0,0 +1,140 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
|
||||
CONF="rustdesk-server"
|
||||
RUNDIR="/var/run/rustdesk-server"
|
||||
WORKDIR="/etc/rustdesk-server"
|
||||
|
||||
start_service() {
|
||||
local auto_fw global_key global_port
|
||||
local hbbr_enabled hbbr_downgrade_start_check hbbr_downgrade_threshold \
|
||||
hbbr_limit_speed hbbr_total_bandwidth hbbr_single_bandwidth
|
||||
local hbbs_enabled hbbs_always_use_relay
|
||||
|
||||
config_load "$CONF"
|
||||
config_get_bool auto_fw "global" "auto_fw" "0"
|
||||
config_get global_key "global" "key" ""
|
||||
config_get global_port "global" "port" "21116"
|
||||
|
||||
config_get_bool hbbr_enabled "hbbr" "enabled" "0"
|
||||
config_get hbbr_downgrade_start_check "hbbr" "downgrade_start_check" ""
|
||||
config_get hbbr_downgrade_threshold "hbbr" "downgrade_threshold" ""
|
||||
config_get hbbr_limit_speed "hbbr" "limit_speed" ""
|
||||
config_get hbbr_total_bandwidth "hbbr" "total_bandwidth" ""
|
||||
config_get hbbr_single_bandwidth "hbbr" "single_bandwidth" ""
|
||||
|
||||
config_get_bool hbbs_enabled "hbbs" "enabled" "0"
|
||||
config_get hbbs_always_use_relay "hbbs" "always_use_relay" ""
|
||||
|
||||
[ "$hbbr_enabled" -eq "1" ] || [ "$hbbs_enabled" -eq "1" ] || return 1
|
||||
|
||||
for dir in "$RUNDIR" "$WORKDIR"; do
|
||||
if [ ! -d "$dir" ] && ! mkdir -p "$dir"; then
|
||||
logger -p daemon.error -t "rustdesk-server" "Failed to create working directory: $dir"
|
||||
return 1
|
||||
fi
|
||||
chown -R rustdesk-server:rustdesk-server "$dir"
|
||||
done
|
||||
|
||||
if [ "$hbbr_enabled" -eq "1" ]; then
|
||||
procd_open_instance "hbbr"
|
||||
procd_set_param command /usr/bin/hbbr
|
||||
|
||||
procd_set_param env \
|
||||
DOWNGRADE_START_CHECK="$hbbr_downgrade_start_check" \
|
||||
DOWNGRADE_THRESHOLD="$hbbr_downgrade_threshold" \
|
||||
KEY="$global_key" \
|
||||
LIMIT_SPEED="$hbbr_limit_speed" \
|
||||
PORT="$global_port" \
|
||||
SINGLE_BANDWIDTH="$hbbr_single_bandwidth" \
|
||||
TOTAL_BANDWIDTH="$hbbr_total_bandwidth"
|
||||
|
||||
procd_add_jail hbbr log procfs sysfs
|
||||
procd_add_jail_mount "/etc/ssl/"
|
||||
procd_add_jail_mount_rw "/etc/rustdesk-server/"
|
||||
procd_add_jail_mount_rw "/var/run/rustdesk-server/"
|
||||
|
||||
procd_set_param respawn
|
||||
procd_set_param user rustdesk-server
|
||||
procd_set_param group rustdesk-server
|
||||
|
||||
if [ "$auto_fw" -eq "1" ]; then
|
||||
hbbr_tcp_ports="$(( global_port + 1 ))"
|
||||
|
||||
procd_open_data
|
||||
json_add_array firewall
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string name "Allow-rustdesk-relay-tcp"
|
||||
json_add_string proto "tcp"
|
||||
json_add_string src "*"
|
||||
json_add_string dest_port "$hbbr_tcp_ports"
|
||||
json_add_string target "ACCEPT"
|
||||
json_close_object
|
||||
json_close_array
|
||||
procd_close_data
|
||||
fi
|
||||
procd_close_instance
|
||||
fi
|
||||
|
||||
if [ "$hbbs_enabled" -eq "1" ]; then
|
||||
procd_open_instance "hbbs"
|
||||
procd_set_param command /usr/bin/hbbs
|
||||
|
||||
procd_set_param env \
|
||||
ALWAYS_USE_RELAY="$hbbs_always_use_relay" \
|
||||
KEY="$global_key" \
|
||||
PORT="$global_port"
|
||||
|
||||
procd_add_jail hbbs log procfs sysfs
|
||||
procd_add_jail_mount "/etc/ssl/"
|
||||
procd_add_jail_mount_rw "/etc/rustdesk-server/"
|
||||
procd_add_jail_mount_rw "/var/run/rustdesk-server/"
|
||||
|
||||
procd_set_param respawn
|
||||
procd_set_param user rustdesk-server
|
||||
procd_set_param group rustdesk-server
|
||||
|
||||
if [ "$auto_fw" -eq "1" ]; then
|
||||
hbbs_tcp_ports="$(( global_port - 1 )) $global_port"
|
||||
hbbs_udp_ports="$global_port"
|
||||
|
||||
procd_open_data
|
||||
json_add_array firewall
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string name "Allow-rustdesk-server-tcp"
|
||||
json_add_string proto "tcp"
|
||||
json_add_string src "*"
|
||||
json_add_string dest_port "$hbbs_tcp_ports"
|
||||
json_add_string target "ACCEPT"
|
||||
json_close_object
|
||||
|
||||
json_add_object ""
|
||||
json_add_string type rule
|
||||
json_add_string name "Allow-rustdesk-server-udp"
|
||||
json_add_string proto "udp"
|
||||
json_add_string src "*"
|
||||
json_add_string dest_port "$hbbs_udp_ports"
|
||||
json_add_string target "ACCEPT"
|
||||
json_close_object
|
||||
json_close_array
|
||||
procd_close_data
|
||||
fi
|
||||
procd_close_instance
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
rm -f "$RUNDIR"/hbbr*.log "$RUNDIR"/hbbs*.log
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONF"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
restart
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
--- a/src/hbbr.rs
|
||||
+++ b/src/hbbr.rs
|
||||
@@ -8,7 +8,19 @@ mod version;
|
||||
|
||||
fn main() -> ResultType<()> {
|
||||
let _logger = Logger::try_with_env_or_str("info")?
|
||||
- .log_to_stdout()
|
||||
+ .log_to_file(
|
||||
+ FileSpec::default()
|
||||
+ .directory("/var/run/rustdesk-server")
|
||||
+ .basename("hbbr")
|
||||
+ .suffix("log")
|
||||
+ .suppress_timestamp()
|
||||
+ )
|
||||
+ .rotate(
|
||||
+ Criterion::Size(10_000_000),
|
||||
+ Naming::Numbers,
|
||||
+ Cleanup::KeepLogFiles(3),
|
||||
+ )
|
||||
+ .duplicate_to_stderr(Duplicate::Warn)
|
||||
.format(opt_format)
|
||||
.write_mode(WriteMode::Async)
|
||||
.start()?;
|
||||
--- a/src/main.rs
|
||||
+++ b/src/main.rs
|
||||
@@ -9,7 +9,19 @@ const RMEM: usize = 0;
|
||||
|
||||
fn main() -> ResultType<()> {
|
||||
let _logger = Logger::try_with_env_or_str("info")?
|
||||
- .log_to_stdout()
|
||||
+ .log_to_file(
|
||||
+ FileSpec::default()
|
||||
+ .directory("/var/run/rustdesk-server")
|
||||
+ .basename("hbbs")
|
||||
+ .suffix("log")
|
||||
+ .suppress_timestamp()
|
||||
+ )
|
||||
+ .rotate(
|
||||
+ Criterion::Size(10_000_000),
|
||||
+ Naming::Numbers,
|
||||
+ Cleanup::KeepLogFiles(3),
|
||||
+ )
|
||||
+ .duplicate_to_stderr(Duplicate::Warn)
|
||||
.format(opt_format)
|
||||
.write_mode(WriteMode::Async)
|
||||
.start()?;
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/src/common.rs
|
||||
+++ b/src/common.rs
|
||||
@@ -105,7 +105,7 @@ pub fn now() -> u64 {
|
||||
}
|
||||
|
||||
pub fn gen_sk(wait: u64) -> (String, Option<sign::SecretKey>) {
|
||||
- let sk_file = "id_ed25519";
|
||||
+ let sk_file = "/etc/rustdesk-server/id_ed25519";
|
||||
if wait > 0 && !std::path::Path::new(sk_file).exists() {
|
||||
std::thread::sleep(std::time::Duration::from_millis(wait));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/src/peer.rs
|
||||
+++ b/src/peer.rs
|
||||
@@ -68,17 +68,13 @@ pub(crate) struct PeerMap {
|
||||
impl PeerMap {
|
||||
pub(crate) async fn new() -> ResultType<Self> {
|
||||
let db = std::env::var("DB_URL").unwrap_or({
|
||||
- let mut db = "db_v2.sqlite3".to_owned();
|
||||
+ let db = "/var/run/rustdesk-server/db_v2.sqlite3".to_owned();
|
||||
#[cfg(all(windows, not(debug_assertions)))]
|
||||
{
|
||||
if let Some(path) = hbb_common::config::Config::icon_path().parent() {
|
||||
db = format!("{}\\{}", path.to_str().unwrap_or("."), db);
|
||||
}
|
||||
}
|
||||
- #[cfg(not(windows))]
|
||||
- {
|
||||
- db = format!("./{db}");
|
||||
- }
|
||||
db
|
||||
});
|
||||
log::info!("DB_URL={}", db);
|
||||
@@ -0,0 +1,79 @@
|
||||
--- a/libs/hbb_common/src/config.rs
|
||||
+++ b/libs/hbb_common/src/config.rs
|
||||
@@ -403,36 +403,6 @@ pub fn get_online_state() -> i64 {
|
||||
*ONLINE.lock().unwrap().values().max().unwrap_or(&0)
|
||||
}
|
||||
|
||||
-#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
-fn patch(path: PathBuf) -> PathBuf {
|
||||
- if let Some(_tmp) = path.to_str() {
|
||||
- #[cfg(windows)]
|
||||
- return _tmp
|
||||
- .replace(
|
||||
- "system32\\config\\systemprofile",
|
||||
- "ServiceProfiles\\LocalService",
|
||||
- )
|
||||
- .into();
|
||||
- #[cfg(target_os = "macos")]
|
||||
- return _tmp.replace("Application Support", "Preferences").into();
|
||||
- #[cfg(target_os = "linux")]
|
||||
- {
|
||||
- if _tmp == "/root" {
|
||||
- if let Ok(user) = crate::platform::linux::run_cmds_trim_newline("whoami") {
|
||||
- if user != "root" {
|
||||
- let cmd = format!("getent passwd '{}' | awk -F':' '{{print $6}}'", user);
|
||||
- if let Ok(output) = crate::platform::linux::run_cmds_trim_newline(&cmd) {
|
||||
- return output.into();
|
||||
- }
|
||||
- return format!("/home/{user}").into();
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- path
|
||||
-}
|
||||
-
|
||||
impl Config2 {
|
||||
fn load() -> Config2 {
|
||||
let mut config = Config::load_::<Config2>("2");
|
||||
@@ -608,15 +578,7 @@ impl Config {
|
||||
#[cfg(any(target_os = "android", target_os = "ios"))]
|
||||
return PathBuf::from(APP_HOME_DIR.read().unwrap().as_str());
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
- {
|
||||
- if let Some(path) = dirs_next::home_dir() {
|
||||
- patch(path)
|
||||
- } else if let Ok(path) = std::env::current_dir() {
|
||||
- path
|
||||
- } else {
|
||||
- std::env::temp_dir()
|
||||
- }
|
||||
- }
|
||||
+ PathBuf::from("/var/run/rustdesk-server")
|
||||
}
|
||||
|
||||
pub fn path<P: AsRef<Path>>(p: P) -> PathBuf {
|
||||
@@ -628,19 +590,12 @@ impl Config {
|
||||
}
|
||||
#[cfg(not(any(target_os = "android", target_os = "ios")))]
|
||||
{
|
||||
- #[cfg(not(target_os = "macos"))]
|
||||
- let org = "".to_owned();
|
||||
#[cfg(target_os = "macos")]
|
||||
let org = ORG.read().unwrap().clone();
|
||||
// /var/root for root
|
||||
- if let Some(project) =
|
||||
- directories_next::ProjectDirs::from("", &org, &APP_NAME.read().unwrap())
|
||||
- {
|
||||
- let mut path = patch(project.config_dir().to_path_buf());
|
||||
- path.push(p);
|
||||
- return path;
|
||||
- }
|
||||
- "".into()
|
||||
+ let mut path = PathBuf::from("/var/run/rustdesk-server");
|
||||
+ path.push(p);
|
||||
+ path
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/libs/hbb_common/src/config.rs
|
||||
+++ b/libs/hbb_common/src/config.rs
|
||||
@@ -804,7 +804,12 @@ impl Config {
|
||||
id &= 0x1FFFFFFF;
|
||||
Some(id.to_string())
|
||||
} else {
|
||||
- None
|
||||
+ log::warn!("Failed to get MAC address. Fallback to random ID");
|
||||
+ Some(
|
||||
+ rand::thread_rng()
|
||||
+ .gen_range(1_000_000_000..2_000_000_000)
|
||||
+ .to_string(),
|
||||
+ )
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user