跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

09-host-dns-setup.sh

33 行 · 1.3 KB历史下载
1#!/bin/sh
2
3# SPDX-FileCopyrightText: Copyright The Lima Authors
4# SPDX-License-Identifier: Apache-2.0
5
6set -eux
7
8readonly chain=LIMADNS
9
10chain_exists() {
11 iptables --table nat -n --list "${chain}" >/dev/null 2>&1
12}
13
14# Wait until iptables has been installed; 35-configure-packages.sh will call this script again
15if command -v iptables >/dev/null 2>&1; then
16 if ! chain_exists; then
17 iptables --table nat --new-chain ${chain}
18 iptables --table nat --insert PREROUTING 1 --jump "${chain}"
19 iptables --table nat --insert OUTPUT 1 --jump "${chain}"
20 fi
21
22 # Remove old rules
23 iptables --table nat --flush ${chain}
24 # Add rules for the existing ip:port
25 if [ -n "${LIMA_CIDATA_UDP_DNS_LOCAL_PORT}" ] && [ "${LIMA_CIDATA_UDP_DNS_LOCAL_PORT}" -ne 0 ]; then
26 iptables --table nat --append "${chain}" --destination "${LIMA_CIDATA_SLIRP_DNS}" --protocol udp --dport 53 --jump DNAT \
27 --to-destination "${LIMA_CIDATA_SLIRP_GATEWAY}:${LIMA_CIDATA_UDP_DNS_LOCAL_PORT}"
28 fi
29 if [ -n "${LIMA_CIDATA_TCP_DNS_LOCAL_PORT}" ] && [ "${LIMA_CIDATA_TCP_DNS_LOCAL_PORT}" -ne 0 ]; then
30 iptables --table nat --append "${chain}" --destination "${LIMA_CIDATA_SLIRP_DNS}" --protocol tcp --dport 53 --jump DNAT \
31 --to-destination "${LIMA_CIDATA_SLIRP_GATEWAY}:${LIMA_CIDATA_TCP_DNS_LOCAL_PORT}"
32 fi
33fi