SOme small updates
This commit is contained in:
parent
c256dd3d60
commit
b3347cfa8e
@ -1 +1 @@
|
|||||||
Subproject commit 942ae832e19be25f5f67ddb8b2fe35b8bb0f65de
|
Subproject commit d2b3e9bcadea5130b8ae906d9a1e656351f59936
|
@ -65,7 +65,7 @@ class CLIParser {
|
|||||||
|
|
||||||
#define REQ_CMD(variable, message, ...) \
|
#define REQ_CMD(variable, message, ...) \
|
||||||
if(!options.option_exists({__VA_ARGS__}, false)) { \
|
if(!options.option_exists({__VA_ARGS__}, false)) { \
|
||||||
cerr << "missing user" << endl; \
|
cerr << message << endl; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
auto variable = url_decode(options.get_option({__VA_ARGS__})) \
|
auto variable = url_decode(options.get_option({__VA_ARGS__})) \
|
||||||
@ -84,8 +84,8 @@ int main(int argc, char **argv) {
|
|||||||
REQ_CMD(email, "missing email", "-m", "--email");
|
REQ_CMD(email, "missing email", "-m", "--email");
|
||||||
REQ_CMD(license_type, "missing license_type", "-l", "--license-type");
|
REQ_CMD(license_type, "missing license_type", "-l", "--license-type");
|
||||||
|
|
||||||
REQ_CMD(auth_user, "missing authentification user", "-au", "--auth-user");
|
REQ_CMD(auth_user, "missing authentication user", "-au", "--auth-user");
|
||||||
REQ_CMD(auth_pass, "missing authentification user", "-ap", "--auth-pass");
|
REQ_CMD(auth_pass, "missing authentication user", "-ap", "--auth-pass");
|
||||||
|
|
||||||
REQ_CMD(server_host, "missing server host", "-h", "--server-host");
|
REQ_CMD(server_host, "missing server host", "-h", "--server-host");
|
||||||
REQ_CMD(server_port, "missing server port", "-p", "--server-port");
|
REQ_CMD(server_port, "missing server port", "-p", "--server-port");
|
||||||
|
@ -83,22 +83,41 @@ bool ServerManager::initialize(bool autostart) {
|
|||||||
|
|
||||||
auto beg = system_clock::now();
|
auto beg = system_clock::now();
|
||||||
size_t server_count = 0;
|
size_t server_count = 0;
|
||||||
sql::command(this->handle->getSql(), "SELECT `serverId`, `host`, `port` FROM `servers`").query([&](ServerManager* mgr, int length, char** values, char** columns){
|
sql::command(this->handle->getSql(), "SELECT `serverId`, `host`, `port` FROM `servers`").query([&](ServerManager* mgr, int length, std::string* values, std::string* columns){
|
||||||
ServerId id = 0;
|
ServerId id = 0;
|
||||||
std::string host;
|
std::string host;
|
||||||
uint16_t port = 0;
|
uint16_t port = 0;
|
||||||
|
|
||||||
for(int index = 0; index < length; index++)
|
for(int index = 0; index < length; index++) {
|
||||||
if(strcmp(columns[index], "serverId") == 0)
|
try {
|
||||||
id = static_cast<ServerId>(stoll(values[index]));
|
if(columns[index] == "serverId")
|
||||||
else if(strcmp(columns[index], "host") == 0)
|
id = static_cast<ServerId>(stoll(values[index]));
|
||||||
host = values[index];
|
else if(columns[index] == "host")
|
||||||
else if(strcmp(columns[index], "port") == 0)
|
host = values[index];
|
||||||
port = static_cast<uint16_t>(stoul(values[index]));
|
else if(columns[index] == "port")
|
||||||
|
port = static_cast<uint16_t>(stoul(values[index]));
|
||||||
|
} catch(std::exception& ex) {
|
||||||
|
logError(LOG_INSTANCE, "Failed to parse virtual server from database. Failed to parse field {} with value {}: {}", columns[index], values[index], ex.what());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(id == 0) {
|
||||||
|
logError(LOG_INSTANCE, "Failed to load virtual server from database. Server id is zero!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(host.empty()) {
|
||||||
|
logWarning(id, "The loaded host is empty. Using default one (from the config.yml)");
|
||||||
|
host = config::binding::DefaultVoiceHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(port == 0) {
|
||||||
|
logError(LOG_INSTANCE, "Failed to load virtual server from database. Server port is zero!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
assert(id != 0);
|
|
||||||
assert(port != 0);
|
|
||||||
assert(!host.empty());
|
|
||||||
|
|
||||||
auto server = make_shared<TSServer>(id, this->handle->getSql());
|
auto server = make_shared<TSServer>(id, this->handle->getSql());
|
||||||
server->self = server;
|
server->self = server;
|
||||||
|
@ -255,45 +255,46 @@ bool ConnectedClient::notifyConnectionInfo(const shared_ptr<ConnectedClient> &ta
|
|||||||
Command notify("notifyconnectioninfo");
|
Command notify("notifyconnectioninfo");
|
||||||
notify["clid"] = target->getClientId();
|
notify["clid"] = target->getClientId();
|
||||||
|
|
||||||
|
auto not_set = this->getType() == CLIENT_TEAMSPEAK ? 0 : -1;
|
||||||
/* we deliver data to the web client as well, because its a bit dump :D */
|
/* we deliver data to the web client as well, because its a bit dump :D */
|
||||||
if(target->getClientId() != this->getClientId()) {
|
if(target->getClientId() != this->getClientId()) {
|
||||||
auto report = target->connectionStatistics->full_report();
|
auto report = target->connectionStatistics->full_report();
|
||||||
|
|
||||||
/* default values which normally sets the client */
|
/* default values which normally sets the client */
|
||||||
notify["connection_bandwidth_received_last_minute_control"] = -1;
|
notify["connection_bandwidth_received_last_minute_control"] = not_set;
|
||||||
notify["connection_bandwidth_received_last_minute_keepalive"] = -1;
|
notify["connection_bandwidth_received_last_minute_keepalive"] = not_set;
|
||||||
notify["connection_bandwidth_received_last_minute_speech"] = -1;
|
notify["connection_bandwidth_received_last_minute_speech"] = not_set;
|
||||||
notify["connection_bandwidth_received_last_second_control"] = -1;
|
notify["connection_bandwidth_received_last_second_control"] = not_set;
|
||||||
notify["connection_bandwidth_received_last_second_keepalive"] = -1;
|
notify["connection_bandwidth_received_last_second_keepalive"] = not_set;
|
||||||
notify["connection_bandwidth_received_last_second_speech"] = -1;
|
notify["connection_bandwidth_received_last_second_speech"] = not_set;
|
||||||
|
|
||||||
notify["connection_bandwidth_sent_last_minute_control"] = -1;
|
notify["connection_bandwidth_sent_last_minute_control"] = not_set;
|
||||||
notify["connection_bandwidth_sent_last_minute_keepalive"] = -1;
|
notify["connection_bandwidth_sent_last_minute_keepalive"] = not_set;
|
||||||
notify["connection_bandwidth_sent_last_minute_speech"] = -1;
|
notify["connection_bandwidth_sent_last_minute_speech"] = not_set;
|
||||||
notify["connection_bandwidth_sent_last_second_control"] = -1;
|
notify["connection_bandwidth_sent_last_second_control"] = not_set;
|
||||||
notify["connection_bandwidth_sent_last_second_keepalive"] = -1;
|
notify["connection_bandwidth_sent_last_second_keepalive"] = not_set;
|
||||||
notify["connection_bandwidth_sent_last_second_speech"] = -1;
|
notify["connection_bandwidth_sent_last_second_speech"] = not_set;
|
||||||
|
|
||||||
/* its flipped here because the report is out of the clients view */
|
/* its flipped here because the report is out of the clients view */
|
||||||
notify["connection_bytes_received_control"] = -1;
|
notify["connection_bytes_received_control"] = not_set;
|
||||||
notify["connection_bytes_received_keepalive"] = -1;
|
notify["connection_bytes_received_keepalive"] = not_set;
|
||||||
notify["connection_bytes_received_speech"] = -1;
|
notify["connection_bytes_received_speech"] = not_set;
|
||||||
notify["connection_bytes_sent_control"] = -1;
|
notify["connection_bytes_sent_control"] = not_set;
|
||||||
notify["connection_bytes_sent_keepalive"] = -1;
|
notify["connection_bytes_sent_keepalive"] = not_set;
|
||||||
notify["connection_bytes_sent_speech"] = -1;
|
notify["connection_bytes_sent_speech"] = not_set;
|
||||||
|
|
||||||
/* its flipped here because the report is out of the clients view */
|
/* its flipped here because the report is out of the clients view */
|
||||||
notify["connection_packets_received_control"] = -1;
|
notify["connection_packets_received_control"] = not_set;
|
||||||
notify["connection_packets_received_keepalive"] = -1;
|
notify["connection_packets_received_keepalive"] = not_set;
|
||||||
notify["connection_packets_received_speech"] = -1;
|
notify["connection_packets_received_speech"] = not_set;
|
||||||
notify["connection_packets_sent_control"] = -1;
|
notify["connection_packets_sent_control"] = not_set;
|
||||||
notify["connection_packets_sent_keepalive"] = -1;
|
notify["connection_packets_sent_keepalive"] = not_set;
|
||||||
notify["connection_packets_sent_speech"] = -1;
|
notify["connection_packets_sent_speech"] = not_set;
|
||||||
|
|
||||||
notify["connection_server2client_packetloss_control"] = -1;
|
notify["connection_server2client_packetloss_control"] = not_set;
|
||||||
notify["connection_server2client_packetloss_keepalive"] = -1;
|
notify["connection_server2client_packetloss_keepalive"] = not_set;
|
||||||
notify["connection_server2client_packetloss_speech"] = -1;
|
notify["connection_server2client_packetloss_speech"] = not_set;
|
||||||
notify["connection_server2client_packetloss_total"] = -1;
|
notify["connection_server2client_packetloss_total"] = not_set;
|
||||||
|
|
||||||
notify["connection_ping"] = 0;
|
notify["connection_ping"] = 0;
|
||||||
notify["connection_ping_deviation"] = 0;
|
notify["connection_ping_deviation"] = 0;
|
||||||
@ -344,10 +345,10 @@ bool ConnectedClient::notifyConnectionInfo(const shared_ptr<ConnectedClient> &ta
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Needs to be filled out
|
//Needs to be filled out
|
||||||
notify["connection_client2server_packetloss_speech"] = -1;
|
notify["connection_client2server_packetloss_speech"] = not_set;
|
||||||
notify["connection_client2server_packetloss_keepalive"] = -1;
|
notify["connection_client2server_packetloss_keepalive"] = not_set;
|
||||||
notify["connection_client2server_packetloss_control"] = -1;
|
notify["connection_client2server_packetloss_control"] = not_set;
|
||||||
notify["connection_client2server_packetloss_total"] = -1;
|
notify["connection_client2server_packetloss_total"] = not_set;
|
||||||
|
|
||||||
notify["connection_connected_time"] = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - target->connectTimestamp).count();
|
notify["connection_connected_time"] = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - target->connectTimestamp).count();
|
||||||
notify["connection_idle_time"] = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - target->idleTimestamp).count();
|
notify["connection_idle_time"] = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - target->idleTimestamp).count();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user