mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2025-12-27 01:48:07 +03:00
Add multiple sections with config sets for various domains
This commit is contained in:
113
kargs.c
113
kargs.c
@@ -4,11 +4,11 @@
|
||||
#include <linux/moduleparam.h>
|
||||
#include "types.h"
|
||||
|
||||
static char custom_fake_buf[MAX_FAKE_SIZE];
|
||||
|
||||
#define STR_MAXLEN 2048
|
||||
|
||||
struct config_t config = {
|
||||
static char custom_fake_buf[MAX_FAKE_SIZE];
|
||||
|
||||
static const struct section_config_t default_section_config = {
|
||||
.frag_sni_reverse = 1,
|
||||
.frag_sni_faked = 0,
|
||||
.fragmentation_strategy = FRAGMENTATION_STRATEGY,
|
||||
@@ -16,45 +16,44 @@ struct config_t config = {
|
||||
.faking_ttl = FAKE_TTL,
|
||||
.fake_sni = 1,
|
||||
.fake_sni_seq_len = 1,
|
||||
.fake_sni_type = FAKE_PAYLOAD_DEFAULT,
|
||||
.frag_middle_sni = 1,
|
||||
.frag_sni_pos = 1,
|
||||
.use_ipv6 = 1,
|
||||
.fakeseq_offset = 10000,
|
||||
.mark = DEFAULT_RAWSOCKET_MARK,
|
||||
.synfake = 0,
|
||||
.synfake_len = 0,
|
||||
.fake_sni_type = FAKE_PAYLOAD_DEFAULT,
|
||||
.quic_drop = 0,
|
||||
|
||||
.sni_detection = SNI_DETECTION_PARSE,
|
||||
|
||||
#ifdef SEG2_DELAY
|
||||
.seg2_delay = SEG2_DELAY,
|
||||
#else
|
||||
.seg2_delay = 0,
|
||||
#endif
|
||||
|
||||
#ifdef USE_GSO
|
||||
.use_gso = 1,
|
||||
#else
|
||||
.use_gso = false,
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
.verbose = 2,
|
||||
#else
|
||||
.verbose = 1,
|
||||
#endif
|
||||
|
||||
.domains_str = defaul_snistr,
|
||||
.domains_strlen = sizeof(defaul_snistr),
|
||||
|
||||
.queue_start_num = DEFAULT_QUEUE_NUM,
|
||||
.exclude_domains_str = "",
|
||||
.exclude_domains_strlen = 0,
|
||||
|
||||
.fake_sni_pkt = fake_sni_old,
|
||||
.fake_sni_pkt_sz = sizeof(fake_sni_old) - 1, // - 1 for null-terminator
|
||||
.fake_custom_pkt = custom_fake_buf,
|
||||
.fake_custom_pkt_sz = 0
|
||||
.fake_custom_pkt_sz = 0,
|
||||
.sni_detection = SNI_DETECTION_PARSE,
|
||||
};
|
||||
|
||||
struct config_t config = {
|
||||
.threads = THREADS_NUM,
|
||||
.queue_start_num = DEFAULT_QUEUE_NUM,
|
||||
.mark = DEFAULT_RAWSOCKET_MARK,
|
||||
.use_ipv6 = 1,
|
||||
|
||||
.verbose = VERBOSE_DEBUG,
|
||||
.use_gso = 1,
|
||||
|
||||
.default_config = default_section_config,
|
||||
.custom_configs_len = 0
|
||||
};
|
||||
|
||||
static struct section_config_t *const def_section = &config.default_config;
|
||||
|
||||
static int unumeric_set(const char *val, const struct kernel_param *kp) {
|
||||
int n = 0, ret;
|
||||
ret = kstrtoint(val, 10, &n);
|
||||
@@ -113,19 +112,19 @@ static const struct kernel_param_ops inverse_boolean_ops = {
|
||||
.get = inverse_boolean_get,
|
||||
};
|
||||
|
||||
module_param_cb(fake_sni, &boolean_parameter_ops, &config.fake_sni, 0664);
|
||||
module_param_cb(fake_sni_seq_len, &unumeric_parameter_ops, &config.fake_sni_seq_len, 0664);
|
||||
module_param_cb(faking_ttl, &unumeric_parameter_ops, &config.faking_ttl, 0664);
|
||||
module_param_cb(fake_seq_offset, &unumeric_parameter_ops, &config.fakeseq_offset, 0664);
|
||||
module_param_cb(frag_sni_reverse, &unumeric_parameter_ops, &config.frag_sni_reverse, 0664);
|
||||
module_param_cb(frag_sni_faked, &boolean_parameter_ops, &config.frag_sni_faked, 0664);
|
||||
module_param_cb(frag_middle_sni, &boolean_parameter_ops, &config.frag_middle_sni, 0664);
|
||||
module_param_cb(frag_sni_pos, &unumeric_parameter_ops, &config.frag_sni_pos, 0664);
|
||||
module_param_cb(fk_winsize, &unumeric_parameter_ops, &config.fk_winsize, 0664);
|
||||
module_param_cb(synfake, &boolean_parameter_ops, &config.synfake, 0664);
|
||||
module_param_cb(synfake_len, &unumeric_parameter_ops, &config.synfake_len, 0664);
|
||||
module_param_cb(fake_sni, &boolean_parameter_ops, &def_section->fake_sni, 0664);
|
||||
module_param_cb(fake_sni_seq_len, &unumeric_parameter_ops, &def_section->fake_sni_seq_len, 0664);
|
||||
module_param_cb(faking_ttl, &unumeric_parameter_ops, &def_section->faking_ttl, 0664);
|
||||
module_param_cb(fake_seq_offset, &unumeric_parameter_ops, &def_section->fakeseq_offset, 0664);
|
||||
module_param_cb(frag_sni_reverse, &unumeric_parameter_ops, &def_section->frag_sni_reverse, 0664);
|
||||
module_param_cb(frag_sni_faked, &boolean_parameter_ops, &def_section->frag_sni_faked, 0664);
|
||||
module_param_cb(frag_middle_sni, &boolean_parameter_ops, &def_section->frag_middle_sni, 0664);
|
||||
module_param_cb(frag_sni_pos, &unumeric_parameter_ops, &def_section->frag_sni_pos, 0664);
|
||||
module_param_cb(fk_winsize, &unumeric_parameter_ops, &def_section->fk_winsize, 0664);
|
||||
module_param_cb(synfake, &boolean_parameter_ops, &def_section->synfake, 0664);
|
||||
module_param_cb(synfake_len, &unumeric_parameter_ops, &def_section->synfake_len, 0664);
|
||||
module_param_cb(packet_mark, &unumeric_parameter_ops, &config.mark, 0664);
|
||||
// module_param_cb(seg2delay, &unumeric_parameter_ops, &config.seg2_delay, 0664);
|
||||
// module_param_cb(seg2delay, &unumeric_parameter_ops, &def_section->seg2_delay, 0664);
|
||||
|
||||
static int sni_domains_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -144,13 +143,13 @@ static int sni_domains_set(const char *val, const struct kernel_param *kp) {
|
||||
ret = param_set_charp(val, kp);
|
||||
|
||||
if (ret < 0) {
|
||||
config.domains_strlen = 0;
|
||||
def_section->domains_strlen = 0;
|
||||
} else {
|
||||
config.domains_strlen = len;
|
||||
def_section->domains_strlen = len;
|
||||
if (len == 3 && !strncmp(val, "all", len)) {
|
||||
config.all_domains = 1;
|
||||
def_section->all_domains = 1;
|
||||
} else {
|
||||
config.all_domains = 0;
|
||||
def_section->all_domains = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +162,7 @@ static const struct kernel_param_ops sni_domains_ops = {
|
||||
.get = param_get_charp,
|
||||
};
|
||||
|
||||
module_param_cb(sni_domains, &sni_domains_ops, &config.domains_str, 0664);
|
||||
module_param_cb(sni_domains, &sni_domains_ops, &def_section->domains_str, 0664);
|
||||
|
||||
static int exclude_domains_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -178,9 +177,9 @@ static int exclude_domains_set(const char *val, const struct kernel_param *kp) {
|
||||
ret = param_set_charp(val, kp);
|
||||
|
||||
if (ret < 0) {
|
||||
config.exclude_domains_strlen = 0;
|
||||
def_section->exclude_domains_strlen = 0;
|
||||
} else {
|
||||
config.exclude_domains_strlen = len;
|
||||
def_section->exclude_domains_strlen = len;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -191,10 +190,10 @@ static const struct kernel_param_ops exclude_domains_ops = {
|
||||
.get = param_get_charp,
|
||||
};
|
||||
|
||||
module_param_cb(exclude_domains, &exclude_domains_ops, &config.exclude_domains_str, 0664);
|
||||
module_param_cb(exclude_domains, &exclude_domains_ops, &def_section->exclude_domains_str, 0664);
|
||||
|
||||
module_param_cb(no_ipv6, &inverse_boolean_ops, &config.use_ipv6, 0664);
|
||||
module_param_cb(quic_drop, &boolean_parameter_ops, &config.quic_drop, 0664);
|
||||
module_param_cb(quic_drop, &boolean_parameter_ops, &def_section->quic_drop, 0664);
|
||||
|
||||
static int verbosity_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -297,7 +296,7 @@ static const struct kernel_param_ops frag_strat_ops = {
|
||||
.get = frag_strat_get,
|
||||
};
|
||||
|
||||
module_param_cb(fragmentation_strategy, &frag_strat_ops, &config.fragmentation_strategy, 0664);
|
||||
module_param_cb(fragmentation_strategy, &frag_strat_ops, &def_section->fragmentation_strategy, 0664);
|
||||
|
||||
static int fake_strat_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -358,7 +357,7 @@ static const struct kernel_param_ops fake_strat_ops = {
|
||||
.get = fake_strat_get,
|
||||
};
|
||||
|
||||
module_param_cb(faking_strategy, &fake_strat_ops, &config.faking_strategy, 0664);
|
||||
module_param_cb(faking_strategy, &fake_strat_ops, &def_section->faking_strategy, 0664);
|
||||
|
||||
static int sni_detection_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -404,7 +403,7 @@ static const struct kernel_param_ops sni_detection_ops = {
|
||||
.get = sni_detection_get,
|
||||
};
|
||||
|
||||
module_param_cb(sni_detection, &sni_detection_ops, &config.sni_detection, 0664);
|
||||
module_param_cb(sni_detection, &sni_detection_ops, &def_section->sni_detection, 0664);
|
||||
|
||||
static int fake_type_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -455,7 +454,7 @@ static const struct kernel_param_ops fake_type_ops = {
|
||||
.get = fake_type_get,
|
||||
};
|
||||
|
||||
module_param_cb(fake_sni_type, &fake_type_ops, &config.fake_sni_type, 0664);
|
||||
module_param_cb(fake_sni_type, &fake_type_ops, &def_section->fake_sni_type, 0664);
|
||||
|
||||
static int fake_custom_pl_set(const char *val, const struct kernel_param *kp) {
|
||||
size_t len;
|
||||
@@ -488,16 +487,16 @@ static int fake_custom_pl_set(const char *val, const struct kernel_param *kp) {
|
||||
sscanf(custom_hex_fake + (i << 1), "%2hhx", custom_buf + i);
|
||||
}
|
||||
|
||||
config.fake_custom_pkt_sz = custom_len;
|
||||
config.fake_custom_pkt = (char *)custom_buf;
|
||||
def_section->fake_custom_pkt_sz = custom_len;
|
||||
def_section->fake_custom_pkt = (char *)custom_buf;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fake_custom_pl_get(char *buffer, const struct kernel_param *kp) {
|
||||
int cflen = config.fake_custom_pkt_sz;
|
||||
const uint8_t *cbf_data = config.fake_custom_pkt;
|
||||
int bflen = config.fake_custom_pkt_sz << 1;
|
||||
int cflen = def_section->fake_custom_pkt_sz;
|
||||
const uint8_t *cbf_data = def_section->fake_custom_pkt;
|
||||
int bflen = def_section->fake_custom_pkt_sz << 1;
|
||||
|
||||
for (int i = 0; i < cflen; i++) {
|
||||
sprintf(buffer + (i << 1), "%02x", *((unsigned char *)cbf_data + i));
|
||||
@@ -511,4 +510,4 @@ static const struct kernel_param_ops fake_custom_pl_ops = {
|
||||
.get = fake_custom_pl_get,
|
||||
};
|
||||
|
||||
module_param_cb(fake_custom_payload, &fake_custom_pl_ops, &config.fake_custom_pkt, 0664);
|
||||
module_param_cb(fake_custom_payload, &fake_custom_pl_ops, &def_section->fake_custom_pkt, 0664);
|
||||
|
||||
Reference in New Issue
Block a user