2024-10-28 11:32:24 +05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <time.h>
|
2024-11-03 17:32:51 +05:00
|
|
|
#ifndef __OpenBSD__
|
2024-10-31 21:59:26 +05:00
|
|
|
#include <wordexp.h>
|
2024-11-03 17:32:51 +05:00
|
|
|
#endif
|
2024-10-31 21:59:26 +05:00
|
|
|
|
2024-10-28 11:32:24 +05:00
|
|
|
#include "tpws.h"
|
|
|
|
#include "pools.h"
|
|
|
|
#include "helpers.h"
|
|
|
|
#include "protocol.h"
|
|
|
|
|
|
|
|
#define HOSTLIST_AUTO_FAIL_THRESHOLD_DEFAULT 3
|
|
|
|
#define HOSTLIST_AUTO_FAIL_TIME_DEFAULT 60
|
|
|
|
|
|
|
|
enum bindll { unwanted=0, no, prefer, force };
|
|
|
|
|
|
|
|
#define MAX_BINDS 32
|
|
|
|
struct bind_s
|
|
|
|
{
|
|
|
|
char bindaddr[64],bindiface[IF_NAMESIZE];
|
|
|
|
bool bind_if6;
|
|
|
|
enum bindll bindll;
|
|
|
|
int bind_wait_ifup,bind_wait_ip,bind_wait_ip_ll;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum log_target { LOG_TARGET_CONSOLE=0, LOG_TARGET_FILE, LOG_TARGET_SYSLOG };
|
|
|
|
|
|
|
|
struct desync_profile
|
|
|
|
{
|
|
|
|
int n; // number of the profile
|
|
|
|
|
|
|
|
bool hostcase, hostdot, hosttab, hostnospace, methodspace, methodeol, unixeol, domcase;
|
|
|
|
int hostpad;
|
|
|
|
char hostspell[4];
|
|
|
|
enum httpreqpos split_http_req;
|
|
|
|
enum tlspos tlsrec;
|
|
|
|
int tlsrec_pos;
|
|
|
|
enum tlspos split_tls;
|
|
|
|
bool split_any_protocol;
|
|
|
|
int split_pos;
|
|
|
|
bool disorder, disorder_http, disorder_tls;
|
|
|
|
bool oob, oob_http, oob_tls;
|
|
|
|
uint8_t oob_byte;
|
|
|
|
|
|
|
|
int mss;
|
|
|
|
|
|
|
|
bool tamper_start_n,tamper_cutoff_n;
|
|
|
|
unsigned int tamper_start,tamper_cutoff;
|
2024-10-29 17:08:05 +05:00
|
|
|
|
2024-10-28 11:32:24 +05:00
|
|
|
bool filter_ipv4,filter_ipv6;
|
2024-10-29 19:17:58 +05:00
|
|
|
struct port_filters_head pf_tcp;
|
2024-10-14 16:58:31 +05:00
|
|
|
uint32_t filter_l7; // L7_PROTO_* bits
|
2024-10-29 17:08:05 +05:00
|
|
|
|
|
|
|
// list of pointers to ipsets
|
|
|
|
struct ipset_collection_head ips_collection, ips_collection_exclude;
|
|
|
|
|
|
|
|
// list of pointers to hostlist files
|
|
|
|
struct hostlist_collection_head hl_collection, hl_collection_exclude;
|
|
|
|
// pointer to autohostlist. NULL if no autohostlist for the profile.
|
|
|
|
struct hostlist_file *hostlist_auto;
|
|
|
|
int hostlist_auto_fail_threshold, hostlist_auto_fail_time, hostlist_auto_retrans_threshold;
|
|
|
|
|
2024-10-28 11:32:24 +05:00
|
|
|
hostfail_pool *hostlist_auto_fail_counters;
|
|
|
|
};
|
|
|
|
|
2024-10-30 11:01:14 +05:00
|
|
|
#define PROFILE_IPSETS_ABSENT(dp) (!LIST_FIRST(&dp->ips_collection) && !LIST_FIRST(&dp->ips_collection_exclude))
|
2024-10-29 17:08:05 +05:00
|
|
|
#define PROFILE_IPSETS_EMPTY(dp) (ipset_collection_is_empty(&dp->ips_collection) && ipset_collection_is_empty(&dp->ips_collection_exclude))
|
|
|
|
#define PROFILE_HOSTLISTS_EMPTY(dp) (hostlist_collection_is_empty(&dp->hl_collection) && hostlist_collection_is_empty(&dp->hl_collection_exclude))
|
2024-10-14 16:58:31 +05:00
|
|
|
|
2024-10-28 11:32:24 +05:00
|
|
|
struct desync_profile_list {
|
|
|
|
struct desync_profile dp;
|
|
|
|
LIST_ENTRY(desync_profile_list) next;
|
|
|
|
};
|
|
|
|
LIST_HEAD(desync_profile_list_head, desync_profile_list);
|
|
|
|
struct desync_profile_list *dp_list_add(struct desync_profile_list_head *head);
|
|
|
|
void dp_list_destroy(struct desync_profile_list_head *head);
|
|
|
|
|
|
|
|
struct params_s
|
|
|
|
{
|
2024-11-03 17:32:51 +05:00
|
|
|
#ifndef __OpenBSD__
|
2024-10-31 21:59:26 +05:00
|
|
|
wordexp_t wexp; // for file based config
|
2024-11-03 17:32:51 +05:00
|
|
|
#endif
|
2024-10-31 19:55:26 +05:00
|
|
|
|
2024-10-28 11:32:24 +05:00
|
|
|
int debug;
|
|
|
|
enum log_target debug_target;
|
|
|
|
char debug_logfile[PATH_MAX];
|
|
|
|
|
|
|
|
struct bind_s binds[MAX_BINDS];
|
|
|
|
int binds_last;
|
|
|
|
bool bind_wait_only;
|
|
|
|
uint16_t port;
|
|
|
|
struct sockaddr_in connect_bind4;
|
|
|
|
struct sockaddr_in6 connect_bind6;
|
|
|
|
char connect_bind6_ifname[IF_NAMESIZE];
|
|
|
|
|
|
|
|
uint8_t proxy_type;
|
|
|
|
bool no_resolve;
|
|
|
|
bool skip_nodelay;
|
|
|
|
bool droproot;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
|
|
|
bool daemon;
|
|
|
|
char pidfile[256];
|
|
|
|
int maxconn,resolver_threads,maxfiles,max_orphan_time;
|
|
|
|
int local_rcvbuf,local_sndbuf,remote_rcvbuf,remote_sndbuf;
|
|
|
|
#if defined(__linux__) || defined(__APPLE__)
|
|
|
|
int tcp_user_timeout_local,tcp_user_timeout_remote;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(BSD)
|
|
|
|
bool pf_enable;
|
|
|
|
#endif
|
|
|
|
#ifdef SPLICE_PRESENT
|
|
|
|
bool nosplice;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int ttl_default;
|
|
|
|
char hostlist_auto_debuglog[PATH_MAX];
|
|
|
|
|
2024-10-29 17:08:05 +05:00
|
|
|
// hostlist files with data for all profiles
|
|
|
|
struct hostlist_files_head hostlists;
|
|
|
|
// ipset files with data for all profiles
|
|
|
|
struct ipset_files_head ipsets;
|
|
|
|
|
2024-10-28 11:32:24 +05:00
|
|
|
bool tamper; // any tamper option is set
|
|
|
|
bool tamper_lim; // tamper-start or tamper-cutoff set in any profile
|
|
|
|
struct desync_profile_list_head desync_profiles;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct params_s params;
|
|
|
|
|
|
|
|
int DLOG(const char *format, int level, ...);
|
|
|
|
int DLOG_CONDUP(const char *format, ...);
|
|
|
|
int DLOG_ERR(const char *format, ...);
|
|
|
|
int DLOG_PERROR(const char *s);
|
|
|
|
int HOSTLIST_DEBUGLOG_APPEND(const char *format, ...);
|
|
|
|
|
|
|
|
#define VPRINT(format, ...) DLOG(format, 1, ##__VA_ARGS__)
|
|
|
|
#define DBGPRINT(format, ...) DLOG(format, 2, ##__VA_ARGS__)
|