10 Commits

Author SHA1 Message Date
dijunkun
3b34c26555 [feat] enable custom configuration of Coturn server port 2025-10-27 16:04:40 +08:00
dijunkun
b668b3c936 [chore] update README 2025-10-27 13:42:49 +08:00
dijunkun
cc19ec125a [ci] update close-issue.yml 2025-10-27 11:04:36 +08:00
dijunkun
ffa77fdf44 Merge branch 'run-in-bg' into self-hosted-server 2025-10-27 10:41:16 +08:00
dijunkun
47cf806532 [ci] add permissions to close-issue.yml 2025-10-25 17:06:14 +08:00
dijunkun
911dce2e71 [feat] optimize certificate selection table 2025-10-24 17:39:25 +08:00
dijunkun
9f80d4f69d Merge branch 'self-hosted-server' into run-in-bg 2025-10-24 14:16:18 +08:00
dijunkun
f733fe9e49 Merge branch 'self-hosted-server' into run-in-bg 2025-10-24 11:05:07 +08:00
dijunkun
698bf72a6c Merge branch 'self-hosted-server' into run-in-bg 2025-10-24 10:05:54 +08:00
dijunkun
b2ab940f20 [feat] use no close select table 2025-10-23 17:55:30 +08:00
12 changed files with 950 additions and 785 deletions

View File

@@ -5,6 +5,11 @@ on:
# run every day at midnight # run every day at midnight
- cron: "0 0 * * *" - cron: "0 0 * * *"
permissions:
issues: write
pull-requests: write
contents: read
jobs: jobs:
close_inactive_issues: close_inactive_issues:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -53,6 +58,14 @@ jobs:
// check inactivity // check inactivity
if (now - lastActivityTime > inactivePeriod) { if (now - lastActivityTime > inactivePeriod) {
console.log(`Closing inactive issue: #${issue.number} (No recent replies for 7 days)`); console.log(`Closing inactive issue: #${issue.number} (No recent replies for 7 days)`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: "This issue has been automatically closed due to inactivity for 7 days."
});
await github.rest.issues.update({ await github.rest.issues.update({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,

View File

@@ -31,11 +31,13 @@ jobs:
- name: Update download links - name: Update download links
run: | run: |
cd pages cd pages
sed -E -i "s/crossdesk-win-x64-[0-9]+\.[0-9]+\.[0-9]+\.exe/crossdesk-win-x64-${VERSION_NUM}.exe/g" index.html echo "Updating download links to ${VERSION_NUM}"
sed -E -i "s/crossdesk-macos-x64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-x64-${VERSION_NUM}.pkg/g" index.html sed -E -i "s/crossdesk-win-x64-[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?\.exe/crossdesk-win-x64-${VERSION_NUM}.exe/g" index.html
sed -E -i "s/crossdesk-macos-arm64-[0-9]+\.[0-9]+\.[0-9]+\.pkg/crossdesk-macos-arm64-${VERSION_NUM}.pkg/g" index.html sed -E -i "s/crossdesk-macos-x64-[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?\.pkg/crossdesk-macos-x64-${VERSION_NUM}.pkg/g" index.html
sed -E -i "s/crossdesk-linux-amd64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-amd64-${VERSION_NUM}.deb/g" index.html sed -E -i "s/crossdesk-macos-arm64-[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?\.pkg/crossdesk-macos-arm64-${VERSION_NUM}.pkg/g" index.html
sed -E -i "s/crossdesk-linux-arm64-[0-9]+\.[0-9]+\.[0-9]+\.deb/crossdesk-linux-arm64-${VERSION_NUM}.deb/g" index.html sed -E -i "s/crossdesk-linux-amd64-[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?\.deb/crossdesk-linux-amd64-${VERSION_NUM}.deb/g" index.html
sed -E -i "s/crossdesk-linux-arm64-[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9._-]+)?\.deb/crossdesk-linux-arm64-${VERSION_NUM}.deb/g" index.html
git diff index.html || true
- name: Commit & Push changes - name: Commit & Push changes
run: | run: |

View File

@@ -146,11 +146,14 @@ sudo docker run -d \
--network host \ --network host \
-e EXTERNAL_IP=xxx.xxx.xxx.xxx \ -e EXTERNAL_IP=xxx.xxx.xxx.xxx \
-e INTERNAL_IP=xxx.xxx.xxx.xxx \ -e INTERNAL_IP=xxx.xxx.xxx.xxx \
-e CROSSDESK_SERVER_PORT=9099 \ -e CROSSDESK_SERVER_PORT=xxxx \
-e COTURN_PORT=xxxx \
-e MIN_PORT=xxxxx \
-e MAX_PORT=xxxxx \
-v /path/to/your/certs:/crossdesk-server/certs \ -v /path/to/your/certs:/crossdesk-server/certs \
-v /path/to/your/db:/crossdesk-server/db \ -v /path/to/your/db:/crossdesk-server/db \
-v /path/to/your/logs:/crossdesk-server/logs \ -v /path/to/your/logs:/crossdesk-server/logs \
crossdesk/crossdesk-server:latest crossdesk/crossdesk-server:v1.0.0
``` ```
上述命令中,用户需注意的参数如下: 上述命令中,用户需注意的参数如下:
@@ -161,6 +164,10 @@ sudo docker run -d \
- CROSSDESK_SERVER_PORT自托管服务使用的端口对应 CrossDesk 客户端**自托管服务器配置**中填写的**服务器端口** - CROSSDESK_SERVER_PORT自托管服务使用的端口对应 CrossDesk 客户端**自托管服务器配置**中填写的**服务器端口**
- COTURN_PORT: COTURN 服务使用的端口, 对应 CrossDesk 客户端**自托管服务器配置**中填写的**中继服务端口**
- MIN_PORT/MAX_PORTCOTURN 服务使用的端口范围例如MIN_PORT=50000, MAX_PORT=60000范围可根据客户端数量调整。
- /path/to/your/certs证书文件目录 - /path/to/your/certs证书文件目录
- /path/to/your/dbCrossDesk Server 设备管理数据库 - /path/to/your/dbCrossDesk Server 设备管理数据库
@@ -169,7 +176,7 @@ sudo docker run -d \
**注意** **注意**
- **/path/to/your/ 是示例路径,请替换为你自己的实际路径。挂载的目录必须事先创建好,否则容器会报错。** - **/path/to/your/ 是示例路径,请替换为你自己的实际路径。挂载的目录必须事先创建好,否则容器会报错。**
- **服务器需开放端口3478/udp3478/tcp30000-60000/udpCROSSDESK_SERVER_PORT/tcp443/tcp。** - **服务器需开放端口3478/udp3478/tcpMIN_PORT-MAX_PORT/udpCROSSDESK_SERVER_PORT/tcp。**
## 证书文件 ## 证书文件
客户端需加载根证书文件,服务端需加载服务器私钥和服务器证书文件。 客户端需加载根证书文件,服务端需加载服务器私钥和服务器证书文件。

View File

@@ -149,13 +149,16 @@ It is recommended to deploy CrossDesk Server using Docker.
sudo docker run -d \ sudo docker run -d \
--name crossdesk_server \ --name crossdesk_server \
--network host \ --network host \
-e EXTERNAL_IP=150.158.81.30 \ -e EXTERNAL_IP=xxx.xxx.xxx.xxx \
-e INTERNAL_IP=10.0.4.3 \ -e INTERNAL_IP=xxx.xxx.xxx.xxx \
-e CROSSDESK_SERVER_PORT=9099 \ -e CROSSDESK_SERVER_PORT=xxxx \
-e COTURN_PORT=xxxx \
-e MIN_PORT=xxxxx \
-e MAX_PORT=xxxxx \
-v /path/to/your/certs:/crossdesk-server/certs \ -v /path/to/your/certs:/crossdesk-server/certs \
-v /path/to/your/db:/crossdesk-server/db \ -v /path/to/your/db:/crossdesk-server/db \
-v /path/to/your/logs:/crossdesk-server/logs \ -v /path/to/your/logs:/crossdesk-server/logs \
crossdesk/crossdesk-server:latest crossdesk/crossdesk-server:v1.0.0
``` ```
The parameters you need to pay attention to are as follows: The parameters you need to pay attention to are as follows:
@@ -166,6 +169,10 @@ The parameters you need to pay attention to are as follows:
- **CROSSDESK_SERVER_PORT**: The port used by the self-hosted server, corresponding to the **Server Port** in the CrossDesk client **Self-Hosted Server Configuration**. - **CROSSDESK_SERVER_PORT**: The port used by the self-hosted server, corresponding to the **Server Port** in the CrossDesk client **Self-Hosted Server Configuration**.
- **COTURN_PORT**: The port used by Coturn, corresponding to the **Relay Server Port** in the CrossDesk client **Self-Hosted Server Configuration**.
- **MIN_PORT** and **MAX_PORT**: The range of ports used by the self-hosted server, corresponding to the **Minimum Port** and **Maximum Port** in the CrossDesk client **Self-Hosted Server Configuration**. Example: 50000-60000. It depends on the number of devices connected to the server.
- **/path/to/your/certs**: Directory for certificate files. - **/path/to/your/certs**: Directory for certificate files.
- **/path/to/your/db**: CrossDesk Server device management database. - **/path/to/your/db**: CrossDesk Server device management database.
@@ -174,7 +181,7 @@ The parameters you need to pay attention to are as follows:
**Note**: **Note**:
- **/path/to/your/ is an example path; please replace it with your actual path. The mounted directories must be created in advance, otherwise the container will fail.** - **/path/to/your/ is an example path; please replace it with your actual path. The mounted directories must be created in advance, otherwise the container will fail.**
- **The server must open the following ports: 3478/udp, 3478/tcp, 30000-60000/udp, CROSSDESK_SERVER_PORT/tcp, 443/tcp.** - **The server must open the following ports: 3478/udp, 3478/tcp, 30000-60000/udp, CROSSDESK_SERVER_PORT/tcp.**
## Certificate Files ## Certificate Files
The client needs to load the root certificate, and the server needs to load the server private key and server certificate. The client needs to load the root certificate, and the server needs to load the server private key and server certificate.

View File

@@ -36,9 +36,12 @@ int ConfigCenter::Load() {
enable_turn_ = ini_.GetBoolValue(section_, "enable_turn", enable_turn_); enable_turn_ = ini_.GetBoolValue(section_, "enable_turn", enable_turn_);
enable_srtp_ = ini_.GetBoolValue(section_, "enable_srtp", enable_srtp_); enable_srtp_ = ini_.GetBoolValue(section_, "enable_srtp", enable_srtp_);
server_host_ = ini_.GetValue(section_, "server_host", server_host_.c_str()); signal_server_host_ = ini_.GetValue(section_, "signal_server_host",
server_port_ = static_cast<int>( signal_server_host_.c_str());
ini_.GetLongValue(section_, "server_port", server_port_)); signal_server_port_ = static_cast<int>(
ini_.GetLongValue(section_, "signal_server_port", signal_server_port_));
coturn_server_port_ = static_cast<int>(
ini_.GetLongValue(section_, "coturn_server_port", coturn_server_port_));
cert_file_path_ = cert_file_path_ =
ini_.GetValue(section_, "cert_file_path", cert_file_path_.c_str()); ini_.GetValue(section_, "cert_file_path", cert_file_path_.c_str());
enable_self_hosted_ = enable_self_hosted_ =
@@ -61,8 +64,9 @@ int ConfigCenter::Save() {
ini_.SetBoolValue(section_, "hardware_video_codec", hardware_video_codec_); ini_.SetBoolValue(section_, "hardware_video_codec", hardware_video_codec_);
ini_.SetBoolValue(section_, "enable_turn", enable_turn_); ini_.SetBoolValue(section_, "enable_turn", enable_turn_);
ini_.SetBoolValue(section_, "enable_srtp", enable_srtp_); ini_.SetBoolValue(section_, "enable_srtp", enable_srtp_);
ini_.SetValue(section_, "server_host", server_host_.c_str()); ini_.SetValue(section_, "signal_server_host", signal_server_host_.c_str());
ini_.SetLongValue(section_, "server_port", static_cast<long>(server_port_)); ini_.SetLongValue(section_, "signal_server_port",
static_cast<long>(signal_server_port_));
ini_.SetValue(section_, "cert_file_path", cert_file_path_.c_str()); ini_.SetValue(section_, "cert_file_path", cert_file_path_.c_str());
ini_.SetBoolValue(section_, "enable_self_hosted", enable_self_hosted_); ini_.SetBoolValue(section_, "enable_self_hosted", enable_self_hosted_);
ini_.SetBoolValue(section_, "enable_minimize_to_tray", ini_.SetBoolValue(section_, "enable_minimize_to_tray",
@@ -152,9 +156,9 @@ int ConfigCenter::SetSrtp(bool enable_srtp) {
return 0; return 0;
} }
int ConfigCenter::SetServerHost(const std::string& server_host) { int ConfigCenter::SetServerHost(const std::string& signal_server_host) {
server_host_ = server_host; signal_server_host_ = signal_server_host;
ini_.SetValue(section_, "server_host", server_host_.c_str()); ini_.SetValue(section_, "signal_server_host", signal_server_host_.c_str());
SI_Error rc = ini_.SaveFile(config_path_.c_str()); SI_Error rc = ini_.SaveFile(config_path_.c_str());
if (rc < 0) { if (rc < 0) {
return -1; return -1;
@@ -162,9 +166,10 @@ int ConfigCenter::SetServerHost(const std::string& server_host) {
return 0; return 0;
} }
int ConfigCenter::SetServerPort(int server_port) { int ConfigCenter::SetServerPort(int signal_server_port) {
server_port_ = server_port; signal_server_port_ = signal_server_port;
ini_.SetLongValue(section_, "server_port", static_cast<long>(server_port_)); ini_.SetLongValue(section_, "signal_server_port",
static_cast<long>(signal_server_port_));
SI_Error rc = ini_.SaveFile(config_path_.c_str()); SI_Error rc = ini_.SaveFile(config_path_.c_str());
if (rc < 0) { if (rc < 0) {
return -1; return -1;
@@ -172,6 +177,16 @@ int ConfigCenter::SetServerPort(int server_port) {
return 0; return 0;
} }
int ConfigCenter::SetCoturnServerPort(int coturn_server_port) {
coturn_server_port_ = coturn_server_port;
SI_Error rc = ini_.SetLongValue(section_, "coturn_server_port",
static_cast<long>(coturn_server_port_));
if (rc < 0) {
return -1;
}
return 0;
}
int ConfigCenter::SetCertFilePath(const std::string& cert_file_path) { int ConfigCenter::SetCertFilePath(const std::string& cert_file_path) {
cert_file_path_ = cert_file_path; cert_file_path_ = cert_file_path;
ini_.SetValue(section_, "cert_file_path", cert_file_path_.c_str()); ini_.SetValue(section_, "cert_file_path", cert_file_path_.c_str());
@@ -220,17 +235,27 @@ bool ConfigCenter::IsEnableTurn() const { return enable_turn_; }
bool ConfigCenter::IsEnableSrtp() const { return enable_srtp_; } bool ConfigCenter::IsEnableSrtp() const { return enable_srtp_; }
std::string ConfigCenter::GetServerHost() const { return server_host_; } std::string ConfigCenter::GetSignalServerHost() const {
return signal_server_host_;
}
int ConfigCenter::GetServerPort() const { return server_port_; } int ConfigCenter::GetSignalServerPort() const { return signal_server_port_; }
int ConfigCenter::GetCoturnServerPort() const { return coturn_server_port_; }
std::string ConfigCenter::GetCertFilePath() const { return cert_file_path_; } std::string ConfigCenter::GetCertFilePath() const { return cert_file_path_; }
std::string ConfigCenter::GetDefaultServerHost() const { std::string ConfigCenter::GetDefaultServerHost() const {
return server_host_default_; return signal_server_host_default_;
} }
int ConfigCenter::GetDefaultServerPort() const { return server_port_default_; } int ConfigCenter::GetDefaultSignalServerPort() const {
return server_port_default_;
}
int ConfigCenter::GetDefaultCoturnServerPort() const {
return coturn_server_port_default_;
}
std::string ConfigCenter::GetDefaultCertFilePath() const { std::string ConfigCenter::GetDefaultCertFilePath() const {
return cert_file_path_default_; return cert_file_path_default_;

View File

@@ -32,8 +32,9 @@ class ConfigCenter {
int SetHardwareVideoCodec(bool hardware_video_codec); int SetHardwareVideoCodec(bool hardware_video_codec);
int SetTurn(bool enable_turn); int SetTurn(bool enable_turn);
int SetSrtp(bool enable_srtp); int SetSrtp(bool enable_srtp);
int SetServerHost(const std::string& server_host); int SetServerHost(const std::string& signal_server_host);
int SetServerPort(int server_port); int SetServerPort(int signal_server_port);
int SetCoturnServerPort(int coturn_server_port);
int SetCertFilePath(const std::string& cert_file_path); int SetCertFilePath(const std::string& cert_file_path);
int SetSelfHosted(bool enable_self_hosted); int SetSelfHosted(bool enable_self_hosted);
int SetMinimizeToTray(bool enable_minimize_to_tray); int SetMinimizeToTray(bool enable_minimize_to_tray);
@@ -47,11 +48,13 @@ class ConfigCenter {
bool IsHardwareVideoCodec() const; bool IsHardwareVideoCodec() const;
bool IsEnableTurn() const; bool IsEnableTurn() const;
bool IsEnableSrtp() const; bool IsEnableSrtp() const;
std::string GetServerHost() const; std::string GetSignalServerHost() const;
int GetServerPort() const; int GetSignalServerPort() const;
int GetCoturnServerPort() const;
std::string GetCertFilePath() const; std::string GetCertFilePath() const;
std::string GetDefaultServerHost() const; std::string GetDefaultServerHost() const;
int GetDefaultServerPort() const; int GetDefaultSignalServerPort() const;
int GetDefaultCoturnServerPort() const;
std::string GetDefaultCertFilePath() const; std::string GetDefaultCertFilePath() const;
bool IsSelfHosted() const; bool IsSelfHosted() const;
bool IsMinimizeToTray() const; bool IsMinimizeToTray() const;
@@ -72,10 +75,12 @@ class ConfigCenter {
bool hardware_video_codec_ = false; bool hardware_video_codec_ = false;
bool enable_turn_ = false; bool enable_turn_ = false;
bool enable_srtp_ = false; bool enable_srtp_ = false;
std::string server_host_ = "api.crossdesk.cn"; std::string signal_server_host_ = "api.crossdesk.cn";
int server_port_ = 9099; std::string signal_server_host_default_ = "api.crossdesk.cn";
std::string server_host_default_ = "api.crossdesk.cn"; int signal_server_port_ = 9099;
int server_port_default_ = 9099; int server_port_default_ = 9099;
int coturn_server_port_ = 3478;
int coturn_server_port_default_ = 3478;
std::string cert_file_path_default_ = ""; std::string cert_file_path_default_ = "";
bool enable_self_hosted_ = false; bool enable_self_hosted_ = false;
bool enable_minimize_to_tray_ = false; bool enable_minimize_to_tray_ = false;

File diff suppressed because it is too large Load Diff

View File

@@ -29,8 +29,8 @@
#endif #endif
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_CN 228 #define SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_CN 228
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_EN 275 #define SELF_HOSTED_SERVER_CONFIG_WINDOW_WIDTH_EN 275
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_CN 165 #define SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_CN 195
#define SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_EN 165 #define SELF_HOSTED_SERVER_CONFIG_WINDOW_HEIGHT_EN 195
#define LANGUAGE_SELECT_WINDOW_PADDING_CN 120 #define LANGUAGE_SELECT_WINDOW_PADDING_CN 120
#define LANGUAGE_SELECT_WINDOW_PADDING_EN 167 #define LANGUAGE_SELECT_WINDOW_PADDING_EN 167
#define VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN 120 #define VIDEO_QUALITY_SELECT_WINDOW_PADDING_CN 120

View File

@@ -106,7 +106,9 @@ static std::vector<std::string> self_hosted_server_settings = {
static std::vector<std::string> self_hosted_server_address = { static std::vector<std::string> self_hosted_server_address = {
reinterpret_cast<const char*>(u8"服务器地址:"), "Server Address:"}; reinterpret_cast<const char*>(u8"服务器地址:"), "Server Address:"};
static std::vector<std::string> self_hosted_server_port = { static std::vector<std::string> self_hosted_server_port = {
reinterpret_cast<const char*>(u8"服务端口:"), "Server Port:"}; reinterpret_cast<const char*>(u8"信令服务端口:"), "Signal Service Port:"};
static std::vector<std::string> self_hosted_server_coturn_server_port = {
reinterpret_cast<const char*>(u8"中继服务端口:"), "Relay Service Port:"};
static std::vector<std::string> self_hosted_server_certificate_path = { static std::vector<std::string> self_hosted_server_certificate_path = {
reinterpret_cast<const char*>(u8"证书文件路径:"), "Certificate File Path:"}; reinterpret_cast<const char*>(u8"证书文件路径:"), "Certificate File Path:"};
static std::vector<std::string> select_a_file = { static std::vector<std::string> select_a_file = {

View File

@@ -427,39 +427,57 @@ int Render::StopKeyboardCapturer() {
int Render::CreateConnectionPeer() { int Render::CreateConnectionPeer() {
params_.use_cfg_file = false; params_.use_cfg_file = false;
std::string server_ip; std::string signal_server_ip;
int server_port; int signal_server_port;
std::string server_cert_path; int coturn_server_port;
std::string tls_cert_path;
if (config_center_->IsSelfHosted()) { if (config_center_->IsSelfHosted()) {
server_ip = config_center_->GetServerHost(); signal_server_ip = config_center_->GetSignalServerHost();
server_port = config_center_->GetServerPort(); signal_server_port = config_center_->GetSignalServerPort();
server_cert_path = config_center_->GetCertFilePath(); coturn_server_port = config_center_->GetCoturnServerPort();
tls_cert_path = config_center_->GetCertFilePath();
} else { } else {
server_ip = config_center_->GetDefaultServerHost(); signal_server_ip = config_center_->GetDefaultServerHost();
server_port = config_center_->GetDefaultServerPort(); signal_server_port = config_center_->GetDefaultSignalServerPort();
server_cert_path = config_center_->GetDefaultCertFilePath(); coturn_server_port = config_center_->GetDefaultCoturnServerPort();
tls_cert_path = config_center_->GetDefaultCertFilePath();
} }
strncpy((char*)params_.signal_server_ip, server_ip.c_str(), // self hosted server config
strncpy(signal_server_ip_self_, config_center_->GetSignalServerHost().c_str(),
sizeof(signal_server_ip_self_) - 1);
signal_server_ip_self_[sizeof(signal_server_ip_self_) - 1] = '\0';
strncpy(signal_server_port_self_,
std::to_string(config_center_->GetSignalServerPort()).c_str(),
sizeof(signal_server_port_self_) - 1);
signal_server_port_self_[sizeof(signal_server_port_self_) - 1] = '\0';
strncpy(coturn_server_port_self_,
std::to_string(config_center_->GetCoturnServerPort()).c_str(),
sizeof(coturn_server_port_self_) - 1);
coturn_server_port_self_[sizeof(coturn_server_port_self_) - 1] = '\0';
tls_cert_path_self_ = config_center_->GetCertFilePath();
// peer config
strncpy((char*)params_.signal_server_ip, signal_server_ip.c_str(),
sizeof(params_.signal_server_ip) - 1); sizeof(params_.signal_server_ip) - 1);
params_.signal_server_ip[sizeof(params_.signal_server_ip) - 1] = '\0'; params_.signal_server_ip[sizeof(params_.signal_server_ip) - 1] = '\0';
params_.signal_server_port = server_port; params_.signal_server_port = signal_server_port;
strncpy((char*)params_.stun_server_ip, server_ip.c_str(), strncpy((char*)params_.stun_server_ip, signal_server_ip.c_str(),
sizeof(params_.stun_server_ip) - 1); sizeof(params_.stun_server_ip) - 1);
params_.stun_server_ip[sizeof(params_.stun_server_ip) - 1] = '\0'; params_.stun_server_ip[sizeof(params_.stun_server_ip) - 1] = '\0';
params_.stun_server_port = 3478; params_.stun_server_port = coturn_server_port;
strncpy((char*)params_.turn_server_ip, server_ip.c_str(), strncpy((char*)params_.turn_server_ip, signal_server_ip.c_str(),
sizeof(params_.turn_server_ip) - 1); sizeof(params_.turn_server_ip) - 1);
params_.turn_server_ip[sizeof(params_.turn_server_ip) - 1] = '\0'; params_.turn_server_ip[sizeof(params_.turn_server_ip) - 1] = '\0';
params_.turn_server_port = 3478; params_.turn_server_port = coturn_server_port;
strncpy((char*)params_.turn_server_username, "crossdesk", strncpy((char*)params_.turn_server_username, "crossdesk",
sizeof(params_.turn_server_username) - 1); sizeof(params_.turn_server_username) - 1);
params_.turn_server_username[sizeof(params_.turn_server_username) - 1] = '\0'; params_.turn_server_username[sizeof(params_.turn_server_username) - 1] = '\0';
strncpy((char*)params_.turn_server_password, "crossdeskpw", strncpy((char*)params_.turn_server_password, "crossdeskpw",
sizeof(params_.turn_server_password) - 1); sizeof(params_.turn_server_password) - 1);
params_.turn_server_password[sizeof(params_.turn_server_password) - 1] = '\0'; params_.turn_server_password[sizeof(params_.turn_server_password) - 1] = '\0';
strncpy(params_.tls_cert_path, server_cert_path.c_str(), strncpy(params_.tls_cert_path, tls_cert_path.c_str(),
sizeof(params_.tls_cert_path) - 1); sizeof(params_.tls_cert_path) - 1);
params_.tls_cert_path[sizeof(params_.tls_cert_path) - 1] = '\0'; params_.tls_cert_path[sizeof(params_.tls_cert_path) - 1] = '\0';
@@ -883,13 +901,14 @@ int Render::Run() {
cache_path_ = path_manager_->GetCachePath().string(); cache_path_ = path_manager_->GetCachePath().string();
config_center_ = config_center_ =
std::make_unique<ConfigCenter>(cache_path_ + "/config.ini", cert_path_); std::make_unique<ConfigCenter>(cache_path_ + "/config.ini", cert_path_);
strncpy(signal_server_ip_tmp_, config_center_->GetServerHost().c_str(), strncpy(signal_server_ip_self_,
sizeof(signal_server_ip_tmp_) - 1); config_center_->GetSignalServerHost().c_str(),
signal_server_ip_tmp_[sizeof(signal_server_ip_tmp_) - 1] = '\0'; sizeof(signal_server_ip_self_) - 1);
strncpy(signal_server_port_tmp_, signal_server_ip_self_[sizeof(signal_server_ip_self_) - 1] = '\0';
std::to_string(config_center_->GetServerPort()).c_str(), strncpy(signal_server_port_self_,
sizeof(signal_server_port_tmp_) - 1); std::to_string(config_center_->GetSignalServerPort()).c_str(),
signal_server_port_tmp_[sizeof(signal_server_port_tmp_) - 1] = '\0'; sizeof(signal_server_port_self_) - 1);
signal_server_port_self_[sizeof(signal_server_port_self_) - 1] = '\0';
strncpy(cert_file_path_, cert_path_.c_str(), sizeof(cert_file_path_) - 1); strncpy(cert_file_path_, cert_path_.c_str(), sizeof(cert_file_path_) - 1);
cert_file_path_[sizeof(cert_file_path_) - 1] = '\0'; cert_file_path_[sizeof(cert_file_path_) - 1] = '\0';
} else { } else {

View File

@@ -442,6 +442,7 @@ class Render {
bool enable_srtp_ = false; bool enable_srtp_ = false;
char signal_server_ip_[256] = "api.crossdesk.cn"; char signal_server_ip_[256] = "api.crossdesk.cn";
char signal_server_port_[6] = "9099"; char signal_server_port_[6] = "9099";
char coturn_server_port_[6] = "3478";
char cert_file_path_[256] = ""; char cert_file_path_[256] = "";
bool enable_self_hosted_server_ = false; bool enable_self_hosted_server_ = false;
int language_button_value_last_ = 0; int language_button_value_last_ = 0;
@@ -452,12 +453,14 @@ class Render {
bool enable_srtp_last_ = false; bool enable_srtp_last_ = false;
bool enable_minimize_to_tray_ = false; bool enable_minimize_to_tray_ = false;
bool enable_minimize_to_tray_last_ = false; bool enable_minimize_to_tray_last_ = false;
char signal_server_ip_tmp_[256] = "api.crossdesk.cn"; char signal_server_ip_self_[256] = "";
char signal_server_port_tmp_[6] = "9099"; char signal_server_port_self_[6] = "";
char coturn_server_port_self_[6] = "";
std::string tls_cert_path_self_ = "";
bool settings_window_pos_reset_ = true; bool settings_window_pos_reset_ = true;
bool self_hosted_server_config_window_pos_reset_ = true; bool self_hosted_server_config_window_pos_reset_ = true;
std::string selected_current_file_path_ = ""; std::string selected_current_file_path_ = "";
std::string selected_file_ = ""; bool show_file_browser_ = true;
/* ------ main window property end ------ */ /* ------ main window property end ------ */
/* ------ sub stream window property start ------ */ /* ------ sub stream window property start ------ */

View File

@@ -28,8 +28,14 @@ std::vector<std::string> GetRootEntries() {
int Render::ShowSimpleFileBrowser() { int Render::ShowSimpleFileBrowser() {
std::string display_text; std::string display_text;
if (!selected_file_.empty()) {
display_text = std::filesystem::path(selected_file_).filename().string(); if (selected_current_file_path_.empty()) {
selected_current_file_path_ = std::filesystem::current_path().string();
}
if (!tls_cert_path_self_.empty()) {
display_text =
std::filesystem::path(tls_cert_path_self_).filename().string();
} else if (selected_current_file_path_ != "Root") { } else if (selected_current_file_path_ != "Root") {
display_text = display_text =
std::filesystem::path(selected_current_file_path_).filename().string(); std::filesystem::path(selected_current_file_path_).filename().string();
@@ -43,49 +49,69 @@ int Render::ShowSimpleFileBrowser() {
localization::select_a_file[localization_language_index_].c_str(); localization::select_a_file[localization_language_index_].c_str();
} }
if (ImGui::BeginCombo("##select_a_file", display_text.c_str())) { if (show_file_browser_) {
if (selected_current_file_path_ == "Root" || ImGui::PushItemFlag(ImGuiItemFlags_AutoClosePopups, false);
!std::filesystem::exists(selected_current_file_path_) ||
!std::filesystem::is_directory(selected_current_file_path_)) { float fixed_width = 130.0f;
ImGui::SetNextItemWidth(fixed_width);
ImGui::SetNextWindowSizeConstraints(ImVec2(fixed_width, 0),
ImVec2(fixed_width, 100.0f));
if (ImGui::BeginCombo("##select_a_file", display_text.c_str(), 0)) {
bool file_selected = false;
auto roots = GetRootEntries(); auto roots = GetRootEntries();
for (const auto& root : roots) { if (selected_current_file_path_ == "Root" ||
if (ImGui::Selectable(root.c_str())) { !std::filesystem::exists(selected_current_file_path_) ||
selected_current_file_path_ = root; !std::filesystem::is_directory(selected_current_file_path_)) {
selected_file_.clear(); for (const auto& root : roots) {
} if (ImGui::Selectable(root.c_str())) {
} selected_current_file_path_ = root;
} else { tls_cert_path_self_.clear();
std::filesystem::path p(selected_current_file_path_);
if (ImGui::Selectable("..")) {
if (p.has_parent_path() && p != p.root_path())
selected_current_file_path_ = p.parent_path().string();
else
selected_current_file_path_ = "Root";
selected_file_.clear();
}
try {
for (const auto& entry :
std::filesystem::directory_iterator(selected_current_file_path_)) {
std::string name = entry.path().filename().string();
if (entry.is_directory()) {
if (ImGui::Selectable(name.c_str())) {
selected_current_file_path_ = entry.path().string();
selected_file_.clear();
}
} else {
if (ImGui::Selectable(name.c_str())) {
selected_file_ = entry.path().string();
}
} }
} }
} catch (const std::exception& e) { } else {
ImGui::TextColored(ImVec4(1, 0, 0, 1), "Error: %s", e.what()); std::filesystem::path p(selected_current_file_path_);
}
}
ImGui::EndCombo(); if (ImGui::Selectable("..")) {
if (std::find(roots.begin(), roots.end(),
selected_current_file_path_) != roots.end()) {
selected_current_file_path_ = "Root";
} else if (p.has_parent_path()) {
selected_current_file_path_ = p.parent_path().string();
} else {
selected_current_file_path_ = "Root";
}
tls_cert_path_self_.clear();
}
try {
for (const auto& entry : std::filesystem::directory_iterator(
selected_current_file_path_)) {
std::string name = entry.path().filename().string();
if (entry.is_directory()) {
if (ImGui::Selectable(name.c_str())) {
selected_current_file_path_ = entry.path().string();
tls_cert_path_self_.clear();
}
} else {
if (ImGui::Selectable(name.c_str())) {
tls_cert_path_self_ = entry.path().string();
file_selected = true;
show_file_browser_ = false;
}
}
}
} catch (const std::exception& e) {
ImGui::TextColored(ImVec4(1, 0, 0, 1), "Error: %s", e.what());
}
}
ImGui::EndCombo();
}
ImGui::PopItemFlag();
} else {
show_file_browser_ = true;
} }
return 0; return 0;
@@ -157,8 +183,8 @@ int Render::SelfHostedServerWindow() {
ImGui::SetCursorPosY(settings_items_offset); ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH); ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH);
ImGui::InputText("##signal_server_ip_tmp_", signal_server_ip_tmp_, ImGui::InputText("##signal_server_ip_self_", signal_server_ip_self_,
IM_ARRAYSIZE(signal_server_ip_tmp_), IM_ARRAYSIZE(signal_server_ip_self_),
ImGuiInputTextFlags_AlwaysOverwrite); ImGuiInputTextFlags_AlwaysOverwrite);
} }
@@ -180,8 +206,29 @@ int Render::SelfHostedServerWindow() {
ImGui::SetCursorPosY(settings_items_offset); ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH); ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH);
ImGui::InputText("##signal_server_port_tmp_", signal_server_port_tmp_, ImGui::InputText("##signal_server_port_self_", signal_server_port_self_,
IM_ARRAYSIZE(signal_server_port_tmp_)); IM_ARRAYSIZE(signal_server_port_self_));
}
ImGui::Separator();
{
settings_items_offset += settings_items_padding;
ImGui::SetCursorPosY(settings_items_offset + 2);
ImGui::Text("%s", localization::self_hosted_server_coturn_server_port
[localization_language_index_]
.c_str());
if (ConfigCenter::LANGUAGE::CHINESE == localization_language_) {
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_CN);
} else {
ImGui::SetCursorPosX(SELF_HOSTED_SERVER_PORT_INPUT_BOX_PADDING_EN);
}
ImGui::SetCursorPosY(settings_items_offset);
ImGui::SetNextItemWidth(SELF_HOSTED_SERVER_INPUT_WINDOW_WIDTH);
ImGui::InputText("##coturn_server_port_self_", coturn_server_port_self_,
IM_ARRAYSIZE(coturn_server_port_self_));
} }
ImGui::Separator(); ImGui::Separator();
@@ -223,16 +270,20 @@ int Render::SelfHostedServerWindow() {
localization::ok[localization_language_index_].c_str())) { localization::ok[localization_language_index_].c_str())) {
show_self_hosted_server_config_window_ = false; show_self_hosted_server_config_window_ = false;
config_center_->SetServerHost(signal_server_ip_tmp_); config_center_->SetServerHost(signal_server_ip_self_);
config_center_->SetServerPort(atoi(signal_server_port_tmp_)); config_center_->SetServerPort(atoi(signal_server_port_self_));
config_center_->SetCertFilePath(selected_file_); config_center_->SetCoturnServerPort(atoi(coturn_server_port_self_));
strncpy(signal_server_ip_, signal_server_ip_tmp_, config_center_->SetCertFilePath(tls_cert_path_self_);
strncpy(signal_server_ip_, signal_server_ip_self_,
sizeof(signal_server_ip_) - 1); sizeof(signal_server_ip_) - 1);
signal_server_ip_[sizeof(signal_server_ip_) - 1] = '\0'; signal_server_ip_[sizeof(signal_server_ip_) - 1] = '\0';
strncpy(signal_server_port_, signal_server_port_tmp_, strncpy(signal_server_port_, signal_server_port_self_,
sizeof(signal_server_port_) - 1); sizeof(signal_server_port_) - 1);
signal_server_port_[sizeof(signal_server_port_) - 1] = '\0'; signal_server_port_[sizeof(signal_server_port_) - 1] = '\0';
strncpy(cert_file_path_, selected_file_.c_str(), strncpy(coturn_server_port_, coturn_server_port_self_,
sizeof(coturn_server_port_) - 1);
coturn_server_port_[sizeof(coturn_server_port_) - 1] = '\0';
strncpy(cert_file_path_, tls_cert_path_self_.c_str(),
sizeof(cert_file_path_) - 1); sizeof(cert_file_path_) - 1);
cert_file_path_[sizeof(cert_file_path_) - 1] = '\0'; cert_file_path_[sizeof(cert_file_path_) - 1] = '\0';
@@ -246,15 +297,15 @@ int Render::SelfHostedServerWindow() {
show_self_hosted_server_config_window_ = false; show_self_hosted_server_config_window_ = false;
self_hosted_server_config_window_pos_reset_ = true; self_hosted_server_config_window_pos_reset_ = true;
strncpy(signal_server_ip_tmp_, signal_server_ip_, strncpy(signal_server_ip_self_, signal_server_ip_,
sizeof(signal_server_ip_tmp_) - 1); sizeof(signal_server_ip_self_) - 1);
signal_server_ip_tmp_[sizeof(signal_server_ip_tmp_) - 1] = '\0'; signal_server_ip_self_[sizeof(signal_server_ip_self_) - 1] = '\0';
strncpy(signal_server_port_tmp_, signal_server_port_, strncpy(signal_server_port_self_, signal_server_port_,
sizeof(signal_server_port_tmp_) - 1); sizeof(signal_server_port_self_) - 1);
signal_server_port_tmp_[sizeof(signal_server_port_tmp_) - 1] = '\0'; signal_server_port_self_[sizeof(signal_server_port_self_) - 1] = '\0';
config_center_->SetServerHost(signal_server_ip_tmp_); config_center_->SetServerHost(signal_server_ip_self_);
config_center_->SetServerPort(atoi(signal_server_port_tmp_)); config_center_->SetServerPort(atoi(signal_server_port_self_));
selected_file_.clear(); tls_cert_path_self_.clear();
} }
ImGui::SetWindowFontScale(1.0f); ImGui::SetWindowFontScale(1.0f);