mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 13:03:56 +08:00
⛅ Sync 2026-09-22 23:24:55
This commit is contained in:
1 parent
de9cc9a6a9
commit
d45e210b8a
16 files changed
+174
-72
No files matched your search
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-xray
|
||||
PKG_VERSION:=3.7.2
|
||||
PKG_RELEASE:=9
|
||||
PKG_RELEASE:=10
|
||||
|
||||
PKG_LICENSE:=MPLv2
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
@@ -2,52 +2,70 @@
|
||||
|
||||
import { server_outbound } from "./outbound.mjs";
|
||||
|
||||
function manual_tproxy_redirect(v) {
|
||||
return sprintf("%s:%d", v["dest_addr"] || "", v["dest_port"] || 0);
|
||||
}
|
||||
|
||||
function manual_tproxy_outbound_tag(v, name) {
|
||||
return `manual_tproxy:${v[".name"]}@${name}`;
|
||||
}
|
||||
|
||||
function manual_tproxy_force_forward_tag(v, name, force_forward_key, server_key) {
|
||||
if (v[force_forward_key] !== "1" || v[server_key] == null) {
|
||||
return null;
|
||||
}
|
||||
return `manual_tproxy:${v[".name"]}@${name}@force_forward:${v[server_key]}`;
|
||||
}
|
||||
|
||||
function manual_tproxy_needs_dialer_proxy(v, force_forward_key, server_key) {
|
||||
if (v[force_forward_key] !== "1") {
|
||||
return true;
|
||||
}
|
||||
if (v[server_key] == null) {
|
||||
return true;
|
||||
}
|
||||
if (manual_tproxy_redirect(v) !== ":0") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function manual_tproxy_outbound(config, v, name, force_forward_key, server_key) {
|
||||
const force_forward_tag = manual_tproxy_force_forward_tag(v, name, force_forward_key, server_key);
|
||||
let result = [];
|
||||
if (force_forward_tag != null) {
|
||||
push(result, ...server_outbound(config[v[server_key]], force_forward_tag, config));
|
||||
}
|
||||
if (manual_tproxy_needs_dialer_proxy(v, force_forward_key, server_key)) {
|
||||
push(result, {
|
||||
protocol: "freedom",
|
||||
tag: manual_tproxy_outbound_tag(v, name),
|
||||
settings: {
|
||||
redirect: manual_tproxy_redirect(v),
|
||||
domainStrategy: "AsIs"
|
||||
},
|
||||
streamSettings: {
|
||||
sockOpt: {
|
||||
dialerProxy: force_forward_tag != null ? force_forward_tag : "direct"
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function manual_tproxy_rule_tag(v, name, force_forward_key, server_key) {
|
||||
if (manual_tproxy_needs_dialer_proxy(v, force_forward_key, server_key)) {
|
||||
return manual_tproxy_outbound_tag(v, name);
|
||||
}
|
||||
return manual_tproxy_force_forward_tag(v, name, force_forward_key, server_key);
|
||||
}
|
||||
|
||||
export function manual_tproxy_outbounds(config, manual_tproxy) {
|
||||
let result = [];
|
||||
for (let v in manual_tproxy) {
|
||||
let tcp_tag = "direct";
|
||||
if (v["force_forward_tcp"] === "1") {
|
||||
if (v["force_forward_server_tcp"] != null) {
|
||||
tcp_tag = `manual_tproxy:${v[".name"]}@tcp_outbound@force_forward:${v["force_forward_server_tcp"]}`;
|
||||
const force_forward_server_tcp = config[v["force_forward_server_tcp"]];
|
||||
push(result, ...server_outbound(force_forward_server_tcp, tcp_tag, config));
|
||||
}
|
||||
}
|
||||
push(result, {
|
||||
protocol: "freedom",
|
||||
tag: sprintf("manual_tproxy:%s@tcp_outbound", v[".name"]),
|
||||
settings: {
|
||||
redirect: sprintf("%s:%d", v["dest_addr"] || "", v["dest_port"] || 0),
|
||||
domainStrategy: "AsIs"
|
||||
},
|
||||
streamSettings: {
|
||||
sockOpt: {
|
||||
dialerProxy: tcp_tag
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let udp_tag = "direct";
|
||||
if (v["force_forward_udp"] === "1") {
|
||||
if (v["force_forward_server_udp"] != null) {
|
||||
udp_tag = `manual_tproxy:${v[".name"]}@udp_outbound@force_forward:${v["force_forward_server_udp"]}`;
|
||||
const force_forward_server_udp = config[v["force_forward_server_udp"]];
|
||||
push(result, ...server_outbound(force_forward_server_udp, udp_tag, config));
|
||||
}
|
||||
}
|
||||
push(result, {
|
||||
protocol: "freedom",
|
||||
tag: sprintf("manual_tproxy:%s@udp_outbound", v[".name"]),
|
||||
settings: {
|
||||
redirect: sprintf("%s:%d", v["dest_addr"] || "", v["dest_port"] || 0),
|
||||
domainStrategy: "AsIs"
|
||||
},
|
||||
streamSettings: {
|
||||
sockOpt: {
|
||||
dialerProxy: udp_tag
|
||||
}
|
||||
}
|
||||
});
|
||||
push(result, ...manual_tproxy_outbound(config, v, "tcp_outbound", "force_forward_tcp", "force_forward_server_tcp"));
|
||||
push(result, ...manual_tproxy_outbound(config, v, "udp_outbound", "force_forward_udp", "force_forward_server_udp"));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -55,11 +73,13 @@ export function manual_tproxy_outbounds(config, manual_tproxy) {
|
||||
export function manual_tproxy_outbound_tags(manual_tproxy) {
|
||||
let result = [];
|
||||
for (let v in manual_tproxy) {
|
||||
if (v["force_forward_tcp"] === "1") {
|
||||
push(result, `manual_tproxy:${v[".name"]}@tcp_outbound@force_forward:${v["force_forward_server_tcp"]}`);
|
||||
const tcp_tag = manual_tproxy_force_forward_tag(v, "tcp_outbound", "force_forward_tcp", "force_forward_server_tcp");
|
||||
if (tcp_tag != null) {
|
||||
push(result, tcp_tag);
|
||||
}
|
||||
if (v["force_forward_udp"] === "1") {
|
||||
push(result, `manual_tproxy:${v[".name"]}@udp_outbound@force_forward:${v["force_forward_server_udp"]}`);
|
||||
const udp_tag = manual_tproxy_force_forward_tag(v, "udp_outbound", "force_forward_udp", "force_forward_server_udp");
|
||||
if (udp_tag != null) {
|
||||
push(result, udp_tag);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -73,14 +93,14 @@ export function manual_tproxy_rules(manual_tproxy) {
|
||||
inboundTag: ["tproxy_tcp_inbound_v4", "tproxy_tcp_inbound_v6", "socks_inbound", "https_inbound", "http_inbound"],
|
||||
ip: [v["source_addr"]],
|
||||
port: v["source_port"],
|
||||
outboundTag: sprintf("manual_tproxy:%s@tcp_outbound", v[".name"])
|
||||
outboundTag: manual_tproxy_rule_tag(v, "tcp_outbound", "force_forward_tcp", "force_forward_server_tcp")
|
||||
});
|
||||
splice(result, 0, 0, {
|
||||
type: "field",
|
||||
inboundTag: ["tproxy_udp_inbound_v4", "tproxy_udp_inbound_v6"],
|
||||
ip: [v["source_addr"]],
|
||||
port: v["source_port"],
|
||||
outboundTag: sprintf("manual_tproxy:%s@udp_outbound", v[".name"])
|
||||
outboundTag: manual_tproxy_rule_tag(v, "udp_outbound", "force_forward_udp", "force_forward_server_udp")
|
||||
});
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user