mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-29 21:40:52 +03:00
Compare commits
5 Commits
c964677913
...
8b4b8c3fb0
Author | SHA1 | Date | |
---|---|---|---|
|
8b4b8c3fb0 | ||
|
228572afb5 | ||
|
ebb89c48e0 | ||
|
067be122b3 | ||
|
a4632ef6d7 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -350,6 +350,7 @@ blockcheck: restring fooling to testing domain's IPs
|
||||
nfqws,tpws: internal hostlist deduplication to save RAM
|
||||
nfqws,tpws: hostlist/ipset auto reload on file change. no more HUP.
|
||||
nfqws,tpws: --filter-tcp, --filter-udp take comma separated port range list
|
||||
nfqws,tpws: @<config_file> - read config from a file
|
||||
config: <HOSTLIST_NOAUTO> marker
|
||||
binaries: remove zapret-winws. add win32.
|
||||
blockcheck, install_easy.sh: preserve user environment variables during elevation
|
||||
|
@ -112,7 +112,7 @@ badseq может работать только на https и не работа
|
||||
|
||||
Если кратко, то обычно параметры конструируются так :
|
||||
"--filter-udp=443 'параметры для quic' <HOSTLIST_NOAUTO> --new
|
||||
--filter-tcp=80-443 'обьединенные параметры для http и https' <HOSTLIST>"
|
||||
--filter-tcp=80,443 'обьединенные параметры для http и https' <HOSTLIST>"
|
||||
|
||||
Или так :
|
||||
"--filter-udp=443 "параметры для quic" <HOSTLIST_NOAUTO> --new
|
||||
|
@ -111,7 +111,7 @@ badseq может работать только на https и не работа
|
||||
|
||||
Если кратко по мультистратегии, то обычно параметры конструируются так :
|
||||
"--filter-udp=443 'параметры для quic' --new
|
||||
--filter-tcp=80-443 'обьединенные параметры для http и https'"
|
||||
--filter-tcp=80,443 'обьединенные параметры для http и https'"
|
||||
|
||||
Или так :
|
||||
"--filter-udp=443 "параметры для quic" --new
|
||||
|
@ -153,6 +153,8 @@ For BSD systems there is dvtws. Its built from the same source and has almost th
|
||||
nfqws takes the following parameters:
|
||||
|
||||
```
|
||||
@<config_file> ; read file for options. must be the only argument. other options are ignored.
|
||||
|
||||
--debug=0|1
|
||||
--qnum=<nfqueue_number>
|
||||
--daemon ; daemonize
|
||||
@ -608,6 +610,8 @@ It's for the systems that lack ipset support : Windows and Linux without nftable
|
||||
tpws is transparent proxy.
|
||||
|
||||
```
|
||||
@<config_file> ; read file for options. must be the only argument. other options are ignored.
|
||||
|
||||
--debug=0|1|2|syslog|@<filename> ; 1 and 2 means log to console and set debug level. for other targets use --debug-level.
|
||||
--debug-level=0|1|2 ; specify debug level for syslog and @<filename>
|
||||
--bind-addr=<v4_addr>|<v6_addr>; for v6 link locals append %interface_name : fe80::1%br-lan
|
||||
|
@ -225,6 +225,8 @@ nfqws
|
||||
Эта программа - модификатор пакетов и обработчик очереди NFQUEUE.
|
||||
Для BSD систем существует адаптированный вариант - dvtws, собираемый из тех же исходников (см. bsd.txt).
|
||||
|
||||
@<config_file> ; читать конфигурацию из файла. опция должна быть первой. остальные опции игнорируются.
|
||||
|
||||
--debug=0|1 ; 1=выводить отладочные сообщения
|
||||
--daemon ; демонизировать прогу
|
||||
--pidfile=<file> ; сохранить PID в файл
|
||||
@ -706,6 +708,9 @@ tpws
|
||||
-----
|
||||
|
||||
tpws - это transparent proxy.
|
||||
|
||||
@<config_file> ; читать конфигурацию из файла. опция должна быть первой. остальные опции игнорируются.
|
||||
|
||||
--debug=0|1|2|syslog|@<filename> ; 0,1,2 = логирование на косоль : 0=тихо, 1(default)=подробно, 2=отладка.
|
||||
--debug-level=0|1|2 ; указать уровень логирования для syslog и @<filename>
|
||||
--daemon ; демонизировать прогу
|
||||
|
@ -105,6 +105,7 @@ network locations в win10/11. Кое-что есть в powershell.
|
||||
|
||||
Если в путях присутствуют национальные символы, то при вызове winws из cmd или bat кодировку нужно использовать OEM.
|
||||
Для русского языка это 866. Пути с пробелами нужно брать в кавычки.
|
||||
При использовании опции @<config_file> кодировка в файле должна быть UTF-8 без BOM mark.
|
||||
|
||||
Существует неочевидный момент, каcаемый запуска winws из cygwin шелла. Если в директории, где находится winws, находится
|
||||
копия cygwin1.dll, winws не запустится.
|
||||
|
@ -164,7 +164,7 @@ standard_mode_daemons()
|
||||
[ "$TPWS_SOCKS_ENABLE" = 1 ] && {
|
||||
opt="--socks --user=$WS_USER --port=$TPPORT_SOCKS"
|
||||
tpws_apply_socks_binds opt
|
||||
opt="$opt $TPWS_OPT"
|
||||
opt="$opt $TPWS_SOCKS_OPT"
|
||||
filter_apply_hostlist_target opt
|
||||
do_daemon $1 2 "$TPWS" "$opt"
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ standard_mode_daemons()
|
||||
run_tpws 1 "$opt"
|
||||
}
|
||||
[ "$TPWS_SOCKS_ENABLE" = 1 ] && {
|
||||
opt="--port=$TPPORT_SOCKS $TPWS_OPT"
|
||||
opt="--port=$TPPORT_SOCKS $TPWS_SOCKS_OPT"
|
||||
filter_apply_hostlist_target opt
|
||||
run_tpws_socks 2 "$opt"
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ standard_mode_daemons()
|
||||
do_tpws $1 1 "$opt"
|
||||
}
|
||||
[ "$TPWS_SOCKS_ENABLE" = 1 ] && {
|
||||
opt="--port=$TPPORT_SOCKS $TPWS_OPT"
|
||||
opt="--port=$TPPORT_SOCKS $TPWS_SOCKS_OPT"
|
||||
filter_apply_hostlist_target opt
|
||||
do_tpws_socks $1 2 "$opt"
|
||||
}
|
||||
|
@ -17,20 +17,9 @@ void rtrim(char *s)
|
||||
for (char *p = s + strlen(s) - 1; p >= s && (*p == '\n' || *p == '\r'); p--) *p = '\0';
|
||||
}
|
||||
|
||||
void hexdump_limited_dlog(const uint8_t *data, size_t size, size_t limit)
|
||||
void replace_char(char *s, char from, char to)
|
||||
{
|
||||
size_t k;
|
||||
bool bcut = false;
|
||||
if (size > limit)
|
||||
{
|
||||
size = limit;
|
||||
bcut = true;
|
||||
}
|
||||
if (!size) return;
|
||||
for (k = 0; k < size; k++) DLOG("%02X ", data[k]);
|
||||
DLOG(bcut ? "... : " : ": ");
|
||||
for (k = 0; k < size; k++) DLOG("%c", data[k] >= 0x20 && data[k] <= 0x7F ? (char)data[k] : '.');
|
||||
if (bcut) DLOG(" ...");
|
||||
for(;*s;s++) if (*s==from) *s=to;
|
||||
}
|
||||
|
||||
char *strncasestr(const char *s, const char *find, size_t slen)
|
||||
@ -54,6 +43,23 @@ char *strncasestr(const char *s, const char *find, size_t slen)
|
||||
return (char *)s;
|
||||
}
|
||||
|
||||
void hexdump_limited_dlog(const uint8_t *data, size_t size, size_t limit)
|
||||
{
|
||||
size_t k;
|
||||
bool bcut = false;
|
||||
if (size > limit)
|
||||
{
|
||||
size = limit;
|
||||
bcut = true;
|
||||
}
|
||||
if (!size) return;
|
||||
for (k = 0; k < size; k++) DLOG("%02X ", data[k]);
|
||||
DLOG(bcut ? "... : " : ": ");
|
||||
for (k = 0; k < size; k++) DLOG("%c", data[k] >= 0x20 && data[k] <= 0x7F ? (char)data[k] : '.');
|
||||
if (bcut) DLOG(" ...");
|
||||
}
|
||||
|
||||
|
||||
bool load_file(const char *filename, void *buffer, size_t *buffer_size)
|
||||
{
|
||||
FILE *F;
|
||||
|
@ -18,9 +18,10 @@ typedef union
|
||||
} sockaddr_in46;
|
||||
|
||||
void rtrim(char *s);
|
||||
void replace_char(char *s, char from, char to);
|
||||
char *strncasestr(const char *s,const char *find, size_t slen);
|
||||
|
||||
void hexdump_limited_dlog(const uint8_t *data, size_t size, size_t limit);
|
||||
char *strncasestr(const char *s,const char *find, size_t slen);
|
||||
bool load_file(const char *filename,void *buffer,size_t *buffer_size);
|
||||
bool load_file_nonempty(const char *filename,void *buffer,size_t *buffer_size);
|
||||
bool save_file(const char *filename, const void *buffer, size_t buffer_size);
|
||||
|
41
nfq/nfqws.c
41
nfq/nfqws.c
@ -46,6 +46,8 @@
|
||||
#define CTRACK_T_EST 300
|
||||
#define CTRACK_T_UDP 60
|
||||
|
||||
#define MAX_CONFIG_FILE_SIZE 16384
|
||||
|
||||
struct params_s params;
|
||||
#ifdef __CYGWIN__
|
||||
bool bQuit=false;
|
||||
@ -550,8 +552,15 @@ static bool parse_ws_scale_factor(char *s, uint16_t *wsize, uint8_t *wscale)
|
||||
|
||||
|
||||
|
||||
static void cleanup_args()
|
||||
{
|
||||
wordfree(¶ms.wexp);
|
||||
}
|
||||
|
||||
static void cleanup_params(void)
|
||||
{
|
||||
cleanup_args();
|
||||
|
||||
ConntrackPoolDestroy(¶ms.conntrack);
|
||||
|
||||
dp_list_destroy(¶ms.desync_profiles);
|
||||
@ -842,6 +851,7 @@ static unsigned int hash_jen(const void *data,unsigned int len)
|
||||
static void exithelp(void)
|
||||
{
|
||||
printf(
|
||||
" @<config_file>\t\t\t\t\t; read file for options. must be the only argument. other options are ignored.\n\n"
|
||||
" --debug=0|1|syslog|@<filename>\n"
|
||||
#ifdef __linux__
|
||||
" --qnum=<nfqueue_number>\n"
|
||||
@ -1036,6 +1046,33 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc>=2 && argv[1][0]=='@')
|
||||
{
|
||||
// config from a file
|
||||
|
||||
char buf[MAX_CONFIG_FILE_SIZE];
|
||||
buf[0]='x'; // fake argv[0]
|
||||
buf[1]=' ';
|
||||
size_t bufsize=sizeof(buf)-3;
|
||||
if (!load_file(argv[1]+1,buf+2,&bufsize))
|
||||
{
|
||||
DLOG_ERR("could not load config file '%s'\n",argv[1]+1);
|
||||
exit_clean(1);
|
||||
}
|
||||
buf[bufsize+2]=0;
|
||||
// wordexp fails if it sees \t \n \r between args
|
||||
replace_char(buf,'\n',' ');
|
||||
replace_char(buf,'\r',' ');
|
||||
replace_char(buf,'\t',' ');
|
||||
if (wordexp(buf, ¶ms.wexp, WRDE_NOCMD))
|
||||
{
|
||||
DLOG_ERR("failed to split command line options from file '%s'\n",argv[1]+1);
|
||||
exit_clean(1);
|
||||
}
|
||||
argv=params.wexp.we_wordv;
|
||||
argc=params.wexp.we_wordc;
|
||||
}
|
||||
|
||||
const struct option long_options[] = {
|
||||
{"debug",optional_argument,0,0}, // optidx=0
|
||||
#ifdef __linux__
|
||||
@ -1783,6 +1820,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
// do not need args from file anymore
|
||||
cleanup_args();
|
||||
argv=NULL; argc=0;
|
||||
|
||||
#ifdef __linux__
|
||||
if (params.qnum<0)
|
||||
{
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <sys/queue.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#define TLS_PARTIALS_ENABLE true
|
||||
|
||||
@ -95,6 +96,8 @@ bool dp_list_have_autohostlist(struct desync_profile_list_head *head);
|
||||
|
||||
struct params_s
|
||||
{
|
||||
wordexp_t wexp; // for file based config
|
||||
|
||||
enum log_target debug_target;
|
||||
char debug_logfile[PATH_MAX];
|
||||
bool debug;
|
||||
|
@ -17,6 +17,11 @@ void rtrim(char *s)
|
||||
for (char *p = s + strlen(s) - 1; p >= s && (*p == '\n' || *p == '\r'); p--) *p = '\0';
|
||||
}
|
||||
|
||||
void replace_char(char *s, char from, char to)
|
||||
{
|
||||
for(;*s;s++) if (*s==from) *s=to;
|
||||
}
|
||||
|
||||
char *strncasestr(const char *s,const char *find, size_t slen)
|
||||
{
|
||||
char c, sc;
|
||||
@ -38,6 +43,24 @@ char *strncasestr(const char *s,const char *find, size_t slen)
|
||||
return (char *)s;
|
||||
}
|
||||
|
||||
bool load_file(const char *filename, void *buffer, size_t *buffer_size)
|
||||
{
|
||||
FILE *F;
|
||||
|
||||
F = fopen(filename, "rb");
|
||||
if (!F) return false;
|
||||
|
||||
*buffer_size = fread(buffer, 1, *buffer_size, F);
|
||||
if (ferror(F))
|
||||
{
|
||||
fclose(F);
|
||||
return false;
|
||||
}
|
||||
|
||||
fclose(F);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool append_to_list_file(const char *filename, const char *s)
|
||||
{
|
||||
FILE *F = fopen(filename,"at");
|
||||
|
@ -16,8 +16,10 @@ typedef union
|
||||
} sockaddr_in46;
|
||||
|
||||
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 load_file(const char *filename,void *buffer,size_t *buffer_size);
|
||||
bool append_to_list_file(const char *filename, const char *s);
|
||||
|
||||
void ntop46(const struct sockaddr *sa, char *str, size_t len);
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/queue.h>
|
||||
#include <time.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "tpws.h"
|
||||
#include "pools.h"
|
||||
#include "helpers.h"
|
||||
@ -79,6 +81,8 @@ void dp_list_destroy(struct desync_profile_list_head *head);
|
||||
|
||||
struct params_s
|
||||
{
|
||||
wordexp_t wexp; // for file based config
|
||||
|
||||
int debug;
|
||||
enum log_target debug_target;
|
||||
char debug_logfile[PATH_MAX];
|
||||
|
41
tpws/tpws.c
41
tpws/tpws.c
@ -41,6 +41,9 @@
|
||||
#include "gzip.h"
|
||||
#include "pools.h"
|
||||
|
||||
|
||||
#define MAX_CONFIG_FILE_SIZE 16384
|
||||
|
||||
struct params_s params;
|
||||
|
||||
static void onhup(int sig)
|
||||
@ -119,6 +122,7 @@ static int get_default_ttl(void)
|
||||
static void exithelp(void)
|
||||
{
|
||||
printf(
|
||||
" @<config_file>\t\t\t\t; read file for options. must be the only argument. other options are ignored.\n\n"
|
||||
" --bind-addr=<v4_addr>|<v6_addr>\t; for v6 link locals append %%interface_name\n"
|
||||
" --bind-iface4=<interface_name>\t\t; bind to the first ipv4 addr of interface\n"
|
||||
" --bind-iface6=<interface_name>\t\t; bind to the first ipv6 addr of interface\n"
|
||||
@ -211,8 +215,14 @@ static void exithelp(void)
|
||||
);
|
||||
exit(1);
|
||||
}
|
||||
static void cleanup_args()
|
||||
{
|
||||
wordfree(¶ms.wexp);
|
||||
}
|
||||
static void cleanup_params(void)
|
||||
{
|
||||
cleanup_args();
|
||||
|
||||
dp_list_destroy(¶ms.desync_profiles);
|
||||
|
||||
hostlist_files_destroy(¶ms.hostlists);
|
||||
@ -393,6 +403,33 @@ void parse_params(int argc, char *argv[])
|
||||
dp = &dpl->dp;
|
||||
dp->n = ++desync_profile_count;
|
||||
|
||||
if (argc>=2 && argv[1][0]=='@')
|
||||
{
|
||||
// config from a file
|
||||
|
||||
char buf[MAX_CONFIG_FILE_SIZE];
|
||||
buf[0]='x'; // fake argv[0]
|
||||
buf[1]=' ';
|
||||
size_t bufsize=sizeof(buf)-3;
|
||||
if (!load_file(argv[1]+1,buf+2,&bufsize))
|
||||
{
|
||||
DLOG_ERR("could not load config file '%s'\n",argv[1]+1);
|
||||
exit_clean(1);
|
||||
}
|
||||
buf[bufsize+2]=0;
|
||||
// wordexp fails if it sees \t \n \r between args
|
||||
replace_char(buf,'\n',' ');
|
||||
replace_char(buf,'\r',' ');
|
||||
replace_char(buf,'\t',' ');
|
||||
if (wordexp(buf, ¶ms.wexp, WRDE_NOCMD))
|
||||
{
|
||||
DLOG_ERR("failed to split command line options from file '%s'\n",argv[1]+1);
|
||||
exit_clean(1);
|
||||
}
|
||||
argv=params.wexp.we_wordv;
|
||||
argc=params.wexp.we_wordc;
|
||||
}
|
||||
|
||||
const struct option long_options[] = {
|
||||
{ "help",no_argument,0,0 },// optidx=0
|
||||
{ "h",no_argument,0,0 },// optidx=1
|
||||
@ -1091,6 +1128,9 @@ void parse_params(int argc, char *argv[])
|
||||
HostlistsDebug();
|
||||
IpsetsDebug();
|
||||
VPRINT("\n");
|
||||
|
||||
// do not need args from file anymore
|
||||
cleanup_args();
|
||||
}
|
||||
|
||||
|
||||
@ -1250,6 +1290,7 @@ int main(int argc, char *argv[])
|
||||
mask_from_preflen6_prepare();
|
||||
|
||||
parse_params(argc, argv);
|
||||
argv=NULL; argc=0;
|
||||
|
||||
if (params.daemon) daemonize();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user