V10.425 add 111 Ollama usage guard
All checks were successful
CD Pipeline / deploy (push) Successful in 1m6s

This commit is contained in:
OoO
2026-05-24 15:44:01 +08:00
committed by AiderHeal Bot
parent 868d75f972
commit 0208c014d2
8 changed files with 171 additions and 5 deletions

View File

@@ -16,7 +16,7 @@ INSTALL_SCRIPT_PATH="${INSTALL_DIR}/ollama111_allow_proxy.py"
PYTHON_BIN="${PYTHON_BIN:-/usr/bin/python3}"
OLLAMA_APP="${OLLAMA_APP:-/Applications/Ollama.app}"
OLLAMA_HOST_VALUE="${OLLAMA_HOST_VALUE:-127.0.0.1:11434}"
ALLOWED_CIDRS="${OLLAMA111_PROXY_ALLOWED_CIDRS:-127.0.0.1/32,192.168.0.80/32,192.168.0.111/32,192.168.0.188/32}"
ALLOWED_CIDRS="${OLLAMA111_PROXY_ALLOWED_CIDRS:-127.0.0.1/32,192.168.0.111/32,192.168.0.188/32}"
GUI_DOMAIN="gui/$(id -u)"
if [[ ! -f "${PROJECT_DIR}/scripts/ops/ollama111_allow_proxy.py" ]]; then

View File

@@ -15,7 +15,7 @@ import ipaddress
import logging
import os
import signal
from typing import Iterable
import sys
LISTEN_HOST = os.getenv("OLLAMA111_PROXY_LISTEN_HOST", "192.168.0.111")
@@ -26,7 +26,7 @@ ALLOWED_CIDRS = tuple(
item.strip()
for item in os.getenv(
"OLLAMA111_PROXY_ALLOWED_CIDRS",
"127.0.0.1/32,192.168.0.80/32,192.168.0.111/32,192.168.0.188/32",
"127.0.0.1/32,192.168.0.111/32,192.168.0.188/32",
).split(",")
if item.strip()
)
@@ -93,6 +93,7 @@ async def _main() -> None:
logging.basicConfig(
level=os.getenv("OLLAMA111_PROXY_LOG_LEVEL", "INFO"),
format="%(asctime)s %(levelname)s %(message)s",
stream=sys.stdout,
)
server = await asyncio.start_server(_handle_client, LISTEN_HOST, LISTEN_PORT)
sockets = ", ".join(str(sock.getsockname()) for sock in (server.sockets or []))