Velocity
Velocity是次世代Minecraft服务器代理,致力于增强的服务器支持与可拓展性,同时保持灵活性。
官方网站:https://www.velocitypowered.com/
本文参考了官方文档:https://docs.velocitypowered.com/en/latest/index.html
以及Sponge论坛的帖子:https://forums.spongepowered.org ... necraft-proxy/25426
现在的进度如何
截止2018年九月8日,Velocity功能已经完全实现,并在Paper,Sponge以及Minecraft Forge上进行过测试。Velocity尚未经历过严格的测试,并且我们现在也不建议在大型网络(群组)中使用。对于测试环境以及小网络,Velocity已经准备好了,虽然还有某些地方没有打磨好。不要忘记Velocity才诞生不到1个月。
等一下,为什么需要另一种代理
既然已经有BungeeCord了,为什么还需要另一种代理。
I was the founder of the Waterfall project. I’m sure most of you are familiar with Waterfall given that it is the best-supported proxy for Sponge and Forge at the moment. If you’re unfamiliar, Waterfall is a fork of BungeeCord that adds many new features and enhancements, notably enhanced support for Forge.
I left the Waterfall project in 2017 (but was inactive before then). Since then, I realized that BungeeCord’s design has numerous flaws that can only be solved by a total rewrite.
But technical concerns were not the only factors driving the decision to create Velocity. md_5, the author of BungeeCord, has been extremely hostile to Forge mod support, and has indicated he plans to not support Forge beyond Minecraft 1.13. The Velocity project, on the other hand, wishes to encourage the growth of modded Minecraft, and plans to support Forge for Minecraft 1.13 and above.
大体翻译一下就是:作者是Waterfall项目的创始人,曾经的开发经历使他意识到,通过修改BC能达到的能力是有限的。Velocity项目会在今后对mod提供更好的支持。
开始
安装Java
Velocity也是Java的如果你没有安装java的话,你现在需要安装一份。如何安装Java不在本文范围内。
下载Velocity
你需要首先下载Velocity。访问https://www.velocitypowered.com/downloads,并且下载最新的版本的proxy。之后你可以使用 `java -jar velocity-proxy-1.0-SNAPSHOT-all.jar` 运行这个Jar。
配置你的服务器
运行一次Velocity之后,我们可以继续来配置与Velocity搭配使用的你的服务器了。现在我们只进行基础的设置。
打开 `velocity.toml` 找到 `[servers]` 部分。这部分看起来是这样的
- [servers]
- lobby = "127.0.0.1:30066"
- factions = "127.0.0.1:30067"
- minigames = "127.0.0.1:30068"
把你的服务器填进去,之后重启Velocity。完成之后,你需要编辑你每个子服的 `server.properties` 。
并且将 `online-mode` 设置为 `false` (与BC相同)。这样才能允许Velocity连接到你的服务器。完成之后重启服务器,这样Velocity就已经可以使用了。
配置Velocity
Velocity设计被为简单并且设置明晰。
配置文件
Velocity主要的配置位于文件`velocity.toml`。这个文件会被创建在你开启代理的文件夹中。
配置文件格式
Velocity自身的配置使用`TOML <https://github.com/toml-lang/toml>`格式。
TOML的设计易于理解,所以你应该不会有太多困难理解Velocity的配置文件。
根部分
这里的设置包括了大部分Velocity最基本,最基础的设置。
设置名 | 类型 | 默认值 | 描述 |
bind | Address 地址 | 0.0.0.0:25577 | 告诉代理接收哪个Ip上的连接。默认会监听这个电脑的所有IP的25577端口的连接 |
motd | Chat 消息 | &3A Velocity Server | 这里允许你修改玩家服务器列表上显示的消息,你可以使用样式代码或者JSON文本。 |
show-max-players | Integer 整数 | 500 | 这里允许你自定义玩家服务器列表中显示的“最大”玩家数。注意Velocity并没有支持的最大玩家数的限制 |
player-info-forwarding | Mode 模式 | modern | 这里允许你自定义,通过什么样的方式将玩家的信息(如UUID,和IP传递给你的子服,详见“玩家信息传递” |
player-info-forwarding-secret | String 字符串 | 5up3r53cr3t | 玩家信息传递的密钥,详见“玩家信息传递” |
announce-forge | Boolean 布尔值 | false | 这里设置Velocity是否应当声明自己是一个支持Forge/FML的服务器,默认关闭 |
server部分
设置名 | 类型 | 默认值 | 描述 |
一个服务器的名字 | Address | 参考下面的默认设置 | 这里让代理知道都可以连接哪些服务器 |
try | Array 数组 | ["lobby"] | 这里指定在玩家登入,或者被服务器踢出时,Velocity将会尝试(按顺序)连接哪些服务器 |
advanced部分
设置名 | 类型 | 默认值 | 描述 |
compression-threshold | Integer | 1024 | This is the minimum size (in bytes) that a packet has to be before the proxy compresses it. Minecraft uses 256 bytes by default. Velocity uses a higher value for efficiency. |
compression-level | Integer | -1 | This setting indicates what zlib compression level the proxy should use to compress packets. The default value uses the default zlib level, which is dependent on the zlib version. This number goes from 0 to 9, where 0 means no compression and 9 indicates maximum compression. |
login-ratelimit | Integer | 3000 | This setting determines the minimum amount of time (in milliseconds) that must pass before a connection from the same IP address will be accepted by the proxy. A value of 0 disables the rate limit. |
query部分
设置名 | 类型 | 默认值 | 描述 |
enabled | Boolean | false | Velocity是否需要回应GameSpy4的查询请求,你通常可以设置这里为false |
port | Number | 25577 | 监听GameSpy4的端口 |
默认配置文件
- # What port should the proxy be bound to? By default, we'll bind to all addresses on port 25577.
- bind = "0.0.0.0:25577"
- # What should be the MOTD? Legacy color codes and JSON are accepted.
- motd = "&3A Velocity Server"
- # What should we display for the maximum number of players? (Velocity does not support a cap
- # on the number of players online.)
- show-max-players = 500
- # Should we authenticate players with Mojang? By default, this is on.
- online-mode = true
- # Should we forward IP addresses and other data to backend servers?
- # Available options:
- # - "none": No forwarding will be done. All players will appear to be connecting from the proxy
- # and will have offline-mode UUIDs.
- # - "legacy": Forward player IPs and UUIDs in BungeeCord-compatible fashion. Use this if you run
- # servers using Minecraft 1.12 or lower.
- # - "modern": Forward player IPs and UUIDs as part of the login process using Velocity's native
- # forwarding. Only applicable for Minecraft 1.13 or higher.
- player-info-forwarding = "modern"
- # If you are using modern IP forwarding, configure an unique secret here.
- player-info-forwarding-secret = "5up3r53cr3t"
- # Announce whether or not your server supports Forge/FML. If you run a modded server, we suggest turning this on.
- announce-forge = false
- [servers]
- # Configure your servers here.
- lobby = "127.0.0.1:30066"
- factions = "127.0.0.1:30067"
- minigames = "127.0.0.1:30068"
- # In what order we should try servers when a player logs in or is kicked from a server.
- try = [
- "lobby"
- ]
- [advanced]
- # How large a Minecraft packet has to be before we compress it. Setting this to zero will compress all packets, and
- # setting it to -1 will disable compression entirely.
- compression-threshold = 1024
- # How much compression should be done (from 0-9). The default is -1, which uses zlib's default level of 6.
- compression-level = -1
- # How fast (in miliseconds) are clients allowed to connect after the last connection? Default: 3000
- # Disable by setting to 0
- login-ratelimit = 3000
- [query]
- # Whether to enable responding to GameSpy 4 query responses or not
- enabled = false
- # If query responding is enabled, on what port should query response listener listen on?
- port = 25577
配置玩家信息传递
Velocity 支持传递你的玩家的信息给你的服务器,例如IP地址与UUID和皮肤信息。
Velocity支持两种不同的方式传递玩家信息:
- ``modern`` 是Velocity原生的格式,通过高效的二进制格式传递所有玩家的信息,并且保证
没有人能够通过模仿你的Velocity代理来混入你的服务器。然而他只能在Minecraft1.13以上使用。 - ``legacy`` 使用BungeeCord的协议传递玩家的信息,可以在Velocity支持的所有Minecraft版本中可用,
但是需要通过正确的设置防火墙,或者Ip白名单插件,来防止其他人假装是你的代理。
配置 modern forwarding
目前,还没有一个服务器实现Velocity的modern forwarding的支持
配置 legacy BungeeCord-compatible forwarding
如果你需要使用legacy BungeeCord-compatible forwarding,设置你的``velocity.toml``中的``player-info-forwarding``
为``legacy``。你还需要配置你的服务器,使其理解数据。
注意:: BunggeCord的协议允许任何人假装他们是你的代理,并且使用任意用户名或IP登陆,你必须确保你的防火墙设置正确,
或者使用类似`[url=https://www.spigotmc.org/resources/ipwhitelist.61/%5Dhttps://www.spigotmc.org/resources/ipwhitelist.61/]IPWhitelist[/url]`的插件来保护你的服务器。
Spigot / Paper
使Spigot或者Paper理解Velocity传递的数据只需设置``spigot.yml``中的``settings.bungeecord``为``true`` ,然后重启服务器.
Sponge
配置 Sponge理解Velocity传递的数据只需设置``config/sponge/global.conf``文件中的 ``modules.bungeecord``为``true``以及``bungeecord.ip-forwarding``为``true`` ,然后重启你的Sponge服务器。