Browse Source

chore: optimize code style; bump version

pull/390/head
yichya 9 months ago
committed by yichya QC
parent
commit
ec534a4968
  1. 4
      README.md
  2. 3
      core/Makefile
  3. 38
      core/root/usr/share/xray/feature/dns.mjs
  4. 69
      core/root/usr/share/xray/feature/extra_inbound.mjs
  5. 60
      core/root/usr/share/xray/feature/inbound.mjs
  6. 12
      core/root/usr/share/xray/gen_config.uc
  7. 2
      status/Makefile

4
README.md

@ -40,6 +40,10 @@ Fork this repository and:
* Wait until actions finish
* Use `opkg -i *` to install both ipks from Releases.
## Changelog since 3.4.0
* 2024-02-18 chore: optimize code style; bump version
## Changelog since 3.3.0
* 2024-01-19 chore: bump version

3
core/Makefile

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-xray
PKG_VERSION:=3.3.1
PKG_VERSION:=3.4.0
PKG_RELEASE:=1
PKG_LICENSE:=MPLv2
@ -132,7 +132,6 @@ endif
$(INSTALL_DIR) $(1)/usr/share/xray/feature
$(INSTALL_DATA) ./root/usr/share/xray/feature/bridge.mjs $(1)/usr/share/xray/feature/bridge.mjs
$(INSTALL_DATA) ./root/usr/share/xray/feature/dns.mjs $(1)/usr/share/xray/feature/dns.mjs
$(INSTALL_DATA) ./root/usr/share/xray/feature/extra_inbound.mjs $(1)/usr/share/xray/feature/extra_inbound.mjs
$(INSTALL_DATA) ./root/usr/share/xray/feature/fake_dns.mjs $(1)/usr/share/xray/feature/fake_dns.mjs
$(INSTALL_DATA) ./root/usr/share/xray/feature/inbound.mjs $(1)/usr/share/xray/feature/inbound.mjs
$(INSTALL_DATA) ./root/usr/share/xray/feature/manual_tproxy.mjs $(1)/usr/share/xray/feature/manual_tproxy.mjs

38
core/root/usr/share/xray/feature/dns.mjs

@ -75,31 +75,34 @@ export function dns_rules(proxy, tcp_hijack_inbound_tags, udp_hijack_inbound_tag
for (let i = dns_port; i <= dns_port + dns_count; i++) {
push(dns_server_tags, sprintf("dns_server_inbound:%d", i));
}
return [
let result = [
{
type: "field",
inboundTag: dns_server_tags,
outboundTag: "dns_server_outbound"
},
];
if (proxy.dns_tcp_hijack) {
push(result, {
type: "field",
port: "53",
inboundTag: tcp_hijack_inbound_tags,
outboundTag: "dns_tcp_hijack_outbound"
},
{
});
}
if (proxy.dns_udp_hijack) {
push(result, {
type: "field",
port: "53",
inboundTag: udp_hijack_inbound_tags,
outboundTag: "dns_udp_hijack_outbound"
},
{
type: "field",
inboundTag: dns_server_tags,
outboundTag: "dns_server_outbound"
},
];
});
}
return result;
};
export function dns_server_outbounds(proxy) {
return [
direct_outbound("dns_tcp_hijack_outbound", proxy.dns_tcp_hijack || ""),
direct_outbound("dns_udp_hijack_outbound", proxy.dns_udp_hijack || ""),
let result = [
{
protocol: "dns",
settings: {
@ -113,6 +116,13 @@ export function dns_server_outbounds(proxy) {
tag: "dns_server_outbound"
}
];
if (proxy.dns_tcp_hijack) {
push(result, direct_outbound("dns_tcp_hijack_outbound", proxy.dns_tcp_hijack));
}
if (proxy.dns_udp_hijack) {
push(result, direct_outbound("dns_udp_hijack_outbound", proxy.dns_udp_hijack));
}
return result;
};
export function dns_conf(proxy, config, manual_tproxy, fakedns) {
@ -136,7 +146,7 @@ export function dns_conf(proxy, config, manual_tproxy, fakedns) {
let servers = [
...fake_dns_domains(fakedns),
...map(keys(domain_extra_options), function (k) {
const i = split_ipv4_host_port(domain_extra_options[k]);
let i = split_ipv4_host_port(domain_extra_options[k]);
i["domains"] = [`domain:${k}`];
i["skipFallback"] = true;
return i;

69
core/root/usr/share/xray/feature/extra_inbound.mjs

@ -1,69 +0,0 @@
"use strict";
import { dokodemo_inbound, http_inbound, socks_inbound } from "./inbound.mjs";
import { balancer } from "./system.mjs";
export function extra_inbounds(proxy, extra_inbound) {
let result = [];
for (let v in extra_inbound) {
const tag = `extra_inbound:${v[".name"]}`;
if (v["inbound_type"] == "http") {
push(result, http_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, v["inbound_username"], v["inbound_password"]));
} else if (v["inbound_type"] == "socks5") {
push(result, socks_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, v["inbound_username"], v["inbound_password"]));
} else if (v["inbound_type"] == "tproxy_tcp") {
push(result, dokodemo_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, proxy["tproxy_sniffing"], proxy["route_only"], ["http", "tls"], "0", "tcp", "tproxy"));
} else if (v["inbound_type"] == "tproxy_udp") {
push(result, dokodemo_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, proxy["tproxy_sniffing"], proxy["route_only"], ["quic"], "0", "udp", "tproxy"));
} else {
die(`unknown inbound type ${v["inbound_type"]}`);
}
}
return result;
};
export function extra_inbound_rules(extra_inbound) {
let result = [];
for (let v in extra_inbound) {
if (v["specify_outbound"] == "1") {
push(result, {
type: "field",
inboundTag: [`extra_inbound:${v[".name"]}`],
balancerTag: `extra_inbound_outbound:${v[".name"]}`
});
}
}
return result;
};
export function extra_inbound_balancers(extra_inbound) {
let result = [];
for (let e in extra_inbound) {
if (e["specify_outbound"] == "1") {
push(result, {
"tag": `extra_inbound_outbound:${e[".name"]}`,
"selector": balancer(e, "destination", `extra_inbound:${e[".name"]}`),
"strategy": {
"type": e["balancer_strategy"] || "random"
}
});
}
}
return result;
};
export function extra_inbound_global_tcp(extra_inbound) {
return map(filter(extra_inbound, v => v["specify_outbound"] != "1" && v["inbound_type"] == "tproxy_tcp"), v => `extra_inbound_${v[".name"]}`);
};
export function extra_inbound_global_udp(extra_inbound) {
return map(filter(extra_inbound, v => v["specify_outbound"] != "1" && v["inbound_type"] == "tproxy_udp"), v => `extra_inbound_${v[".name"]}`);
};
export function extra_inbound_global_http(extra_inbound) {
return map(filter(extra_inbound, v => v["specify_outbound"] != "1" && v["inbound_type"] == "http"), v => `extra_inbound_${v[".name"]}`);
};
export function extra_inbound_global_socks5(extra_inbound) {
return map(filter(extra_inbound, v => v["specify_outbound"] != "1" && v["inbound_type"] == "socks5"), v => `extra_inbound_${v[".name"]}`);
};

60
core/root/usr/share/xray/feature/inbound.mjs

@ -2,6 +2,7 @@
import { https_trojan_inbound } from "../protocol/trojan.mjs";
import { https_vless_inbound } from "../protocol/vless.mjs";
import { balancer } from "./system.mjs";
export function dokodemo_inbound(listen, port, tag, sniffing, sniffing_route_only, sniffing_dest_override, sniffing_metadata_only, network, tproxy, timeout) {
let result = {
@ -87,3 +88,62 @@ export function https_inbound(proxy, config) {
}
return null;
};
export function extra_inbounds(proxy, extra_inbound) {
let result = [];
for (let v in extra_inbound) {
const tag = `extra_inbound:${v[".name"]}`;
if (v["inbound_type"] == "http") {
push(result, http_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, v["inbound_username"], v["inbound_password"]));
} else if (v["inbound_type"] == "socks5") {
push(result, socks_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, v["inbound_username"], v["inbound_password"]));
} else if (v["inbound_type"] == "tproxy_tcp") {
push(result, dokodemo_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, proxy["tproxy_sniffing"], proxy["route_only"], ["http", "tls"], "0", "tcp", "tproxy"));
} else if (v["inbound_type"] == "tproxy_udp") {
push(result, dokodemo_inbound(v["inbound_addr"] || "0.0.0.0", v["inbound_port"], tag, proxy["tproxy_sniffing"], proxy["route_only"], ["quic"], "0", "udp", "tproxy"));
} else {
die(`unknown inbound type ${v["inbound_type"]}`);
}
}
return result;
};
export function extra_inbound_rules(extra_inbound) {
let result = [];
for (let v in extra_inbound) {
if (v["specify_outbound"] == "1") {
push(result, {
type: "field",
inboundTag: [`extra_inbound:${v[".name"]}`],
balancerTag: `extra_inbound_outbound:${v[".name"]}`
});
}
}
return result;
};
export function extra_inbound_balancers(extra_inbound) {
let result = [];
for (let e in extra_inbound) {
if (e["specify_outbound"] == "1") {
push(result, {
"tag": `extra_inbound_outbound:${e[".name"]}`,
"selector": balancer(e, "destination", `extra_inbound:${e[".name"]}`),
"strategy": {
"type": e["balancer_strategy"] || "random"
}
});
}
}
return result;
};
export function extra_inbound_global(extra_inbound) {
const global_tags = filter(extra_inbound, v => v["specify_outbound"] != "1");
return {
"tproxy_tcp": map(filter(global_tags, v => v["inbound_type"] == "tproxy_tcp"), v => `extra_inbound_${v[".name"]}`),
"tproxy_udp": map(filter(global_tags, v => v["inbound_type"] == "tproxy_udp"), v => `extra_inbound_${v[".name"]}`),
"http": map(filter(global_tags, v => v["inbound_type"] == "http"), v => `extra_inbound_${v[".name"]}`),
"socks5": map(filter(global_tags, v => v["inbound_type"] == "socks5"), v => `extra_inbound_${v[".name"]}`),
};
};

12
core/root/usr/share/xray/gen_config.uc

@ -5,9 +5,8 @@ import { access } from "fs";
import { load_config } from "./common/config.mjs";
import { bridge_outbounds, bridge_rules, bridges } from "./feature/bridge.mjs";
import { blocked_domain_rules, dns_conf, dns_rules, dns_server_inbounds, dns_server_outbounds, fast_domain_rules, secure_domain_rules } from "./feature/dns.mjs";
import { extra_inbound_balancers, extra_inbound_global_http, extra_inbound_global_socks5, extra_inbound_global_tcp, extra_inbound_global_udp, extra_inbound_rules, extra_inbounds } from "./feature/extra_inbound.mjs";
import { fake_dns_balancers, fake_dns_conf, fake_dns_rules } from "./feature/fake_dns.mjs";
import { dokodemo_inbound, http_inbound, https_inbound, socks_inbound } from "./feature/inbound.mjs";
import { dokodemo_inbound, extra_inbound_balancers, extra_inbound_global, extra_inbound_rules, extra_inbounds, http_inbound, https_inbound, socks_inbound } from "./feature/inbound.mjs";
import { manual_tproxy_outbound_tags, manual_tproxy_outbounds, manual_tproxy_rules } from "./feature/manual_tproxy.mjs";
import { blackhole_outbound, direct_outbound, server_outbound } from "./feature/outbound.mjs";
import { api_conf, balancer, logging, metrics_conf, policy, system_route_rules } from "./feature/system.mjs";
@ -108,10 +107,11 @@ function rules(proxy, bridge, manual_tproxy, extra_inbound, fakedns) {
const tproxy_udp_inbound_v4_tags = ["tproxy_udp_inbound_v4"];
const tproxy_tcp_inbound_v6_tags = ["tproxy_tcp_inbound_v6"];
const tproxy_udp_inbound_v6_tags = ["tproxy_udp_inbound_v6"];
const extra_inbound_global_tcp_tags = extra_inbound_global_tcp() || [];
const extra_inbound_global_udp_tags = extra_inbound_global_udp() || [];
const extra_inbound_global_http_tags = extra_inbound_global_http() || [];
const extra_inbound_global_socks5_tags = extra_inbound_global_socks5() || [];
const extra_inbound_global_tags = extra_inbound_global();
const extra_inbound_global_tcp_tags = extra_inbound_global_tags["tproxy_tcp"] || [];
const extra_inbound_global_udp_tags = extra_inbound_global_tags["tproxy_udp"] || [];
const extra_inbound_global_http_tags = extra_inbound_global_tags["http"] || [];
const extra_inbound_global_socks5_tags = extra_inbound_global_tags["socks5"] || [];
const built_in_tcp_inbounds = [...tproxy_tcp_inbound_v4_tags, ...extra_inbound_global_tcp_tags, ...extra_inbound_global_http_tags, ...extra_inbound_global_socks5_tags, "socks_inbound", "https_inbound", "http_inbound"];
const built_in_udp_inbounds = [...tproxy_udp_inbound_v4_tags, ...extra_inbound_global_udp_tags, "dns_conf_inbound"];
let result = [

2
status/Makefile

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-xray-status
PKG_VERSION:=3.3.1
PKG_VERSION:=3.4.0
PKG_RELEASE:=1
PKG_LICENSE:=MPLv2

Loading…
Cancel
Save