Browse Source

feat: socks / http outbound

pull/376/head
yichya QC 10 months ago
committed by yichya QC
parent
commit
6aa4691e94
  1. 5
      README.md
  2. 4
      core/Makefile
  3. 12
      core/root/usr/share/xray/common/stream.mjs
  4. 6
      core/root/usr/share/xray/feature/outbound.mjs
  5. 31
      core/root/usr/share/xray/protocol/http.mjs
  6. 1
      core/root/usr/share/xray/protocol/shadowsocks.mjs
  7. 31
      core/root/usr/share/xray/protocol/socks.mjs
  8. 1
      core/root/usr/share/xray/protocol/trojan.mjs
  9. 1
      core/root/usr/share/xray/protocol/vless.mjs
  10. 1
      core/root/usr/share/xray/protocol/vmess.mjs
  11. 5
      core/root/www/luci-static/resources/view/xray/core.js
  12. 12
      core/root/www/luci-static/resources/view/xray/protocol.js
  13. 2
      status/Makefile

5
README.md

@ -36,12 +36,17 @@ Fork this repository and:
* Wait until actions finish * Wait until actions finish
* Use `opkg -i *` to install both ipks from Releases. * Use `opkg -i *` to install both ipks from Releases.
## Changelog since 3.3.0
* 2024-01-19 chore: bump version
## Changelog since 3.2.0 ## Changelog since 3.2.0
* 2023-12-20 chore: bump version * 2023-12-20 chore: bump version
* 2023-12-22 chore: optimize list folded format; add roundRobin balancer * 2023-12-22 chore: optimize list folded format; add roundRobin balancer
* 2024-01-04 chore: start later than sysntpd; change firewall include file path * 2024-01-04 chore: start later than sysntpd; change firewall include file path
* 2024-01-18 feat: make "Resolve Domain via DNS" available to all outbounds * 2024-01-18 feat: make "Resolve Domain via DNS" available to all outbounds
* 2024-01-19 feat: socks / http outbound
## Changelog since 3.1.0 ## Changelog since 3.1.0

4
core/Makefile

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-xray PKG_NAME:=luci-app-xray
PKG_VERSION:=3.2.1 PKG_VERSION:=3.3.0
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=MPLv2 PKG_LICENSE:=MPLv2
@ -143,6 +143,8 @@ endif
$(INSTALL_DATA) ./root/usr/share/xray/protocol/trojan.mjs $(1)/usr/share/xray/protocol/trojan.mjs $(INSTALL_DATA) ./root/usr/share/xray/protocol/trojan.mjs $(1)/usr/share/xray/protocol/trojan.mjs
$(INSTALL_DATA) ./root/usr/share/xray/protocol/vless.mjs $(1)/usr/share/xray/protocol/vless.mjs $(INSTALL_DATA) ./root/usr/share/xray/protocol/vless.mjs $(1)/usr/share/xray/protocol/vless.mjs
$(INSTALL_DATA) ./root/usr/share/xray/protocol/vmess.mjs $(1)/usr/share/xray/protocol/vmess.mjs $(INSTALL_DATA) ./root/usr/share/xray/protocol/vmess.mjs $(1)/usr/share/xray/protocol/vmess.mjs
$(INSTALL_DATA) ./root/usr/share/xray/protocol/socks.mjs $(1)/usr/share/xray/protocol/socks.mjs
$(INSTALL_DATA) ./root/usr/share/xray/protocol/http.mjs $(1)/usr/share/xray/protocol/http.mjs
endef endef
$(eval $(call BuildPackage,$(PKG_NAME))) $(eval $(call BuildPackage,$(PKG_NAME)))

12
core/root/usr/share/xray/common/stream.mjs

@ -9,14 +9,14 @@ function stream_tcp_fake_http_request(server) {
method: "GET", method: "GET",
path: server["http_path"], path: server["http_path"],
headers: { headers: {
Host: server["http_host"], "Host": server["http_host"],
User_Agent: [ "User-Agent": [
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
"Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46" "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0_2 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/53.0.2785.109 Mobile/14A456 Safari/601.1.46"
], ],
Accept_Encoding: ["gzip, deflate"], "Accept-Encoding": ["gzip, deflate"],
Connection: ["keep-alive"], "Connection": ["keep-alive"],
Pragma: "no-cache" "Pragma": "no-cache"
} }
}; };
} }

6
core/root/usr/share/xray/feature/outbound.mjs

@ -4,6 +4,8 @@ import { shadowsocks_outbound } from "../protocol/shadowsocks.mjs";
import { trojan_outbound } from "../protocol/trojan.mjs"; import { trojan_outbound } from "../protocol/trojan.mjs";
import { vless_outbound } from "../protocol/vless.mjs"; import { vless_outbound } from "../protocol/vless.mjs";
import { vmess_outbound } from "../protocol/vmess.mjs"; import { vmess_outbound } from "../protocol/vmess.mjs";
import { http_outbound } from "../protocol/http.mjs";
import { socks_outbound } from "../protocol/socks.mjs";
function override_custom_config_recursive(x, y) { function override_custom_config_recursive(x, y) {
if (type(x) != "object" || type(y) != "object") { if (type(x) != "object" || type(y) != "object") {
@ -25,6 +27,10 @@ function server_outbound_recursive(t, server, tag, config) {
outbound_result = shadowsocks_outbound(server, tag); outbound_result = shadowsocks_outbound(server, tag);
} else if (server["protocol"] == "trojan") { } else if (server["protocol"] == "trojan") {
outbound_result = trojan_outbound(server, tag); outbound_result = trojan_outbound(server, tag);
} else if (server["protocol"] == "http") {
outbound_result = http_outbound(server, tag);
} else if (server["protocol"] == "socks") {
outbound_result = socks_outbound(server, tag);
} }
if (outbound_result == null) { if (outbound_result == null) {
die(`unknown outbound server protocol ${server["protocol"]}`); die(`unknown outbound server protocol ${server["protocol"]}`);

31
core/root/usr/share/xray/protocol/http.mjs

@ -0,0 +1,31 @@
"use strict";
import { stream_settings } from "../common/stream.mjs";
export function http_outbound(server, tag) {
const stream_settings_object = stream_settings(server, "http", tag);
const stream_settings_result = stream_settings_object["stream_settings"];
const dialer_proxy = stream_settings_object["dialer_proxy"];
return {
outbound: {
protocol: "http",
tag: tag,
settings: {
servers: [
{
address: server["server"],
port: int(server["server_port"]),
users: [
{
user: server["username"],
pass: server["password"],
}
]
}
]
},
streamSettings: stream_settings_result
},
dialer_proxy: dialer_proxy
};
};

1
core/root/usr/share/xray/protocol/shadowsocks.mjs

@ -15,6 +15,7 @@ export function shadowsocks_outbound(server, tag) {
{ {
address: server["server"], address: server["server"],
port: int(server["server_port"]), port: int(server["server_port"]),
email: server["username"],
password: server["password"], password: server["password"],
method: server["shadowsocks_security"], method: server["shadowsocks_security"],
uot: server["shadowsocks_udp_over_tcp"] == '1' uot: server["shadowsocks_udp_over_tcp"] == '1'

31
core/root/usr/share/xray/protocol/socks.mjs

@ -0,0 +1,31 @@
"use strict";
import { stream_settings } from "../common/stream.mjs";
export function socks_outbound(server, tag) {
const stream_settings_object = stream_settings(server, "socks", tag);
const stream_settings_result = stream_settings_object["stream_settings"];
const dialer_proxy = stream_settings_object["dialer_proxy"];
return {
outbound: {
protocol: "socks",
tag: tag,
settings: {
servers: [
{
address: server["server"],
port: int(server["server_port"]),
users: [
{
user: server["username"],
pass: server["password"],
}
]
}
]
},
streamSettings: stream_settings_result
},
dialer_proxy: dialer_proxy
};
};

1
core/root/usr/share/xray/protocol/trojan.mjs

@ -22,6 +22,7 @@ export function trojan_outbound(server, tag) {
{ {
address: server["server"], address: server["server"],
port: int(server["server_port"]), port: int(server["server_port"]),
email: server["username"],
password: server["password"] password: server["password"]
} }
] ]

1
core/root/usr/share/xray/protocol/vless.mjs

@ -34,6 +34,7 @@ export function vless_outbound(server, tag) {
port: int(server["server_port"]), port: int(server["server_port"]),
users: [ users: [
{ {
email: server["username"],
id: server["password"], id: server["password"],
flow: flow, flow: flow,
encryption: server["vless_encryption"] encryption: server["vless_encryption"]

1
core/root/usr/share/xray/protocol/vmess.mjs

@ -17,6 +17,7 @@ export function vmess_outbound(server, tag) {
port: int(server["server_port"]), port: int(server["server_port"]),
users: [ users: [
{ {
email: server["username"],
id: server["password"], id: server["password"],
alterId: int(server["alter_id"]), alterId: int(server["alter_id"]),
security: server["vmess_security"] security: server["vmess_security"]

5
core/root/www/luci-static/resources/view/xray/core.js

@ -184,7 +184,10 @@ return view.extend({
o.datatype = 'port'; o.datatype = 'port';
o.rmempty = false; o.rmempty = false;
o = ss.taboption('general', form.Value, 'password', _('UserId / Password'), _('Fill user_id for vmess / VLESS, or password for shadowsocks / trojan (also supports <a href="https://github.com/XTLS/Xray-core/issues/158">Xray UUID Mapping</a>)')); o = ss.taboption('general', form.Value, 'username', _('Email / Username'), _('Optional; username for SOCKS / HTTP outbound, email for other outbound.'));
o.modalonly = true;
o = ss.taboption('general', form.Value, 'password', _('UserId / Password'), _('Fill user_id for vmess / VLESS, or password for other outbound (also supports <a href="https://github.com/XTLS/Xray-core/issues/158">Xray UUID Mapping</a>)'));
o.modalonly = true; o.modalonly = true;
o.rmempty = false; o.rmempty = false;

12
core/root/www/luci-static/resources/view/xray/protocol.js

@ -223,6 +223,16 @@ function vless_client(protocol, sub_section, tab_name) {
add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "vless", true, false); add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "vless", true, false);
} }
function socks_client(protocol, sub_section, tab_name) {
protocol.value("socks", "SOCKS");
add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "socks", false, false);
}
function http_client(protocol, sub_section, tab_name) {
protocol.value("http", "HTTP");
add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "http", false, false);
}
function vless_server(protocol, section, tab_name) { function vless_server(protocol, section, tab_name) {
protocol.value("vless", "VLESS"); protocol.value("vless", "VLESS");
add_flow_and_stream_security_conf(section, tab_name, "web_server_protocol", "vless", true, true); add_flow_and_stream_security_conf(section, tab_name, "web_server_protocol", "vless", true, true);
@ -244,6 +254,8 @@ return baseclass.extend({
vless_client(protocol, sub_section, tab_name); vless_client(protocol, sub_section, tab_name);
trojan_client(protocol, sub_section, tab_name); trojan_client(protocol, sub_section, tab_name);
shadowsocks_client(protocol, sub_section, tab_name); shadowsocks_client(protocol, sub_section, tab_name);
http_client(protocol, sub_section, tab_name);
socks_client(protocol, sub_section, tab_name);
}, },
add_server_protocol: function (protocol, section, tab_name) { add_server_protocol: function (protocol, section, tab_name) {
vless_server(protocol, section, tab_name); vless_server(protocol, section, tab_name);

2
status/Makefile

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

Loading…
Cancel
Save