mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
fix(proxy): test endpoint resolves real credentials from DB via proxyId
The proxy test button in Settings was always failing with 'Socks5 Authentication failed' because the frontend sent redacted credentials (***) from listProxies(). The backend received '***' as the password and tried to authenticate with it. Fix: Frontend now sends proxyId in the test request body. The test endpoint looks up the proxy from the DB with includeSecrets: true and uses the real stored credentials for the SOCKS5 handshake. Also: removed username/password from the frontend test payload since they are always redacted and useless for testing.
This commit is contained in:
@@ -209,12 +209,11 @@ export default function ProxyRegistryManager() {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
proxyId: item.id,
|
||||
proxy: {
|
||||
type: item.type || "http",
|
||||
host: item.host,
|
||||
port: String(item.port || 8080),
|
||||
username: item.username,
|
||||
password: item.password,
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { testProxySchema } from "@/shared/validation/schemas";
|
||||
import { isValidationFailure, validateBody } from "@/shared/validation/helpers";
|
||||
import { createErrorResponse, createErrorResponseFromUnknown } from "@/lib/api/errorResponse";
|
||||
import { getProxyById } from "@/lib/localDb";
|
||||
|
||||
const BASE_SUPPORTED_PROXY_TYPES = new Set(["http", "https"]);
|
||||
|
||||
@@ -56,7 +57,26 @@ export async function POST(request: Request) {
|
||||
type: "invalid_request",
|
||||
});
|
||||
}
|
||||
const { proxy } = validation.data;
|
||||
let { proxy } = validation.data;
|
||||
|
||||
// If a proxyId is provided, look up the real (non-redacted) credentials from DB.
|
||||
// The frontend sends redacted credentials (***) from listProxies(), so we need
|
||||
// the actual secrets for testing.
|
||||
const body = rawBody as Record<string, unknown>;
|
||||
const proxyId = typeof body.proxyId === "string" ? body.proxyId.trim() : null;
|
||||
if (proxyId) {
|
||||
const dbProxy = await getProxyById(proxyId, { includeSecrets: true });
|
||||
if (dbProxy) {
|
||||
proxy = {
|
||||
...proxy,
|
||||
host: proxy.host || dbProxy.host,
|
||||
port: proxy.port || String(dbProxy.port),
|
||||
type: proxy.type || dbProxy.type,
|
||||
username: dbProxy.username,
|
||||
password: dbProxy.password,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
const proxyType = String(proxy.type || "http").toLowerCase();
|
||||
if (proxyType === "socks5" && !isSocks5ProxyEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user