u
This commit is contained in:
parent
c22b8d6b73
commit
dcf554806b
@ -1,7 +1,10 @@
|
||||
// 使用Node.js实现Shell脚本逻辑:获取公网IP并检查是否以.172结尾
|
||||
const https = require('https')
|
||||
const { execFileSync } = require('child_process')
|
||||
|
||||
//https.get('https://api.ipify.org', (res) => {
|
||||
// `curl -s https://ifconfig.me` returns the IP address only, but open the url in browser or https.get() returns the HTML content
|
||||
// `https://api.ipify.org` returns the IP address only with curl, browser or nodejs. But it seems it doesn't work in China.
|
||||
|
||||
// https.get 没有同步版本,使用 child_process.execFileSync 同步获取公网 IP
|
||||
let ip
|
||||
try {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user