1
0
mirror of https://github.com/MGislv/NekoX.git synced 2024-07-04 11:13:36 +00:00

Increase proxy timeout

This commit is contained in:
世界 2021-04-11 08:42:31 +08:00
parent ae7023e9d4
commit 5d88b7c83e
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
6 changed files with 39 additions and 16 deletions

View File

@ -127,7 +127,7 @@ void Connection::onReceivedData(NativeByteBuffer *buffer) {
currentDatacenter->storeCurrentAddressAndPortNum();
isTryingNextPort = false;
if (connectionType == ConnectionTypeProxy) {
setTimeout(5);
setTimeout(25);
} else if (connectionType == ConnectionTypePush) {
setTimeout(60 * 15);
} else if (connectionType == ConnectionTypeUpload) {
@ -373,7 +373,7 @@ void Connection::connect() {
hasSomeDataSinceLastConnect = false;
openConnection(hostAddress, hostPort, secret, ipv6 != 0, ConnectionsManager::getInstance(currentDatacenter->instanceNum).currentNetworkType);
if (connectionType == ConnectionTypeProxy) {
setTimeout(50);
setTimeout(25);
} else if (connectionType == ConnectionTypePush) {
if (isTryingNextPort) {
setTimeout(40);

View File

@ -18,7 +18,7 @@ public class BuildVars {
public static boolean DEBUG_VERSION = BuildConfig.BUILD_TYPE.equals("debug");
public static boolean DEBUG_PRIVATE_VERSION = DEBUG_VERSION;
public static boolean LOGS_ENABLED;
public static boolean LOGS_ENABLED = DEBUG_PRIVATE_VERSION;
public static boolean USE_CLOUD_STRINGS = true;
public static int BUILD_VERSION;
@ -45,7 +45,7 @@ public class BuildVars {
BUILD_VERSION_STRING = BuildConfig.VERSION_NAME;
}
if (ApplicationLoader.applicationContext != null) {
if (!DEBUG_PRIVATE_VERSION && ApplicationLoader.applicationContext != null) {
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", Context.MODE_PRIVATE);
LOGS_ENABLED = DEBUG_VERSION = sharedPreferences.getBoolean("logsEnabled", DEBUG_VERSION);
}

View File

@ -20,6 +20,7 @@ import android.util.Base64;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.pm.ShortcutManagerCompat;
import com.v2ray.ang.V2RayConfig;
@ -27,6 +28,8 @@ import com.v2ray.ang.dto.AngConfig;
import com.v2ray.ang.util.Utils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.dizitart.no2.objects.filters.ObjectFilters;
import org.json.JSONArray;
import org.json.JSONException;
@ -958,6 +961,11 @@ public class SharedConfig {
return "WS";
}
@Override
public int hashCode() {
return bean.hashCode();
}
@Override
public JSONObject toJsonInternal() throws JSONException {
JSONObject obj = new JSONObject();

View File

@ -7,7 +7,6 @@ import okhttp3.HttpUrl
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
import tw.nekomimi.nekogram.tcp2ws.Tcp2wsServer
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
class WsLoader {
lateinit var server: Tcp2wsServer

View File

@ -14,7 +14,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Objects;
import cn.hutool.core.util.StrUtil;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@ -157,8 +156,24 @@ public class ProxyHandler implements Runnable {
@Override
public void onMessage(@NotNull okhttp3.WebSocket webSocket, @NotNull ByteString bytes) {
FileLog.d("[" + webSocket.request().url() + "] Reveived " + bytes.size() + " bytes");
ProxyHandler.this.sendToClient(bytes.toByteArray());
}
@Override
public void onMessage(@NotNull WebSocket webSocket, @NotNull String text) {
FileLog.d("[" + webSocket.request().url() + "] Reveived text: " + text);
}
@Override
public void onClosed(@NotNull WebSocket webSocket, int code, @NotNull String reason) {
FileLog.d("[" + webSocket.request().url() + "] Closed: " + code + " " + reason);
}
@Override
public void onClosing(@NotNull WebSocket webSocket, int code, @NotNull String reason) {
FileLog.d("[" + webSocket.request().url() + "] Closing: " + code + " " + reason);
}
});
}
@ -235,6 +250,7 @@ public class ProxyHandler implements Runnable {
}
}
if (error != null) throw new RuntimeException(error);
FileLog.d("[" + m_ServerSocket.request().url() + "] Send " + dlen + " bytes");
this.m_ServerSocket.send(ByteString.of(Arrays.copyOf(this.m_Buffer, dlen)));
}
}

View File

@ -2,17 +2,17 @@ package tw.nekomimi.nekogram.tcp2ws;
public interface SocksConstants {
// refactor
int LISTEN_TIMEOUT = 200;
int DEFAULT_SERVER_TIMEOUT = 200;
// refactor
int LISTEN_TIMEOUT = 2000;
int DEFAULT_SERVER_TIMEOUT = 2000;
int DEFAULT_BUF_SIZE = 4096;
int DEFAULT_PROXY_TIMEOUT = 10;
int DEFAULT_BUF_SIZE = 4096;
int DEFAULT_PROXY_TIMEOUT = 2000;
byte SOCKS5_Version = 0x05;
byte SOCKS4_Version = 0x04;
byte SOCKS5_Version = 0x05;
byte SOCKS4_Version = 0x04;
byte SC_CONNECT = 0x01;
byte SC_BIND = 0x02;
byte SC_UDP = 0x03;
byte SC_CONNECT = 0x01;
byte SC_BIND = 0x02;
byte SC_UDP = 0x03;
}