在網頁中顯示伺服器IP、客戶端IP並顯示ping。每次ping將傳送至discord webhook。
- 需要先安裝nodeJS 18以上的版本
- 下載並解壓縮檔案
- 將server.js的 11、12行改掉
const webhookId = '12345678'; //設定webhook ID
const webhookToken = 'abcdefghijk'; //設定webhook token
(webhook ID跟token去哪裡拿? 這裡有webhook範例網址: https://discord.com/api/webhooks/ID/token)
- 安裝套件
npm install
- 打開來即可完成! (
node server.js
) - 如果要放在systemctl裡面的話,這裡是
ping.service
的範例 (放在/etc/systemd/system/ping.service
後systemctl enable ping && systemctl start ping
):
[Unit]
Description=CheapServer Edge PING
[Service]
User=root
WorkingDirectory=/root/edge-ping
LimitNOFILE=4096
ExecStart=/usr/bin/node /root/edge-ping/server.js
Restart=on-failure
StartLimitInterval=180
StartLimitBurst=30
RestartSec=5s
[Install]
WantedBy=multi-user.target
本程式碼部分使用 GPT-4 編寫,這裡要說他比 GPT-3.5 好用多ㄌ