2020-09-12 12:51:03 +00:00
|
|
|
import {ChannelTree} from "./ChannelTree";
|
2020-09-12 13:49:20 +00:00
|
|
|
import {Settings, settings} from "../settings";
|
|
|
|
import * as contextmenu from "../ui/elements/ContextMenu";
|
|
|
|
import * as log from "../log";
|
|
|
|
import {LogCategory, LogType} from "../log";
|
|
|
|
import {Sound} from "../sound/Sounds";
|
|
|
|
import * as bookmarks from "../bookmarks";
|
|
|
|
import {spawnInviteEditor} from "../ui/modal/ModalInvite";
|
|
|
|
import {openServerInfo} from "../ui/modal/ModalServerInfo";
|
|
|
|
import {createServerModal} from "../ui/modal/ModalServerEdit";
|
|
|
|
import {spawnIconSelect} from "../ui/modal/ModalIconSelect";
|
|
|
|
import {spawnAvatarList} from "../ui/modal/ModalAvatarList";
|
|
|
|
import {connection_log} from "../ui/modal/ModalConnect";
|
|
|
|
import {Registry} from "../events";
|
2020-09-12 12:51:03 +00:00
|
|
|
import {ChannelTreeEntry, ChannelTreeEntryEvents} from "./ChannelTreeEntry";
|
2020-11-29 13:42:02 +00:00
|
|
|
import { tr } from "tc-shared/i18n/localize";
|
2020-03-30 11:44:18 +00:00
|
|
|
|
|
|
|
export class ServerProperties {
|
2018-08-11 13:02:11 +00:00
|
|
|
virtualserver_host: string = "";
|
|
|
|
virtualserver_port: number = 0;
|
|
|
|
|
2018-06-20 19:05:35 +00:00
|
|
|
virtualserver_name: string = "";
|
2018-08-13 11:06:42 +00:00
|
|
|
virtualserver_name_phonetic: string = "";
|
2018-06-20 19:05:35 +00:00
|
|
|
virtualserver_icon_id: number = 0;
|
|
|
|
virtualserver_version: string = "unknown";
|
|
|
|
virtualserver_platform: string = "unknown";
|
|
|
|
virtualserver_unique_identifier: string = "";
|
|
|
|
|
|
|
|
virtualserver_clientsonline: number = 0;
|
|
|
|
virtualserver_queryclientsonline: number = 0;
|
|
|
|
virtualserver_channelsonline: number = 0;
|
|
|
|
virtualserver_uptime: number = 0;
|
2019-08-30 21:06:39 +00:00
|
|
|
virtualserver_created: number = 0;
|
2018-08-11 13:02:11 +00:00
|
|
|
virtualserver_maxclients: number = 0;
|
|
|
|
virtualserver_reserved_slots: number = 0;
|
|
|
|
|
|
|
|
virtualserver_password: string = "";
|
|
|
|
virtualserver_flag_password: boolean = false;
|
|
|
|
|
2019-08-21 08:00:01 +00:00
|
|
|
virtualserver_ask_for_privilegekey: boolean = false;
|
|
|
|
|
2018-08-11 13:02:11 +00:00
|
|
|
virtualserver_welcomemessage: string = "";
|
|
|
|
|
|
|
|
virtualserver_hostmessage: string = "";
|
|
|
|
virtualserver_hostmessage_mode: number = 0;
|
|
|
|
|
|
|
|
virtualserver_hostbanner_url: string = "";
|
|
|
|
virtualserver_hostbanner_gfx_url: string = "";
|
|
|
|
virtualserver_hostbanner_gfx_interval: number = 0;
|
|
|
|
virtualserver_hostbanner_mode: number = 0;
|
|
|
|
|
|
|
|
virtualserver_hostbutton_tooltip: string = "";
|
|
|
|
virtualserver_hostbutton_url: string = "";
|
|
|
|
virtualserver_hostbutton_gfx_url: string = "";
|
2018-08-13 09:03:55 +00:00
|
|
|
|
2018-08-13 11:06:42 +00:00
|
|
|
virtualserver_codec_encryption_mode: number = 0;
|
|
|
|
|
2018-09-24 19:21:48 +00:00
|
|
|
virtualserver_default_music_group: number = 0;
|
2018-08-13 11:06:42 +00:00
|
|
|
virtualserver_default_server_group: number = 0;
|
|
|
|
virtualserver_default_channel_group: number = 0;
|
|
|
|
virtualserver_default_channel_admin_group: number = 0;
|
|
|
|
|
2018-08-13 09:03:55 +00:00
|
|
|
//Special requested properties
|
|
|
|
virtualserver_default_client_description: string = "";
|
|
|
|
virtualserver_default_channel_description: string = "";
|
|
|
|
virtualserver_default_channel_topic: string = "";
|
2018-08-13 09:28:33 +00:00
|
|
|
|
|
|
|
virtualserver_antiflood_points_tick_reduce: number = 0;
|
|
|
|
virtualserver_antiflood_points_needed_command_block: number = 0;
|
|
|
|
virtualserver_antiflood_points_needed_ip_block: number = 0;
|
2018-08-13 11:06:42 +00:00
|
|
|
|
2019-08-21 08:00:01 +00:00
|
|
|
virtualserver_country_code: string = "XX";
|
|
|
|
|
2018-08-13 11:06:42 +00:00
|
|
|
virtualserver_complain_autoban_count: number = 0;
|
|
|
|
virtualserver_complain_autoban_time: number = 0;
|
|
|
|
virtualserver_complain_remove_time: number = 0;
|
|
|
|
|
|
|
|
virtualserver_needed_identity_security_level: number = 8;
|
|
|
|
virtualserver_weblist_enabled: boolean = false;
|
|
|
|
virtualserver_min_clients_in_channel_before_forced_silence: number = 0;
|
2019-08-21 08:00:01 +00:00
|
|
|
virtualserver_channel_temp_delete_delay_default: number = 60;
|
|
|
|
virtualserver_priority_speaker_dimm_modificator: number = -18;
|
2018-11-04 13:20:38 +00:00
|
|
|
|
|
|
|
virtualserver_max_upload_total_bandwidth: number = 0;
|
|
|
|
virtualserver_upload_quota: number = 0;
|
|
|
|
virtualserver_max_download_total_bandwidth: number = 0;
|
|
|
|
virtualserver_download_quota: number = 0;
|
2019-08-21 08:00:01 +00:00
|
|
|
|
|
|
|
virtualserver_month_bytes_downloaded: number = 0;
|
|
|
|
virtualserver_month_bytes_uploaded: number = 0;
|
|
|
|
virtualserver_total_bytes_downloaded: number = 0;
|
|
|
|
virtualserver_total_bytes_uploaded: number = 0;
|
|
|
|
}
|
|
|
|
|
2020-03-30 11:44:18 +00:00
|
|
|
export interface ServerConnectionInfo {
|
2019-08-21 08:00:01 +00:00
|
|
|
connection_filetransfer_bandwidth_sent: number;
|
|
|
|
connection_filetransfer_bandwidth_received: number;
|
|
|
|
|
|
|
|
connection_filetransfer_bytes_sent_total: number;
|
|
|
|
connection_filetransfer_bytes_received_total: number;
|
|
|
|
|
|
|
|
connection_filetransfer_bytes_sent_month: number;
|
|
|
|
connection_filetransfer_bytes_received_month: number;
|
|
|
|
|
|
|
|
connection_packets_sent_total: number;
|
|
|
|
connection_bytes_sent_total: number;
|
|
|
|
connection_packets_received_total: number;
|
|
|
|
connection_bytes_received_total: number;
|
|
|
|
|
|
|
|
connection_bandwidth_sent_last_second_total: number;
|
|
|
|
connection_bandwidth_sent_last_minute_total: number;
|
|
|
|
connection_bandwidth_received_last_second_total: number;
|
|
|
|
connection_bandwidth_received_last_minute_total: number;
|
|
|
|
|
|
|
|
connection_connected_time: number;
|
|
|
|
connection_packetloss_total: number;
|
|
|
|
connection_ping: number;
|
2018-06-20 19:05:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-30 11:44:18 +00:00
|
|
|
export interface ServerAddress {
|
2018-06-20 19:05:35 +00:00
|
|
|
host: string;
|
|
|
|
port: number;
|
|
|
|
}
|
|
|
|
|
2020-04-18 17:37:30 +00:00
|
|
|
export interface ServerEvents extends ChannelTreeEntryEvents {
|
|
|
|
notify_properties_updated: {
|
|
|
|
updated_properties: {[Key in keyof ServerProperties]: ServerProperties[Key]};
|
|
|
|
server_properties: ServerProperties
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ServerEntry extends ChannelTreeEntry<ServerEvents> {
|
2018-06-20 19:05:35 +00:00
|
|
|
remote_address: ServerAddress;
|
2018-02-27 16:20:49 +00:00
|
|
|
channelTree: ChannelTree;
|
2018-06-20 19:05:35 +00:00
|
|
|
properties: ServerProperties;
|
2018-02-27 16:20:49 +00:00
|
|
|
|
2020-04-18 17:37:30 +00:00
|
|
|
readonly events: Registry<ServerEvents>;
|
|
|
|
|
2018-08-13 09:03:55 +00:00
|
|
|
private info_request_promise: Promise<void> = undefined;
|
|
|
|
private info_request_promise_resolve: any = undefined;
|
|
|
|
private info_request_promise_reject: any = undefined;
|
|
|
|
|
2019-08-21 08:00:01 +00:00
|
|
|
private _info_connection_promise: Promise<ServerConnectionInfo>;
|
|
|
|
private _info_connection_promise_timestamp: number;
|
|
|
|
private _info_connection_promise_resolve: any;
|
|
|
|
private _info_connection_promise_reject: any;
|
|
|
|
|
2018-02-27 16:20:49 +00:00
|
|
|
lastInfoRequest: number = 0;
|
|
|
|
nextInfoRequest: number = 0;
|
2019-08-21 08:00:01 +00:00
|
|
|
private _destroyed = false;
|
2018-02-27 16:20:49 +00:00
|
|
|
|
2018-06-20 19:05:35 +00:00
|
|
|
constructor(tree, name, address: ServerAddress) {
|
2020-04-18 17:37:30 +00:00
|
|
|
super();
|
|
|
|
|
|
|
|
this.events = new Registry<ServerEvents>();
|
|
|
|
|
2018-06-20 19:05:35 +00:00
|
|
|
this.properties = new ServerProperties();
|
2018-02-27 16:20:49 +00:00
|
|
|
this.channelTree = tree;
|
2020-04-18 17:37:30 +00:00
|
|
|
this.remote_address = Object.assign({}, address); /* copy the address because it might get changed due to the DNS resolve */
|
2018-02-27 16:20:49 +00:00
|
|
|
this.properties.virtualserver_name = name;
|
|
|
|
}
|
|
|
|
|
2019-08-21 08:00:01 +00:00
|
|
|
destroy() {
|
|
|
|
this._destroyed = true;
|
|
|
|
this.info_request_promise = undefined;
|
|
|
|
this.info_request_promise_resolve = undefined;
|
|
|
|
this.info_request_promise_reject = undefined;
|
|
|
|
|
|
|
|
this.channelTree = undefined;
|
|
|
|
this.remote_address = undefined;
|
|
|
|
}
|
|
|
|
|
2020-04-18 17:37:30 +00:00
|
|
|
contextMenuItems() : contextmenu.MenuEntry[] {
|
|
|
|
return [
|
|
|
|
{
|
2019-06-30 14:03:28 +00:00
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
2019-03-07 14:30:53 +00:00
|
|
|
name: tr("Show server info"),
|
|
|
|
callback: () => {
|
2020-03-30 11:44:18 +00:00
|
|
|
openServerInfo(this);
|
2019-03-07 14:30:53 +00:00
|
|
|
},
|
2019-08-30 21:06:39 +00:00
|
|
|
icon_class: "client-about"
|
|
|
|
}, {
|
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: "client-invite_buddy",
|
|
|
|
name: tr("Invite buddy"),
|
2020-03-30 11:44:18 +00:00
|
|
|
callback: () => spawnInviteEditor(this.channelTree.client)
|
2019-08-30 21:06:39 +00:00
|
|
|
}, {
|
|
|
|
type: contextmenu.MenuEntryType.HR,
|
|
|
|
name: ''
|
2019-08-21 08:00:01 +00:00
|
|
|
}, {
|
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: "client-channel_switch",
|
|
|
|
name: tr("Join server text channel"),
|
|
|
|
callback: () => {
|
2020-12-09 12:36:56 +00:00
|
|
|
this.channelTree.client.getChannelConversations().setSelectedConversation(0);
|
|
|
|
this.channelTree.client.side_bar.showChannelConversations();
|
2019-08-21 08:00:01 +00:00
|
|
|
},
|
|
|
|
visible: !settings.static_global(Settings.KEY_SWITCH_INSTANT_CHAT)
|
2019-03-07 14:30:53 +00:00
|
|
|
}, {
|
2019-06-30 14:03:28 +00:00
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: "client-virtualserver_edit",
|
2018-12-05 19:46:33 +00:00
|
|
|
name: tr("Edit"),
|
2018-08-11 13:02:11 +00:00
|
|
|
callback: () => {
|
2020-03-30 11:44:18 +00:00
|
|
|
createServerModal(this, properties => {
|
2018-12-05 19:46:33 +00:00
|
|
|
log.info(LogCategory.SERVER, tr("Changing server properties %o"), properties);
|
|
|
|
console.log(tr("Changed properties: %o"), properties);
|
2019-08-21 08:00:01 +00:00
|
|
|
if (properties) {
|
|
|
|
if(Object.keys(properties)) {
|
|
|
|
return this.channelTree.client.serverConnection.send_command("serveredit", properties).then(() => {
|
|
|
|
this.channelTree.client.sound.play(Sound.SERVER_EDITED_SELF);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Promise.resolve();
|
2018-08-11 13:02:11 +00:00
|
|
|
});
|
|
|
|
}
|
2019-08-30 21:06:39 +00:00
|
|
|
}, {
|
|
|
|
type: contextmenu.MenuEntryType.HR,
|
|
|
|
visible: true,
|
|
|
|
name: ''
|
2019-03-25 19:04:04 +00:00
|
|
|
}, {
|
2019-06-30 14:03:28 +00:00
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: "client-iconviewer",
|
2019-03-25 19:04:04 +00:00
|
|
|
name: tr("View icons"),
|
2020-03-30 11:44:18 +00:00
|
|
|
callback: () => spawnIconSelect(this.channelTree.client)
|
2019-03-25 19:04:04 +00:00
|
|
|
}, {
|
2019-06-30 14:03:28 +00:00
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: 'client-iconsview',
|
2019-03-25 19:04:04 +00:00
|
|
|
name: tr("View avatars"),
|
2019-10-13 19:33:07 +00:00
|
|
|
visible: false, //TODO: Enable again as soon the new design is finished
|
2020-03-30 11:44:18 +00:00
|
|
|
callback: () => spawnAvatarList(this.channelTree.client)
|
2020-04-18 19:26:44 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
type: contextmenu.MenuEntryType.HR,
|
|
|
|
name: ''
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: "client-channel_collapse_all",
|
|
|
|
name: tr("Collapse all channels"),
|
|
|
|
callback: () => this.channelTree.collapse_channels()
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: contextmenu.MenuEntryType.ENTRY,
|
|
|
|
icon_class: "client-channel_expand_all",
|
|
|
|
name: tr("Expend all channels"),
|
|
|
|
callback: () => this.channelTree.expand_channels()
|
|
|
|
},
|
2020-04-18 17:37:30 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-09-26 19:34:46 +00:00
|
|
|
showContextMenu(x: number, y: number, on_close: () => void = () => {}) {
|
2020-04-18 17:37:30 +00:00
|
|
|
contextmenu.spawn_context_menu(x, y, ...this.contextMenuItems(),
|
|
|
|
contextmenu.Entry.CLOSE(on_close)
|
2018-02-27 16:20:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-08-13 09:03:55 +00:00
|
|
|
updateVariables(is_self_notify: boolean, ...variables: {key: string, value: string}[]) {
|
2018-12-05 19:46:33 +00:00
|
|
|
let group = log.group(log.LogType.DEBUG, LogCategory.SERVER, tr("Update properties (%i)"), variables.length);
|
2018-06-20 19:05:35 +00:00
|
|
|
|
2019-03-25 19:04:04 +00:00
|
|
|
{
|
|
|
|
const entries = [];
|
|
|
|
for(const variable of variables)
|
|
|
|
entries.push({
|
|
|
|
key: variable.key,
|
|
|
|
value: variable.value,
|
|
|
|
type: typeof (this.properties[variable.key])
|
|
|
|
});
|
2019-08-30 21:06:39 +00:00
|
|
|
log.table(LogType.DEBUG, LogCategory.PERMISSIONS, "Server update properties", entries);
|
2019-03-25 19:04:04 +00:00
|
|
|
}
|
|
|
|
|
2020-10-05 13:18:50 +00:00
|
|
|
let update_bannner = false, update_bookmarks = false;
|
2018-06-20 19:05:35 +00:00
|
|
|
for(let variable of variables) {
|
2018-08-10 19:30:58 +00:00
|
|
|
JSON.map_field_to(this.properties, variable.value, variable.key);
|
|
|
|
|
2020-09-25 16:29:42 +00:00
|
|
|
if(variable.key == "virtualserver_icon_id") {
|
2019-04-25 18:21:50 +00:00
|
|
|
/* For more detail lookup client::updateVariables and client_icon_id!
|
|
|
|
* ATTENTION: This is required!
|
|
|
|
*/
|
|
|
|
this.properties.virtualserver_icon_id = variable.value as any >>> 0;
|
2020-04-18 17:37:30 +00:00
|
|
|
update_bookmarks = true;
|
2018-11-03 11:16:13 +00:00
|
|
|
} else if(variable.key.indexOf('hostbanner') != -1) {
|
|
|
|
update_bannner = true;
|
2018-06-20 19:05:35 +00:00
|
|
|
}
|
2018-02-27 16:20:49 +00:00
|
|
|
}
|
2020-04-18 17:37:30 +00:00
|
|
|
{
|
|
|
|
let properties = {};
|
|
|
|
for(const property of variables)
|
|
|
|
properties[property.key] = this.properties[property.key];
|
|
|
|
this.events.fire("notify_properties_updated", { updated_properties: properties as any, server_properties: this.properties });
|
|
|
|
}
|
|
|
|
if(update_bookmarks) {
|
|
|
|
const bmarks = bookmarks.bookmarks_flat()
|
|
|
|
.filter(e => e.server_properties.server_address === this.remote_address.host && e.server_properties.server_port == this.remote_address.port)
|
|
|
|
.filter(e => e.last_icon_id !== this.properties.virtualserver_icon_id || e.last_icon_server_id !== this.properties.virtualserver_unique_identifier);
|
|
|
|
if(bmarks.length > 0) {
|
|
|
|
bmarks.forEach(e => {
|
|
|
|
e.last_icon_id = this.properties.virtualserver_icon_id;
|
|
|
|
e.last_icon_server_id = this.properties.virtualserver_unique_identifier;
|
|
|
|
});
|
|
|
|
bookmarks.save_bookmark();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-03 11:16:13 +00:00
|
|
|
if(update_bannner)
|
2019-08-21 08:00:01 +00:00
|
|
|
this.channelTree.client.hostbanner.update();
|
2020-04-18 17:37:30 +00:00
|
|
|
|
2018-06-20 19:05:35 +00:00
|
|
|
group.end();
|
2018-08-13 09:03:55 +00:00
|
|
|
if(is_self_notify && this.info_request_promise_resolve) {
|
|
|
|
this.info_request_promise_resolve();
|
|
|
|
this.info_request_promise = undefined;
|
|
|
|
this.info_request_promise_reject = undefined;
|
|
|
|
this.info_request_promise_resolve = undefined;
|
|
|
|
}
|
2019-08-21 08:00:01 +00:00
|
|
|
|
|
|
|
connection_log.update_address_info({
|
|
|
|
hostname: this.remote_address.host,
|
|
|
|
port: this.remote_address.port
|
|
|
|
}, {
|
|
|
|
clients_online: this.properties.virtualserver_clientsonline,
|
|
|
|
clients_total: this.properties.virtualserver_maxclients,
|
|
|
|
country: this.properties.virtualserver_country_code,
|
|
|
|
flag_password: this.properties.virtualserver_flag_password,
|
|
|
|
name: this.properties.virtualserver_name,
|
|
|
|
icon_id: this.properties.virtualserver_icon_id,
|
2020-04-18 17:37:30 +00:00
|
|
|
server_unique_id: this.properties.virtualserver_unique_identifier,
|
2019-08-21 08:00:01 +00:00
|
|
|
|
|
|
|
password_hash: undefined /* we've here no clue */
|
|
|
|
});
|
2018-02-27 16:20:49 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 08:00:01 +00:00
|
|
|
/* this result !must! be cached for at least a second */
|
2018-08-13 09:03:55 +00:00
|
|
|
updateProperties() : Promise<void> {
|
|
|
|
if(this.info_request_promise && Date.now() - this.lastInfoRequest < 1000) return this.info_request_promise;
|
|
|
|
this.lastInfoRequest = Date.now();
|
2018-02-27 16:20:49 +00:00
|
|
|
this.nextInfoRequest = this.lastInfoRequest + 10 * 1000;
|
2019-02-23 13:15:22 +00:00
|
|
|
this.channelTree.client.serverConnection.send_command("servergetvariables").catch(error => {
|
2018-08-13 09:03:55 +00:00
|
|
|
this.info_request_promise_reject(error);
|
|
|
|
this.info_request_promise = undefined;
|
|
|
|
this.info_request_promise_reject = undefined;
|
|
|
|
this.info_request_promise_resolve = undefined;
|
|
|
|
});
|
|
|
|
|
|
|
|
return this.info_request_promise = new Promise<void>((resolve, reject) => {
|
|
|
|
this.info_request_promise_reject = reject;
|
|
|
|
this.info_request_promise_resolve = resolve;
|
|
|
|
});
|
2018-02-27 16:20:49 +00:00
|
|
|
}
|
|
|
|
|
2019-08-21 08:00:01 +00:00
|
|
|
/* max 1s ago, so we could update every second */
|
|
|
|
request_connection_info() : Promise<ServerConnectionInfo> {
|
|
|
|
if(Date.now() - 900 < this._info_connection_promise_timestamp && this._info_connection_promise)
|
|
|
|
return this._info_connection_promise;
|
|
|
|
|
|
|
|
if(this._info_connection_promise_reject)
|
|
|
|
this._info_connection_promise_resolve("timeout");
|
|
|
|
|
|
|
|
let _local_reject; /* to ensure we're using the right resolve! */
|
|
|
|
this._info_connection_promise = new Promise<ServerConnectionInfo>((resolve, reject) => {
|
|
|
|
this._info_connection_promise_resolve = resolve;
|
|
|
|
this._info_connection_promise_reject = reject;
|
|
|
|
_local_reject = reject;
|
|
|
|
});
|
|
|
|
|
|
|
|
this._info_connection_promise_timestamp = Date.now();
|
2019-08-30 21:06:39 +00:00
|
|
|
this.channelTree.client.serverConnection.send_command("serverrequestconnectioninfo", {}, {process_result: false}).catch(error => _local_reject(error));
|
2019-08-21 08:00:01 +00:00
|
|
|
return this._info_connection_promise;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_connection_info(info: ServerConnectionInfo) {
|
|
|
|
if(!this._info_connection_promise_resolve)
|
|
|
|
return;
|
|
|
|
this._info_connection_promise_resolve(info);
|
|
|
|
this._info_connection_promise_resolve = undefined;
|
|
|
|
this._info_connection_promise_reject = undefined;
|
|
|
|
}
|
|
|
|
|
2018-02-27 16:20:49 +00:00
|
|
|
shouldUpdateProperties() : boolean {
|
2018-04-30 21:57:21 +00:00
|
|
|
return this.nextInfoRequest < Date.now();
|
2018-02-27 16:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
calculateUptime() : number {
|
2018-06-20 19:05:35 +00:00
|
|
|
if(this.properties.virtualserver_uptime == 0 || this.lastInfoRequest == 0) return this.properties.virtualserver_uptime;
|
|
|
|
return this.properties.virtualserver_uptime + (new Date().getTime() - this.lastInfoRequest) / 1000;
|
2018-02-27 16:20:49 +00:00
|
|
|
}
|
2019-09-18 23:25:57 +00:00
|
|
|
|
2020-04-18 17:37:30 +00:00
|
|
|
reset() {
|
|
|
|
this.properties = new ServerProperties();
|
|
|
|
this._info_connection_promise = undefined;
|
|
|
|
this._info_connection_promise_reject = undefined;
|
|
|
|
this._info_connection_promise_resolve = undefined;
|
|
|
|
this._info_connection_promise_timestamp = undefined;
|
2019-09-18 23:25:57 +00:00
|
|
|
}
|
2018-02-27 16:20:49 +00:00
|
|
|
}
|