Skip to content

Commit

Permalink
sync (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan168 authored Jun 18, 2024
2 parents f773dc5 + 6d8e55f commit a5fa67a
Show file tree
Hide file tree
Showing 21 changed files with 327 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1003,8 +1003,8 @@ function wizard_add()
ucic:set("xray","omrout","s_vless_reality_user_security","chacha20-poly1305")
ucic:set("xray","omrout","s_trojan_user_security","chacha20-poly1305")
ucic:set("xray","omrout","s_socks_user_security","chacha20-poly1305")
ucic:set("xray","omrout","s_shadowsocks_method","2022-blake3-chacha20-poly1305")
--ucic:set("xray","omrout","s_shadowsocks_method","2022-blake3-aes-256-gcm")
--ucic:set("xray","omrout","s_shadowsocks_method","2022-blake3-chacha20-poly1305")
ucic:set("xray","omrout","s_shadowsocks_method","2022-blake3-aes-256-gcm")
--ucic:set("shadowsocks-rust","sss0","method","2022-blake3-chacha20-poly1305")
--ucic:set("shadowsocks-rust","sss1","method","2022-blake3-chacha20-poly1305")
ucic:set("shadowsocks-rust","sss0","method","2022-blake3-aes-256-gcm")
Expand Down
5 changes: 5 additions & 0 deletions modemmanager/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define Package/modemmanager
+glib2 \
+dbus \
+ppp \
+lua-cjson \
+MODEMMANAGER_WITH_MBIM:libmbim \
+MODEMMANAGER_WITH_QMI:libqmi \
+MODEMMANAGER_WITH_QRTR:libqrtr-glib
Expand Down Expand Up @@ -95,6 +96,10 @@ define Package/modemmanager/install
$(INSTALL_BIN) ./files/usr/sbin/ModemManager-wrapper $(1)/usr/sbin
$(INSTALL_BIN) ./files/usr/sbin/ModemManager-monitor $(1)/usr/sbin

$(INSTALL_DIR) $(1)/usr/libexec/rpcd
$(INSTALL_BIN) ./files/usr/libexec/rpcd/modemmanager \
$(1)/usr/libexec/rpcd/

$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mmcli $(1)/usr/bin

Expand Down
2 changes: 1 addition & 1 deletion modemmanager/files/etc/init.d/modemmanager
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2016 Aleksander Morgado <[email protected]>

USE_PROCD=1
START=11
START=05

LOG_LEVEL="INFO"

Expand Down
13 changes: 11 additions & 2 deletions modemmanager/files/lib/netifd/proto/modemmanager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,17 @@ proto_modemmanager_teardown() {
mmcli --modem="${device}" --simple-disconnect ||
proto_notify_error "${interface}" DISCONNECT_FAILED

# disable
mmcli --modem="${device}" --disable
# reading variable from var state which was set in
# '/usr/lib/ModemManager/connection.d/10-report-down'
# because of a reconnect event.
# The modem therefore does not need to be disabled.
local disable="$(uci_get_state network "$interface" disable_modem "1")"
if [ "${disable}" -eq 0 ]; then
echo "Skipping modem disable"
uci_revert_state network "${interface}" disable_modem
else
mmcli --modem="${device}" --disable
fi

# low power, only if requested
[ "${lowpower:-0}" -lt 1 ] ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ IFUP=$(ifstatus "${CFG}" | jsonfilter -e "@.up")

[ "${IFUP}" = "true" ] && {
mm_log "info" "Reconnecting '${CFG}' on '${STATE}' event"

uci_toggle_state network "${CFG}" disable_modem "0"
ubus call network.interface down "{ 'interface': '${CFG}'}"
ubus call network.interface up "{ 'interface': '${CFG}'}"
}
Expand Down
216 changes: 216 additions & 0 deletions modemmanager/files/usr/libexec/rpcd/modemmanager
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
#!/usr/bin/env lua

local json = require "cjson"

local status = {}
local bearers = {}
local sim = {}
local signal = {}
local location = {}

local info = {}

function mm_get_modem_bearer(index)

local command = string.format("/usr/bin/mmcli --bearer=%s --output-json 2>/dev/null", index)

local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

local ok, status = pcall(function()
return json.decode(string.format(output))
end)

if not ok then
return
end

table.insert(bearers, status["bearer"])
end

function mm_get_modem_sim(index)

local command = string.format("/usr/bin/mmcli --sim=%s --output-json 2>/dev/null", index)

local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

local ok, status = pcall(function()
return json.decode(string.format(output))
end)

if not ok then
return
end

sim = status["sim"]
end

function mm_get_modem_signal(modem)

local command = string.format("/usr/bin/mmcli --modem=%s --signal-get --output-json 2>/dev/null", modem)

local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

local ok, status = pcall(function()
return json.decode(string.format(output))
end)

if ok == false then
return
end

signal = status["modem"]["signal"]
end

function mm_get_modem_location(modem)

local command = string.format("/usr/bin/mmcli --modem=%s --location-get --output-json 2>/dev/null", modem)

local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

local ok, status = pcall(function()
return json.decode(string.format(output))
end)

if ok == false then
return
end

location = status["modem"]["location"]
end

function mm_get_modem_status(modem)

local command = string.format("/usr/bin/mmcli --modem=%s --output-json 2>/dev/null", modem)

local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

local ok, mstatus = pcall(function()
return json.decode(string.format(output))
end)

if ok == false then
return
end

if mstatus["modem"]["generic"]["bearers"] ~= nil then
bearers = {}
for k, v in ipairs(mstatus["modem"]["generic"]["bearers"]) do
mm_get_modem_bearer(v)
end
if (next(bearers) ~= nil) then
mstatus["modem"]["generic"]["bearers"] = bearers
end
end

if mstatus["modem"]["generic"]["sim"] ~= "--" then
sim = {}
mm_get_modem_sim(mstatus["modem"]["generic"]["sim"])
if (next(sim) ~= nil) then
mstatus["modem"]["generic"]["sim"] = sim
end
else
mstatus["modem"]["generic"]["sim"] = {}
end

signal = {}
mm_get_modem_signal(modem)
if (next(signal) ~= nil) then
mstatus["modem"]["signal"] = signal
else
mstatus["modem"]["signal"] = {}
end

location = {}
mm_get_modem_location(modem)
if (next(location) ~= nil) then
mstatus["modem"]["location"] = location
else
mstatus["modem"]["location"] = {}
end

mstatus["modem"]["device"] = mstatus["modem"]["generic"]["device"]

table.insert(status["modem"], mstatus["modem"])
end

function aquire_data_modemmanager()

local command = string.format("/usr/bin/mmcli --list-modems --output-json 2>/dev/null")

local handle = io.popen(command)
local output = handle:read("*a")
handle:close()

local ok, modems = pcall(function()
return json.decode(output)
end)

if not ok then
return
end

entry_cache = {}
status = {}
status["modem"] = {}
for k, v in ipairs(modems["modem-list"]) do
mm_get_modem_status(modems["modem-list"][k])
end
end

function aquire_data_info()
aquire_data_modemmanager()

-- check if modemmanger is available and is using a modem
if status['modem'] == nil then
return
end

info['modem'] = {}

for k, v in ipairs(status['modem']) do
local element = {}

element['imei'] = status['modem'][k]['3gpp']['imei']
element['signal'] = status['modem'][k]['generic']['signal-quality']['value']
element['technology'] = status['modem'][k]['generic']['access-technologies'][1]
if status['modem'][k]['3gpp']['operator-name'] ~= '--' then
element['operator'] = status['modem'][k]['3gpp']['operator-name']
end
if status['modem'][k]['generic']['sim']['properties'] ~= nil then
element['iccid'] = status['modem'][k]['generic']['sim']['properties']['iccid']
element['imsi'] = status['modem'][k]['generic']['sim']['properties']['imsi']
end
element['device'] = status['modem'][k]['device']

table.insert(info['modem'], element)
end
end

function main(cmd, call)
if cmd == "list" then
print(json.encode({
dump = {},
info = {}
}))
elseif cmd == "call" then
if call == "dump" then
aquire_data_modemmanager()
print(json.encode(status))
elseif call == "info" then
aquire_data_info()
print(json.encode(info))
end
end
end

main(arg[1], arg[2])
2 changes: 1 addition & 1 deletion mptcp-bpf-burst/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define Package/mptcp-bpf-burst
SECTION:=net
CATEGORY:=Network
TITLE:=MPTCP BPF Burst Scheduler
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS)
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS) @!LINUX_5_4
endef

define Build/Prepare
Expand Down
2 changes: 1 addition & 1 deletion mptcp-bpf-first/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define Package/mptcp-bpf-first
SECTION:=net
CATEGORY:=Network
TITLE:=MPTCP BPF First Scheduler
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS)
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS) @!LINUX_5_4
endef

TARGET_CFLAGS += \
Expand Down
2 changes: 1 addition & 1 deletion mptcp-bpf-red/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define Package/mptcp-bpf-red
SECTION:=net
CATEGORY:=Network
TITLE:=MPTCP BPF Redundant Scheduler
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS)
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS) @!LINUX_5_4
endef

define Build/Prepare
Expand Down
2 changes: 1 addition & 1 deletion mptcp-bpf-rr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define Package/mptcp-bpf-rr
SECTION:=net
CATEGORY:=Network
TITLE:=MPTCP BPF RoundRobin Scheduler
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS)
DEPENDS:=+libbpf +kmod-sched-core +kmod-sched-flower +kmod-sched-bpf $(BPF_DEPENDS) @!LINUX_5_4
endef

define Build/Prepare
Expand Down
Loading

0 comments on commit a5fa67a

Please sign in to comment.