From 77ac202f5c67f25c8960d50c13dad6e5d2b4b6c5 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Mon, 23 Sep 2024 14:56:03 +0300 Subject: [PATCH 1/8] create empty group if a trigger is spec #144 --- main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b8d1e36..baf56df 100644 --- a/main.c +++ b/main.c @@ -479,6 +479,7 @@ int main(int argc, char **argv) long val = 0; char *end = 0; + bool all_limited = 1; struct desync_params *dp = add((void *)¶ms.dp, ¶ms.dp_count, sizeof(struct desync_params)); @@ -573,6 +574,9 @@ int main(int argc, char **argv) break; case 'A': + if (!(dp->hosts || dp->proto || dp->pf[0] || dp->detect)) { + all_limited = 0; + } dp = add((void *)¶ms.dp, ¶ms.dp_count, sizeof(struct desync_params)); if (!dp) { @@ -866,7 +870,7 @@ int main(int argc, char **argv) clear_params(); return -1; } - if (dp->hosts || dp->proto || dp->pf[0]) { + if (all_limited) { dp = add((void *)¶ms.dp, ¶ms.dp_count, sizeof(struct desync_params)); if (!dp) { From dca3b5693a8fbdaafec12267d587022fd1174562 Mon Sep 17 00:00:00 2001 From: Aleksey Smirnov Date: Tue, 24 Sep 2024 14:05:52 +0300 Subject: [PATCH 2/8] Separate options from service, add system service (#152) --- dist/linux/README.md | 22 ++++++++++++++++++---- dist/linux/byedpi.conf | 8 ++++++++ dist/linux/byedpi.service | 15 ++++++++++----- 3 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 dist/linux/byedpi.conf diff --git a/dist/linux/README.md b/dist/linux/README.md index 96db4d8..f211b46 100644 --- a/dist/linux/README.md +++ b/dist/linux/README.md @@ -9,16 +9,30 @@ sudo make install ## Systemd Service (optional) -Copy and enable the service: +You can configure the program to run as systemd service, user- or system-wide (only one at a time). + +### As user service: ```sh cp byedpi.service ~/.config/systemd/user/ -systemctl --user daemon-reload -systemctl --user enable byedpi.service -systemctl --user start byedpi.service +cp byedpi.conf ~/.config/ +systemctl --user enable --now byedpi.service ``` You should see the service now marked as "active": ```sh systemctl --user status byedpi.service ``` + +### As system service: + +```sh +sudo cp byedpi.service /etc/systemd/system/ +sudo cp byedpi.conf /etc/ +sudo systemctl enable --now byedpi.service +``` + +You should see the service now marked as "active": +```sh +systemctl status byedpi.service +``` diff --git a/dist/linux/byedpi.conf b/dist/linux/byedpi.conf new file mode 100644 index 0000000..e52e18a --- /dev/null +++ b/dist/linux/byedpi.conf @@ -0,0 +1,8 @@ +# More options and their descriptions can be found here: +# https://github.com/hufrea/byedpi/blob/main/README.md +# +# By default, ciadpi listens on all interfaces, +# a specific one can be specified via "--ip 127.0.0.1". + +# Put your options here +BYEDPI_OPTIONS="--split 1 --disorder 3+s --mod-http=h,d --auto=torst --tlsrec 1+s" diff --git a/dist/linux/byedpi.service b/dist/linux/byedpi.service index af986ae..7abe067 100644 --- a/dist/linux/byedpi.service +++ b/dist/linux/byedpi.service @@ -1,14 +1,19 @@ [Unit] -Description=byedpi +Description=ByeDPI Documentation=https://github.com/hufrea/byedpi +Wants=network-online.target +After=network-online.target nss-lookup.target [Service] -ExecStart=ciadpi --split 1 --disorder 3+s --mod-http=h,d --auto=torst --tlsrec 1+s +NoNewPrivileges=yes +StandardOutput=null +StandardError=journal +EnvironmentFile=-/etc/byedpi.conf +EnvironmentFile=-%h/.config/byedpi.conf +ExecStart=ciadpi $BYEDPI_OPTIONS TimeoutStopSec=5s -LimitNOFILE=1048576 -LimitNPROC=512 PrivateTmp=true ProtectSystem=full [Install] -WantedBy=default.target \ No newline at end of file +WantedBy=default.target From e4064766101ea3b5fc6ddde4f335a3ec57ce8368 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Tue, 24 Sep 2024 04:59:19 +0300 Subject: [PATCH 3/8] rst if exist only one group --- extend.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/extend.c b/extend.c index c696cbe..9010234 100644 --- a/extend.c +++ b/extend.c @@ -223,21 +223,24 @@ int on_torst(struct poolhd *pool, struct eval *val) for (; m < params.dp_count; m++) { struct desync_params *dp = ¶ms.dp[m]; if (!dp->detect) { - return -1; + m = 0; + break; } if (dp->detect & DETECT_TORST) { break; } } - if (m >= params.dp_count) { + if (m == 0) { + } + else if (m >= params.dp_count) { if (m > 1) mode_add_get( (struct sockaddr_ina *)&val->in6, 0); } - else if (can_reconn) + else if (can_reconn) { return reconnect(pool, val, m); - else - mode_add_get( - (struct sockaddr_ina *)&val->in6, m); + } + else mode_add_get( + (struct sockaddr_ina *)&val->in6, m); } struct linger l = { .l_onoff = 1 }; if (setsockopt(val->pair->fd, SOL_SOCKET, From 7dde94e3d2c88a50b03afb2137e1b3200f6a4a9d Mon Sep 17 00:00:00 2001 From: ruti <> Date: Tue, 24 Sep 2024 17:49:51 +0300 Subject: [PATCH 4/8] compile without sa_family_t --- extend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extend.c b/extend.c index 9010234..da8b135 100644 --- a/extend.c +++ b/extend.c @@ -24,7 +24,8 @@ #include "packets.h" #define KEY_SIZE sizeof(uint16_t) + \ - sizeof(sa_family_t) + sizeof(struct sockaddr_in6) + sizeof(((struct sockaddr){}).sa_family) + \ + sizeof(struct sockaddr_in6) int set_timeout(int fd, unsigned int s) From dcc492b8fd3dea82f8dce809758183cd280eb6e1 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Tue, 24 Sep 2024 21:04:30 +0300 Subject: [PATCH 5/8] sizeof(struct sockaddr_ina) as the max key size --- extend.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extend.c b/extend.c index da8b135..d03c326 100644 --- a/extend.c +++ b/extend.c @@ -23,9 +23,7 @@ #include "desync.h" #include "packets.h" -#define KEY_SIZE sizeof(uint16_t) + \ - sizeof(((struct sockaddr){}).sa_family) + \ - sizeof(struct sockaddr_in6) +#define KEY_SIZE sizeof(struct sockaddr_ina) int set_timeout(int fd, unsigned int s) From 322f9261cc58caf97a06c715e5580874ab93ada5 Mon Sep 17 00:00:00 2001 From: Kirill <20815458+dartvader316@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:39:10 +0000 Subject: [PATCH 6/8] Fix send_fake implementation conditional (#163) --- desync.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/desync.c b/desync.c index 0b3208a..fde50b3 100644 --- a/desync.c +++ b/desync.c @@ -249,7 +249,9 @@ ssize_t send_fake(int sfd, char *buffer, close(fds[1]); return len; } -#else +#endif + +#ifdef _WIN32 OVERLAPPED ov = {}; ssize_t send_fake(int sfd, char *buffer, From c71a09616816fa8ecbf929525ddaf9120b0ee7a5 Mon Sep 17 00:00:00 2001 From: ruti <> Date: Sun, 6 Oct 2024 18:59:48 +0300 Subject: [PATCH 7/8] Check IPv6 support #175 #169 --- main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/main.c b/main.c index baf56df..77f84ad 100644 --- a/main.c +++ b/main.c @@ -361,6 +361,17 @@ int get_default_ttl() } +bool ipv6_support() +{ + int fd = socket(AF_INET6, SOCK_STREAM, 0); + if (fd < 0) { + return 0; + } + close(fd); + return 1; +} + + int parse_offset(struct part *part, const char *str) { char *end = 0; @@ -879,6 +890,9 @@ int main(int argc, char **argv) } } + if (!ipv6_support()) { + params.baddr.sin6_family = AF_INET; + } if (params.baddr.sin6_family != AF_INET6) { params.ipv6 = 0; } From dbc85417af4e2847b65542cb576d7eda3dd6144d Mon Sep 17 00:00:00 2001 From: ruti <> Date: Sun, 6 Oct 2024 19:08:45 +0300 Subject: [PATCH 8/8] Check IPv6 support Change family for default address only --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 77f84ad..dc16943 100644 --- a/main.c +++ b/main.c @@ -484,6 +484,9 @@ int main(int argc, char **argv) } params.laddr.sin6_port = htons(1080); + if (!ipv6_support()) { + params.baddr.sin6_family = AF_INET; + } int rez; int invalid = 0; @@ -890,9 +893,6 @@ int main(int argc, char **argv) } } - if (!ipv6_support()) { - params.baddr.sin6_family = AF_INET; - } if (params.baddr.sin6_family != AF_INET6) { params.ipv6 = 0; }