diff --git a/htdocs/luci-static/resources/view/homeproxy/client.js b/htdocs/luci-static/resources/view/homeproxy/client.js index c9f6ae90..1740e3d9 100644 --- a/htdocs/luci-static/resources/view/homeproxy/client.js +++ b/htdocs/luci-static/resources/view/homeproxy/client.js @@ -254,6 +254,11 @@ return view.extend({ o.default = o.enabled; o.rmempty = false; + o = s.taboption('routing', form.Value, 'clash_api_port', _('Enable Clash API')); + o.value('', _('Disable')); + o.value('9090', _('9090')); + o.datatype = 'port'; + /* Custom routing settings start */ /* Routing settings start */ o = s.taboption('routing', form.SectionValue, '_routing', form.NamedSection, 'routing', 'homeproxy'); diff --git a/root/etc/config/homeproxy b/root/etc/config/homeproxy index e0ccb069..cf5983a1 100644 --- a/root/etc/config/homeproxy +++ b/root/etc/config/homeproxy @@ -23,6 +23,7 @@ config homeproxy 'config' option routing_port 'common' option proxy_mode 'redirect_tproxy' option ipv6_support '1' + option clash_api_port '' config homeproxy 'control' option lan_proxy_mode 'disabled' diff --git a/root/etc/homeproxy/scripts/generate_client.uc b/root/etc/homeproxy/scripts/generate_client.uc index d6301820..ce1a251d 100755 --- a/root/etc/homeproxy/scripts/generate_client.uc +++ b/root/etc/homeproxy/scripts/generate_client.uc @@ -76,6 +76,7 @@ if (routing_mode !== 'custom') { const proxy_mode = uci.get(uciconfig, ucimain, 'proxy_mode') || 'redirect_tproxy', ipv6_support = uci.get(uciconfig, ucimain, 'ipv6_support') || '0', + clash_api_port = uci.get(uciconfig, ucimain, 'clash_api_port'), default_interface = uci.get(uciconfig, ucicontrol, 'bind_interface'); let self_mark, redirect_port, tproxy_port, @@ -550,5 +551,17 @@ if (!isEmpty(main_node)) { } /* Routing rules end */ +/* Experimental start */ +if (!isEmpty(clash_api_port)) { + config.experimental = { + clash_api: { + external_controller: '[::]:'+ clash_api_port, + external_ui: RUN_DIR + '/ui', + store_selected: true + } + } +} +/* Experimental end */ + system('mkdir -p ' + RUN_DIR); writefile(RUN_DIR + '/sing-box-c.json', sprintf('%.J\n', removeBlankAttrs(config))); diff --git a/root/etc/init.d/homeproxy b/root/etc/init.d/homeproxy index 7b13b826..99932cdc 100755 --- a/root/etc/init.d/homeproxy +++ b/root/etc/init.d/homeproxy @@ -155,20 +155,6 @@ start_service() { procd_set_param command "$PROG" procd_append_param command run --config "$RUN_DIR/sing-box-c.json" - if [ -x "/sbin/ujail" ] && [ "$routing_mode" != "custom" ] && ! grep -Eq '"type": "(wireguard|tun)"' "$RUN_DIR/sing-box-c.json"; then - procd_add_jail "sing-box-c" log procfs - procd_add_jail_mount "$RUN_DIR/sing-box-c.json" - procd_add_jail_mount_rw "$RUN_DIR/sing-box-c.log" - procd_add_jail_mount "$HP_DIR/certs/" - procd_add_jail_mount "/etc/ssl/" - procd_add_jail_mount "/etc/localtime" - procd_add_jail_mount "/etc/TZ" - procd_set_param capabilities "/etc/capabilities/homeproxy.json" - procd_set_param no_new_privs 1 - procd_set_param user sing-box - procd_set_param group sing-box - fi - procd_set_param limits core="unlimited" procd_set_param limits nofile="1000000 1000000" procd_set_param stderr 1 @@ -195,15 +181,6 @@ start_service() { procd_append_param command --gfwlist-file "$HP_DIR/resources/gfw_list.txt" [ "$ipv6_support" -eq "1" ] || procd_append_param command --no-ipv6=tC - if [ -x "/sbin/ujail" ]; then - procd_add_jail "chinadns-ng" log - procd_add_jail_mount "$HP_DIR/resources/gfw_list.txt" - procd_set_param capabilities "/etc/capabilities/homeproxy.json" - procd_set_param no_new_privs 1 - procd_set_param user sing-box - procd_set_param group sing-box - fi - procd_set_param limits core="unlimited" procd_set_param limits nofile="1000000 1000000" procd_set_param stderr 1 @@ -231,19 +208,6 @@ start_service() { procd_set_param command "$PROG" procd_append_param command run --config "$RUN_DIR/sing-box-s.json" - if [ -x "/sbin/ujail" ]; then - procd_add_jail "sing-box-s" log procfs - procd_add_jail_mount "$RUN_DIR/sing-box-s.json" - procd_add_jail_mount_rw "$RUN_DIR/sing-box-s.log" - procd_add_jail_mount "$HP_DIR/certs/" - procd_add_jail_mount "/etc/localtime" - procd_add_jail_mount "/etc/TZ" - procd_set_param capabilities "/etc/capabilities/homeproxy.json" - procd_set_param no_new_privs 1 - procd_set_param user sing-box - procd_set_param group sing-box - fi - procd_set_param limits core="unlimited" procd_set_param limits nofile="1000000 1000000" procd_set_param stderr 1 @@ -258,13 +222,6 @@ start_service() { procd_set_param respawn procd_close_instance - # Update permissions for ujail - if [ "$outbound_node" != "nil" ]; then - echo > "$RUN_DIR/sing-box-c.log" - chown sing-box:sing-box "$RUN_DIR/sing-box-c.log" - chown sing-box:sing-box "$RUN_DIR/sing-box-c.json" - chmod 0644 "$HP_DIR/resources/gfw_list.txt" - fi if [ "$server_enabled" = "1" ]; then echo > "$RUN_DIR/sing-box-s.log" chown sing-box:sing-box "$RUN_DIR/sing-box-s.log"