Skip to content

Commit

Permalink
chore: optimize code style; bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
yichya committed Feb 17, 2024
1 parent 0a2da66 commit ec534a4
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 92 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions core/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
38 changes: 24 additions & 14 deletions core/root/usr/share/xray/feature/dns.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
69 changes: 0 additions & 69 deletions core/root/usr/share/xray/feature/extra_inbound.mjs

This file was deleted.

60 changes: 60 additions & 0 deletions core/root/usr/share/xray/feature/inbound.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 changes: 6 additions & 6 deletions core/root/usr/share/xray/gen_config.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion status/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ec534a4

Please sign in to comment.