Skip to content

Commit

Permalink
feat: add username / password for extra socks / http inbound
Browse files Browse the repository at this point in the history
  • Loading branch information
yichya committed Feb 17, 2024
1 parent 1e6ced5 commit 0a2da66
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Fork this repository and:
* 2024-01-19 chore: bump version
* 2024-01-24 feat: add alias to LAN Hosts Access Control
* 2024-02-04 fix: avoid firewall restart failure & some minor adjustments
* 2024-02-17 feat: add DNS Hijacking (preview)
* 2024-02-16 feat: dns hijacking preview; deprecate global http / socks inbound
* 2024-02-17 feat: add username / password for extra socks / http inbound

## Changelog since 3.2.0

Expand Down
4 changes: 2 additions & 2 deletions core/root/usr/share/xray/feature/extra_inbound.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export function extra_inbounds(proxy, extra_inbound) {
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));
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));
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") {
Expand Down
27 changes: 25 additions & 2 deletions core/root/usr/share/xray/feature/inbound.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,48 @@ export function dokodemo_inbound(listen, port, tag, sniffing, sniffing_route_onl
return result;
};

export function http_inbound(addr, port, tag) {
export function http_inbound(addr, port, tag, username, password) {
let accounts = null;
if (username && password) {
accounts = [
{
"user": username,
"pass": password
}
];
}
return {
listen: addr || "0.0.0.0",
port: port,
protocol: "http",
tag: tag,
settings: {
accounts: accounts,
allowTransparent: false
}
};
};

export function socks_inbound(addr, port, tag) {
export function socks_inbound(addr, port, tag, username, password) {
let auth = "noauth";
let accounts = null;
if (username && password) {
auth = "password";
accounts = [
{
"user": username,
"pass": password
}
];
}
return {
listen: addr || "0.0.0.0",
port: port,
protocol: "socks",
tag: tag,
settings: {
auth: auth,
accounts: accounts,
udp: true
}
};
Expand Down
12 changes: 11 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 @@ -284,7 +284,17 @@ return view.extend({
inbound_type.value("tproxy_udp", _("Transparent Proxy (UDP)"));
inbound_type.rmempty = false;

let specify_outbound = extra_inbounds.option(form.Flag, 'specify_outbound', _('Specify Outbound'), _('If not selected, this inbound will use global settings (including sniffing settings). '));
let inbound_username = extra_inbounds.option(form.Value, "inbound_username", _("Username (Optional)"));
inbound_username.depends("inbound_type", "socks5");
inbound_username.depends("inbound_type", "http");
inbound_username.modalonly = true;

let inbound_password = extra_inbounds.option(form.Value, "inbound_password", _("Password (Optional)"));
inbound_password.depends("inbound_type", "socks5");
inbound_password.depends("inbound_type", "http");
inbound_password.modalonly = true;

let specify_outbound = extra_inbounds.option(form.Flag, 'specify_outbound', _('Specify Outbound'), _('If not selected, this inbound will use global settings (including sniffing settings).'));
specify_outbound.modalonly = true;

let destination = extra_inbounds.option(form.MultiValue, 'destination', _('Destination'), _("Select multiple outbounds for load balancing. If none selected, requests will be sent via direct outbound."));
Expand Down

0 comments on commit 0a2da66

Please sign in to comment.