mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
feat(provider): add CodeBuddy CN provider (copilot.tencent.com)
Add Tencent CodeBuddy CN (codebuddy-cn) OAuth provider with full support: OAuth login (GET poll with state query param), token refresh, 15-model catalog, /v2 inference endpoint, forced streaming, OpenAI-style reasoning, and per-model capabilities. Renamed from codebuddy to codebuddy-cn to allow a future codebuddy-ai variant. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
db4499d6df
commit
efd20be8d8
+9
-4
@@ -10,10 +10,15 @@ http.createServer = (...args) => {
|
||||
const rest = args.filter((a) => typeof a !== "function");
|
||||
if (!handler) return origCreate(...args);
|
||||
const wrapped = (req, res) => {
|
||||
const ip = req.socket && req.socket.remoteAddress ? req.socket.remoteAddress : "";
|
||||
// Forwarding headers present = request arrived via a reverse proxy; loopback
|
||||
// socket is the proxy hop, not the end-user, so it must not be trusted as local.
|
||||
const viaProxy = !!(req.headers["x-forwarded-for"] || req.headers["x-real-ip"]);
|
||||
const socketIp = req.socket && req.socket.remoteAddress ? req.socket.remoteAddress : "";
|
||||
const xff = req.headers["x-forwarded-for"];
|
||||
const xRealIp = req.headers["x-real-ip"];
|
||||
const viaProxy = !!(xff || xRealIp);
|
||||
const isLoopbackProxy = socketIp === "127.0.0.1" || socketIp === "::1" || socketIp === "::ffff:127.0.0.1";
|
||||
// Trust forwarding headers only when the TCP peer is a local reverse proxy.
|
||||
// Direct/public sockets remain keyed by the unspoofable peer address.
|
||||
const proxyIp = xRealIp || (xff ? String(xff).split(",")[0].trim() : "");
|
||||
const ip = isLoopbackProxy && proxyIp ? proxyIp : socketIp;
|
||||
delete req.headers["x-9r-real-ip"];
|
||||
delete req.headers["x-forwarded-for"];
|
||||
delete req.headers["x-9r-via-proxy"];
|
||||
|
||||
Reference in New Issue
Block a user