|
|
|
@ -59,23 +59,24 @@ static int daemon_loop(sqlite3 *db)
|
|
|
|
|
if (cp != NULL) |
|
|
|
|
*cp= '\0'; |
|
|
|
|
|
|
|
|
|
char *ipstr = strtok(line, " \t"); |
|
|
|
|
char *tmp = strtok(line, " \t"); |
|
|
|
|
char *ipstr = strtok(NULL, " \t"); |
|
|
|
|
char *urlstr = strtok(NULL, " \t"); |
|
|
|
|
if (ipstr == NULL || urlstr == NULL) { |
|
|
|
|
puts("ERR\n"); |
|
|
|
|
if (tmp == NULL || ipstr == NULL || urlstr == NULL) { |
|
|
|
|
puts("ERR"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct in_addr addr; |
|
|
|
|
ret = inet_aton(ipstr, &addr); |
|
|
|
|
if (ret == 0) { |
|
|
|
|
puts("ERR\n"); |
|
|
|
|
puts("ERR"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ret = snprintf(query, BUF_SIZE, "SELECT url FROM urlfilter WHERE (ip & mask) == (%u & mask);", addr.s_addr); |
|
|
|
|
if (ret < 0 || ret >= BUF_SIZE) { |
|
|
|
|
puts("ERR\n"); |
|
|
|
|
puts("ERR"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -86,15 +87,16 @@ static int daemon_loop(sqlite3 *db)
|
|
|
|
|
|
|
|
|
|
ret = sqlite3_exec(db, query, daemon_callback, &args, NULL); |
|
|
|
|
if (ret != SQLITE_OK) { |
|
|
|
|
puts("ERR\n"); |
|
|
|
|
puts("ERR"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (args.flags) |
|
|
|
|
puts("ERR\n"); |
|
|
|
|
puts("ERR"); |
|
|
|
|
else |
|
|
|
|
puts("OK\n"); |
|
|
|
|
puts("OK"); |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int show_callback(void *data, int cols, char **values, char **colnames) |
|
|
|
|