mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 09:03:56 +08:00
🤞 Sync 2026-06-04 01:12:20
This commit is contained in:
1 parent
50ef4176ab
commit
896fe66ef0
10 files changed
+144
-91
No files matched your search
@@ -121,6 +121,7 @@ config routing 'routing'
|
||||
option 'dummy_device' 'momo-dummy'
|
||||
|
||||
config log 'log'
|
||||
option 'clear_at_stop' '1'
|
||||
option 'scheduled_clear' '1'
|
||||
option 'scheduled_clear_cron' '*/5 * * * *'
|
||||
option 'scheduled_clear_size_limit' '1'
|
||||
|
||||
+23
-1
@@ -67,7 +67,9 @@ start_service() {
|
||||
local fast_reload
|
||||
config_get_bool fast_reload "procd" "fast_reload" 0
|
||||
### rlimit
|
||||
local rlimit_address_space_soft rlimit_address_space_hard rlimit_data_soft rlimit_data_hard rlimit_stack_soft rlimit_stack_hard rlimit_nofile_soft rlimit_nofile_hard
|
||||
local rlimit_nproc_soft rlimit_nproc_hard rlimit_address_space_soft rlimit_address_space_hard rlimit_data_soft rlimit_data_hard rlimit_stack_soft rlimit_stack_hard rlimit_nofile_soft rlimit_nofile_hard
|
||||
config_get rlimit_nproc_soft "procd" "rlimit_nproc_soft" "$(ulimit -Su)"
|
||||
config_get rlimit_nproc_hard "procd" "rlimit_nproc_hard" "$(ulimit -Hu)"
|
||||
config_get rlimit_address_space_soft "procd" "rlimit_address_space_soft"
|
||||
config_get rlimit_address_space_hard "procd" "rlimit_address_space_hard"
|
||||
config_get rlimit_data_soft "procd" "rlimit_data_soft"
|
||||
@@ -76,6 +78,10 @@ start_service() {
|
||||
config_get rlimit_stack_hard "procd" "rlimit_stack_hard"
|
||||
config_get rlimit_nofile_soft "procd" "rlimit_nofile_soft" "$(ulimit -Sn)"
|
||||
config_get rlimit_nofile_hard "procd" "rlimit_nofile_hard" "$(ulimit -Hn)"
|
||||
### environment variable
|
||||
local env_go_max_procs env_go_mem_limit
|
||||
config_get env_go_max_procs "procd" "env_go_max_procs"
|
||||
config_get env_go_mem_limit "procd" "env_go_mem_limit"
|
||||
## core config
|
||||
local redirect_inbound_tag tproxy_inbound_tag tun_inbound_tag dns_inbound_tag fake_ip_dns_server_tag
|
||||
config_get redirect_inbound_tag "core" "redirect_inbound_tag"
|
||||
@@ -133,6 +139,8 @@ start_service() {
|
||||
log "Mixin" "Mixin config."
|
||||
ucode -S "$MIXIN_UC"
|
||||
fi
|
||||
# format profile
|
||||
$PROG -c "$RUN_PROFILE_PATH" format -w
|
||||
# check profile
|
||||
if [ "$core_only" = 0 ] && [ "$proxy_enabled" = 1 ]; then
|
||||
log "Profile" "Checking..."
|
||||
@@ -197,11 +205,16 @@ start_service() {
|
||||
fi
|
||||
procd_set_param pidfile "$PID_FILE_PATH"
|
||||
procd_set_param respawn
|
||||
|
||||
procd_append_param limits nproc="${rlimit_nproc_soft} ${rlimit_nproc_hard}"
|
||||
procd_append_param limits as="${rlimit_address_space_soft:-unlimited} ${rlimit_address_space_hard:-unlimited}"
|
||||
procd_append_param limits data="${rlimit_data_soft:-unlimited} ${rlimit_data_hard:-unlimited}"
|
||||
procd_append_param limits stack="${rlimit_stack_soft:-unlimited} ${rlimit_stack_hard:-unlimited}"
|
||||
procd_append_param limits nofile="${rlimit_nofile_soft} ${rlimit_nofile_hard}"
|
||||
|
||||
procd_append_param env GOMAXPROCS="$env_go_max_procs"
|
||||
procd_append_param env GOMEMLIMIT="$env_go_mem_limit"
|
||||
|
||||
procd_close_instance
|
||||
# cron
|
||||
local reload_cron; reload_cron=0
|
||||
@@ -379,11 +392,20 @@ cleanup() {
|
||||
# load config
|
||||
config_load momo
|
||||
# get config
|
||||
## log config
|
||||
local log_clear_at_stop
|
||||
config_get_bool log_clear_at_stop "log" "clear_at_stop" 0
|
||||
## routing config
|
||||
local tproxy_route_table tun_route_table dummy_device
|
||||
config_get tproxy_route_table "routing" "tproxy_route_table" "80"
|
||||
config_get tun_route_table "routing" "tun_route_table" "81"
|
||||
config_get dummy_device "routing" "dummy_device" "momo-dummy"
|
||||
# clear logs if needed
|
||||
if [ "$log_clear_at_stop" = 1 ]; then
|
||||
echo -n > "$APP_LOG_PATH"
|
||||
echo -n > "$CORE_LOG_PATH"
|
||||
log "Log" "Logs are cleared due to clear at stop is enabled."
|
||||
fi
|
||||
# delete routing policy
|
||||
ip -4 rule del table "$tproxy_route_table" > /dev/null 2>&1
|
||||
ip -4 rule del table "$tun_route_table" > /dev/null 2>&1
|
||||
|
||||
@@ -51,6 +51,9 @@ section_mixin=$(uci -q get momo.mixin); [ -z "$section_mixin" ] && {
|
||||
uci set momo.mixin.external_control_ui_download_url='https://github.com/Zephyruso/zashboard/releases/latest/download/dist-cdn-fonts.zip'
|
||||
}
|
||||
|
||||
# since v1.2.1
|
||||
config_clear_at_stop=$(uci -q get momo.log.clear_at_stop); [ -z "$config_clear_at_stop" ] && uci set momo.log.clear_at_stop=1
|
||||
|
||||
# commit
|
||||
uci commit momo
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ table inet momo {
|
||||
}
|
||||
|
||||
{% if (router_proxy): %}
|
||||
{% if (length(dns_hijack_nfproto) > 0): %}
|
||||
chain router_dns_hijack {
|
||||
{% for (let access_control in router_access_control): %}
|
||||
{% if (length(access_control['user']) == 0 && length(access_control['group']) == 0 && length(access_control['cgroup']) == 0): %}
|
||||
@@ -267,6 +268,7 @@ table inet momo {
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if (tcp_mode == 'redirect'): %}
|
||||
chain router_redirect {
|
||||
@@ -360,6 +362,7 @@ table inet momo {
|
||||
{% endif %}
|
||||
|
||||
{% if (lan_proxy): %}
|
||||
{% if (length(dns_hijack_nfproto) > 0): %}
|
||||
chain lan_dns_hijack {
|
||||
{% for (let access_control in lan_access_control): %}
|
||||
{% if (length(access_control['ip']) == 0 && length(access_control['ip6']) == 0 && length(access_control['mac']) == 0): %}
|
||||
@@ -381,6 +384,7 @@ table inet momo {
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if (tcp_mode == 'redirect'): %}
|
||||
chain lan_redirect {
|
||||
|
||||
Reference in new issue
Block a user