lolly/docs/config/advanced/stream-udp.conf
xfy 103e8ff0cf feat(geoip): 添加基于国家代码的 GeoIP 访问控制功能
- 新增 GeoIPConfig 配置结构,支持 MaxMind MMDB 数据库
- 实现 GeoIPLookup 查询器,带 LRU 缓存和 TTL 支持
- AccessControl 集成 GeoIP 检查,按国家代码过滤请求
- 支持私有 IP 特殊处理策略 (allow/deny)
- 添加完整的单元测试和配置验证测试
- 新增 stream-udp.conf 示例配置文档

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 16:14:44 +08:00

111 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# Lolly UDP Stream 代理配置示例
# ============================================================
#
# 功能说明:
# - UDP 四层代理DNS、游戏服务器、VoIP 等)
# - 会话管理和超时控制
# - 负载均衡支持
#
# Lolly 对应配置:
# stream:
# - listen: ":53"
# protocol: "udp"
# timeout: 60s # 默认值
# upstream:
# targets:
# - addr: "dns1:53"
# weight: 1
# - addr: "dns2:53"
# weight: 1
# load_balance: "round_robin"
# ============================================================
# ------------------------------------------------------------
# DNS UDP 代理配置示例
# ------------------------------------------------------------
#
# YAML 格式:
stream:
# DNS 服务器代理
- listen: ":53"
protocol: "udp"
timeout: 60s # 会话超时,默认 60 秒
# DNS 请求通常很快,可设置较短如 30s
upstream:
targets:
- addr: "8.8.8.8:53"
weight: 1
- addr: "8.8.4.4:53"
weight: 1
load_balance: "round_robin"
# ------------------------------------------------------------
# 游戏服务器 UDP 代理配置示例
# ------------------------------------------------------------
#
# 游戏服务器需要长会话,建议使用 ip_hash 保持会话一致性
#
stream:
- listen: ":27015"
protocol: "udp"
timeout: 300s # 游戏会话较长,设置 5 分钟超时
upstream:
targets:
- addr: "game1:27015"
weight: 3
- addr: "game2:27015"
weight: 1
load_balance: "ip_hash" # IP Hash 保持会话一致性
# ------------------------------------------------------------
# VoIP SIP UDP 代理配置示例
# ------------------------------------------------------------
#
# VoIP 服务需要稳定连接
#
stream:
- listen: ":5060"
protocol: "udp"
timeout: 180s # VoIP 会话超时 3 分钟
upstream:
targets:
- addr: "sip1:5060"
weight: 1
- addr: "sip2:5060"
weight: 1
load_balance: "least_conn" # 最少连接,均匀分配
# ============================================================
# UDP Stream 配置参数详解
# ============================================================
#
# 1. UDP vs TCP:
# - UDP: 无连接,数据报协议,适合实时应用
# - TCP: 有连接,流协议,适合可靠传输
#
# 2. 会话管理:
# - Lolly 自动管理 UDP 会话
# - 同一客户端 IP 映射到同一后端
# - 会话空闲超时后自动清理
#
# 3. timeout 参数:
# - 默认值: 60 秒 (未配置时使用)
# - DNS: 建议 30-60 秒
# - 游戏服务器: 建议 300 秒 (5 分钟)
# - VoIP: 建议 180 秒 (3 分钟)
# - Syslog: 建议 60 秒
#
# 4. 负载均衡算法:
# - round_robin: 轮询(默认)
# - weighted_round_robin: 加权轮询
# - least_conn: 最少连接
# - ip_hash: IP 哈希推荐游戏服务器、VoIP
#
# 5. 适用场景:
# - DNS 服务器代理
# - 游戏服务器代理 (CS2, Minecraft 等)
# - VoIP 服务代理 (SIP, RTP)
# - 日志收集服务 (Syslog)
# - NTP 时间服务器