Skip to content

Commit

Permalink
feat: socks / http outbound
Browse files Browse the repository at this point in the history
  • Loading branch information
yichya committed Jan 18, 2024
1 parent d4722d2 commit 6aa4691
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 9 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@ Fork this repository and:
* Wait until actions finish
* 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

* 2023-12-20 chore: bump version
* 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-18 feat: make "Resolve Domain via DNS" available to all outbounds
* 2024-01-19 feat: socks / http outbound

## Changelog since 3.1.0

Expand Down
4 changes: 3 additions & 1 deletion 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.2.1
PKG_VERSION:=3.3.0
PKG_RELEASE:=1

PKG_LICENSE:=MPLv2
Expand Down Expand Up @@ -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/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/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

$(eval $(call BuildPackage,$(PKG_NAME)))
12 changes: 6 additions & 6 deletions core/root/usr/share/xray/common/stream.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ function stream_tcp_fake_http_request(server) {
method: "GET",
path: server["http_path"],
headers: {
Host: server["http_host"],
User_Agent: [
"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36",
"Host": server["http_host"],
"User-Agent": [
"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"
],
Accept_Encoding: ["gzip, deflate"],
Connection: ["keep-alive"],
Pragma: "no-cache"
"Accept-Encoding": ["gzip, deflate"],
"Connection": ["keep-alive"],
"Pragma": "no-cache"
}
};
}
Expand Down
6 changes: 6 additions & 0 deletions core/root/usr/share/xray/feature/outbound.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { shadowsocks_outbound } from "../protocol/shadowsocks.mjs";
import { trojan_outbound } from "../protocol/trojan.mjs";
import { vless_outbound } from "../protocol/vless.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) {
if (type(x) != "object" || type(y) != "object") {
Expand All @@ -25,6 +27,10 @@ function server_outbound_recursive(t, server, tag, config) {
outbound_result = shadowsocks_outbound(server, tag);
} else if (server["protocol"] == "trojan") {
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) {
die(`unknown outbound server protocol ${server["protocol"]}`);
Expand Down
31 changes: 31 additions & 0 deletions core/root/usr/share/xray/protocol/http.mjs
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions core/root/usr/share/xray/protocol/shadowsocks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function shadowsocks_outbound(server, tag) {
{
address: server["server"],
port: int(server["server_port"]),
email: server["username"],
password: server["password"],
method: server["shadowsocks_security"],
uot: server["shadowsocks_udp_over_tcp"] == '1'
Expand Down
31 changes: 31 additions & 0 deletions core/root/usr/share/xray/protocol/socks.mjs
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions core/root/usr/share/xray/protocol/trojan.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function trojan_outbound(server, tag) {
{
address: server["server"],
port: int(server["server_port"]),
email: server["username"],
password: server["password"]
}
]
Expand Down
1 change: 1 addition & 0 deletions core/root/usr/share/xray/protocol/vless.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function vless_outbound(server, tag) {
port: int(server["server_port"]),
users: [
{
email: server["username"],
id: server["password"],
flow: flow,
encryption: server["vless_encryption"]
Expand Down
1 change: 1 addition & 0 deletions core/root/usr/share/xray/protocol/vmess.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export function vmess_outbound(server, tag) {
port: int(server["server_port"]),
users: [
{
email: server["username"],
id: server["password"],
alterId: int(server["alter_id"]),
security: server["vmess_security"]
Expand Down
5 changes: 4 additions & 1 deletion core/root/www/luci-static/resources/view/xray/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ return view.extend({
o.datatype = 'port';
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.rmempty = false;

Expand Down
12 changes: 12 additions & 0 deletions core/root/www/luci-static/resources/view/xray/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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) {
protocol.value("vless", "VLESS");
add_flow_and_stream_security_conf(section, tab_name, "web_server_protocol", "vless", true, true);
Expand All @@ -244,6 +254,8 @@ return baseclass.extend({
vless_client(protocol, sub_section, tab_name);
trojan_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) {
vless_server(protocol, section, tab_name);
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.2.1
PKG_VERSION:=3.3.0
PKG_RELEASE:=1

PKG_LICENSE:=MPLv2
Expand Down

0 comments on commit 6aa4691

Please sign in to comment.