Skip to content

Commit 6aa4691

Browse files
committed
feat: socks / http outbound
1 parent d4722d2 commit 6aa4691

File tree

13 files changed

+103
-9
lines changed

13 files changed

+103
-9
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@ Fork this repository and:
3636
* Wait until actions finish
3737
* Use `opkg -i *` to install both ipks from Releases.
3838

39+
## Changelog since 3.3.0
40+
41+
* 2024-01-19 chore: bump version
42+
3943
## Changelog since 3.2.0
4044

4145
* 2023-12-20 chore: bump version
4246
* 2023-12-22 chore: optimize list folded format; add roundRobin balancer
4347
* 2024-01-04 chore: start later than sysntpd; change firewall include file path
4448
* 2024-01-18 feat: make "Resolve Domain via DNS" available to all outbounds
49+
* 2024-01-19 feat: socks / http outbound
4550

4651
## Changelog since 3.1.0
4752

core/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=luci-app-xray
4-
PKG_VERSION:=3.2.1
4+
PKG_VERSION:=3.3.0
55
PKG_RELEASE:=1
66

77
PKG_LICENSE:=MPLv2
@@ -143,6 +143,8 @@ endif
143143
$(INSTALL_DATA) ./root/usr/share/xray/protocol/trojan.mjs $(1)/usr/share/xray/protocol/trojan.mjs
144144
$(INSTALL_DATA) ./root/usr/share/xray/protocol/vless.mjs $(1)/usr/share/xray/protocol/vless.mjs
145145
$(INSTALL_DATA) ./root/usr/share/xray/protocol/vmess.mjs $(1)/usr/share/xray/protocol/vmess.mjs
146+
$(INSTALL_DATA) ./root/usr/share/xray/protocol/socks.mjs $(1)/usr/share/xray/protocol/socks.mjs
147+
$(INSTALL_DATA) ./root/usr/share/xray/protocol/http.mjs $(1)/usr/share/xray/protocol/http.mjs
146148
endef
147149

148150
$(eval $(call BuildPackage,$(PKG_NAME)))

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ function stream_tcp_fake_http_request(server) {
99
method: "GET",
1010
path: server["http_path"],
1111
headers: {
12-
Host: server["http_host"],
13-
User_Agent: [
14-
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
12+
"Host": server["http_host"],
13+
"User-Agent": [
14+
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36",
1515
"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"
1616
],
17-
Accept_Encoding: ["gzip, deflate"],
18-
Connection: ["keep-alive"],
19-
Pragma: "no-cache"
17+
"Accept-Encoding": ["gzip, deflate"],
18+
"Connection": ["keep-alive"],
19+
"Pragma": "no-cache"
2020
}
2121
};
2222
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { shadowsocks_outbound } from "../protocol/shadowsocks.mjs";
44
import { trojan_outbound } from "../protocol/trojan.mjs";
55
import { vless_outbound } from "../protocol/vless.mjs";
66
import { vmess_outbound } from "../protocol/vmess.mjs";
7+
import { http_outbound } from "../protocol/http.mjs";
8+
import { socks_outbound } from "../protocol/socks.mjs";
79

810
function override_custom_config_recursive(x, y) {
911
if (type(x) != "object" || type(y) != "object") {
@@ -25,6 +27,10 @@ function server_outbound_recursive(t, server, tag, config) {
2527
outbound_result = shadowsocks_outbound(server, tag);
2628
} else if (server["protocol"] == "trojan") {
2729
outbound_result = trojan_outbound(server, tag);
30+
} else if (server["protocol"] == "http") {
31+
outbound_result = http_outbound(server, tag);
32+
} else if (server["protocol"] == "socks") {
33+
outbound_result = socks_outbound(server, tag);
2834
}
2935
if (outbound_result == null) {
3036
die(`unknown outbound server protocol ${server["protocol"]}`);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
3+
import { stream_settings } from "../common/stream.mjs";
4+
5+
export function http_outbound(server, tag) {
6+
const stream_settings_object = stream_settings(server, "http", tag);
7+
const stream_settings_result = stream_settings_object["stream_settings"];
8+
const dialer_proxy = stream_settings_object["dialer_proxy"];
9+
return {
10+
outbound: {
11+
protocol: "http",
12+
tag: tag,
13+
settings: {
14+
servers: [
15+
{
16+
address: server["server"],
17+
port: int(server["server_port"]),
18+
users: [
19+
{
20+
user: server["username"],
21+
pass: server["password"],
22+
}
23+
]
24+
}
25+
]
26+
},
27+
streamSettings: stream_settings_result
28+
},
29+
dialer_proxy: dialer_proxy
30+
};
31+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function shadowsocks_outbound(server, tag) {
1515
{
1616
address: server["server"],
1717
port: int(server["server_port"]),
18+
email: server["username"],
1819
password: server["password"],
1920
method: server["shadowsocks_security"],
2021
uot: server["shadowsocks_udp_over_tcp"] == '1'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"use strict";
2+
3+
import { stream_settings } from "../common/stream.mjs";
4+
5+
export function socks_outbound(server, tag) {
6+
const stream_settings_object = stream_settings(server, "socks", tag);
7+
const stream_settings_result = stream_settings_object["stream_settings"];
8+
const dialer_proxy = stream_settings_object["dialer_proxy"];
9+
return {
10+
outbound: {
11+
protocol: "socks",
12+
tag: tag,
13+
settings: {
14+
servers: [
15+
{
16+
address: server["server"],
17+
port: int(server["server_port"]),
18+
users: [
19+
{
20+
user: server["username"],
21+
pass: server["password"],
22+
}
23+
]
24+
}
25+
]
26+
},
27+
streamSettings: stream_settings_result
28+
},
29+
dialer_proxy: dialer_proxy
30+
};
31+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function trojan_outbound(server, tag) {
2222
{
2323
address: server["server"],
2424
port: int(server["server_port"]),
25+
email: server["username"],
2526
password: server["password"]
2627
}
2728
]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function vless_outbound(server, tag) {
3434
port: int(server["server_port"]),
3535
users: [
3636
{
37+
email: server["username"],
3738
id: server["password"],
3839
flow: flow,
3940
encryption: server["vless_encryption"]

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export function vmess_outbound(server, tag) {
1717
port: int(server["server_port"]),
1818
users: [
1919
{
20+
email: server["username"],
2021
id: server["password"],
2122
alterId: int(server["alter_id"]),
2223
security: server["vmess_security"]

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ return view.extend({
184184
o.datatype = 'port';
185185
o.rmempty = false;
186186

187-
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>)'));
187+
o = ss.taboption('general', form.Value, 'username', _('Email / Username'), _('Optional; username for SOCKS / HTTP outbound, email for other outbound.'));
188+
o.modalonly = true;
189+
190+
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>)'));
188191
o.modalonly = true;
189192
o.rmempty = false;
190193

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ function vless_client(protocol, sub_section, tab_name) {
223223
add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "vless", true, false);
224224
}
225225

226+
function socks_client(protocol, sub_section, tab_name) {
227+
protocol.value("socks", "SOCKS");
228+
add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "socks", false, false);
229+
}
230+
231+
function http_client(protocol, sub_section, tab_name) {
232+
protocol.value("http", "HTTP");
233+
add_flow_and_stream_security_conf(sub_section, tab_name, "protocol", "http", false, false);
234+
}
235+
226236
function vless_server(protocol, section, tab_name) {
227237
protocol.value("vless", "VLESS");
228238
add_flow_and_stream_security_conf(section, tab_name, "web_server_protocol", "vless", true, true);
@@ -244,6 +254,8 @@ return baseclass.extend({
244254
vless_client(protocol, sub_section, tab_name);
245255
trojan_client(protocol, sub_section, tab_name);
246256
shadowsocks_client(protocol, sub_section, tab_name);
257+
http_client(protocol, sub_section, tab_name);
258+
socks_client(protocol, sub_section, tab_name);
247259
},
248260
add_server_protocol: function (protocol, section, tab_name) {
249261
vless_server(protocol, section, tab_name);

status/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include $(TOPDIR)/rules.mk
22

33
PKG_NAME:=luci-app-xray-status
4-
PKG_VERSION:=3.2.1
4+
PKG_VERSION:=3.3.0
55
PKG_RELEASE:=1
66

77
PKG_LICENSE:=MPLv2

0 commit comments

Comments
 (0)