mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2026-04-04 03:57:56 +03:00
Update logging
Add syslog for daemonize. This allows to log not only to the standard output but also in system log
This commit is contained in:
69
args.c
69
args.c
@@ -8,6 +8,7 @@
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "args.h"
|
||||
#include "logging.h"
|
||||
|
||||
static char custom_fake_buf[MAX_FAKE_SIZE];
|
||||
|
||||
@@ -24,7 +25,8 @@ struct config_t config = {
|
||||
.custom_configs_len = 0,
|
||||
|
||||
.daemonize = 0,
|
||||
.noclose = 0
|
||||
.noclose = 0,
|
||||
.syslog = 0,
|
||||
};
|
||||
|
||||
#define OPT_SNI_DOMAINS 1
|
||||
@@ -39,6 +41,7 @@ struct config_t config = {
|
||||
#define OPT_END_SECTION 30
|
||||
#define OPT_DAEMONIZE 31
|
||||
#define OPT_NOCLOSE 32
|
||||
#define OPT_SYSLOG 33
|
||||
#define OPT_FRAG 4
|
||||
#define OPT_FRAG_SNI_REVERSE 12
|
||||
#define OPT_FRAG_SNI_FAKED 13
|
||||
@@ -59,7 +62,7 @@ struct config_t config = {
|
||||
#define OPT_NO_GSO 8
|
||||
#define OPT_QUEUE_NUM 9
|
||||
|
||||
#define OPT_MAX OPT_NOCLOSE
|
||||
#define OPT_MAX OPT_SYSLOG
|
||||
|
||||
static struct option long_opt[] = {
|
||||
{"help", 0, 0, 'h'},
|
||||
@@ -91,6 +94,7 @@ static struct option long_opt[] = {
|
||||
{"no-ipv6", 0, 0, OPT_NO_IPV6},
|
||||
{"daemonize", 0, 0, OPT_DAEMONIZE},
|
||||
{"noclose", 0, 0, OPT_NOCLOSE},
|
||||
{"syslog", 0, 0, OPT_SYSLOG},
|
||||
{"queue-num", 1, 0, OPT_QUEUE_NUM},
|
||||
{"packet-mark", 1, 0, OPT_PACKET_MARK},
|
||||
{"fbegin", 0, 0, OPT_START_SECTION},
|
||||
@@ -161,6 +165,7 @@ void print_usage(const char *argv0) {
|
||||
printf("\t--no-ipv6\n");
|
||||
printf("\t--daemonize\n");
|
||||
printf("\t--noclose\n");
|
||||
printf("\t--syslog\n");
|
||||
printf("\t--fbegin\n");
|
||||
printf("\t--fend\n");
|
||||
printf("\n");
|
||||
@@ -217,6 +222,9 @@ int parse_args(int argc, char *argv[]) {
|
||||
case OPT_NOCLOSE:
|
||||
config.noclose = 1;
|
||||
break;
|
||||
case OPT_SYSLOG:
|
||||
config.syslog = 1;
|
||||
break;
|
||||
case OPT_THREADS:
|
||||
if (section_iter != SECT_ITER_DEFAULT)
|
||||
goto invalid_opt;
|
||||
@@ -486,96 +494,99 @@ error:
|
||||
}
|
||||
|
||||
void print_welcome() {
|
||||
if (config.syslog) {
|
||||
printf("Logging to system log\n");
|
||||
}
|
||||
if (config.use_gso) {
|
||||
printf("GSO is enabled\n");
|
||||
lginfo("GSO is enabled\n");
|
||||
}
|
||||
|
||||
if (config.use_ipv6) {
|
||||
printf("IPv6 is enabled\n");
|
||||
lginfo("IPv6 is enabled\n");
|
||||
} else {
|
||||
printf("IPv6 is disabled\n");
|
||||
lginfo("IPv6 is disabled\n");
|
||||
}
|
||||
|
||||
printf("Detected %d config sections\n", config.custom_configs_len + 1);
|
||||
printf("The sections will be processed in order they goes in this output\n");
|
||||
lginfo("Detected %d config sections\n", config.custom_configs_len + 1);
|
||||
lginfo("The sections will be processed in order they goes in this output\n");
|
||||
|
||||
ITER_CONFIG_SECTIONS(section) {
|
||||
int section_number = CONFIG_SECTION_NUMBER(section);
|
||||
printf("Section #%d\n", section_number);
|
||||
lginfo("Section #%d\n", section_number);
|
||||
|
||||
switch (section->fragmentation_strategy) {
|
||||
case FRAG_STRAT_TCP:
|
||||
printf("Using TCP segmentation\n");
|
||||
lginfo("Using TCP segmentation\n");
|
||||
break;
|
||||
case FRAG_STRAT_IP:
|
||||
printf("Using IP fragmentation\n");
|
||||
lginfo("Using IP fragmentation\n");
|
||||
break;
|
||||
default:
|
||||
printf("SNI fragmentation is disabled\n");
|
||||
lginfo("SNI fragmentation is disabled\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (section->seg2_delay) {
|
||||
printf("Some outgoing googlevideo request segments will be delayed for %d ms as of seg2_delay define\n", section->seg2_delay);
|
||||
lginfo("Some outgoing googlevideo request segments will be delayed for %d ms as of seg2_delay define\n", section->seg2_delay);
|
||||
}
|
||||
|
||||
if (section->fake_sni) {
|
||||
printf("Fake SNI will be sent before each target client hello\n");
|
||||
lginfo("Fake SNI will be sent before each target client hello\n");
|
||||
} else {
|
||||
printf("Fake SNI is disabled\n");
|
||||
lginfo("Fake SNI is disabled\n");
|
||||
}
|
||||
|
||||
if (section->frag_sni_reverse) {
|
||||
printf("Fragmentation Client Hello will be reversed\n");
|
||||
lginfo("Fragmentation Client Hello will be reversed\n");
|
||||
}
|
||||
|
||||
if (section->frag_sni_faked) {
|
||||
printf("Fooling packets will be sent near the original Client Hello\n");
|
||||
lginfo("Fooling packets will be sent near the original Client Hello\n");
|
||||
}
|
||||
|
||||
if (section->fake_sni_seq_len > 1) {
|
||||
printf("Faking sequence of length %d will be built as fake sni\n", section->fake_sni_seq_len);
|
||||
lginfo("Faking sequence of length %d will be built as fake sni\n", section->fake_sni_seq_len);
|
||||
}
|
||||
|
||||
switch (section->faking_strategy) {
|
||||
case FAKE_STRAT_TTL:
|
||||
printf("TTL faking strategy will be used with TTL %d\n", section->faking_ttl);
|
||||
lginfo("TTL faking strategy will be used with TTL %d\n", section->faking_ttl);
|
||||
break;
|
||||
case FAKE_STRAT_RAND_SEQ:
|
||||
printf("Random seq faking strategy will be used\n");
|
||||
printf("Fake seq offset set to %u\n", section->fakeseq_offset);
|
||||
lginfo("Random seq faking strategy will be used\n");
|
||||
lginfo("Fake seq offset set to %u\n", section->fakeseq_offset);
|
||||
break;
|
||||
case FAKE_STRAT_TCP_CHECK:
|
||||
printf("TCP checksum faking strategy will be used\n");
|
||||
lginfo("TCP checksum faking strategy will be used\n");
|
||||
break;
|
||||
case FAKE_STRAT_PAST_SEQ:
|
||||
printf("Past seq faking strategy will be used\n");
|
||||
lginfo("Past seq faking strategy will be used\n");
|
||||
break;
|
||||
case FAKE_STRAT_TCP_MD5SUM:
|
||||
printf("md5sum faking strategy will be used\n");
|
||||
lginfo("md5sum faking strategy will be used\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (section->fk_winsize) {
|
||||
printf("Response TCP window will be set to %d with the appropriate scale\n", section->fk_winsize);
|
||||
lginfo("Response TCP window will be set to %d with the appropriate scale\n", section->fk_winsize);
|
||||
}
|
||||
|
||||
if (section->synfake) {
|
||||
printf("Fake SYN payload will be sent with each TCP request SYN packet\n");
|
||||
lginfo("Fake SYN payload will be sent with each TCP request SYN packet\n");
|
||||
}
|
||||
|
||||
if (section->quic_drop) {
|
||||
printf("All QUIC packets will be dropped\n");
|
||||
lginfo("All QUIC packets will be dropped\n");
|
||||
}
|
||||
|
||||
if (section->sni_detection == SNI_DETECTION_BRUTE) {
|
||||
printf("Server Name Extension will be parsed in the bruteforce mode\n");
|
||||
lginfo("Server Name Extension will be parsed in the bruteforce mode\n");
|
||||
}
|
||||
|
||||
if (section->all_domains) {
|
||||
printf("All Client Hello will be targeted by youtubeUnblock!\n");
|
||||
lginfo("All Client Hello will be targeted by youtubeUnblock!\n");
|
||||
} else {
|
||||
printf("Target sni domains: %s\n", section->domains_str);
|
||||
lginfo("Target sni domains: %s\n", section->domains_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user