Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Mar 1, 2024
1 parent 20ad81a commit 18a635f
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Protest/Front/keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ const KEEP = {
break;

default:
console.log("none register action: " + message.action);
console.warn("none register action: " + message.action);
break;
}
},
Expand Down
80 changes: 58 additions & 22 deletions Protest/Front/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ class Monitor extends Window {
this.socket.send(this.params.file);
this.ConsoleLog("Web-socket connection established", "info");

//this.socket.send("ping=true");
//this.socket.send("cpu=true");
//this.socket.send("cores=true");

if (this.hideConsoleOnce) {
this.hideConsoleOnce = false;
setTimeout(()=>this.toggleConsoleButton.onclick(), 400);
Expand All @@ -161,13 +157,7 @@ class Monitor extends Window {

for (let i=0; i<this.chartsList.length; i++) {
if (this.chartsList[i].index !== message.index) { continue; }

if (this.chartsList[i].options.type === "percents") {
this.chartsList[i].Update(message.data);
}
else {
this.chartsList[i].Update(parseInt(message.data));
}
this.chartsList[i].Update(message.data);
break;
}
};
Expand Down Expand Up @@ -425,7 +415,11 @@ class Monitor extends Window {
{
format: "Line chart",
prefix: "Usage",
unit: "%"
unit: "%",
min: 0,
max: 100,
value: "PercentIdleTime",
isComplement: true
}
));

Expand All @@ -437,7 +431,11 @@ class Monitor extends Window {
{
format: "Line charts (grid)",
prefix: "Usage",
unit: "%"
unit: "%",
min: 0,
max: 100,
value: "PercentIdleTime",
isComplement: true,
}
));

Expand All @@ -449,7 +447,11 @@ class Monitor extends Window {
{
format: "Line chart",
prefix: "Usage",
unit: "%"
unit: "%",
min: 0,
max: "TotalVisibleMemorySize",
value: "FreePhysicalMemory",
isComplement: true,
}
));

Expand All @@ -461,19 +463,41 @@ class Monitor extends Window {
{
format: "Delta chart",
prefix: "Usage",
unit: "%"
unit: "%",
min: 0,
max: 100,
value: "PercentIdleTime",
isComplement: true,
}
));

templatesBox.appendChild(CreateTemplate(
"Network usage",
"NIC downstream",
"mono/portscan.svg",
"wmi",
"SELECT BytesReceivedPersec, BytesSentPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface",
"SELECT BytesReceivedPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface",
{
format: "Delta chart",
prefix: "Usage",
unit: "%"
unit: "bps",
min: 0,
value: "BytesReceivedPersec",
isComplement: false,
}
));

templatesBox.appendChild(CreateTemplate(
"NIC upstream",
"mono/portscan.svg",
"wmi",
"SELECT BytesSentPersec FROM Win32_PerfFormattedData_Tcpip_NetworkInterface",
{
format: "Delta chart",
prefix: "Usage",
unit: "bps",
min: 0,
value: "BytesSentPersec",
isComplement: false,
}
));

Expand Down Expand Up @@ -725,7 +749,7 @@ class Monitor extends Window {
case "Line chart" : return this.CreateLineChart(inner, valueLabel, name, height, options);
case "Grid line chart" : return this.CreateGridLineChart(inner, valueLabel, name, height, options);
case "Delta chart" : return this.CreateDeltaChart(inner, valueLabel, name, height, options);
case "Single value" : return this.CreateSingleValue(inner, valueLabel, name, options);
case "Single value" : return this.CreateSingleValue(inner, name, options);
case "List" : return this.CreateList(inner, valueLabel, name, height, options);
case "Table" : return this.CreateTable(inner, valueLabel, name, height, options);
}
Expand Down Expand Up @@ -1015,11 +1039,23 @@ class Monitor extends Window {
};
}

CreateSingleValue(inner, valueLabel, name, options) {
//TODO:
CreateSingleValue(inner, name, options) {
inner.style.height = "56px";

const valueBox = document.createElement("div");
valueBox.style.position = "absolute";
valueBox.style.left = "20px";
valueBox.style.right = "20px";
valueBox.style.top = "24px";
valueBox.style.fontSize = "20px";
valueBox.style.fontFamily = "monospace";
valueBox.style.overflow = "hidden";
valueBox.style.whiteSpace = "nowrap";
valueBox.style.userSelect = "text";
inner.appendChild(valueBox);

const Update = value=>{
//TODO:
valueBox.textContent = Object.values(value)[0][0];
};

return {
Expand Down
10 changes: 5 additions & 5 deletions Protest/Front/personalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Personalize extends Tabs {
this.chatTab = this.AddTab("Chat", "mono/chat.svg");
this.agentTab = this.AddTab("Agent", "mono/agent.svg");

this.guiTab.onclick = ()=> this.ShowGui();
thr.onclickTab = ()=> this.ShowRegion();
this.sessionTab.onclick = ()=> this.ShowSession();
this.chatTab.onclick = ()=> this.ShowChat();
this.agentTab.onclick = ()=> this.ShowAgent();
this.guiTab.onclick = ()=> this.ShowGui();
this.regionTab.onclickTab = ()=> this.ShowRegion();
this.sessionTab.onclick = ()=> this.ShowSession();
this.chatTab.onclick = ()=> this.ShowChat();
this.agentTab.onclick = ()=> this.ShowAgent();

switch (this.params) {
case "region":
Expand Down
2 changes: 1 addition & 1 deletion Protest/Front/portscan.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class PortScan extends Console {
};
};

this.ws.onerror = (error)=> console.log(error);
this.ws.onerror = error=> console.error(error);

this.ws.onmessage = event=> {
let split = event.data.split(String.fromCharCode(127));
Expand Down
5 changes: 5 additions & 0 deletions Protest/Front/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ class Settings extends Tabs {
nameLabel.style.top = "0";
nameLabel.style.left = "0";
nameLabel.style.width = "33%";
nameLabel.style.whiteSpace = "nowrap";
nameLabel.style.overflow = "hidden";
nameLabel.style.textOverflow = "ellipsis";
nameLabel.style.lineHeight = "32px";
nameLabel.style.paddingLeft = "4px";
nameLabel.textContent = json[i].name;
Expand All @@ -425,6 +428,8 @@ class Settings extends Tabs {
networkLabel.style.top = "0";
networkLabel.style.left = "33%";
networkLabel.style.width = "33%";
networkLabel.style.whiteSpace = "nowrap";
networkLabel.style.overflow = "hidden";
networkLabel.style.lineHeight = "32px";
networkLabel.textContent = json[i].network;

Expand Down
2 changes: 1 addition & 1 deletion Protest/Front/telnet.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class Telnet extends Window {
this.list.scrollTop = this.list.scrollHeight;
};

//this.ws.onerror = error=> console.log(error);
//this.ws.onerror = error=> console.error(error);
}

PushText(text, front, back, bold = false, underline = false) {
Expand Down
2 changes: 1 addition & 1 deletion Protest/Tasks/Fetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public static byte[] DevicesTask(string[] hosts, bool dns, bool wmi, bool kerber

KeepAlive.Broadcast($"{{\"action\":\"update-fetch\",\"type\":\"devices\",\"task\":{Encoding.UTF8.GetString(Status())}}}", "/fetch/status");

await task.asyncSleep((int)(interval * 3_600_000));
await task.asyncSleep((int)(interval * 3_600_000), 60_000);
if (task.cancellationToken.IsCancellationRequested) {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Protest/Tasks/TaskWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void RequestCancel(string origin) {
cancellationTokenSource.Cancel();
}

public void Sleep(int millisecond, int interval = 360_000) {
public void Sleep(int millisecond, int interval = 300_000) {
long start = DateTime.UtcNow.Ticks;
while (!cancellationToken.IsCancellationRequested) {
long elapsed = (DateTime.UtcNow.Ticks - start) / 10_000; //to milliseconds
Expand All @@ -90,7 +90,7 @@ public void Sleep(int millisecond, int interval = 360_000) {
}
}

public async Task asyncSleep(int millisecond, int interval = 360_000) {
public async Task asyncSleep(int millisecond, int interval = 300_000) {
long start = DateTime.UtcNow.Ticks;
while (!cancellationToken.IsCancellationRequested) {
long elapsed = (DateTime.UtcNow.Ticks - start) / 10_000; //to milliseconds
Expand Down

0 comments on commit 18a635f

Please sign in to comment.