mirror of
https://github.com/hufrea/byedpi.git
synced 2024-12-22 06:15:14 +00:00
Split range
This commit is contained in:
parent
93587ce8c1
commit
13b0048514
33
desync.c
33
desync.c
@ -457,16 +457,19 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
|
|||||||
}
|
}
|
||||||
else if (type == IS_HTTPS && dp.tlsrec_n) {
|
else if (type == IS_HTTPS && dp.tlsrec_n) {
|
||||||
long lp = 0;
|
long lp = 0;
|
||||||
for (int i = 0; i < dp.tlsrec_n; i++) {
|
struct part part;
|
||||||
struct part part = dp.tlsrec[i];
|
int i = 0, r = 0, rc = 0;
|
||||||
|
|
||||||
long pos = i * 5;
|
for (; r > 0 || i < dp.tlsrec_n; rc++, r--) {
|
||||||
pos += gen_offset(part.pos,
|
if (!r) {
|
||||||
part.flag, n - pos, lp, type, host_pos, len);
|
part = dp.tlsrec[i];
|
||||||
|
r = part.r; i++;
|
||||||
if (part.pos < 0 || part.flag) {
|
|
||||||
pos -= 5;
|
|
||||||
}
|
}
|
||||||
|
long pos = rc * 5;
|
||||||
|
pos += gen_offset(part.pos,
|
||||||
|
part.flag, n - pos - 5, lp, type, host_pos - 5, len);
|
||||||
|
|
||||||
|
pos += part.s * (part.r - r);
|
||||||
if (pos < lp) {
|
if (pos < lp) {
|
||||||
LOG(LOG_E, "tlsrec cancel: %ld < %ld\n", pos, lp);
|
LOG(LOG_E, "tlsrec cancel: %ld < %ld\n", pos, lp);
|
||||||
break;
|
break;
|
||||||
@ -488,20 +491,26 @@ ssize_t desync(int sfd, char *buffer, size_t bfsize,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
long lp = offset;
|
long lp = offset;
|
||||||
|
struct part part;
|
||||||
|
int i = 0, r = 0;
|
||||||
|
|
||||||
for (int i = 0; i < dp.parts_n; i++) {
|
for (; r > 0 || i < dp.parts_n; r--) {
|
||||||
struct part part = dp.parts[i];
|
if (!r) {
|
||||||
|
part = dp.parts[i];
|
||||||
|
r = part.r; i++;
|
||||||
|
}
|
||||||
long pos = gen_offset(part.pos,
|
long pos = gen_offset(part.pos,
|
||||||
part.flag, n, lp, type, host_pos, len);
|
part.flag, n, lp, type, host_pos, len);
|
||||||
|
|
||||||
|
pos += part.s * (part.r - r);
|
||||||
|
|
||||||
// after EAGAIN
|
// after EAGAIN
|
||||||
if (offset && pos <= offset) {
|
if (offset && pos <= offset) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (pos < 0 || pos > n || pos < lp) {
|
else if (pos < 0 || pos > n || pos < lp) {
|
||||||
LOG(LOG_E, "split cancel: pos=%ld-%ld, n=%zd\n", lp, pos, n);
|
LOG(LOG_E, "split cancel: pos=%ld-%ld, n=%zd\n", lp, pos, n);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
// send part
|
// send part
|
||||||
ssize_t s = 0;
|
ssize_t s = 0;
|
||||||
|
32
main.c
32
main.c
@ -86,14 +86,14 @@ const char help_text[] = {
|
|||||||
" -K, --proto <t,h,u> Protocol whitelist: tls,http,udp\n"
|
" -K, --proto <t,h,u> Protocol whitelist: tls,http,udp\n"
|
||||||
" -H, --hosts <file|:str> Hosts whitelist, filename or :string\n"
|
" -H, --hosts <file|:str> Hosts whitelist, filename or :string\n"
|
||||||
" -V, --pf <port[-portr]> Ports range whitelist\n"
|
" -V, --pf <port[-portr]> Ports range whitelist\n"
|
||||||
" -s, --split <n[+s]> Split packet at n\n"
|
" -s, --split <pos_t> Position format: offset[:repeats:skip][+flag1[flag2]]\n"
|
||||||
" +s - add SNI offset\n"
|
" Flags: +s - SNI offset, +h - HTTP host offset\n"
|
||||||
" +h - add HTTP Host offset\n"
|
" Additional flags: +e - end, +m - middle, +r - random\n"
|
||||||
" -d, --disorder <n[+s]> Split and send reverse order\n"
|
" -d, --disorder <pos_t> Split and send reverse order\n"
|
||||||
" -o, --oob <n[+s]> Split and send as OOB data\n"
|
" -o, --oob <pos_t> Split and send as OOB data\n"
|
||||||
" -q, --disoob <n[+s]> Split and send reverse order as OOB data\n"
|
" -q, --disoob <pos_t> Split and send reverse order as OOB data\n"
|
||||||
#ifdef FAKE_SUPPORT
|
#ifdef FAKE_SUPPORT
|
||||||
" -f, --fake <n[+s]> Split and send fake packet\n"
|
" -f, --fake <pos_t> Split and send fake packet\n"
|
||||||
" -t, --ttl <num> TTL of fake packets, default 8\n"
|
" -t, --ttl <num> TTL of fake packets, default 8\n"
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
" -k, --ip-opt[=f|:str] IP options of fake packets\n"
|
" -k, --ip-opt[=f|:str] IP options of fake packets\n"
|
||||||
@ -105,7 +105,7 @@ const char help_text[] = {
|
|||||||
#endif
|
#endif
|
||||||
" -e, --oob-data <char> Set custom OOB data\n"
|
" -e, --oob-data <char> Set custom OOB data\n"
|
||||||
" -M, --mod-http <h,d,r> Modify HTTP: hcsmix,dcsmix,rmspace\n"
|
" -M, --mod-http <h,d,r> Modify HTTP: hcsmix,dcsmix,rmspace\n"
|
||||||
" -r, --tlsrec <n[+s]> Make TLS record at position\n"
|
" -r, --tlsrec <pos_t> Make TLS record at position\n"
|
||||||
" -a, --udp-fake <count> UDP fakes count, default 0\n"
|
" -a, --udp-fake <count> UDP fakes count, default 0\n"
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
" -Y, --drop-sack Drop packets with SACK extension\n"
|
" -Y, --drop-sack Drop packets with SACK extension\n"
|
||||||
@ -376,6 +376,22 @@ int parse_offset(struct part *part, const char *str)
|
|||||||
{
|
{
|
||||||
char *end = 0;
|
char *end = 0;
|
||||||
long val = strtol(str, &end, 0);
|
long val = strtol(str, &end, 0);
|
||||||
|
|
||||||
|
while (*end == ':') {
|
||||||
|
long rs = strtol(end + 1, &end, 0);
|
||||||
|
if (rs < 0 || rs > INT_MAX) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!part->r) {
|
||||||
|
if (!rs)
|
||||||
|
return -1;
|
||||||
|
part->r = rs;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
part->s = rs;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (*end == '+') {
|
if (*end == '+') {
|
||||||
switch (*(end + 1)) {
|
switch (*(end + 1)) {
|
||||||
case 's':
|
case 's':
|
||||||
|
Loading…
Reference in New Issue
Block a user