use curl not nslookup
This commit is contained in:
parent
2a70ca0b28
commit
766b2bd007
12
vim/.vimrc
12
vim/.vimrc
@ -3,20 +3,20 @@
|
||||
" License : MIT
|
||||
" Author : Feng Bohan <1953356163@qq.com>
|
||||
" Date : 2025-04-18 08:39:57
|
||||
" Last Modified Date: 2025-04-21 16:47:19
|
||||
" Last Modified Date: 2025-04-22 10:19:39
|
||||
" Last Modified By : Feng Bohan <1953356163@qq.com>
|
||||
" Copyright © 2025 Shanghai Fudan Microelectronics Group Co.,Ltd. All Rights Reserved.
|
||||
|
||||
" 环境检测
|
||||
function! IsAtCompany()
|
||||
" 检查 baidu.com 是否能解析
|
||||
let l:cmd = 'nslookup baidu.com >/dev/null 2>&1'
|
||||
let l:cmd = 'curl -s -o /dev/null -m 2 -w "%{http_code}" https://baidu.com'
|
||||
let l:http_code = system(l:cmd)
|
||||
|
||||
" 执行命令,返回 0 表示解析成功(不在公司),非 0 表示解析失败(在公司)
|
||||
if system(l:cmd) == 0
|
||||
return 0 " 能解析,不在公司
|
||||
else
|
||||
if match(l:http_code, '^[23][0-9][0-9]$') == -1
|
||||
return 1 " 不能解析,在公司
|
||||
else
|
||||
return 0 " 能解析,不在公司
|
||||
endif
|
||||
endfunction
|
||||
" 只在 Vim 启动时检测一次
|
||||
|
Loading…
x
Reference in New Issue
Block a user