Loading tpws/helpers.c +23 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,13 @@ char *strncasestr(const char *s, const char *find, size_t slen) return (char *)s; } bool str_ends_with(const char *s, const char *suffix) { size_t slen = strlen(s); size_t suffix_len = strlen(suffix); return suffix_len <= slen && !strcmp(s + slen - suffix_len, suffix); } bool load_file(const char *filename, void *buffer, size_t *buffer_size) { FILE *F; Loading Loading @@ -565,4 +572,20 @@ bool socket_wait_notsent(int sfd, unsigned int delay_ms, unsigned int *wasted_ms } return false; } int is_wsl(void) { struct utsname buf; if (uname(&buf) != 0) return -1; if (strcmp(buf.sysname, "Linux") != 0) return 0; if (str_ends_with(buf.release, "microsoft-standard-WSL2")) return 2; if (str_ends_with(buf.release, "-Microsoft")) return 1; return 0; } #endif tpws/helpers.h +5 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include <netdb.h> #include <stdio.h> #include <time.h> #include <sys/utsname.h> // this saves memory. sockaddr_storage is larger than required. it can be 128 bytes. sockaddr_in6 is 28 bytes. typedef union Loading @@ -22,6 +23,8 @@ void rtrim(char *s); void replace_char(char *s, char from, char to); char *strncasestr(const char *s,const char *find, size_t slen); bool str_ends_with(const char *s, const char *suffix); bool load_file(const char *filename,void *buffer,size_t *buffer_size); bool append_to_list_file(const char *filename, const char *s); Loading Loading @@ -133,4 +136,6 @@ void msleep(unsigned int ms); bool socket_supports_notsent(); bool socket_has_notsent(int sfd); bool socket_wait_notsent(int sfd, unsigned int delay_ms, unsigned int *wasted_ms); int is_wsl(); #endif tpws/tpws.c +20 −1 Original line number Diff line number Diff line Loading @@ -1490,6 +1490,10 @@ void parse_params(int argc, char *argv[]) fprintf(stderr, "could not chown %s. log file may not be writable after privilege drop\n", params.debug_logfile); if (params.droproot && *params.hostlist_auto_debuglog && chown(params.hostlist_auto_debuglog, params.uid, -1)) DLOG_ERR("could not chown %s. auto hostlist debug log may not be writable after privilege drop\n", params.hostlist_auto_debuglog); #ifdef __linux__ bool bHasMSS=false, bHasOOB=false, bHasDisorder=false; #endif LIST_FOREACH(dpl, ¶ms.desync_profiles, next) { dp = &dpl->dp; Loading @@ -1500,7 +1504,22 @@ void parse_params(int argc, char *argv[]) } if (params.droproot && dp->hostlist_auto && chown(dp->hostlist_auto->filename, params.uid, -1)) DLOG_ERR("could not chown %s. auto hostlist file may not be writable after privilege drop\n", dp->hostlist_auto->filename); #ifdef __linux__ if (dp->mss) bHasMSS=true; if (dp->oob || dp->oob_http || dp->oob_tls) bHasOOB=true; if (dp->disorder || dp->disorder_http || dp->disorder_tls) bHasDisorder=true; #endif } #ifdef __linux__ if (is_wsl()==1) { if (!params.nosplice) DLOG_CONDUP("WARNING ! WSL1 may have problems with splice. Consider using `--nosplice`.\n"); if (bHasMSS) DLOG_CONDUP("WARNING ! WSL1 does not support MSS socket option. MSS will likely fail.\n"); if (bHasOOB) DLOG_CONDUP("WARNING ! WSL1 does not support OOB. OOB will likely fail.\n"); if (bHasDisorder) DLOG_CONDUP("WARNING ! Windows retransmits whole TCP segment. Disorder will not function properly.\n"); fflush(stdout); } #endif if (!LoadAllHostLists()) { Loading Loading
tpws/helpers.c +23 −0 Original line number Diff line number Diff line Loading @@ -78,6 +78,13 @@ char *strncasestr(const char *s, const char *find, size_t slen) return (char *)s; } bool str_ends_with(const char *s, const char *suffix) { size_t slen = strlen(s); size_t suffix_len = strlen(suffix); return suffix_len <= slen && !strcmp(s + slen - suffix_len, suffix); } bool load_file(const char *filename, void *buffer, size_t *buffer_size) { FILE *F; Loading Loading @@ -565,4 +572,20 @@ bool socket_wait_notsent(int sfd, unsigned int delay_ms, unsigned int *wasted_ms } return false; } int is_wsl(void) { struct utsname buf; if (uname(&buf) != 0) return -1; if (strcmp(buf.sysname, "Linux") != 0) return 0; if (str_ends_with(buf.release, "microsoft-standard-WSL2")) return 2; if (str_ends_with(buf.release, "-Microsoft")) return 1; return 0; } #endif
tpws/helpers.h +5 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ #include <netdb.h> #include <stdio.h> #include <time.h> #include <sys/utsname.h> // this saves memory. sockaddr_storage is larger than required. it can be 128 bytes. sockaddr_in6 is 28 bytes. typedef union Loading @@ -22,6 +23,8 @@ void rtrim(char *s); void replace_char(char *s, char from, char to); char *strncasestr(const char *s,const char *find, size_t slen); bool str_ends_with(const char *s, const char *suffix); bool load_file(const char *filename,void *buffer,size_t *buffer_size); bool append_to_list_file(const char *filename, const char *s); Loading Loading @@ -133,4 +136,6 @@ void msleep(unsigned int ms); bool socket_supports_notsent(); bool socket_has_notsent(int sfd); bool socket_wait_notsent(int sfd, unsigned int delay_ms, unsigned int *wasted_ms); int is_wsl(); #endif
tpws/tpws.c +20 −1 Original line number Diff line number Diff line Loading @@ -1490,6 +1490,10 @@ void parse_params(int argc, char *argv[]) fprintf(stderr, "could not chown %s. log file may not be writable after privilege drop\n", params.debug_logfile); if (params.droproot && *params.hostlist_auto_debuglog && chown(params.hostlist_auto_debuglog, params.uid, -1)) DLOG_ERR("could not chown %s. auto hostlist debug log may not be writable after privilege drop\n", params.hostlist_auto_debuglog); #ifdef __linux__ bool bHasMSS=false, bHasOOB=false, bHasDisorder=false; #endif LIST_FOREACH(dpl, ¶ms.desync_profiles, next) { dp = &dpl->dp; Loading @@ -1500,7 +1504,22 @@ void parse_params(int argc, char *argv[]) } if (params.droproot && dp->hostlist_auto && chown(dp->hostlist_auto->filename, params.uid, -1)) DLOG_ERR("could not chown %s. auto hostlist file may not be writable after privilege drop\n", dp->hostlist_auto->filename); #ifdef __linux__ if (dp->mss) bHasMSS=true; if (dp->oob || dp->oob_http || dp->oob_tls) bHasOOB=true; if (dp->disorder || dp->disorder_http || dp->disorder_tls) bHasDisorder=true; #endif } #ifdef __linux__ if (is_wsl()==1) { if (!params.nosplice) DLOG_CONDUP("WARNING ! WSL1 may have problems with splice. Consider using `--nosplice`.\n"); if (bHasMSS) DLOG_CONDUP("WARNING ! WSL1 does not support MSS socket option. MSS will likely fail.\n"); if (bHasOOB) DLOG_CONDUP("WARNING ! WSL1 does not support OOB. OOB will likely fail.\n"); if (bHasDisorder) DLOG_CONDUP("WARNING ! Windows retransmits whole TCP segment. Disorder will not function properly.\n"); fflush(stdout); } #endif if (!LoadAllHostLists()) { Loading