Compare commits
2 commits
935aba1228
...
4109595fe3
| Author | SHA1 | Date | |
|---|---|---|---|
| 4109595fe3 | |||
| 7520f17a8e |
1 changed files with 39 additions and 8 deletions
47
ipf
47
ipf
|
|
@ -85,7 +85,8 @@ init_nft() {
|
|||
|
||||
test_connection() {
|
||||
local host=$1; local port=$2; local info=""
|
||||
# Protocol Banner Check
|
||||
|
||||
# A. Protocol Banner Check (SSH, FTP, etc.)
|
||||
local banner=$(timeout 0.5s nc -w 1 "$host" "$port" 2>/dev/null | head -n 1 | tr -d '\000-\031')
|
||||
if [[ -n "$banner" ]]; then
|
||||
case "$banner" in
|
||||
|
|
@ -97,21 +98,51 @@ test_connection() {
|
|||
esac
|
||||
echo -e "\e[32mUP\e[0m${info}"; return 0
|
||||
fi
|
||||
# HTTP/HTTPS Check
|
||||
|
||||
# B. HTTP/HTTPS & Ollama Check
|
||||
if nc -z -w 1 "$host" "$port" >/dev/null 2>&1; then
|
||||
local schemas=("http" "https"); [[ "$port" == "443" ]] && schemas=("https" "http")
|
||||
local schemas=("http" "https")
|
||||
[[ "$port" == "443" ]] && schemas=("https" "http")
|
||||
|
||||
for sch in "${schemas[@]}"; do
|
||||
local res=$(curl -IsLk -m 2 -A "Mozilla/5.0 ipf-tester" -o /dev/null -w "%{http_code}" "${sch}://${host}:${port}/" 2>/dev/null)
|
||||
[[ "$res" == "000" ]] && res=$(curl -sLk -m 2 -A "Mozilla/5.0 ipf-tester" -o /dev/null -w "%{http_code}" "${sch}://${host}:${port}/" 2>/dev/null)
|
||||
if [[ "$res" == "400" ]]; then info=" (HTTPS? 400 Bad Request)"; break
|
||||
elif [[ "$res" =~ ^[0-9]+$ && "$res" -ne 000 ]]; then info=" (${sch^^} $res)"; break; fi
|
||||
# Ollama Check (Port 11434 or general HTTP)
|
||||
local url="${sch}://${host}:${port}"
|
||||
local res=$(curl -sLk -m 3 -A "Mozilla/5.0 ipf-tester" "${url}/api/tags" 2>/dev/null)
|
||||
|
||||
# Ollama API 判定 (JSONに "models" が含まれているか)
|
||||
if [[ "$res" == *"models"* ]]; then
|
||||
info=" (Ollama API)"
|
||||
echo -e "\e[32mUP\e[0m${info}"
|
||||
|
||||
# "__" を含むモデル名の抽出
|
||||
local hidden_models=$(echo "$res" | grep -oP '"name":"[^"]*__[^"]*"' | cut -d'"' -f4)
|
||||
if [[ -n "$hidden_models" ]]; then
|
||||
echo -e " \e[35m[!] Hidden Models Found:\e[0m"
|
||||
while read -r m; do
|
||||
echo -e " - $m"
|
||||
done <<< "$hidden_models"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
# 通常のHTTP/HTTPSステータス判定
|
||||
local code=$(curl -IsLk -m 2 -o /dev/null -w "%{http_code}" "${url}/" 2>/dev/null)
|
||||
[[ "$code" == "000" ]] && code=$(curl -sLk -m 2 -o /dev/null -w "%{http_code}" "${url}/" 2>/dev/null)
|
||||
|
||||
if [[ "$code" == "400" ]]; then
|
||||
info=" (HTTPS? 400 Bad Request)"; break
|
||||
elif [[ "$code" =~ ^[0-9]+$ && "$code" -ne 000 ]]; then
|
||||
info=" (${sch^^} $code)"; break
|
||||
fi
|
||||
done
|
||||
echo -e "\e[32mUP\e[0m${info}"; return 0
|
||||
echo -e "\e[32mUP\e[0m${info}"
|
||||
return 0
|
||||
else
|
||||
echo -e "\e[31mDOWN\e[0m"; return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
show_help() {
|
||||
if [[ "$SYSTEM_LANG" == "ja" ]]; then
|
||||
cat << EOF
|
||||
|
|
|
|||
Loading…
Reference in a new issue