-t でollama検出
This commit is contained in:
parent
d11c152767
commit
7520f17a8e
1 changed files with 39 additions and 8 deletions
47
ipf
47
ipf
|
|
@ -85,7 +85,8 @@ init_nft() {
|
||||||
|
|
||||||
test_connection() {
|
test_connection() {
|
||||||
local host=$1; local port=$2; local info=""
|
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')
|
local banner=$(timeout 0.5s nc -w 1 "$host" "$port" 2>/dev/null | head -n 1 | tr -d '\000-\031')
|
||||||
if [[ -n "$banner" ]]; then
|
if [[ -n "$banner" ]]; then
|
||||||
case "$banner" in
|
case "$banner" in
|
||||||
|
|
@ -97,21 +98,51 @@ test_connection() {
|
||||||
esac
|
esac
|
||||||
echo -e "\e[32mUP\e[0m${info}"; return 0
|
echo -e "\e[32mUP\e[0m${info}"; return 0
|
||||||
fi
|
fi
|
||||||
# HTTP/HTTPS Check
|
|
||||||
|
# B. HTTP/HTTPS & Ollama Check
|
||||||
if nc -z -w 1 "$host" "$port" >/dev/null 2>&1; then
|
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
|
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)
|
# Ollama Check (Port 11434 or general HTTP)
|
||||||
[[ "$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)
|
local url="${sch}://${host}:${port}"
|
||||||
if [[ "$res" == "400" ]]; then info=" (HTTPS? 400 Bad Request)"; break
|
local res=$(curl -sLk -m 3 -A "Mozilla/5.0 ipf-tester" "${url}/api/tags" 2>/dev/null)
|
||||||
elif [[ "$res" =~ ^[0-9]+$ && "$res" -ne 000 ]]; then info=" (${sch^^} $res)"; break; fi
|
|
||||||
|
# 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
|
done
|
||||||
echo -e "\e[32mUP\e[0m${info}"; return 0
|
echo -e "\e[32mUP\e[0m${info}"
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
echo -e "\e[31mDOWN\e[0m"; return 1
|
echo -e "\e[31mDOWN\e[0m"; return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
if [[ "$SYSTEM_LANG" == "ja" ]]; then
|
if [[ "$SYSTEM_LANG" == "ja" ]]; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue