คำสั่ง CLI
คู่มืออ้างอิงคำสั่ง CLI ทั้งหมด
คำสั่ง CLI
คู่มืออ้างอิงคำสั่ง TH-Tunnel CLI ทั้งหมด
ตัวเลือกทั่วไป
| ตัวเลือก | คำอธิบาย |
|---|---|
-v, --version | แสดงหมายเลขเวอร์ชัน |
-h, --help | แสดงข้อมูลช่วยเหลือ |
คำสั่งตั้งค่า
config set-server <url>
ตั้ง URL เซิร์ฟเวอร์ API
tunnel config set-server https://api.your-domain.com
config add-authtoken <token>
บันทึก Token การยืนยันตัวตนอย่างปลอดภัย
tunnel config add-authtoken tht_your_token_here
config show
แสดงการตั้งค่าปัจจุบัน (Token ถูกซ่อน)
tunnel config show
config clear
ลบการตั้งค่าที่บันทึกไว้
tunnel config clear
config nodes
แสดงรายการ Edge Server ที่มี
tunnel config nodes
คำสั่ง Tunnel
http <port>
สร้าง HTTP Tunnel ไปยัง Port ในเครื่อง
tunnel http 3000
tunnel http 8080 --subdomain myapp
tunnel http 3000 --inspect
ตัวเลือก:
| ตัวเลือก | คำอธิบาย |
|---|---|
-s, --subdomain <name> | ขอ Subdomain เฉพาะ |
--inspect | เปิด Web Inspector ที่ http://127.0.0.1:4040 |
--allow-ip <ips...> | อนุญาตเฉพาะ IP ที่ระบุ (รองรับ CIDR เช่น 192.168.1.0/24) |
--deny-ip <ips...> | บล็อก IP ที่ระบุ (รองรับ CIDR) |
-l, --label <key=value> | เพิ่ม Metadata Label |
--log <path> | บันทึก Request ลงไฟล์ |
--log-format <format> | รูปแบบ Log: combined, json, minimal |
ตัวอย่าง:
# Subdomain ที่กำหนดเอง
tunnel http 3000 --subdomain myapp
# พร้อม Inspector
tunnel http 3000 --inspect
# กรอง IP
tunnel http 3000 --allow-ip 192.168.1.0/24
# พร้อม Label
tunnel http 3000 --label env=dev --label project=api
# บันทึก Request
tunnel http 3000 --log ./requests.log --log-format json
tcp <port>
สร้าง TCP Tunnel ไปยัง Port ในเครื่อง
tunnel tcp 3306
tunnel tcp 22 --subdomain ssh-server
file <directory>
ให้บริการไฟล์ Static ผ่าน Tunnel
tunnel file ./public
tunnel file ./dist --subdomain files
การแสดงผล
เมื่อทำงาน CLI จะแสดง:
Account: your@email.com
Forwarding: https://subdomain.domain.com -> http://localhost:3000
Status: ONLINE
Latency: 45ms
Requests: 0
HTTP Requests
─────────────────────────────────────────
GET /api/users 200 45ms
POST /api/login 201 120ms
Keyboard Shortcuts
| ปุ่ม | การดำเนินการ |
|---|---|
Ctrl+C | ปิดอย่างสุภาพ |
q | ออก (เหมือน Ctrl+C) |
ตัวอย่าง
การพัฒนา Local
# เริ่ม Dev Server ของคุณ
npm run dev # รันที่ Port 3000
# ใน Terminal อื่น
tunnel http 3000 --subdomain myapp-dev
ทดสอบ Webhooks
# เปิด Inspector เพื่อดู Webhook ที่เข้ามา
tunnel http 3000 --inspect
# เปิด http://127.0.0.1:4040 เพื่อดู Requests
แชร์ไฟล์
# แชร์โฟลเดอร์
tunnel file ~/Documents/share