Skip to content

Commit 2efed28

Browse files
committed
snapshot
1 parent 9cea20e commit 2efed28

File tree

3 files changed

+141
-5
lines changed

3 files changed

+141
-5
lines changed

hosts/idols-ai/default.nix

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,76 @@ rec {
100100
${pkgs.ntfy-sh}/bin/ntfy publish $ntfy_topic "$MSG"
101101
}
102102
103-
anonymous(){
104-
~/.config/*/scripts/tp_link_script http://192.168.0.1 111111 "$(cat /sys/class/net/wlp0s20f3/address)" "匿名主机" 0
103+
# 获取MAC地址函数
104+
get_mac() {
105+
local interface="wlp0s20f3"
106+
local mac_file="/sys/class/net/$interface/address"
107+
108+
if [[ -f "$mac_file" ]]; then
109+
cat "$mac_file"
110+
return 0
111+
else
112+
echo "Warning: Cannot get MAC address for network interface $interface" >&2
113+
echo "Warning: File $mac_file does not exist" >&2
114+
return 1
115+
fi
116+
}
117+
# 查找tp_link_script函数(严格版本)
118+
find_tp_link_script() {
119+
local script_pattern="$HOME/.config/*/scripts/tp_link_script"
120+
local script_paths=($script_pattern)
121+
local script_path
122+
123+
if [[ ''${#script_paths[@]} -eq 0 ]]; then
124+
echo "Error: No tp_link_script found matching pattern: $script_pattern" >&2
125+
return 1
126+
elif [[ ''${#script_paths[@]} -gt 1 ]]; then
127+
echo "Warning: Multiple tp_link_script files found, using the first one" >&2
128+
for path in "''${script_paths[@]}"; do
129+
echo " Found: $path" >&2
130+
done
131+
fi
132+
133+
script_path="''${script_paths[0]}"
134+
135+
if [[ ! -f "$script_path" ]]; then
136+
echo "Error: tp_link_script not found: $script_path" >&2
137+
return 1
138+
fi
139+
140+
if [[ ! -x "$script_path" ]]; then
141+
echo "Error: tp_link_script is not executable: $script_path" >&2
142+
return 1
143+
fi
144+
145+
echo "$script_path"
146+
return 0
147+
}
148+
149+
# 匿名函数
150+
anonymous() {
151+
local mac_address
152+
local script_path
153+
154+
# 获取MAC地址
155+
mac_address=$(get_mac)
156+
if [[ $? -ne 0 ]] || [[ -z "$mac_address" ]]; then
157+
echo "Error: Failed to get MAC address, aborting execution" >&2
158+
return 1
159+
fi
160+
161+
# 查找tp_link_script
162+
script_path=$(find_tp_link_script)
163+
if [[ $? -ne 0 ]] || [[ -z "$script_path" ]]; then
164+
echo "Error: Cannot find tp_link_script, aborting execution" >&2
165+
return 1
166+
fi
167+
168+
echo "Info: Using script: $script_path"
169+
echo "Info: MAC address: $mac_address"
170+
171+
# 执行命令
172+
"$script_path" "http://192.168.0.1" "111111" "$mac_address" "Anonymous Host" "0"
105173
}
106174
107175
case "$STATUS" in

hosts/wsl-r9000p2025/default.nix

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,76 @@ rec {
9898
${pkgs.ntfy-sh}/bin/ntfy publish $ntfy_topic "$MSG"
9999
}
100100
101-
anonymous(){
102-
~/.config/*/scripts/tp_link_script http://192.168.0.1 111111 "$(cat /sys/class/net/wlp0s20f3/address)" "匿名主机" 0
101+
# 获取MAC地址函数
102+
get_mac() {
103+
local interface="wlp0s20f3"
104+
local mac_file="/sys/class/net/$interface/address"
105+
106+
if [[ -f "$mac_file" ]]; then
107+
cat "$mac_file"
108+
return 0
109+
else
110+
echo "Warning: Cannot get MAC address for network interface $interface" >&2
111+
echo "Warning: File $mac_file does not exist" >&2
112+
return 1
113+
fi
114+
}
115+
# 查找tp_link_script函数(严格版本)
116+
find_tp_link_script() {
117+
local script_pattern="$HOME/.config/*/scripts/tp_link_script"
118+
local script_paths=($script_pattern)
119+
local script_path
120+
121+
if [[ ''${#script_paths[@]} -eq 0 ]]; then
122+
echo "Error: No tp_link_script found matching pattern: $script_pattern" >&2
123+
return 1
124+
elif [[ ''${#script_paths[@]} -gt 1 ]]; then
125+
echo "Warning: Multiple tp_link_script files found, using the first one" >&2
126+
for path in "''${script_paths[@]}"; do
127+
echo " Found: $path" >&2
128+
done
129+
fi
130+
131+
script_path="''${script_paths[0]}"
132+
133+
if [[ ! -f "$script_path" ]]; then
134+
echo "Error: tp_link_script not found: $script_path" >&2
135+
return 1
136+
fi
137+
138+
if [[ ! -x "$script_path" ]]; then
139+
echo "Error: tp_link_script is not executable: $script_path" >&2
140+
return 1
141+
fi
142+
143+
echo "$script_path"
144+
return 0
145+
}
146+
147+
# 匿名函数
148+
anonymous() {
149+
local mac_address
150+
local script_path
151+
152+
# 获取MAC地址
153+
mac_address=$(get_mac)
154+
if [[ $? -ne 0 ]] || [[ -z "$mac_address" ]]; then
155+
echo "Error: Failed to get MAC address, aborting execution" >&2
156+
return 1
157+
fi
158+
159+
# 查找tp_link_script
160+
script_path=$(find_tp_link_script)
161+
if [[ $? -ne 0 ]] || [[ -z "$script_path" ]]; then
162+
echo "Error: Cannot find tp_link_script, aborting execution" >&2
163+
return 1
164+
fi
165+
166+
echo "Info: Using script: $script_path"
167+
echo "Info: MAC address: $mac_address"
168+
169+
# 执行命令
170+
"$script_path" "http://192.168.0.1" "111111" "$mac_address" "Anonymous Host" "0"
103171
}
104172
105173
case "$STATUS" in

modules/nixos/desktop/networking/clash-verge.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
serviceMode = true;
1212
tunMode = true;
1313
# default value is clash-verge-rev
14-
package = pkgs-stable.clash-verge-rev;
14+
package = pkgs-latest.clash-verge-rev;
1515
};
1616
}

0 commit comments

Comments
 (0)