Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
M
macos-runtime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭阔
macos-runtime
Commits
53d6062f
Commit
53d6062f
authored
Oct 28, 2026
by
郭阔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: ip-check.sh IP 类型判定(数据中心/住宅/移动/代理);墙审计快照自动归类出口 IP
parent
86cc8a75
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
ip-check.sh
bin/ip-check.sh
+26
-0
wall-audit.sh
bin/wall-audit.sh
+13
-0
No files found.
bin/ip-check.sh
0 → 100755
View file @
53d6062f
#!/bin/bash
# ip-check.sh [ip ...] - 判断出口 IP 类型:数据中心/住宅/移动/代理
# 无参数=检测当前出口 IP。数据来源:ip-api.com(hosting/proxy/mobile 字段)+ ASN 归属。
set
-uo
pipefail
export
PATH
=
"/opt/homebrew/bin:/usr/local/bin:
$PATH
"
ips
=(
"
$@
"
)
if
[
${#
ips
[@]
}
-eq
0
]
;
then
_cur
=
"
$(
curl
-s
--max-time
8 https://api.ipify.org
)
"
||
_cur
=
""
[
-n
"
$_cur
"
]
||
{
echo
"❌ 取当前出口 IP 失败"
;
exit
1
;
}
ips
=(
"
$_cur
"
)
fi
for
ip
in
"
${
ips
[@]
}
"
;
do
j
=
"
$(
curl
-s
--max-time
10
"http://ip-api.com/json/
${
ip
}
?fields=status,country,city,isp,org,as,hosting,proxy,mobile,reverse&lang=zh-CN"
)
"
if
[
"
$(
echo
"
$j
"
| jq
-r
'.status // ""'
2>/dev/null
)
"
!=
"success"
]
;
then
echo
"
$ip
❓ 查询失败:
$(
echo
"
$j
"
|
head
-c
80
)
"
continue
fi
hosting
=
"
$(
echo
"
$j
"
| jq
-r
'.hosting'
)
"
;
proxy
=
"
$(
echo
"
$j
"
| jq
-r
'.proxy'
)
"
;
mobile
=
"
$(
echo
"
$j
"
| jq
-r
'.mobile'
)
"
if
[
"
$hosting
"
=
"true"
]
;
then
kind
=
"🏢 数据中心/主机商"
;
elif
[
"
$mobile
"
=
"true"
]
;
then
kind
=
"📱 移动网络"
;
else
kind
=
"🏠 住宅/家宽"
;
fi
[
"
$proxy
"
=
"true"
]
&&
kind
=
"
$kind
+ 🚩代理标记"
printf
"%s %s
\n
%s | %s | %s | 反查:%s
\n
"
"
$ip
"
"
$kind
"
\
"
$(
echo
"
$j
"
| jq
-r
'.as'
)
"
"
$(
echo
"
$j
"
| jq
-r
'.isp'
)
"
"
$(
echo
"
$j
"
| jq
-r
'.country'
)$(
echo
"
$j
"
| jq
-r
'.city'
|
sed
's/^/·/'
)
"
\
"
$(
echo
"
$j
"
| jq
-r
'.reverse // "-"'
)
"
done
bin/wall-audit.sh
View file @
53d6062f
...
...
@@ -38,6 +38,19 @@ for line in sh("scutil --proxy").splitlines():
k, v = line.split(" : ", 1); proxy[k.strip()] = v.strip()
snap["systemProxy"] = proxy
snap["vpnInterfaces"] = [l.split(":")[0].strip() for l in sh("ifconfig -l").split() if l.startswith("utun")]
ip = snap.get("egressIP", "")
if ip:
import urllib.request
try:
with urllib.request.urlopen(f"http://ip-api.com/json/{ip}?fields=hosting,proxy,mobile,as", timeout=8) as r:
c = json.loads(r.read())
if c.get("hosting"): cls = "数据中心"
elif c.get("mobile"): cls = "移动网络"
else: cls = "住宅"
if c.get("proxy"): cls += "+代理标记"
snap["egressIPClass"] = f"{cls} ({c.get('as','')})"
except Exception:
snap["egressIPClass"] = "判定失败"
json.dump(snap, open(p, "w"), ensure_ascii=False, indent=2)
print(f" 系统代理: HTTP={proxy.get('HTTPEnable','?')} HTTPS={proxy.get('HTTPSEnable','?')} SOCKS={proxy.get('SOCKSEnable','?')}"
+ (f" ({proxy.get('HTTPProxy','')}:{proxy.get('HTTPPort','')})" if proxy.get('HTTPEnable') == '1' else "")
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment