mirror of
https://github.com/bol-van/zapret.git
synced 2025-04-20 22:12:58 +03:00
Compare commits
3 Commits
d5b794cd1c
...
849dbd7d2c
Author | SHA1 | Date | |
---|---|---|---|
|
849dbd7d2c | ||
|
5f9fa28251 | ||
|
92ba6b439e |
40
ipset/get_antifilter_domains.sh
Normal file
40
ipset/get_antifilter_domains.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
IPSET_DIR="$(dirname "$0")"
|
||||
IPSET_DIR="$(cd "$IPSET_DIR"; pwd)"
|
||||
|
||||
. "$IPSET_DIR/def.sh"
|
||||
|
||||
TMPLIST="$TMPDIR/list.txt"
|
||||
|
||||
URL="https://antifilter.download/list/domains.lst"
|
||||
|
||||
dl()
|
||||
{
|
||||
# $1 - url
|
||||
# $2 - file
|
||||
# $3 - minsize
|
||||
# $4 - maxsize
|
||||
curl -L -H "Accept-Encoding: gzip" -k --fail --max-time 60 --connect-timeout 10 --retry 4 --max-filesize 251658240 -o "$TMPLIST" "$1" ||
|
||||
{
|
||||
echo list download failed : $1
|
||||
exit 2
|
||||
}
|
||||
dlsize=$(LANG=C wc -c "$TMPLIST" | xargs | cut -f 1 -d ' ')
|
||||
if test $dlsize -lt $3; then
|
||||
echo list is too small : $dlsize bytes. can be bad.
|
||||
exit 2
|
||||
fi
|
||||
zzcat "$TMPLIST" | tr -d '\015' | zz "$2"
|
||||
rm -f "$TMPLIST"
|
||||
}
|
||||
|
||||
# useful in case ipban set is used in custom scripts
|
||||
FAIL=
|
||||
getipban || FAIL=1
|
||||
"$IPSET_DIR/create_ipset.sh"
|
||||
[ -n "$FAIL" ] && exit
|
||||
|
||||
dl "$URL" "$ZHOSTLIST" 32768 4194304
|
||||
|
||||
exit 0
|
@ -9,6 +9,7 @@
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <libgen.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int unique_size_t(size_t *pu, int ct)
|
||||
{
|
||||
@ -313,6 +314,17 @@ bool file_mod_signature(const char *filename, file_mod_sig *ms)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool file_open_test(const char *filename, int flags)
|
||||
{
|
||||
int fd = open(filename,flags);
|
||||
if (fd>=0)
|
||||
{
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pf_in_range(uint16_t port, const port_filter *pf)
|
||||
{
|
||||
return port && (((!pf->from && !pf->to) || (port>=pf->from && port<=pf->to)) ^ pf->neg);
|
||||
|
@ -77,6 +77,7 @@ typedef struct
|
||||
#define FILE_MOD_RESET(ms) memset(ms,0,sizeof(file_mod_sig))
|
||||
bool file_mod_signature(const char *filename, file_mod_sig *ms);
|
||||
time_t file_mod_time(const char *filename);
|
||||
bool file_open_test(const char *filename, int flags);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -126,16 +126,16 @@ static bool test_list_files()
|
||||
struct ipset_file *ifile;
|
||||
|
||||
LIST_FOREACH(hfile, ¶ms.hostlists, next)
|
||||
if (!file_mod_time(hfile->filename))
|
||||
if (!file_open_test(hfile->filename, O_RDONLY))
|
||||
{
|
||||
DLOG_PERROR("file_mod_time");
|
||||
DLOG_PERROR("file_open_test");
|
||||
DLOG_ERR("cannot access hostlist file '%s'\n",hfile->filename);
|
||||
return false;
|
||||
}
|
||||
LIST_FOREACH(ifile, ¶ms.ipsets, next)
|
||||
if (!file_mod_time(ifile->filename))
|
||||
if (!file_open_test(ifile->filename, O_RDONLY))
|
||||
{
|
||||
DLOG_PERROR("file_mod_time");
|
||||
DLOG_PERROR("file_open_test");
|
||||
DLOG_ERR("cannot access ipset file '%s'\n",ifile->filename);
|
||||
return false;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "andr/ifaddrs.h"
|
||||
@ -327,6 +328,17 @@ bool file_mod_signature(const char *filename, file_mod_sig *ms)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool file_open_test(const char *filename, int flags)
|
||||
{
|
||||
int fd = open(filename,flags);
|
||||
if (fd>=0)
|
||||
{
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool pf_in_range(uint16_t port, const port_filter *pf)
|
||||
{
|
||||
return port && (((!pf->from && !pf->to) || (port >= pf->from && port <= pf->to)) ^ pf->neg);
|
||||
|
@ -71,6 +71,7 @@ typedef struct
|
||||
#define FILE_MOD_RESET(ms) memset(ms,0,sizeof(file_mod_sig))
|
||||
bool file_mod_signature(const char *filename, file_mod_sig *ms);
|
||||
time_t file_mod_time(const char *filename);
|
||||
bool file_open_test(const char *filename, int flags);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -122,16 +122,16 @@ static bool test_list_files()
|
||||
struct ipset_file *ifile;
|
||||
|
||||
LIST_FOREACH(hfile, ¶ms.hostlists, next)
|
||||
if (!file_mod_time(hfile->filename))
|
||||
if (!file_open_test(hfile->filename, O_RDONLY))
|
||||
{
|
||||
DLOG_PERROR("file_mod_time");
|
||||
DLOG_PERROR("file_open_test");
|
||||
DLOG_ERR("cannot access hostlist file '%s'\n",hfile->filename);
|
||||
return false;
|
||||
}
|
||||
LIST_FOREACH(ifile, ¶ms.ipsets, next)
|
||||
if (!file_mod_time(ifile->filename))
|
||||
if (!file_open_test(ifile->filename, O_RDONLY))
|
||||
{
|
||||
DLOG_PERROR("file_mod_time");
|
||||
DLOG_PERROR("file_open_test");
|
||||
DLOG_ERR("cannot access ipset file '%s'\n",ifile->filename);
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user