Celerity:基于地理位置的服务器重定向
请自行承担责任使用(尚未投入生产环境)
简介
此插件允许玩家根据其地理位置连接到最近的服务器。只需输入 myserver.com,玩家即可自动被重定向到距离最近的服务器,无需通过代理转发连接。
示例场景:
Server A (east.myserver.com) 位于纽约。
Server B (west.myserver.com) 位于洛杉矶。
通过 myserver.com 连接的玩家将根据地理距离被重定向至 Server A 或 Server B。
路线图
该项目仍在开发中,以下是基本待办事项列表:
- 设置缓存过期系统。
- 允许旧版本客户端通过连接。
- 添加更多 API 选项。
- 支持在本地存储 IP 历史记录。SQLite?
如果您想提供帮助,请查看 GitHub!
安装
将其放入主代理服务器的 Velocity plugins 文件夹中,然后确保所有下游服务器已配置为接受带有传输数据包的玩家。
它将生成如下 config.toml 配置文件:
[settings]
# 如果用户使用以下域名连接,则不执行传输跳转
no_transfer_domains = ["east.myserver.com", "est.myserver.com"]
debug = false # 启用以获取调试消息。你懂的
[settings.api]
enabled = true # 禁用此项将阻止用户使用 API。
provider = "ipgeolocation" # 目前仅支持 ipgeolocation (https://ipgeolocation.io/),请前往该网站获取 API 密钥
key = "somekeyyouget" # 如果不需要密钥,设置为 None
[settings.db_cache]
enabled = true # 是否使用数据库缓存功能
cache_ip = true # 在数据库中保存 IP
cache_username = true # 在数据库中保存用户名(可能会降低准确性)
cache_expire = 730 # 缓存条目过期的时间(小时)(0 表示禁用过期)
[db] ## 用于缓存的数据库配置
address = "120.0.0.1:12345"
database = "fundatabase"
table_prefix = "cel_"
username = "username"
password = "password"
[servers] ## 服务器配置部分
[servers.easternserver]
ip = "east.myserver.net"
port = 25565
latitude = 40.7128 # 示例:纽约市的纬度
longitude = -74.0060 # 示例:纽约市的经度
[servers.westernserver]
ip = "123.45.68.79"
port = 42069
latitude = 34.0522 # 示例:洛杉矶的纬度
longitude = -118.2437 # 示例:洛杉矶的经度
构建
您应该能够使用 Java 21 和 Maven 构建此插件。
Celerity: Geo-Based Server Redirection
USE AT YOUR OWN RISK (NOT IN PRODUCTION)
About
This plugin allows players to connect to the closest server based on their geographic location. By simply entering myserver.com, players are automatically redirected to the nearest server without the need for proxying their connection.
Example Scenario:
Server A (east.myserver.com) located in New York.
Server B (west.myserver.com) located in Los Angeles.
Players who connect through myserver.com will be redirected to either Server A or Server B, depending on which is geographically closer.
Road Map
This is a work in progress but here is a basic roadmap for what needs to be done:
- Set up the cache expiry system.
- Allow clients with old versions to connect through.
- Add more API options
- Allow IP history to be stored locally. SQLite?
If you would like to help out, check out the github!
Installing
Drop it into the velocity plugins folder of your main proxy server, then make sure all downstream server are configured to accept players with transfer packets.
It will then make a config.toml like such:
[settings]
# List of domains where no transfer should occur if the user connects using these
no_transfer_domains = ["east.myserver.com", "est.myserver.com"]
debug = false # Enable to get debug messages. You know the drill
[settings.api]
enabled = true # Disabling this will stop use from using the api.
provider = "ipgeolocation" # Right now only ipgeolocation (https://ipgeolocation.io/) is supported, go there to make an api key
key = "somekeyyouget" # If no key is needed, set to None
[settings.db_cache]
enabled = true # Whether to use the database caching feature
cache_ip = true # Save IPs in the database
cache_username = true # Save usernames in the database (may decrease accuracy)
cache_expire = 730 # Hours until a cached entry expires (0 disables expiration)
[db] ## Database Configuration for Cache
address = "120.0.0.1:12345"
database = "fundatabase"
table_prefix = "cel_"
username = "username"
password = "password"
[servers] ## Server Configuration section
[servers.easternserver]
ip = "east.myserver.net"
port = 25565
latitude = 40.7128 # Example: Latitude of New York City
longitude = -74.0060 # Example: Longitude of New York City
[servers.westernserver]
ip = "123.45.68.79"
port = 42069
latitude = 34.0522 # Example: Latitude of Los Angeles
longitude = -118.2437 # Example: Longitude of Los Angeles
Building
You should be able to build this plugin with Maven, using Java 21.
评论 0
登录后参与评分
还没有评论,来抢沙发吧