Skip to content

Commit

Permalink
Improvements and fixes (v 1.2.0):
Browse files Browse the repository at this point in the history
- Update ByeDPI to versions v0.13
- Added new options to UI editor
- Structured UI editor
- Changed default split position to 1
- Fixed listen ip validation
  • Loading branch information
dovecoteescapee committed Aug 23, 2024
1 parent 9a62548 commit c95be6e
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 158 deletions.
2 changes: 1 addition & 1 deletion README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ height="80">](https://apt.izzysoft.de/fdroid/index/apk/io.github.dovecoteescapee

## Настройки

Для обхода некоторых блокировок может потребоваться изменить настройки. Подробнее о различных настройках можно прочитать в [документации ByeDPI](https://github.com/hufrea/byedpi/tree/v0.12#readme).
Для обхода некоторых блокировок может потребоваться изменить настройки. Подробнее о различных настройках можно прочитать в [документации ByeDPI](https://github.com/hufrea/byedpi/blob/v0.13/README.md).

## FAQ

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ This application runs a SOCKS5 proxy [ByeDPI](https://github.com/hufrea/byedpi)

## Settings

To bypass some blocks, you may need to change the settings. More about the various settings can be found in the [ByeDPI documentation](https://github.com/hufrea/byedpi/tree/v0.12#readme).
To bypass some blocks, you may need to change the settings. More about the various settings can be found in the [ByeDPI documentation](https://github.com/hufrea/byedpi/blob/v0.13/README.md).

## FAQ

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId = "io.github.dovecoteescapee.byedpi"
minSdk = 21
targetSdk = 34
versionCode = 9
versionName = "1.1.1"
versionCode = 10
versionName = "1.2.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/cpp/byedpi
Submodule byedpi updated 24 files
+11 −0 .editorconfig
+4 −1 .gitignore
+21 −0 LICENSE
+20 −9 Makefile
+107 −68 README.md
+0 −1 conev.c
+5 −1 conev.h
+144 −69 desync.c
+19 −8 desync.h
+1 −1 dist/windows/byedpi.bat
+1 −1 dist/windows/service_install.bat
+11 −4 error.h
+50 −16 extend.c
+12 −1 extend.h
+91 −47 main.c
+2 −2 mpool.c
+5 −0 mpool.h
+28 −23 packets.c
+8 −2 packets.h
+16 −6 params.h
+37 −22 proxy.c
+10 −0 proxy.h
+2 −1 win_service.c
+1 −1 win_service.h
5 changes: 4 additions & 1 deletion app/src/main/cpp/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ void clear_params(void);

char *ftob(const char *str, ssize_t *sl);

char *parse_cform(const char *str, ssize_t *size);
char *data_from_str(const char *str, ssize_t *size);

size_t parse_cform(char *buffer, size_t blen,
const char *str, size_t slen);

struct mphdr *parse_hosts(char *buffer, size_t size);

Expand Down
27 changes: 12 additions & 15 deletions app/src/main/cpp/native-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const enum demode DESYNC_METHODS[] = {
DESYNC_DISORDER,
DESYNC_FAKE,
DESYNC_OOB,
DESYNC_DISOOB,
};

enum hosts_mode {
Expand Down Expand Up @@ -81,7 +82,7 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
jboolean split_at_host,
jint fake_ttl,
jstring fake_sni,
jstring custom_oob_data,
jbyte custom_oob_char,
jboolean host_mixed_case,
jboolean domain_mixed_case,
jboolean host_remove_spaces,
Expand All @@ -91,7 +92,9 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
jint hosts_mode,
jstring hosts,
jboolean tfo,
jint udp_fake_count) {
jint udp_fake_count,
jboolean drop_sack,
jint fake_offset) {
struct sockaddr_ina s;

const char *address = (*env)->GetStringUTFChars(env, ip, 0);
Expand Down Expand Up @@ -135,7 +138,7 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
}

const char *str = (*env)->GetStringUTFChars(env, hosts, 0);
dp->file_ptr = parse_cform(str, &dp->file_size);
dp->file_ptr = data_from_str(str, &dp->file_size);
(*env)->ReleaseStringUTFChars(env, hosts, str);
dp->hosts = parse_hosts(dp->file_ptr, dp->file_size);
if (!dp->hosts) {
Expand All @@ -158,7 +161,7 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(

if (hosts_mode == HOSTS_BLACKLIST) {
const char *str = (*env)->GetStringUTFChars(env, hosts, 0);
dp->file_ptr = parse_cform(str, &dp->file_size);
dp->file_ptr = data_from_str(str, &dp->file_size);
(*env)->ReleaseStringUTFChars(env, hosts, str);
dp->hosts = parse_hosts(dp->file_ptr, dp->file_size);
if (!dp->hosts) {
Expand All @@ -170,6 +173,7 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(

dp->ttl = fake_ttl;
dp->udp_fake_count = udp_fake_count;
dp->drop_sack = drop_sack;
dp->proto =
IS_HTTP * desync_http |
IS_HTTPS * desync_https |
Expand Down Expand Up @@ -216,6 +220,8 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
}

if (mode == DESYNC_FAKE) {
dp->fake_offset = fake_offset;

const char *sni = (*env)->GetStringUTFChars(env, fake_sni, 0);
LOG(LOG_S, "fake_sni: %s", sni);
res = change_tls_sni(sni, fake_tls.data, fake_tls.size);
Expand All @@ -227,17 +233,8 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
}

if (mode == DESYNC_OOB) {
const char *oob = (*env)->GetStringUTFChars(env, custom_oob_data, 0);
const size_t oob_len = strlen(oob);

oob_data.size = oob_len;
oob_data.data = malloc(oob_len);
if (oob_data.data == NULL) {
uniperror("malloc");
return -1;
}
memcpy(oob_data.data, oob, oob_len);
(*env)->ReleaseStringUTFChars(env, custom_oob_data, oob);
dp->oob_char[0] = custom_oob_char;
dp->oob_char[1] = 1;
}

if (dp->proto) {
Expand Down
68 changes: 44 additions & 24 deletions app/src/main/cpp/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ void reset_params(void) {
params = default_params;
}

extern const struct option options[35];
extern const struct option options[38];

int parse_args(int argc, char **argv) {
int parse_args(int argc, char **argv)
{
int optc = sizeof(options)/sizeof(*options);
for (int i = 0, e = optc; i < e; i++)
optc += options[i].has_arg;
Expand Down Expand Up @@ -50,8 +51,9 @@ int parse_args(int argc, char **argv) {

optind = optreset = 1;

while (!invalid && (rez = getopt_long_only(
while (!invalid && (rez = getopt_long(
argc, argv, opt, options, 0)) != -1) {

switch (rez) {

case 'N':
Expand All @@ -64,6 +66,15 @@ int parse_args(int argc, char **argv) {
params.udp = 0;
break;

// case 'h':
// printf(help_text);
// reset_params();
// return 0;
// case 'v':
// printf("%s\n", VERSION);
// reset_params();
// return 0;

case 'i':
if (get_addr(optarg,
(struct sockaddr_ina *)&params.laddr) < 0)
Expand Down Expand Up @@ -119,10 +130,6 @@ int parse_args(int argc, char **argv) {
reset_params();
return -1;
}
if (!optarg) {
dp->detect |= DETECT_TORST;
break;
}
end = optarg;
while (end && !invalid) {
switch (*end) {
Expand All @@ -132,14 +139,9 @@ int parse_args(int argc, char **argv) {
case 'r':
dp->detect |= DETECT_HTTP_LOCAT;
break;
case 'c':
dp->detect |= DETECT_HTTP_CLERR;
break;
case 's':
dp->detect |= DETECT_TLS_INVSID;
break;
case 'a':
dp->detect |= DETECT_TLS_ALERT;
case 's':
dp->detect |= DETECT_TLS_ERR;
break;
case 'n':
break;
Expand All @@ -161,8 +163,12 @@ int parse_args(int argc, char **argv) {
break;

case 'T':;
#ifdef __linux__
float f = strtof(optarg, &end);
val = (long)(f * 1000);
#else
val = strtol(optarg, &end, 0);
#endif
if (val <= 0 || val > UINT_MAX || *end)
invalid = 1;
else
Expand Down Expand Up @@ -212,6 +218,7 @@ int parse_args(int argc, char **argv) {
case 's':
case 'd':
case 'o':
case 'q':
case 'f':
;
struct part *part = add((void *)&dp->parts,
Expand All @@ -231,6 +238,8 @@ int parse_args(int argc, char **argv) {
break;
case 'o': part->m = DESYNC_OOB;
break;
case 'q': part->m = DESYNC_DISOOB;
break;
case 'f': part->m = DESYNC_FAKE;
}
break;
Expand Down Expand Up @@ -263,13 +272,21 @@ int parse_args(int argc, char **argv) {
dp->md5sig = 1;
break;

case 'O':
val = strtol(optarg, &end, 0);
if (val <= 0 || *end)
invalid = 1;
else
dp->fake_offset = val;
break;

case 'n':
if (change_tls_sni(optarg, fake_tls.data, fake_tls.size)) {
fprintf(stderr, "error chsni\n");
perror("change_tls_sni");
reset_params();
return -1;
}
printf("sni: %s\n", optarg);
LOG(LOG_S, "sni: %s", optarg);
break;

case 'l':
Expand All @@ -284,14 +301,11 @@ int parse_args(int argc, char **argv) {
break;

case 'e':
if (oob_data.data != oob_char) {
continue;
}
oob_data.data = ftob(optarg, &oob_data.size);
if (!oob_data.data) {
uniperror("read/parse");
val = parse_cform(dp->oob_char, 1, optarg, strlen(optarg));
if (val != 1) {
invalid = 1;
}
else dp->oob_char[1] = 1;
break;

case 'M':
Expand Down Expand Up @@ -366,6 +380,10 @@ int parse_args(int argc, char **argv) {
}
break;

case 'Y':
dp->drop_sack = 1;
break;

case 'w': //
params.sfdelay = strtol(optarg, &end, 0);
if (params.sfdelay < 0 || optarg == end
Expand All @@ -376,9 +394,11 @@ int parse_args(int argc, char **argv) {
case 'W':
params.wait_send = 0;
break;
#ifdef __linux__
case 'P':
params.protect_path = optarg;
break;
#endif
case 0:
break;

Expand All @@ -387,13 +407,13 @@ int parse_args(int argc, char **argv) {
return -1;

default:
printf("?: %c\n", rez);
LOG(LOG_S, "Unknown option: -%c", rez);
reset_params();
return -1;
}
}
if (invalid) {
fprintf(stderr, "invalid value: -%c %s\n", rez, optarg);
LOG(LOG_S, "invalid value: -%c %s", rez, optarg);
reset_params();
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ByeDpiProxy {
splitAtHost = preferences.splitAtHost,
fakeTtl = preferences.fakeTtl,
fakeSni = preferences.fakeSni,
oobData = preferences.oobData,
oobChar = preferences.oobChar,
hostMixedCase = preferences.hostMixedCase,
domainMixedCase = preferences.domainMixedCase,
hostRemoveSpaces = preferences.hostRemoveSpaces,
Expand All @@ -80,6 +80,8 @@ class ByeDpiProxy {
hosts = preferences.hosts,
tcpFastOpen = preferences.tcpFastOpen,
udpFakeCount = preferences.udpFakeCount,
dropSack = preferences.dropSack,
fakeOffset = preferences.fakeOffset,
)
}

Expand All @@ -101,7 +103,7 @@ class ByeDpiProxy {
splitAtHost: Boolean,
fakeTtl: Int,
fakeSni: String,
oobData: String,
oobChar: Byte,
hostMixedCase: Boolean,
domainMixedCase: Boolean,
hostRemoveSpaces: Boolean,
Expand All @@ -112,6 +114,8 @@ class ByeDpiProxy {
hosts: String?,
tcpFastOpen: Boolean,
udpFakeCount: Int,
dropSack: Boolean,
fakeOffset: Int,
): Int

private external fun jniStartProxy(fd: Int): Int
Expand Down
Loading

0 comments on commit c95be6e

Please sign in to comment.