Skip to content

Commit

Permalink
--round (hufrea#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
hufrea authored Oct 20, 2024
1 parent 6dca571 commit 3cfdf4f
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 323 deletions.
17 changes: 8 additions & 9 deletions conev.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define CONEV_H

#include <stdint.h>
#include <stdbool.h>

#ifndef __linux__
#define NOEPOLL
Expand Down Expand Up @@ -37,9 +38,8 @@ enum eid {
EV_CONNECT,
EV_IGNORE,
EV_TUNNEL,
EV_PRE_TUNNEL,
EV_UDP_TUNNEL,
EV_DESYNC
EV_FIRST_TUNNEL
};

#define FLAG_S4 1
Expand All @@ -53,15 +53,14 @@ char *eid_name[] = {
"EV_CONNECT",
"EV_IGNORE",
"EV_TUNNEL",
"EV_PRE_TUNNEL",
"EV_UDP_TUNNEL",
"EV_DESYNC"
"EV_FIRST_TUNNEL"
};
#endif

struct buffer {
ssize_t size;
int offset;
size_t size;
unsigned int offset;
char *data;
};

Expand All @@ -78,11 +77,11 @@ struct eval {
struct sockaddr_in6 in6;
};
ssize_t recv_count;
ssize_t round_sent;
unsigned int round_count;
char last_round;
int attempt;
char cache;
char mark; //
bool cache;
bool mark; //
};

struct poolhd {
Expand Down
37 changes: 18 additions & 19 deletions desync.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,19 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
char *host = 0;
int len = 0, type = 0, host_pos = 0;

// parse packet
if ((len = parse_tls(buffer, n, &host))) {
type = IS_HTTPS;
}
else if ((len = parse_http(buffer, n, &host, 0))) {
type = IS_HTTP;
}
if (len && host) {
LOG(LOG_S, "host: %.*s (%zd)\n",
len, host, host - buffer);
host_pos = host - buffer;
if (offset == 0) {
if ((len = parse_tls(buffer, n, &host))) {
type = IS_HTTPS;
}
else if ((len = parse_http(buffer, n, &host, 0))) {
type = IS_HTTP;
}
if (len && host) {
LOG(LOG_S, "host: %.*s (%zd)\n",
len, host, host - buffer);
host_pos = host - buffer;
}
}

// modify packet
if (type == IS_HTTP && dp.mod_http) {
LOG(LOG_S, "modify HTTP: n=%zd\n", n);
Expand Down Expand Up @@ -484,13 +484,12 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
lp = pos + 5;
}
}
// desync
#ifdef __linux__
if (dp.drop_sack && drop_sack(sfd)) {
if (!offset && dp.drop_sack && drop_sack(sfd)) {
return -1;
}
#endif
long lp = offset;
long lp = 0;
struct part part;
int i = 0, r = 0;

Expand All @@ -504,15 +503,15 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,

pos += part.s * (part.r - r);

// after EAGAIN
if (offset && pos <= offset) {
if (!(part.flag & OFFSET_START) && offset && pos <= offset) {
LOG(LOG_S, "offset: %zd, skip\n", offset);
continue;
}
else if (pos < 0 || pos > n || pos < lp) {
if (pos < 0 || pos > n || pos < lp) {
LOG(LOG_E, "split cancel: pos=%ld-%ld, n=%zd\n", lp, pos, n);
break;
}
// send part

ssize_t s = 0;
switch (part.m) {
#ifdef FAKE_SUPPORT
Expand Down
Loading

0 comments on commit 3cfdf4f

Please sign in to comment.