
Engrok
Engrok 是一款专为专用服务器设计的服务端模组,它会在服务器启动时自动开启 Ngrok 隧道。该模组集成了 GitHub Gists 功能,可将 Ngrok 隧道的 IP 地址上传至一个 GitHub Gist(可以是已有的 Gist 或新建的,具体取决于模组的配置——如果不存在已有的 Gist,则会自动创建一个新的并保存到配置文件中)。用户可以直接从 Gist 中获取 IP 地址,或者在客户端使用 Ever Changing 模组来自动为他们检索 IP。
使用方法
要让模组生成可供修改的配置文件,你需要先在加载了该模组的情况下运行服务器。然后确保停止服务器,进入 "config" 文件夹,并使用文本编辑器打开 "engrok.json5" 文件。
初始配置可能如下所示:
{
"enabled": true,
"ngrokAuthToken": "",
"regionSelect": "AUTO",
"gitHubAuthToken": "",
"gistId": ""
}
配置文件
- Enabled:顾名思义。用于控制模组。
- Ngrok Auth Token:如果你希望模组自动打开 Ngrok 隧道,则需要提供你的 Ngrok 身份验证令牌(Authentication Token),你可以从 Ngrok 网站仪表板 获取。你需要拥有一个 Ngrok 账户才能获取身份验证令牌。
- Region Select:Ngrok 能够根据与你相对延迟最低的情况自动选择隧道位置,因此建议将其保留在默认值。否则,你可以从 此列表 中进行选择。
- GitHub Auth Token:为了方便你的朋友自动更新隧道地址,我集成了一项 GitHub 功能:它会在下一个字段中创建一个新的 Gist 并保存其 ID,或者编辑该字段中已有的 Gist。要获取 GitHub 身份验证令牌,你需要确保已登录 GitHub,然后点击右上角的个人资料头像,进入
Settings » Developer Settings » Personal access tokens » Tokens (classic),点击 Generate new token,然后选择 Generate new token (classic)。将 Expiration 设置为 No expiration(或更短的有效期,视你需求而定),并在 Select scopes 列表中勾选/启用 gist,然后点击 Generate Token。请务必复制该令牌,因为如果不复制,你将需要重新生成一个新令牌,然后再将其复制到配置文件中。
- Gist ID:如果你已经创建了一个 gist,可以将此 ID 更改为 gist 的 ID,以便模组每次打开隧道时编辑该 gist。(如何查找 gist ID:以这个 gist 链接为例 。你可以复制最后一个斜杠之后的部分作为你的 ID,在此例中即为 3bef909cddbfbb117f0bcf101222a5dc)。
游戏内命令
/engrok
此命令本质上用于操作配置文件。如果在使用这些命令时不附带参数,将会清空配置中的对应项并留下一个空白字符串 ""。
/engrok setNgrokAuth <token> - 在配置文件中设置 Ngrok 身份验证令牌。
/engrok setGitHubAuth <token> - 在配置文件中设置 GitHub 身份验证令牌。
/engrok setGistId <id> - 在配置文件中设置 Gist ID。
/tunnel
此命令用于控制 Ngrok 隧道。
/tunnel open - 如果隧道已关闭,则打开它
/tunnel close - 如果隧道已打开,则关闭它。
/tunnel status - 告知你隧道是打开还是关闭状态,并在其处于打开状态时显示其 IP 地址。
/gist
显示与 gist 相关的数据。
/gist getIp - 提供你在在线 gist 中看到的隧道 IP,以确保其与使用 /tunnel status 可见的实际隧道地址一致。
/gist getUrl - 提供 gist 的 URL,你可以将其分享给朋友,以便他们与 Ever Changing 模组配合使用(更多详情即将公布),从而在每次 IP 更改时自动获取新的 IP。
本模组灵感来源于 Alujjdnd 制作的 Ngrok LAN,并且本模组的大部分代码源自 Ngrok LAN。
请注意,本模组仅耗时约 12 小时制作,因此可能无法完美运行,但我已尽力修补所有问题,请勿故意破坏游戏内容。

Engrok
Engrok is a server-side mod for dedicated servers which opens an Ngrok tunnel automatically once the server starts. There's an integration for GitHub Gists which uploads the Ngrok tunnel IP to a GitHub Gist (an existing one or a new one, depending on the mod's config - if there isn't an existing one, a new one will be created and saved to the config file automatically) so users can either retreive the IP from the Gist directly, or, using the mod Ever Changing on their clients to automatically retrieve it for them.
How to use
For the mod to create a config file you can modify you need to run the server with the mod loaded first. Then make sure to stop the server, then head to the folder "config" and open the file "engrok.json5" with a text editor.
The config'll probably look like this at the beginning:
{
"enabled": true,
"ngrokAuthToken": "",
"regionSelect": "AUTO",
"gitHubAuthToken": "",
"gistId": ""
}
Config File
- Enabled: Self explanatory. Controls the mod.
- Ngrok Auth Token: If you want the mod to do automatically open an Ngrok tunnel, you'll have to provide it your Ngrok Authentication Token, which you can get from the Ngrok Website Dashboard. You need an Ngrok account in order to acquire an auth token.
- Region Select: Ngrok is capable of automatically selecting the tunnel location with the least amount of latency relative to you, so you should probably leave it at its default value. Otherwise, you can choose from this list.
- GitHub Auth Token: In case you want to automatically update the tunnel's address for your friends, I have made a GitHub integration which either makes a new Gist and saves its ID in the next field, or edits the existing gist in the following field. To get a GitHub Authentication Token, you'll need to make sure you're logged into GitHub, then press your profile picture on the top right, head into
Settings » Developer Settings » Personal access tokens » Tokens (classic) and press Generate new token, then Generate new token (classic). Then set Expiration to No expiration (or shorter, if you'd like), and under the Select scopes list make sure gist is ticked/enabled, then press Generate Token. Make sure to copy the token, because you'll need to regenerate a new one if you don't, then copy it into the config file.
- Gist ID: If you have already made a gist, you can change this ID to the gist's ID to have the mod edit it everytime the tunnel is opened (How to find a gist ID: Let's take this gist link for example . You can copy the part after the last slash to have your ID, in this case it's 3bef909cddbfbb117f0bcf101222a5dc).
In-game Commands
/engrok
This command essentially manipulates the config file. Leaving any of these commands without their parameters will empty the config from them and leave a blank "".
/engrok setNgrokAuth <token> - Sets the Ngrok Authentication Token in the config file.
/engrok setGitHubAuth <token> - Sets the GitHub Authentication Token in the config file.
/engrok setGistId <id> - Sets the Gist ID in the config file.
/tunnel
This command controls the Ngrok tunnel.
/tunnel open - Opens the tunnel if it's closed
/tunnel close - Closes the tunnel if it's open.
/tunnel status - Tells you wether the tunnel is open or close and its IP address if it's open.
/gist
Displays data relating to the gist.
/gist getIp - Provides you with the IP of the tunnel as shown in the gist online, to make sure it is updated to be like the actual tunnel address you can see using /tunnel status.
/gist getUrl - Provides you with the url of the gist, which you can share with friends to use with the Ever Changing mod (More on that soon) to automatically receive the IP every time it changes.
This mod is inspired by Ngrok LAN by Alujjdnd and a big chunk of this mod's code has been taken from Ngrok LAN.
Please keep in mind this mod was made in about 12 hours so it may not work perfectly, but I did my best to patch everything, so please do not try to intentionally break things.
评论 0
登录后参与评分
还没有评论,来抢沙发吧