zapret/tpws/params.h

103 lines
2.4 KiB
C
Raw Normal View History

2021-03-04 16:30:38 +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>
#include "tpws.h"
2023-10-26 17:12:32 +05:00
#include "pools.h"
2024-04-26 19:23:03 +05:00
#include "helpers.h"
#include "protocol.h"
2023-10-26 17:12:32 +05:00
#define HOSTLIST_AUTO_FAIL_THRESHOLD_DEFAULT 3
2023-10-26 17:12:32 +05:00
#define HOSTLIST_AUTO_FAIL_TIME_DEFAULT 60
2021-03-04 16:30:38 +05:00
2021-03-09 00:33:21 +05:00
enum bindll { unwanted=0, no, prefer, force };
2021-03-04 16:30:38 +05:00
#define MAX_BINDS 32
struct bind_s
{
char bindaddr[64],bindiface[IF_NAMESIZE];
bool bind_if6;
2021-03-09 00:33:21 +05:00
enum bindll bindll;
2021-03-04 16:30:38 +05:00
int bind_wait_ifup,bind_wait_ip,bind_wait_ip_ll;
};
2024-08-23 23:15:27 +05:00
enum log_target { LOG_TARGET_CONSOLE=0, LOG_TARGET_FILE, LOG_TARGET_SYSLOG };
2021-03-04 16:30:38 +05:00
struct params_s
{
struct bind_s binds[MAX_BINDS];
int binds_last;
bool bind_wait_only;
uint16_t port;
uint8_t proxy_type;
bool no_resolve;
bool skip_nodelay;
bool droproot;
uid_t uid;
gid_t gid;
bool daemon;
2024-04-02 20:14:03 +05:00
int maxconn,resolver_threads,maxfiles,max_orphan_time;
2021-03-04 16:30:38 +05:00
int local_rcvbuf,local_sndbuf,remote_rcvbuf,remote_sndbuf;
bool tamper; // any tamper option is set
bool hostcase, hostdot, hosttab, hostnospace, methodspace, methodeol, unixeol, domcase;
int hostpad;
char hostspell[4];
enum httpreqpos split_http_req;
enum tlspos tlsrec;
2023-10-12 14:35:06 +05:00
int tlsrec_pos;
enum tlspos split_tls;
2021-03-04 16:30:38 +05:00
bool split_any_protocol;
int split_pos;
bool disorder, disorder_http, disorder_tls;
bool oob, oob_http, oob_tls;
uint8_t oob_byte;
2023-07-03 17:28:42 +05:00
int ttl_default;
2024-03-27 19:48:37 +05:00
int mss;
port_filter mss_pf;
2021-03-04 16:30:38 +05:00
char pidfile[256];
strpool *hostlist, *hostlist_exclude;
struct str_list_head hostlist_files, hostlist_exclude_files;
2023-11-09 14:08:09 +05:00
char hostlist_auto_filename[PATH_MAX], hostlist_auto_debuglog[PATH_MAX];
2023-10-26 17:12:32 +05:00
int hostlist_auto_fail_threshold, hostlist_auto_fail_time;
time_t hostlist_auto_mod_time;
2023-10-26 17:12:32 +05:00
hostfail_pool *hostlist_auto_fail_counters;
2021-03-04 16:30:38 +05:00
bool tamper_start_n,tamper_cutoff_n;
unsigned int tamper_start,tamper_cutoff;
2024-08-22 13:49:50 +05:00
struct sockaddr_in connect_bind4;
struct sockaddr_in6 connect_bind6;
char connect_bind6_ifname[IF_NAMESIZE];
2024-08-22 13:49:50 +05:00
2021-03-04 16:30:38 +05:00
int debug;
2024-08-23 23:15:27 +05:00
enum log_target debug_target;
char debug_logfile[PATH_MAX];
#if defined(BSD)
bool pf_enable;
#endif
#ifdef SPLICE_PRESENT
2024-04-04 00:21:17 +05:00
bool nosplice;
#endif
2021-03-04 16:30:38 +05:00
};
extern struct params_s params;
2024-08-23 23:15:27 +05:00
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__)