mirror of https://github.com/bol-van/zapret/
9 changed files with 322 additions and 107 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,24 @@ |
|||||
|
#!/bin/sh |
||||
|
# get domain list. not IP |
||||
|
|
||||
|
SCRIPT=$(readlink -f $0) |
||||
|
EXEDIR=$(dirname $SCRIPT) |
||||
|
|
||||
|
. "$EXEDIR/def.sh" |
||||
|
|
||||
|
ZREESTR=$TMPDIR/zapret.txt |
||||
|
#ZURL=https://reestr.rublacklist.net/api/current |
||||
|
ZURL=https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv |
||||
|
|
||||
|
curl -k --fail --max-time 300 --max-filesize 41943040 "$ZURL" >$ZREESTR || |
||||
|
{ |
||||
|
echo reestr list download failed |
||||
|
exit 2 |
||||
|
} |
||||
|
dlsize=$(wc -c "$ZREESTR" | cut -f 1 -d ' ') |
||||
|
if test $dlsize -lt 204800; then |
||||
|
echo list file is too small. can be bad. |
||||
|
exit 2 |
||||
|
fi |
||||
|
(cut -s -f2 -d';' $ZREESTR | grep -a . | sed -re 's/^\*\.(.+)$/\1/' | awk '{ print tolower($0) }' ; cat $ZUSERLIST ) | sort -u >$ZHOSTLIST |
||||
|
rm -f $ZREESTR |
@ -0,0 +1,81 @@ |
|||||
|
#include "chartree.h" |
||||
|
#include <string.h> |
||||
|
#include <stdlib.h> |
||||
|
|
||||
|
static char *DupLower(const char *s) |
||||
|
{ |
||||
|
char *sp,*sl = strdup(s); |
||||
|
if (!sl) return false; |
||||
|
for(sp=sl;*sp;sp++) *sp=tolower(*sp); |
||||
|
return sl; |
||||
|
} |
||||
|
|
||||
|
static cptr *CharTreeInit(char c) |
||||
|
{ |
||||
|
cptr *p; |
||||
|
p=(cptr *)calloc(1,sizeof(cptr)); |
||||
|
if (p) p->chr = c; |
||||
|
return p; |
||||
|
} |
||||
|
void CharTreeDestroy(cptr *p) |
||||
|
{ |
||||
|
if (p) |
||||
|
{ |
||||
|
CharTreeDestroy(p->leaf); |
||||
|
CharTreeDestroy(p->next); |
||||
|
free(p); |
||||
|
} |
||||
|
} |
||||
|
static cptr *CharTreeFindChar(cptr *p,char c) |
||||
|
{ |
||||
|
while (p) |
||||
|
{ |
||||
|
if (p->chr==c) return p; |
||||
|
p = p->next; |
||||
|
} |
||||
|
return NULL; |
||||
|
} |
||||
|
bool CharTreeAddStr(cptr **pp,const char *s) |
||||
|
{ |
||||
|
cptr *p; |
||||
|
if (*pp) |
||||
|
{ |
||||
|
if (!(p=CharTreeFindChar(*pp,*s))) |
||||
|
{ |
||||
|
// already present. append to list head
|
||||
|
if (!(p = CharTreeInit(*s))) |
||||
|
return false; |
||||
|
p->next = *pp; |
||||
|
*pp = p; |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
if (!(p = *pp = CharTreeInit(*s))) return false; |
||||
|
if (!*s) return true; |
||||
|
return CharTreeAddStr(&p->leaf,s+1); |
||||
|
} |
||||
|
bool CharTreeCheckStr(cptr *p,const char *s) |
||||
|
{ |
||||
|
p = CharTreeFindChar(p,*s); |
||||
|
if (!p) return false; |
||||
|
if (!*s) return true; |
||||
|
return CharTreeCheckStr(p->leaf,s+1); |
||||
|
} |
||||
|
bool CharTreeAddStrLower(cptr **pp,const char *s) |
||||
|
{ |
||||
|
bool b; |
||||
|
char *sl = DupLower(s); |
||||
|
if (!sl) return false; |
||||
|
b=CharTreeAddStr(pp,sl); |
||||
|
free(sl); |
||||
|
return b; |
||||
|
} |
||||
|
bool CharTreeCheckStrLower(cptr *pp,const char *s) |
||||
|
{ |
||||
|
bool b; |
||||
|
char *sl = DupLower(s); |
||||
|
if (!sl) return false; |
||||
|
b=CharTreeCheckStr(pp,sl); |
||||
|
free(sl); |
||||
|
return b; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <stdbool.h> |
||||
|
#include <ctype.h> |
||||
|
|
||||
|
typedef struct cptr |
||||
|
{ |
||||
|
char chr; |
||||
|
struct cptr *leaf,*next; |
||||
|
} cptr; |
||||
|
|
||||
|
void CharTreeDestroy(cptr *p); |
||||
|
bool CharTreeAddStr(cptr **pp,const char *s); |
||||
|
bool CharTreeAddStrLower(cptr **pp,const char *s); |
||||
|
bool CharTreeCheckStr(cptr *p,const char *s); |
||||
|
bool CharTreeCheckStrLower(cptr *pp,const char *s); |
Loading…
Reference in new issue