@shopai/dns
v1.0.11
Published
CLI tool overwrite DNS local - redirect domain thành domain khác qua /etc/hosts, kèm Web UI quản lý
Readme
@shopai/dns
Chuyển hướng API request từ domain AI về api.shopaikey.com qua DNS local.
Mua API key giá rẻ tại shopaikey.com
api.openai.com → api.shopaikey.com
api.anthropic.com → api.shopaikey.com
generativelanguage.googleapis.com → api.shopaikey.com
api.deepseek.com → api.shopaikey.comCài đặt Node.js
Dùng nvm (khuyên dùng)
macOS / Linux:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
# hoặc
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bashSau đó đóng mở lại terminal (hoặc source ~/.zshrc / source ~/.bashrc), rồi:
nvm install --lts
node -vWindows:
Tải và chạy nvm-setup.exe từ nvm-windows, sau đó mở Command Prompt (CMD) (dùng PowerShell cần chạy Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser trước):
nvm install lts
nvm use lts
node -vmacOS
# Cách 1: Homebrew
brew install node
# Cách 2: Tải từ trang chủ
# https://nodejs.org (chọn bản LTS)Windows
Tải và cài bản LTS từ https://nodejs.org
Hoặc dùng Winget:
winget install OpenJS.NodeJS.LTSLinux
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Hoặc dùng nvm (khuyên dùng)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install --ltsKiểm tra đã cài xong:
node -v # >= 18
npm -vChạy ngay với npx
# macOS / Linux
sudo npx --yes @shopai/dns
# Windows (chạy PowerShell/CMD với quyền Administrator)
npx --yes @shopai/dnsWeb UI sẽ tự mở tại http://localhost:3000.
Tuỳ chọn cổng
sudo npx --yes @shopai/dns --web-port 8080 --proxy-port 9443Các bước sử dụng
- Cài đặt chứng chỉ — Nhấn nút "Cài đặt Chứng chỉ" trên Web UI
- Bật DNS Overwrite — Gạt toggle sang ON
- Done! Các request đến 3 domain trên sẽ được chuyển hướng
Để tắt: gạt toggle sang OFF. Để gỡ chứng chỉ: nhấn "Gỡ Chứng chỉ".
Cài đặt global (tuỳ chọn)
npm install -g @shopai/dns
# Sau đó chạy
sudo shopai-dnsGỡ cài đặt
npm uninstall -g @shopai/dnsCách hoạt động
- Ghi domain →
127.0.0.1vào hosts file (/etc/hostshoặcC:\Windows\System32\drivers\etc\hosts) - Chạy HTTPS proxy server trên port 443, forward request đến
api.shopaikey.com - Tự sinh chứng chỉ SSL cho từng domain, ký bởi Root CA nội bộ
- Web UI để bật/tắt và quản lý chứng chỉ
Yêu cầu
- Node.js >= 18
- Quyền Administrator (Windows) / sudo (macOS, Linux)
