Skip to content

Commit ddd585f

Browse files
fix: smtp is mistakenly banned.
1 parent 009e631 commit ddd585f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/common/utils/tool_code.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ def init_sandbox_dir():
7373
allow_subprocess = CONFIG.get("SANDBOX_PYTHON_ALLOW_SUBPROCESS", '0')
7474
allow_syscall = CONFIG.get("SANDBOX_PYTHON_ALLOW_SYSCALL", '0')
7575
if banned_hosts:
76-
local_ip = socket.gethostbyname(socket.gethostname())
76+
hostname = socket.gethostname()
77+
local_ip = socket.gethostbyname(hostname)
7778
banned_hosts = f"{banned_hosts},{local_ip}"
79+
banned_hosts = ",".join(s.strip() for s in banned_hosts.split(",") if s.strip() and s.strip().lower() != hostname.lower())
7880
with open(sandbox_conf_file_path, "w") as f:
7981
f.write(f"SANDBOX_PYTHON_BANNED_HOSTS={banned_hosts}\n")
8082
f.write(f"SANDBOX_PYTHON_ALLOW_DL_PATHS={','.join(sorted(set(filter(None, sys.path + _sandbox_python_sys_path + allow_dl_paths.split(',')))))}\n")

0 commit comments

Comments
 (0)