I-Want-To-Control-My-Server
或者简称 IWTCMS
一个简单的 Minecraft 模组,允许你连接到服务器并对其进行控制
简易文档结构:
关于客户端
关于 SSL
关于用户
关于 API
客户端
返回顶部
要启动官方客户端,请输入:python iwtcms_client.py --help
你也可以通过浏览器访问服务器的主页面来下载官方客户端
SSL
返回顶部
我不会在这里讲述如何生成证书,只告诉你如何在 IWTCMS 中使用它。言简意赅
在配置文件中,我们有 ssl 部分:
// 其他设置
# 在此处了解更多关于设置 SSL 的信息:https://modrinth.com/mod/i-want-to-control-my-server
ssl {
# 使用 SSL:为嵌入式服务器启用 SSL,客户端必须通过 SSL 连接,否则无法发送/接收任何数据。默认情况下它是禁用的(false),但强烈建议启用(true)并设置 SSL 连接。
use SSL = false // 布尔值
# 自定义证书:如果启用,IWTCMS 将不会生成新证书,而是从 config/iwtcms/keystore.jks 读取证书
custom Sertificate = false // 布尔值
# 实际上我也不懂这玩意儿是干嘛的,但这里必须输入别名。通常用于自定义生成的证书。默认为 "iwtcms"。你可以在此处阅读更多相关信息:https://security.stackexchange.com/questions/123944/what-is-the-purpose-role-of-the-alias-attribute-in-java-keystore-files
ssl Alias = "iwtcms" // 字符串
# sslPass:证书的密码,证书将使用此密码自动生成,或者如果你使用其他证书,它将使用该密码来读取它们。
ssl Pass = "keystorePassword" // 字符串
}
// 其他设置
事实上,注释里已经写了所有内容,但我想要补充几点:
use SSL - 我始终建议启用它,即使你没有生成证书,如果 custom Sertificate 处于禁用状态,IWTCMS 将在每次启动时生成新证书,并且 SSL 应该能正常工作。
顺便一提,如果启用了 use SSL,则完全禁用非 SSL 连接,你无法连接。请使用 https:// 代替 http://,使用 wss:// 代替 ws://
custom Sertificate - 仅禁用证书的自动生成,改为从 config/iwtcms/keystore.jks 读取证书
ssl Alias 和 ssl Pass 必须与生成证书中的别名和密码相匹配
用户
返回顶部
IWTCMS 支持用户配置文件,非常简单但实用
// 其他设置
auth {
# 使用身份验证:为客户端启用密码,客户端在登录前无法向服务器发送/接收消息。默认情况下它是禁用的(false),但强烈建议启用(true)密码功能。
use Authentication = false // 布尔值
# 仅在启用 useAuthentication 时需要
# 在此处配置用户
# 你可以添加自定义用户或删除现有用户
users : [ // 列表
{
# 匿名用户
name : anonymous // 字符串 # 如果你想保留匿名用户的权限,请勿更改此项
# password : anonymous # 无关紧要
permits : {
read real time logs : false // 布尔值
read logs history : false // 布尔值
execute commands : false // 布尔值
}
}
{
# 管理员
name : admin // 字符串
password : iwtcms // 字符串
permits : {
read real time logs : true // 布尔值
read logs history : true // 布尔值
execute commands : true // 布尔值
}
}
{
# 访客
name : guest // 字符串
password : guest // 字符串
permits : {
read real time logs : true // 布尔值
read logs history : false // 布尔值
execute commands : false // 布尔值
}
}
]
}
// 其他设置
配置文件中的 auth 块负责所有身份验证功能
use Authentication - 启用身份验证,如果禁用,任何人都可以连接、监听、发送命令以及执行 IWTCMS 能对服务器做的任何其他操作。
users - 所有用户的列表,对数量没有限制
每个用户都有各自的权限,False 禁止该用户执行操作,True 允许执行操作。
如果未定义任何权限,IWTCMS 将使用匿名用户对应的权限作为类比。
如果不存在匿名用户或未定义匿名权限,则遵循以下模式:未定义? - 禁止
如果用户在没有 Cookie(即未登录)的情况下发出请求,它将使用匿名用户的权限。
如果匿名用户存在密码,IWTCMS 将忽略该密码。
API
返回顶部
API 锚点:
冷知识:IWTCMS 遵循 REST API 规范,酷吧?
| ApiListGET
| LogsHistoryGET
| LoginPOST
| PermitsGET
wss://127.0.0.1/ws/console | WsConsole
静态文件
本部分文档是为希望编写自己客户端的开发者撰写的
另外,如果你编写了一个很酷的客户端,你可以 提交 Issue 来推广它。
如果你的客户端运行良好,你的客户端可以添加到 关于客户端 中作为示例客户端或示例代码。
顺便说一下 2
如果你需要示例
查看 关于客户端 和 官方 IWTCMS CLI 客户端
(使用 Python 编写)
API(我已经厌倦了写这份文档,但我仍然需要为 API 写一整章)
在这里,我将以启用了 SSL 和本地主机端口 25566 (127.0.0.1:25566) 为例,
将 127.0.0.1 替换为你的 IP,将 25566 替换为你的端口,并为相应的协议使用适当的前缀
(参见 关于 SSL)
让我们开始:
如果你想查看所有可用于请求(以及 websocket)的页面,请访问:
https://127.0.0.1/apiList
我建议在你的客户端中找到这些链接,页面名称不太可能更改,
但 URL 可能会更改(抱歉,IWTCMS 仍在开发中)
| 页面名称 |
类型 |
响应类型 |
使用认证 API(需要 Cookie)? |
需要 Body |
| ApiListGET |
GET |
JSON |
No |
No |
如果你想查看自服务器启动以来的所有日志历史记录,请访问:
https://127.0.0.1/api/logsHistory
返回自服务器启动以来的所有日志列表
| 页面名称 |
类型 |
响应类型 |
使用认证 API(需要 Cookie)? |
需要 Body |
| LogsHistoryGET |
GET |
JSON |
Yes |
No |
如果你想登录,请访问:
https://127.0.0.1/api/login
在请求 Body 中放入包含用户名和密码的 JSON,即可登录
Body 示例:
{
"username": "guest",
"password": "guest"
}
| 页面名称 |
类型 |
响应类型 |
使用认证 API(需要 Cookie)? |
需要 Body |
| LoginPOST |
POST |
Plain (登录成功 / 登录失败) |
No (设置 Cookie) |
Yes |
如果你想查看用户的所有权限,请访问:
https://127.0.0.1/api/permits/{username}
将 "{username}" 替换为你想要查询权限的用户名
| 页面名称 |
类型 |
响应类型 |
使用认证 API(需要 Cookie)? |
需要 Body |
| PermitsGET |
GET |
JSON |
No |
No |
如果你想访问服务器控制台,请访问:
wss://127.0.0.1/ws/console
IWTCMS 的主要功能,连接到 websocket 并获取所有日志!
如果你想执行 Minecraft 命令,通过 websocket 向服务器发送纯文本命令,
IWTCMS 将会执行该命令
| 页面名称 |
类型 |
响应类型 |
使用认证 API(需要 Cookie)? |
需要 Body |
| WsConsole |
Websocket |
Websocket 纯文本消息 (日志) |
Yes |
No |
静态文件
由于 IWTCMS 集成了真实的 Ktor Web 服务器,它托管了许多静态文件,以下是它们的列表:
| 文件名 |
路径 |
替代路径 |
文件类型 |
| style.css |
/style.css |
|
css |
| 404.html |
/404.html |
任何未找到的路径 (404) |
html |
| index.html |
/index.html |
/ |
html |
| favicon.ico |
|
|
ico |
| icon_clearbg.png |
/icon_clearbg.png |
|
png |
| iwtcms_client.zip |
/iwtcms_client.zip |
|
zip |
I-Want-To-Control-My-Server
or just IWTCMS
Simple minecraft mod, which allows you to connect to your server and control it
miniDocumentation structure:
About Clients
About SSL
About Users
About Api
Clients
Go to top
To launch an official client, type: python iwtcms_client.py --help
You also can download an official client if you go to the main page of server in the browser
SSL
Go to top
I will not tell you how to generate a certificate here, I will only tell you how to use it with IWTCMS. let's be brief
In the config file, we have ssl section:
// Other settings
# read more about setting ssl here: https://modrinth.com/mod/i-want-to-control-my-server
ssl {
# use SSL: enabling SSL for embedded server, clients must connect with SSL or they can't send/receive any data. By default it's disabled(false) BUT highly recommended to enable(true) it and setup SSL connection.
use SSL = false // boolean
# custom Sertificate: if enabled IWTCMS won't generating new sertificate, instead it reads sertificates from config/iwtcms/keystore.jks
custom Sertificate = false // boolean
# Actually idk what do this shit, but alias must be entered here. Usually you use it for custom generated certificates. By default it's "iwtcms". You can read more here: https://security.stackexchange.com/questions/123944/what-is-the-purpose-role-of-the-alias-attribute-in-java-keystore-files
ssl Alias = "iwtcms" // string
# sslPass: password for certificates, certs will be automaticly generated with this password or if you use any other certificates it will use pass to read it.
ssl Pass = "keystorePassword" // string
}
// Other settings
In fact, everything is already written here in the comments, but I want to add:
use SSL - I always recommend enabling it even if you don't have generated certificate, if custom Sertificate disabled IWTCMS will generate new certificate every launch and SSL should work fine.
Btw if use SSL enabled non ssl connections disabled at all, you cant connect to it.
Use https:// instead of http:// and wss:// instead of ws://
custom Sertificate - Just disables auto generation of certificates and instead in reads certificate from config/iwtcms/keystore.jks
ssl Alias and ssl Pass must match with alias and password in generated certificates
Users
Go to top
IWTCMS supports user profiles, very simple but useful
// Other settings
auth {
# useAuthentication: enabling password for clients, client can't receive/send messages from/to server before login. By default it's disabled(false) BUT highly recommended to enable(true) it password.
use Authentication = false // boolean
# needs ONLY IF useAuthentication enabled
# here you can configure users
# you can add custom users or remove existing
users : [ // list
{
# anonymous
name : anonymous // string # do not change if you wanna keep permits for anonymous
# password : anonymous # doesn't matter
permits : {
read real time logs : false // boolean
read logs history : false // boolean
execute commands : false // boolean
}
}
{
# admin
name : admin // string
password : iwtcms // string
permits : {
read real time logs : true // boolean
read logs history : true // boolean
execute commands : true // boolean
}
}
{
# guest
name : guest // string
password : guest // string
permits : {
read real time logs : true // boolean
read logs history : false // boolean
execute commands : false // boolean
}
}
]
}
// Other settings
The auth block in the config is responsible for all authentications
use Authentication - enables auth, if it disabled anyone can connect, listen, send commands, and any other shit with server with IWTCMS can do.
users - list of all users, there's no limits for users count
Every user has their own permits, False forbids action for user, True allows action.
If any permit is not defined, IWTCMS will use it analog from anonymous user.
If an anonymous user or anonymous permit doesn't exist, then follow this pattern: not defined? - forbidden
If a user does requests without cookies (without logining in), it uses permits from anonymous.
Anonymous didn't need password if his password exists, IWTCMS will ignore this password.
Api
Go to top
Anchors for api:
Fan fact: IWTCMS follows REST API, cool yup?
| ApiListGET
| LogsHistoryGET
| LoginPOST
| PermitsGET
wss://127.0.0.1/ws/console | WsConsole
Static files
This part of documentation written for developers who want to write their OWN client
Btw if written cool client you can open issue for promoting,
if your client works well, your client can be added to About Clients as client or example code
Btw 2
if you need example
of client look to About Clients and Official IWTCMS CLI client
(written on python)
Fucking API (I'm already tired of writing this documentation, but I still need to write a whole chapter about Api)
Here as examples, I will use enabled SSL and localhost with port 25566 (127.0.0.1:25566),
replace 127.0.0.1 with your ip, 25566 with your port and use appropriate prefixes for the appropriate protocols
(see About SSL)
Let's start:
If you want to see all avail pages for requests (and websockets also), go to:
https://127.0.0.1/apiList
I'd recommend finding links in your clients here, names of pages unlikely to be changed,
but urls can be changed (sorry but IWTCMS still WIP)
| page name |
type |
response type |
uses auth api (needs cookies)? |
needs body |
| ApiListGET |
GET |
JSON |
No |
No |
If you want to see the history of all logs since server launch, go to:
https://127.0.0.1/api/logsHistory
Returns list of all logs since server launch
| page name |
type |
response type |
uses auth api (needs cookies)? |
needs body |
| LogsHistoryGET |
GET |
JSON |
Yes |
No |
If you want to log in, go to:
https://127.0.0.1/api/login
Put to your request body JSON with username and password and get logged
body example:
{
"username": "guest",
"password": "guest"
}
| page name |
type |
response type |
uses auth api (needs cookies)? |
needs body |
| LoginPOST |
POST |
Plain (Login successful / Login failed) |
No (sets cookies) |
Yes |
If you want to see all permits of user, go to:
https://127.0.0.1/api/permits/{username}
replace "{username}" with the name of the user you want to learn permissions from
| page name |
type |
response type |
uses auth api (needs cookies)? |
needs body |
| PermitsGET |
GET |
JSON |
No |
No |
If you want to reach the server console, go to:
wss://127.0.0.1/ws/console
Main feature of IWTCMS, connect to websocket and get all logs!
If you want to execute minecraft command, send command as plain text to server through websocket,
and it will be executed by IWTCMS
| page name |
type |
response type |
uses auth api (needs cookies)? |
needs body |
| WsConsole |
Websocket |
Websocket plain messages (logs) |
Yes |
No |
Static files
Since IWTCMS integrates a real ktor web server, it hosts a lot of static files with it, here is their list:
| file name |
path |
alternative paths |
file type |
| style.css |
/style.css |
|
css |
| 404.html |
/404.html |
any path witch not found (404) |
html |
| index.html |
/index.html |
/ |
html |
| favicon.ico |
|
|
ico |
| icon_clearbg.png |
/ icon_clearbg.png |
|
png |
| iwtcms_client.zip |
/iwtcms_client.zip |
|
zip |
评论 0
登录后参与评分
还没有评论,来抢沙发吧