Small fixes

This commit is contained in:
dovecoteescapee 2024-03-03 15:21:01 +03:00
parent 52bf3cc272
commit 65cfecc679
7 changed files with 13 additions and 17 deletions

View File

@ -23,16 +23,15 @@ extern int get_default_ttl();
extern int get_addr(const char *str, struct sockaddr_ina *addr); extern int get_addr(const char *str, struct sockaddr_ina *addr);
JNIEXPORT jint JNICALL JNIEXPORT jint JNI_OnLoad(JavaVM *vm, __attribute__((unused)) void *reserved) {
Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_00024Companion_jniInit(JNIEnv *env, jobject thiz) {
oob_data.data = NULL; oob_data.data = NULL;
return 0; return JNI_VERSION_1_6;
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket( Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
JNIEnv *env, JNIEnv *env,
jobject thiz, __attribute__((unused)) jobject thiz,
jstring ip, jstring ip,
jint port, jint port,
jint max_connections, jint max_connections,
@ -128,7 +127,9 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniStartProxy(JNIEnv *env, jobject thiz, Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniStartProxy(
__attribute__((unused)) JNIEnv *env,
__attribute__((unused)) jobject thiz,
jint fd) { jint fd) {
LOG(LOG_S, "start_proxy, fd: %d", fd); LOG(LOG_S, "start_proxy, fd: %d", fd);
NOT_EXIT = 1; NOT_EXIT = 1;
@ -139,7 +140,9 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniStartProxy(JNIEnv *env
} }
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniStopProxy(JNIEnv *env, jobject thiz, Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniStopProxy(
__attribute__((unused)) JNIEnv *env,
__attribute__((unused)) jobject thiz,
jint fd) { jint fd) {
LOG(LOG_S, "stop_proxy, fd: %d", fd); LOG(LOG_S, "stop_proxy, fd: %d", fd);
if (shutdown(fd, SHUT_RDWR) < 0) { if (shutdown(fd, SHUT_RDWR) < 0) {

View File

@ -8,10 +8,7 @@ class ByeDpiProxy {
companion object { companion object {
init { init {
System.loadLibrary("byedpi") System.loadLibrary("byedpi")
jniInit()
} }
private external fun jniInit(): Int
} }
private val mutex = Mutex() private val mutex = Mutex()

View File

@ -34,7 +34,7 @@ class ByeDpiProxyPreferences(
val splitPosition: Int = splitPosition ?: 3 val splitPosition: Int = splitPosition ?: 3
val splitAtHost: Boolean = splitAtHost ?: false val splitAtHost: Boolean = splitAtHost ?: false
val fakeTtl: Int = fakeTtl ?: 8 val fakeTtl: Int = fakeTtl ?: 8
val fakeSni: String = fakeSni ?: "www.w3c.org" val fakeSni: String = fakeSni ?: "www.iana.org"
val oobData: String = oobData ?: "a" val oobData: String = oobData ?: "a"
val hostMixedCase: Boolean = hostMixedCase ?: false val hostMixedCase: Boolean = hostMixedCase ?: false
val domainMixedCase: Boolean = domainMixedCase ?: false val domainMixedCase: Boolean = domainMixedCase ?: false

View File

@ -40,7 +40,6 @@ class ByeDpiProxyService : LifecycleService() {
private const val FOREGROUND_SERVICE_ID: Int = 2 private const val FOREGROUND_SERVICE_ID: Int = 2
private const val NOTIFICATION_CHANNEL_ID: String = "ByeDPI Proxy" private const val NOTIFICATION_CHANNEL_ID: String = "ByeDPI Proxy"
@Volatile
private var status: ServiceStatus = ServiceStatus.Disconnected private var status: ServiceStatus = ServiceStatus.Disconnected
} }

View File

@ -3,11 +3,9 @@ package io.github.dovecoteescapee.byedpi.services
import io.github.dovecoteescapee.byedpi.data.AppStatus import io.github.dovecoteescapee.byedpi.data.AppStatus
import io.github.dovecoteescapee.byedpi.data.Mode import io.github.dovecoteescapee.byedpi.data.Mode
@Volatile
var appStatus = AppStatus.Halted to Mode.VPN var appStatus = AppStatus.Halted to Mode.VPN
private set private set
fun setStatus(status: AppStatus, mode: Mode) { fun setStatus(status: AppStatus, mode: Mode) {
appStatus = status to mode appStatus = status to mode
} }

View File

@ -47,7 +47,6 @@ class ByeDpiVpnService : LifecycleVpnService() {
private const val FOREGROUND_SERVICE_ID: Int = 1 private const val FOREGROUND_SERVICE_ID: Int = 1
private const val NOTIFICATION_CHANNEL_ID: String = "ByeDPIVpn" private const val NOTIFICATION_CHANNEL_ID: String = "ByeDPIVpn"
@Volatile
private var status: ServiceStatus = ServiceStatus.Disconnected private var status: ServiceStatus = ServiceStatus.Disconnected
} }

View File

@ -118,7 +118,7 @@
<com.takisoft.preferencex.EditTextPreference <com.takisoft.preferencex.EditTextPreference
android:key="byedpi_fake_sni" android:key="byedpi_fake_sni"
android:title="SNI of fake packet" android:title="SNI of fake packet"
android:defaultValue="www.w3c.org" android:defaultValue="www.iana.org"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<com.takisoft.preferencex.EditTextPreference <com.takisoft.preferencex.EditTextPreference