Skip to content

Commit

Permalink
Merge branch 'EgorWeders-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdikSS committed Aug 7, 2024
2 parents aab7842 + e9ac13b commit c517169
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/goodbyedpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ WINSOCK_API_LINKAGE INT WSAAPI inet_pton(INT Family, LPCSTR pStringBuf, PVOID pA
ttl_of_fake_packet, do_wrong_chksum, do_wrong_seq); \
} while (0)

enum ERROR_CODE{
ERROR_DEFAULT = 1,
ERROR_PORT_BOUNDS,
ERROR_DNS_V4_ADDR,
ERROR_DNS_V6_ADDR,
ERROR_DNS_V4_PORT,
ERROR_DNS_V6_PORT,
ERROR_BLACKLIST_LOAD,
ERROR_AUTOTTL,
ERROR_ATOUSI,
ERROR_AUTOB
};

static int running_from_service = 0;
static int exiting = 0;
Expand Down Expand Up @@ -270,7 +282,7 @@ unsigned short int atousi(const char *str, const char *msg) {

if(res > limitValue) {
puts(msg);
exit(EXIT_FAILURE);
exit(ERROR_ATOUSI);
}
return (unsigned short int)res;
}
Expand All @@ -283,7 +295,7 @@ BYTE atoub(const char *str, const char *msg) {

if(res > limitValue) {
puts(msg);
exit(EXIT_FAILURE);
exit(ERROR_AUTOB);
}
return (BYTE)res;
}
Expand Down Expand Up @@ -768,7 +780,7 @@ int main(int argc, char *argv[]) {
i = atoi(optarg);
if (i <= 0 || i > 65535) {
printf("Port parameter error!\n");
exit(EXIT_FAILURE);
exit(ERROR_PORT_BOUNDS);
}
if (i != 80 && i != 443)
add_filter_str(IPPROTO_TCP, i);
Expand All @@ -787,14 +799,14 @@ int main(int argc, char *argv[]) {
do_dnsv4_redirect = 1;
if (inet_pton(AF_INET, optarg, &dnsv4_addr) != 1) {
puts("DNS address parameter error!");
exit(EXIT_FAILURE);
exit(ERROR_DNS_V4_ADDR);
}
add_filter_str(IPPROTO_UDP, 53);
flush_dns_cache();
break;
}
puts("DNS address parameter error!");
exit(EXIT_FAILURE);
exit(ERROR_DNS_V4_ADDR);
break;
case '!': // --dnsv6-addr
if ((inet_pton(AF_INET6, optarg, dns_temp_addr.s6_addr) == 1) &&
Expand All @@ -803,21 +815,21 @@ int main(int argc, char *argv[]) {
do_dnsv6_redirect = 1;
if (inet_pton(AF_INET6, optarg, dnsv6_addr.s6_addr) != 1) {
puts("DNS address parameter error!");
exit(EXIT_FAILURE);
exit(ERROR_DNS_V6_ADDR);
}
add_filter_str(IPPROTO_UDP, 53);
flush_dns_cache();
break;
}
puts("DNS address parameter error!");
exit(EXIT_FAILURE);
exit(ERROR_DNS_V6_ADDR);
break;
case 'g': // --dns-port
if (!do_dnsv4_redirect) {
puts("--dns-port should be used with --dns-addr!\n"
"Make sure you use --dns-addr and pass it before "
"--dns-port");
exit(EXIT_FAILURE);
exit(ERROR_DNS_V4_PORT);
}
dnsv4_port = atousi(optarg, "DNS port parameter error!");
if (dnsv4_port != 53) {
Expand All @@ -830,7 +842,7 @@ int main(int argc, char *argv[]) {
puts("--dnsv6-port should be used with --dnsv6-addr!\n"
"Make sure you use --dnsv6-addr and pass it before "
"--dnsv6-port");
exit(EXIT_FAILURE);
exit(ERROR_DNS_V6_PORT);
}
dnsv6_port = atousi(optarg, "DNS port parameter error!");
if (dnsv6_port != 53) {
Expand All @@ -846,7 +858,7 @@ int main(int argc, char *argv[]) {
do_blacklist = 1;
if (!blackwhitelist_load_list(optarg)) {
printf("Can't load blacklist from file!\n");
exit(EXIT_FAILURE);
exit(ERROR_BLACKLIST_LOAD);
}
break;
case ']': // --allow-no-sni
Expand Down Expand Up @@ -880,13 +892,13 @@ int main(int argc, char *argv[]) {
autottl_current = strtok(NULL, "-");
if (!autottl_current) {
puts("Set Auto TTL parameter error!");
exit(EXIT_FAILURE);
exit(ERROR_AUTOTTL);
}
auto_ttl_2 = atoub(autottl_current, "Set Auto TTL parameter error!");
autottl_current = strtok(NULL, "-");
if (!autottl_current) {
puts("Set Auto TTL parameter error!");
exit(EXIT_FAILURE);
exit(ERROR_AUTOTTL);
}
auto_ttl_max = atoub(autottl_current, "Set Auto TTL parameter error!");
}
Expand Down Expand Up @@ -990,7 +1002,7 @@ int main(int argc, char *argv[]) {
" -9 -f 2 -e 2 --wrong-seq --wrong-chksum --reverse-frag --max-payload -q (this is the default)\n\n"
"Note: combination of --wrong-seq and --wrong-chksum generates two different fake packets.\n"
);
exit(EXIT_FAILURE);
exit(ERROR_DEFAULT);
}
}

Expand Down

0 comments on commit c517169

Please sign in to comment.