mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-11 17:29:16 +05:00
source cosmetics
This commit is contained in:
parent
38475db45a
commit
37e3a11a77
@ -354,7 +354,6 @@ int main(int argc, char **argv)
|
||||
case 2: /* verbose */
|
||||
glob.verbose = '\1';
|
||||
break;
|
||||
glob.threads = optarg ? atoi(optarg) : 0;
|
||||
case 3: /* stats */
|
||||
glob.stats_every = optarg ? atoi(optarg) : 0;
|
||||
break;
|
||||
|
@ -18,7 +18,7 @@ static uint16_t do_csum(const uint8_t * buff, size_t len)
|
||||
uint64_t result,w,carry=0;
|
||||
uint16_t u16;
|
||||
|
||||
if (len <= 0) return 0;
|
||||
if (!len) return 0;
|
||||
odd = (uint8_t)(1 & (size_t)buff);
|
||||
if (odd)
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ void ConntrackPoolPurge(t_conntrack *p)
|
||||
HASH_ITER(hh, p, t, tmp) { \
|
||||
*sa1=0; inet_ntop(AF_INET##f, &t->conn.e1.adr, sa1, sizeof(sa1)); \
|
||||
*sa2=0; inet_ntop(AF_INET##f, &t->conn.e2.adr, sa2, sizeof(sa2)); \
|
||||
printf("[%s]:%u => [%s]:%u : %s : t0=%lld last=t0+%lld now=last+%lld packets_orig=%llu packets_reply=%llu seq0=%u rseq=%u ack0=%u rack=%u wsize_orig=%u:%d wsize_reply=%u:%d cutoff=%u wss_cutoff=%u d_cutoff=%u\n", \
|
||||
printf("[%s]:%u => [%s]:%u : %s : t0=%llu last=t0+%llu now=last+%llu packets_orig=%llu packets_reply=%llu seq0=%u rseq=%u ack0=%u rack=%u wsize_orig=%u:%d wsize_reply=%u:%d cutoff=%u wss_cutoff=%u d_cutoff=%u\n", \
|
||||
sa1, t->conn.e1.port, sa2, t->conn.e2.port, \
|
||||
connstate_s[t->track.state], \
|
||||
(unsigned long long)t->track.t_start, (unsigned long long)(t->track.t_last - t->track.t_start), (unsigned long long)(tnow - t->track.t_last), \
|
||||
|
@ -103,7 +103,7 @@ static void fill_tcphdr(struct tcphdr *tcp, uint8_t fooling, uint8_t tcp_flags,
|
||||
while (t&3) tcpopt[t++]=1; // noop
|
||||
tcp->th_off += t>>2;
|
||||
}
|
||||
static uint16_t tcpopt_len(uint8_t fooling, uint32_t *timestamps, uint8_t scale_factor)
|
||||
static uint16_t tcpopt_len(uint8_t fooling, const uint32_t *timestamps, uint8_t scale_factor)
|
||||
{
|
||||
uint16_t t=0;
|
||||
if (fooling & TCP_FOOL_MD5SIG) t=18;
|
||||
@ -586,7 +586,7 @@ void print_tcphdr(const struct tcphdr *tcphdr)
|
||||
|
||||
|
||||
|
||||
bool proto_check_ipv4(uint8_t *data, size_t len)
|
||||
bool proto_check_ipv4(const uint8_t *data, size_t len)
|
||||
{
|
||||
return len >= 20 && (data[0] & 0xF0) == 0x40 &&
|
||||
len >= ((data[0] & 0x0F) << 2);
|
||||
@ -600,7 +600,7 @@ void proto_skip_ipv4(uint8_t **data, size_t *len)
|
||||
*data += l;
|
||||
*len -= l;
|
||||
}
|
||||
bool proto_check_tcp(uint8_t *data, size_t len)
|
||||
bool proto_check_tcp(const uint8_t *data, size_t len)
|
||||
{
|
||||
return len >= 20 && len >= ((data[12] & 0xF0) >> 2);
|
||||
}
|
||||
@ -612,7 +612,7 @@ void proto_skip_tcp(uint8_t **data, size_t *len)
|
||||
*len -= l;
|
||||
}
|
||||
|
||||
bool proto_check_ipv6(uint8_t *data, size_t len)
|
||||
bool proto_check_ipv6(const uint8_t *data, size_t len)
|
||||
{
|
||||
return len >= 40 && (data[0] & 0xF0) == 0x60 &&
|
||||
(len - 40) >= htons(*(uint16_t*)(data + 4)); // payload length
|
||||
@ -702,7 +702,6 @@ void tcp_rewrite_wscale(struct tcphdr *tcp, uint8_t scale_factor)
|
||||
void tcp_rewrite_winsize(struct tcphdr *tcp, uint16_t winsize, uint8_t scale_factor)
|
||||
{
|
||||
uint16_t winsize_old;
|
||||
uint8_t *scale,scale_factor_old;
|
||||
|
||||
winsize_old = htons(tcp->th_win); // << scale_factor;
|
||||
tcp->th_win = htons(winsize);
|
||||
|
@ -73,11 +73,11 @@ void print_ip6hdr(const struct ip6_hdr *ip6hdr, uint8_t proto);
|
||||
void print_tcphdr(const struct tcphdr *tcphdr);
|
||||
|
||||
|
||||
bool proto_check_ipv4(uint8_t *data, size_t len);
|
||||
bool proto_check_ipv4(const uint8_t *data, size_t len);
|
||||
void proto_skip_ipv4(uint8_t **data, size_t *len);
|
||||
bool proto_check_tcp(uint8_t *data, size_t len);
|
||||
bool proto_check_tcp(const uint8_t *data, size_t len);
|
||||
void proto_skip_tcp(uint8_t **data, size_t *len);
|
||||
bool proto_check_ipv6(uint8_t *data, size_t len);
|
||||
bool proto_check_ipv6(const uint8_t *data, size_t len);
|
||||
void proto_skip_ipv6(uint8_t **data, size_t *len, uint8_t *proto_type);
|
||||
|
||||
bool tcp_synack_segment(const struct tcphdr *tcphdr);
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "gzip.h"
|
||||
|
||||
|
||||
static bool addpool(strpool **hostlist, char **s, char *end)
|
||||
static bool addpool(strpool **hostlist, char **s, const char *end)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
@ -166,7 +166,7 @@ static int nfq_cb(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg,
|
||||
struct nfq_data *nfa, void *cookie)
|
||||
{
|
||||
int id;
|
||||
size_t len;
|
||||
int len;
|
||||
struct nfqnl_msg_packet_hdr *ph;
|
||||
uint8_t *data;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "gzip.h"
|
||||
#include "params.h"
|
||||
|
||||
static bool addpool(strpool **hostlist, char **s, char *end)
|
||||
static bool addpool(strpool **hostlist, char **s, const char *end)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
@ -16,7 +16,7 @@ bool find_host(char **pHost,char *buf,size_t bs)
|
||||
if (*pHost)
|
||||
{
|
||||
(*pHost)++;
|
||||
VPRINT("Found Host: at pos %zu",*pHost - buf)
|
||||
VPRINT("Found Host: at pos %td",*pHost - buf)
|
||||
}
|
||||
}
|
||||
return !!*pHost;
|
||||
@ -73,7 +73,7 @@ void modify_tcp_segment(char *segment,size_t segment_buffer_size,size_t *size,si
|
||||
if (pp == (p - 1))
|
||||
{
|
||||
// probably end of http headers
|
||||
VPRINT("Found double EOL at pos %zu. Stop replacing.", pp - segment)
|
||||
VPRINT("Found double EOL at pos %td. Stop replacing.", pp - segment)
|
||||
break;
|
||||
}
|
||||
pp = p;
|
||||
@ -141,7 +141,7 @@ void modify_tcp_segment(char *segment,size_t segment_buffer_size,size_t *size,si
|
||||
}
|
||||
if (params.hostcase && find_host(&pHost,segment,*size))
|
||||
{
|
||||
VPRINT("Changing 'Host:' => '%c%c%c%c:' at pos %zu", params.hostspell[0], params.hostspell[1], params.hostspell[2], params.hostspell[3], pHost - segment)
|
||||
VPRINT("Changing 'Host:' => '%c%c%c%c:' at pos %td", params.hostspell[0], params.hostspell[1], params.hostspell[2], params.hostspell[3], pHost - segment)
|
||||
memcpy(pHost, params.hostspell, 4);
|
||||
}
|
||||
if (params.hostpad && find_host(&pHost,segment,*size))
|
||||
|
@ -629,7 +629,7 @@ static bool set_ulimit()
|
||||
DBGPRINT("set_ulimit : current system file-max=%ju",(uintmax_t)cur_lim)
|
||||
if (cur_lim<fdmin_system)
|
||||
{
|
||||
DBGPRINT("set_ulimit : system fd limit is too low. trying to increase to %jd",(uintmax_t)fdmin_system)
|
||||
DBGPRINT("set_ulimit : system fd limit is too low. trying to increase to %ju",(uintmax_t)fdmin_system)
|
||||
if (!write_system_maxfiles(fdmin_system))
|
||||
{
|
||||
fprintf(stderr,"could not set system-wide max file descriptors\n");
|
||||
|
@ -178,7 +178,7 @@ static ssize_t send_buffer_send(send_buffer_t *sb, int fd)
|
||||
}
|
||||
static ssize_t send_buffers_send(send_buffer_t *sb_array, int count, int fd, size_t *real_wr)
|
||||
{
|
||||
ssize_t wr=0,twr=0;
|
||||
ssize_t wr,twr=0;
|
||||
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
@ -596,7 +596,7 @@ static bool epoll_set_flow_pair(tproxy_conn_t *conn)
|
||||
|
||||
static bool handle_unsent(tproxy_conn_t *conn)
|
||||
{
|
||||
ssize_t wr=0,twr=0;
|
||||
ssize_t wr;
|
||||
|
||||
DBGPRINT("+handle_unsent, fd=%d has_unsent=%d has_unsent_partner=%d",conn->fd,conn_has_unsent(conn),conn_partner_alive(conn) ? conn_has_unsent(conn->partner) : false)
|
||||
|
||||
@ -610,7 +610,6 @@ static bool handle_unsent(tproxy_conn_t *conn)
|
||||
if (errno==EAGAIN) wr=0;
|
||||
else return false;
|
||||
}
|
||||
twr += wr;
|
||||
conn->twr += wr;
|
||||
conn->wr_unsent -= wr;
|
||||
}
|
||||
@ -620,7 +619,6 @@ static bool handle_unsent(tproxy_conn_t *conn)
|
||||
wr=conn_buffers_send(conn);
|
||||
DBGPRINT("conn_buffers_send wr=%zd",wr)
|
||||
if (wr<0) return false;
|
||||
twr += wr;
|
||||
}
|
||||
return epoll_set_flow_pair(conn);
|
||||
}
|
||||
@ -1006,7 +1004,7 @@ static bool remove_closed_connections(int efd, struct tailhead *close_list)
|
||||
|
||||
shutdown(conn->fd,SHUT_RDWR);
|
||||
epoll_del(conn);
|
||||
VPRINT("Socket fd=%d (partner_fd=%d, remote=%d) closed, connection removed. total_read=%zu total_write=%zu event_count=%d",
|
||||
VPRINT("Socket fd=%d (partner_fd=%d, remote=%d) closed, connection removed. total_read=%zu total_write=%zu event_count=%u",
|
||||
conn->fd, conn->partner ? conn->partner->fd : 0, conn->remote, conn->trd, conn->twr, conn->event_count)
|
||||
if (conn->remote) legs_remote--; else legs_local--;
|
||||
free_conn(conn);
|
||||
@ -1102,7 +1100,7 @@ static void conn_close_with_partner_check(struct tailhead *conn_list, struct tai
|
||||
}
|
||||
}
|
||||
|
||||
int event_loop(int *listen_fd, size_t listen_fd_ct)
|
||||
int event_loop(const int *listen_fd, size_t listen_fd_ct)
|
||||
{
|
||||
int retval = 0, num_events = 0;
|
||||
int tmp_fd = 0; //Used to temporarily hold the accepted file descriptor
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define DEFAULT_MAX_CONN 512
|
||||
#define DEFAULT_MAX_ORPHAN_TIME 5
|
||||
|
||||
int event_loop(int *listen_fd, size_t listen_fd_ct);
|
||||
int event_loop(const int *listen_fd, size_t listen_fd_ct);
|
||||
|
||||
//Three different states of a connection
|
||||
enum{
|
||||
|
Loading…
Reference in New Issue
Block a user