SecureRedirect 安装指南
本指南介绍了如何安装和配置 SecureRedirect Paper 插件,以便玩家能够使用传输数据包和 Cookie 从一个服务器(“主服务器”)安全地重定向到另一个服务器(“目标服务器”)。
推荐的 Paper 版本:1.21.11(或支持 Player#transfer 的更高版本)
免责声明!!!除非服务器已设置 SRV 记录(通常仅限自建服务器),否则您必须通过端口连接服务器
1. 安装插件
1.1. 构建或下载 JAR 文件
如果您直接使用此仓库:
- 运行:
gradle build
- 插件 JAR 文件将位于:
build/libs/SecureRedirect-1.0.2.jar
将该 JAR 文件复制到所有参与重定向的 Paper 服务器上。
1.2. 将插件放入每个服务器
对于每个 Paper 服务器(包括主服务器和目标服务器):
- 如果服务器正在运行,请先停止它。
- 将
SecureRedirect-1.0.2.jar 放入 plugins/ 文件夹中。
- 启动服务器一次,以生成
plugins/SecureRedirect/config.yml。
2. 配置主(源)服务器
这是玩家正常加入并运行 /redirect 命令的服务器。
编辑 主 服务器上的 plugins/SecureRedirect/config.yml。
2.1. 基本重定向目标
# 在主服务器上使用 /redirect 时将玩家发送到的位置
target-host: "your-dest-host" # 例如 "hello.exaroton.me"
# 可选。如果省略或无效,默认为 25565。
# target-port: 25565
# 将由 /redirect gen-hash 填充
send-hash: ""
# 主服务器上不需要此项,可以留空
receive-hash: ""
# 玩家可以直连主服务器
require-transfer: false
注意事项:
- 如果您的目标服务器使用默认端口 25565,您可以完全省略
target-port。
- 如果您的目标服务器使用自定义端口(例如
25566),请显式设置:
target-port: 25566
2.2. 来源 ID(可选)
# 此服务器在重定向玩家时使用的标识符
origin-id: "main"
# 在主服务器上,您通常允许来自任何地方的重定向,因此此列表可以保持为空
allowed-origins: []
仅当您希望限制哪些服务器允许重定向进入另一台服务器时,才需要关注 origin-id 和 allowed-origins(请参阅目标服务器配置部分)。
2.3. 生成 send-hash
在 主 服务器的游戏内作为 OP 执行,或在控制台中执行:
/redirect gen-hash
这将:
- 生成一个随机十六进制哈希值。
- 将其保存到
config.yml 中的 send-hash。
- 在聊天/控制台中打印该值。
复制此值;您需要将其粘贴到 目标 服务器的 receive-hash 中。
3. 配置目标服务器
这是玩家被重定向到的服务器。
3.1. 在 server.properties 中启用传输
编辑 目标 服务器上的 server.properties:
accepts-transfers=true
然后完全重启目标服务器。
3.2. 基础 config.yml
在 dest 服务器上编辑 plugins/SecureRedirect/config.yml:
# 仅当 DEST 需要继续重定向玩家时,才需要配置 target-host/target-port。
# 对于简单的双服务器设置,可以保留默认值。
target-host: "127.0.0.1"
# 可选。如果省略或无效,则默认为 25565。
# target-port: 25565
除非希望将玩家传送得更远,否则在 DEST 上可选。
send-hash: ""
重要:必须与 MAIN 的 send-hash 匹配
receive-hash: "<粘贴来自 /redirect gen-hash 的值于 MAIN>"
此服务器在重定向玩家时使用的标识符
origin-id: "dest"
允许哪些源服务器重定向到 DEST。
确保此列表包含 MAIN 的 origin-id。
allowed-origins:
阻止直接加入;仅允许传输
require-transfer: true
kick-no-transfer-message: "您必须通过安全重定向加入此服务器。"
kick-bad-hash-message: "无效或缺失的重定向令牌。"
### 3.3. 编辑后重启
在 DEST 上更改 `config.yml` 后,**重启服务器**(或至少重新加载插件),以便应用新值。
</details>
---
<details>
<summary><strong>4. 使用插件</strong></summary>
### 4.1. 重定向自己
在 **main** 服务器上,作为拥有权限的玩家:
```text
/redirect
这将:
- 从 MAIN 向你的浏览器附加一个包含
<origin-id>:<send-hash> 的 Cookie。
- 使用 Mojang 的传输数据包将你移动到
target-host:target-port。
4.2. 重定向其他玩家
/redirect <player>
权限:
secureredirect.redirect – 对自己使用 /redirect。
secureredirect.redirect.others – 对 <player> 使用 /redirect。
secureredirect.genhash – 使用 /redirect gen-hash。
4.3. 轮换令牌
任何时候你想要更改密钥令牌时:
- 在 MAIN 上运行:
/redirect gen-hash
- 复制新的
send-hash 值。
- 在 DEST 上,将
config.yml 中的 receive-hash 更新为此新值。
- 重启 DEST 以读取新配置。
5. 高级用法:origin-id 和 allowed-origins
插件将重定向令牌编码为:
<origin-id>:<send-hash>
在 DEST 上,当玩家通过传输加入时,插件会执行以下操作:
- 验证
player.isTransferred()。
- 读取并解析 cookie 得到
origin-id 和 hash。
- 检查
hash 是否与 receive-hash 匹配。
- 如果
allowed-origins 非空,则检查 origin-id 是否列在其中。
这允许你限制哪些服务器可以重定向到 DEST。
多源示例设置:
-
MAIN 服务器:
origin-id: "main"
allowed-origins: []
-
LOBBY 服务器:
origin-id: "lobby"
allowed-origins: []
-
DEST 服务器:
origin-id: "dest"
allowed-origins:
- "main"
- "lobby"
现在只有 main 和 lobby 可以向 dest 发送玩家(前提是它们的哈希值也与 receive-hash 匹配)。
6. 故障排除
6.1. 卡在“Transferring to a new server...”
如果客户端一直无法完成传输,且控制台中未显示任何错误:
- 检查 DEST 服务器:
server.properties 中已设置 accepts-transfers=true。
- 服务器必须是 Paper 1.21.x(而非 Spigot 或代理二进制文件)。
- 检查 MAIN 服务器:
target-host 和 target-port 指向正确的 DEST 地址。
- 在运行
/redirect 时观察 DEST 控制台:
- 如果没有出现登录/加入消息,说明客户端未能连接到该服务器(可能是主机/端口限制问题)。
6.2. 直接加入仍然可以在 DEST 上生效
- 确保在 DEST 的
config.yml 中:
require-transfer: true
- 更改配置后重启 DEST 服务器。
- 确保在
/plugins 命令中列出了 SecureRedirect 且状态为启用。
6.3. “Invalid or missing redirect token”
- 确认在 DEST 端:
receive-hash 与 MAIN 端的 send-hash 完全匹配。
- 确认在 DEST 端:
allowed-origins 包含 MAIN 端的 origin-id(或者为空以允许所有来源)。
SecureRedirect Setup Guide
This guide explains how to install and configure the SecureRedirect Paper plugin so players can be securely redirected from one server ("main") to another ("dest") using transfer packets and cookies.
Recommended Paper version: 1.21.11 (or later with Player#transfer support)
DISCLAIMER!!! YOU MUST JOIN THE SERVER WITH A PORT, UNLESS THE SERVER HAS AN SRV SET UP (USUALLY ONLY ON SELF-HOSTED SERVERS)
1. Install the plugin
1.1. Build or download the JAR
If you are using this repo directly:
- Run:
gradle build
- The plugin JAR will be at:
build/libs/SecureRedirect-1.0.2.jar
Copy that JAR to each Paper server that should participate in redirects.
1.2. Drop the plugin into each server
For each Paper server (main and dest):
- Stop the server if it is running.
- Place
SecureRedirect-1.0.2.jar into the plugins/ folder.
- Start the server once so it generates
plugins/SecureRedirect/config.yml.
2. Configure the main (source) server
This is the server where players join normally and run /redirect.
Edit plugins/SecureRedirect/config.yml on the main server.
2.1. Basic redirect target
# Where to send players when using /redirect on MAIN
target-host: "your-dest-host" # e.g. "hello.exaroton.me"
# Optional. If omitted or invalid, defaults to 25565.
# target-port: 25565
# Will be filled by /redirect gen-hash
send-hash: ""
# Not required on MAIN, can be left empty
receive-hash: ""
# Players can join MAIN directly
require-transfer: false
Notes:
- If your destination uses the default port 25565, you can omit
target-port entirely.
- If your destination uses a custom port (e.g.
25566), set it explicitly:
target-port: 25566
2.2. Origin ID (optional)
# Identifier this server uses when redirecting players
origin-id: "main"
# On MAIN you typically allow redirects from anywhere, so this list can stay empty
allowed-origins: []
You only need to care about origin-id and allowed-origins if you want to restrict which servers are allowed to redirect into another server (see the dest config section).
2.3. Generate the send-hash
On the main server, in-game as an OP or from the console:
/redirect gen-hash
This will:
- Generate a random hex hash.
- Save it into
send-hash in config.yml.
- Print the value in chat / console.
Copy this value; you will paste it into the dest server receive-hash.
3. Configure the destination server
This is the server that players are redirected TO.
3.1. Enable transfers in server.properties
Edit server.properties on the dest server:
accepts-transfers=true
Then fully restart the dest server.
3.2. Basic config.yml
Edit plugins/SecureRedirect/config.yml on the dest server:
# target-host/target-port are only needed if DEST will redirect players onward.
# For a simple two-server setup you can leave them as defaults.
target-host: "127.0.0.1"
# Optional. If omitted or invalid, defaults to 25565.
# target-port: 25565
# Optional on DEST unless you want it to send players further.
send-hash: ""
# IMPORTANT: must match MAIN's send-hash
receive-hash: "<paste value from /redirect gen-hash on MAIN>"
# Identifier this server uses when redirecting players
origin-id: "dest"
# Which origin servers are allowed to redirect into DEST.
# Make sure this list contains MAIN's origin-id.
allowed-origins:
- "main"
# Block direct joins; only transfers are allowed
require-transfer: true
kick-no-transfer-message: "You must join this server via secure redirect."
kick-bad-hash-message: "Invalid or missing redirect token."
3.3. Restart after editing
After changing config.yml on DEST, restart the server (or at least reload the plugin) so the new values are applied.
4. Using the plugin
4.1. Redirect yourself
On the main server, as a player with permission:
/redirect
This will:
- Attach a cookie to you containing
<origin-id>:<send-hash> from MAIN.
- Use Mojang's transfer packet to move you to
target-host:target-port.
4.2. Redirect another player
/redirect <player>
Permissions:
secureredirect.redirect – use /redirect on yourself.
secureredirect.redirect.others – use /redirect <player>.
secureredirect.genhash – use /redirect gen-hash.
4.3. Rotating the token
Any time you want to change the secret token:
- On MAIN, run:
/redirect gen-hash
- Copy the new
send-hash value.
- On DEST, update
receive-hash in config.yml to this new value.
- Restart DEST so it reads the new config.
5. Advanced: origin-id and allowed-origins
The plugin encodes the redirect token as:
<origin-id>:<send-hash>
On DEST, when a player joins via transfer, the plugin:
- Verifies
player.isTransferred().
- Reads and parses the cookie into
origin-id and hash.
- Checks that
hash matches receive-hash.
- If
allowed-origins is non-empty, checks that origin-id is listed there.
This lets you restrict which servers are allowed to redirect into DEST.
Example multi-origin setup:
-
MAIN server:
origin-id: "main"
allowed-origins: []
-
LOBBY server:
origin-id: "lobby"
allowed-origins: []
-
DEST server:
origin-id: "dest"
allowed-origins:
- "main"
- "lobby"
Now only main and lobby can send players into dest (provided their hashes also match receive-hash).
6. Troubleshooting
6.1. Stuck on "Transferring to a new server..."
If the client never finishes transferring and no errors appear in the console:
- Check on the DEST server:
accepts-transfers=true is set in server.properties.
- The server is actually Paper 1.21.x (not Spigot or a proxy binary).
- Check on the MAIN server:
target-host and target-port point to the correct DEST address.
- Watch the DEST console while running
/redirect:
- If no login/join messages appear, the client is not reaching that server (host/port/host limitations).
6.2. Direct join still works on DEST
- Ensure on DEST
config.yml:
require-transfer: true
- Restart DEST after changing the config.
- Make sure
SecureRedirect is listed as enabled in /plugins.
6.3. "Invalid or missing redirect token"
- Confirm that on DEST:
receive-hash exactly matches MAIN's send-hash.
- Confirm that on DEST:
allowed-origins contains MAIN's origin-id (or is empty to allow any).
评论 0
登录后参与评分
还没有评论,来抢沙发吧