主机名白名单
一个简单而强大的 Velocity 代理插件,用于将服务器访问限制为特定的主机名或 IP 地址。这对于防止直接 IP 连接或强制使用特定域名(例如 play.example.com)非常有用。
为什么这很重要?
恶意行为者可以创建自己的 BungeeCord 或 Velocity 代理,并在玩家不知情的情况下将玩家转发到您的服务器。这使得他们能够执行中间人攻击 (MitM),从而:
- 记录所有命令(包括非正版服务器上的
/login 和 /register 密码)。
- 劫持玩家会话(冒充用户进行游戏)。
- 代表受害者执行命令。
通过强制执行主机名白名单,您可以确保玩家只能通过您的官方域名(例如 uwu.org.ua)连接,从而有效阻止这些恶意的重定向。
像 DonutSMP、2b2t 和 Hypixel 这样的大型服务器也使用类似的安全系统来保护他们的玩家。
功能
- 主机名白名单:仅允许来自指定域或 IP 的连接。
- 通配符支持:轻松将子域名(例如
*.uwu.org.ua)或 IP 范围(例如 192.168.1.*)加入白名单。
- 可自定义的消息:配置被拦截玩家看到的踢出消息。
- 自定义 MOTD:当玩家使用无效主机名 ping 服务器时显示特定的 MOTD。
- Discord Webhook 日志记录:可选地将允许和被阻止的连接记录到 Discord 频道。
安装
- 下载该插件的最新版本。
- 将
.jar 文件放入 Velocity 服务器的 plugins 文件夹中。
- 重启您的代理服务器。
配置
该插件会在 plugins/hostname-whitelist/ 目录下创建一个包含两个文件的配置文件夹:config.yml 和 hostnames.txt。
config.yml
此文件处理插件的一般设置。
# Hostname Whitelist Configuration
# 当玩家使用无效主机名连接时显示的消息
# 占位符:{hostname}
kick-message: "&cUnknown Server: {hostname}\n\n&7Please make sure you are using the correct IP"
# 无效主机名 ping 显示的 MOTD
invalid-motd: "&cInvalid Hostname. Please use the correct IP address."
# 用于记录连接的 Discord Webhook URL
# 留空或设置为 "YOUR_WEBHOOK_URL_HERE" 以禁用
discord-webhook: "YOUR_WEBHOOK_URL_HERE"
# 是否记录允许的连接 (true/false)
log-allowed-connections: false
# 是否记录被拒绝的连接 (true/false)
log-denied-connections: false
hostnames.txt
在此文件中定义允许的主机名或 IP。每行添加一个条目。
示例:
# 允许 uwu.org.ua 的所有子域名
*.uwu.org.ua
# 允许精确匹配的主机名
uwu.org.ua
# 允许特定的 IP 地址
192.168.1.1
# 允许 IP 范围 192.168.1.0-255
192.168.1.*
Discord Webhook
要使用 Discord 日志记录功能:
- 在您的 Discord 服务器中创建一个 Webhook(服务器设置 -> 集成 -> Webhooks)。
- 复制 Webhook URL。
- 将其粘贴到
config.yml 中的 discord-webhook 字段中。
- 根据需要启用
log-allowed-connections 或 log-denied-connections。
许可证
本项目根据 Mozilla Public License 2.0 许可。
Hostname Whitelist
A simple yet powerful Velocity proxy plugin that restricts server access to
specific hostnames or IP addresses. This is useful for preventing direct IP
connections or enforcing the use of specific domains (e.g., play.example.com).
Why is this important?
Malicious actors can create their own BungeeCord or Velocity proxy and forward
players to your server without their knowledge. This allows them to perform a
Man-in-the-Middle (MitM) attack, enabling them to:
- Log all commands (including
/login and /register passwords on non-premium
servers).
- Hijack player sessions (playing as the user).
- Execute commands on behalf of the victim.
By enforcing a hostname whitelist, you ensure that players can ONLY connect via
your official domain (e.g., uwu.org.ua), effectively blocking these malicious
redirects.
Similar security systems are used by major servers like DonutSMP, 2b2t,
and Hypixel to protect their players.
Features
- Hostname Whitelisting: Only allow connections from specified domains or
IPs.
- Wildcard Support: Easily whitelist subdomains (e.g.,
*.uwu.org.ua) or IP
ranges (e.g., 192.168.1.*).
- Customizable Messages: Configure the kick message shown to blocked
players.
- Custom MOTD: Display a specific MOTD for players pinging with an invalid
hostname.
- Discord Webhook Logging: Optionally log allowed and blocked connections to
a Discord channel.
Installation
- Download the latest release of the plugin.
- Place the
.jar file into your Velocity server's plugins folder.
- Restart your proxy server.
Configuration
The plugin creates a configuration folder at plugins/hostname-whitelist/
containing two files: config.yml and hostnames.txt.
config.yml
This file handles the general plugin settings.
# Hostname Whitelist Configuration
# Message shown when player connects with invalid hostname
# Placeholders: {hostname}
kick-message: "&cUnknown Server: {hostname}\n\n&7Please make sure you are using the correct IP"
# MOTD shown for invalid hostname pings
invalid-motd: "&cInvalid Hostname. Please use the correct IP address."
# Discord Webhook URL for logging connections
# Leave empty or set to "YOUR_WEBHOOK_URL_HERE" to disable
discord-webhook: "YOUR_WEBHOOK_URL_HERE"
# Whether to log allowed connections (true/false)
log-allowed-connections: false
# Whether to log denied connections (true/false)
log-denied-connections: false
hostnames.txt
This file is where you define which hostnames or IPs are allowed. You can add
one entry per line.
Examples:
# Allow all subdomains of uwu.org.ua
*.uwu.org.ua
# Allow exact hostname match
uwu.org.ua
# Allow specific IP address
192.168.1.1
# Allow IP range 192.168.1.0-255
192.168.1.*
Discord Webhook
To use the Discord logging feature:
- Create a Webhook in your Discord server (Server Settings -> Integrations ->
Webhooks).
- Copy the Webhook URL.
- Paste it into the
discord-webhook field in config.yml.
- Enable
log-allowed-connections or log-denied-connections as desired.
License
This project is licensed under the Mozilla Public License 2.0
评论 0
登录后参与评分
还没有评论,来抢沙发吧