Fix possible errors on older compilers

This commit is contained in:
Vadim Vetrov 2024-10-14 00:11:58 +03:00
parent 4c7b63fa7f
commit 96cf0365ee
No known key found for this signature in database
GPG Key ID: E8A308689D7A73A5
3 changed files with 35 additions and 67 deletions

35
args.c
View File

@ -1,5 +1,4 @@
#include "config.h" #include "config.h"
#include "raw_replacements.h"
#include <stdbool.h> #include <stdbool.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
@ -12,38 +11,6 @@
static char custom_fake_buf[MAX_FAKE_SIZE]; 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,
.faking_strategy = FAKING_STRATEGY,
.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,
.fakeseq_offset = 10000,
.synfake = 0,
.synfake_len = 0,
.quic_drop = 0,
.seg2_delay = 0,
.domains_str = defaul_snistr,
.domains_strlen = sizeof(defaul_snistr),
.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,
.sni_detection = SNI_DETECTION_PARSE,
};
struct config_t config = { struct config_t config = {
.threads = THREADS_NUM, .threads = THREADS_NUM,
.queue_start_num = DEFAULT_QUEUE_NUM, .queue_start_num = DEFAULT_QUEUE_NUM,
@ -268,7 +235,7 @@ int parse_args(int argc, char *argv[]) {
goto invalid_opt; goto invalid_opt;
sect_config = &config.custom_configs[config.custom_configs_len++]; sect_config = &config.custom_configs[config.custom_configs_len++];
*sect_config = default_section_config; *sect_config = (struct section_config_t)default_section_config;
section_iter = SECT_ITER_INSIDE; section_iter = SECT_ITER_INSIDE;
break; break;

View File

@ -5,6 +5,8 @@
#define USER_SPACE #define USER_SPACE
#endif #endif
#include "raw_replacements.h"
typedef int (*raw_send_t)(const unsigned char *data, unsigned int data_len); typedef int (*raw_send_t)(const unsigned char *data, unsigned int data_len);
/** /**
* Sends the packet after delay_ms. The function should schedule send and return immediately * Sends the packet after delay_ms. The function should schedule send and return immediately
@ -91,6 +93,37 @@ for (struct section_config_t *section = &config.default_config + config.custom_c
#define CONFIG_SECTION_NUMBER(section) (int)((section) - &config.default_config) #define CONFIG_SECTION_NUMBER(section) (int)((section) - &config.default_config)
#define default_section_config { \
.frag_sni_reverse = 1, \
.frag_sni_faked = 0, \
.fragmentation_strategy = FRAGMENTATION_STRATEGY, \
.faking_strategy = FAKING_STRATEGY, \
.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, \
.fakeseq_offset = 10000, \
.synfake = 0, \
.synfake_len = 0, \
.quic_drop = 0, \
\
.seg2_delay = 0, \
\
.domains_str = defaul_snistr, \
.domains_strlen = sizeof(defaul_snistr), \
\
.exclude_domains_str = "", \
.exclude_domains_strlen = 0, \
\
.fake_sni_pkt = fake_sni_old, \
.fake_sni_pkt_sz = sizeof(fake_sni_old) - 1, \
.fake_custom_pkt = custom_fake_buf, \
.fake_custom_pkt_sz = 0, \
.sni_detection = SNI_DETECTION_PARSE, \
}
#define MAX_THREADS 16 #define MAX_THREADS 16
#ifndef THREADS_NUM #ifndef THREADS_NUM

34
kargs.c
View File

@ -1,5 +1,4 @@
#include "config.h" #include "config.h"
#include "raw_replacements.h"
#include "types.h" #include "types.h"
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include "types.h" #include "types.h"
@ -8,37 +7,6 @@
static char custom_fake_buf[MAX_FAKE_SIZE]; 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,
.faking_strategy = FAKING_STRATEGY,
.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,
.fakeseq_offset = 10000,
.synfake = 0,
.synfake_len = 0,
.quic_drop = 0,
.seg2_delay = 0,
.domains_str = defaul_snistr,
.domains_strlen = sizeof(defaul_snistr),
.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,
.sni_detection = SNI_DETECTION_PARSE,
};
struct config_t config = { struct config_t config = {
.threads = THREADS_NUM, .threads = THREADS_NUM,
.queue_start_num = DEFAULT_QUEUE_NUM, .queue_start_num = DEFAULT_QUEUE_NUM,
@ -52,7 +20,7 @@ struct config_t config = {
.custom_configs_len = 0 .custom_configs_len = 0
}; };
static struct section_config_t *const def_section = &config.default_config; #define def_section (&config.default_config)
static int unumeric_set(const char *val, const struct kernel_param *kp) { static int unumeric_set(const char *val, const struct kernel_param *kp) {
int n = 0, ret; int n = 0, ret;