mtt-mu-server allows multiple users to use the wss
mode of mtt-client to transfer data on the same server port (eg: 443). Users are offloaded to the corresponding backend (dst
destination) according to the path (wss-path
) of their HTTP request.
This can increase the concealment and security of the server. Because we no longer need to expose a large number of ports to different users. And if mtt-mu-server can run on port 443, it will look like a normal HTTPS server.
Each user has their own unique path
and dst
.
Use HTTP's POST method to send commands to the Controller to add or delete users.
-c string
[Host:Port] Controller address
// For the following command descriptions, please refer to mtt-server
-mux
-cert string
-key string
-disable-tls
-n string
-fast-open
-timeout duration
-verbose
The Controller accepts HTTP POST requests. The body of a single request cannot be greater than 2M.
Controller json command format example:
Command structure:
{
"opt": 0,
"args_bunch": [
{
"path": "",
"dst": ""
},
{
"path": "",
"dst": ""
}
...
]
}
Add user
{
"opt": 1,
"args_bunch": [
{
"path": "/path_1",
"dst": "127.0.0.1:10001"
},
{
"path": "/path_2",
"dst": "127.0.0.1:10002"
}
...
]
}
Delete user
{
"opt": 2,
"args_bunch": [
{
"path": "/path_1"
},
{
"path": "/path_2"
}
...
]
}
Reset server or Ping
{
"opt": 3
}
{
"opt": 9
}
opt:
- 1: Add users from
args_bunch
.args_bunch
,path
anddst
are required. Repeatedpath
will be overwrited. - 2: Delete the user by
path
inargs_bunch
.args_bunch
andpath
are required. The existingpath
will be deleted. Non-existentpath
s are ignored. - 3: Reset server, delete all users.
- 9: Ping: The Controller responds with a Pong to report the current number of users. If it returns 0, it may mean that the server has restarted and needs to synchronize user data.
Changing or deleting a user does not affect the user's established connection.
args_bunch:
args_bunch
can contain multiple path
and dst
pairs, but the body of a single request cannot be greater than 2M.
Controller json response example:
Response structure:
{
"res": 0,
"err_string":"",
"current_users": 0
}
OK
{
"res": 1,
"err_string":"",
"current_users": 0
}
Err
{
"res": 2,
"err_string":"invalid opt",
"current_users": 0
}
Pong
{
"res": 1,
"err_string":"",
"current_users": 2102
}
res:
- 1: The command was executed successfully.
- 2: An error occurred,
err_string
will contain error description.
current_users: Only valid when "opt": 9
(Ping). The number of users that have been added for the current server.