Skip to content

Commit

Permalink
Tweaking
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Aug 16, 2024
1 parent 932e379 commit 88866a8
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Protest/Front/dns-sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DnsSD extends Console {
this.args = args ?? {
entries : [],
type : "ANY",
timeout : 2000,
timeout : 1000,
additionalRrs : false
};

Expand Down
15 changes: 10 additions & 5 deletions Protest/Front/hexviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class HexViewer extends Window {
const first = this.PopulateLabel("Name", 1, hexContainer, charContainer, start, end - start - 1, true);
index = end;

let type = (stream[index] << 8) | stream[index+1];
const type = (stream[index] << 8) | stream[index+1];
this.PopulateLabel(`Type: ${type} ${HexViewer.DNS_RECORD_TYPES[type] ? `(${HexViewer.DNS_RECORD_TYPES[type]})` : ""}`, 1, hexContainer, charContainer, index, 2);
index += 2;

Expand All @@ -582,9 +582,8 @@ class HexViewer extends Window {
this.PopulateLabel(`Cache-flush: true`, 1, hexContainer, charContainer, index, 2);
}

let class_ = stream[index+1];
const class_ = stream[index+1];
this.PopulateLabel(`Class: ${class_} ${HexViewer.DNS_CLASSES[class_] ? `(${HexViewer.DNS_CLASSES[class_]})` : ""}`, 1, hexContainer, charContainer, index, 2);

index += 2;

const element = this.PopulateLabel("Question:", 0, hexContainer, charContainer, start, index - start, true);
Expand All @@ -595,7 +594,7 @@ class HexViewer extends Window {

const totalRecords = qCount + anCount + auCount + adCount;
while (index < stream.length && count < totalRecords) { //records
let start = index;
const start = index;
let end = index;

if ((stream[index] & 0xC0) === 0xC0) { //pointer
Expand All @@ -618,8 +617,14 @@ class HexViewer extends Window {
index = end;

const type = (stream[index] << 8) | stream[index+1];
this.PopulateLabel(`Type: ${type} ${HexViewer.DNS_RECORD_TYPES[type] ? `(${HexViewer.DNS_RECORD_TYPES[type]})` : ""}`, 1, hexContainer, charContainer, index, 2);
const x = this.PopulateLabel(`Type: ${type}`, 1, hexContainer, charContainer, index, 2);
index += 2;

if (HexViewer.DNS_RECORD_TYPES[type]) {
const typeLabel = document.createElement("div");
typeLabel.textContent = HexViewer.DNS_RECORD_TYPES[type];
x.appendChild(typeLabel);
}

const cacheFlashFlag = stream[index] & 0x80;
if (cacheFlashFlag > 0) {
Expand Down
6 changes: 5 additions & 1 deletion Protest/Front/reverseproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ReverseProxy extends List {
this.totalRxValue.style.fontFamily = "monospace";
this.totalRxValue.style.textAlign = "right";
this.totalRxValue.style.lineHeight = "20px";
this.totalRxValue.style.userSelect = "text";

this.totalTxValue = document.createElement("div");
this.totalTxValue.style.position = "absolute";
Expand All @@ -154,6 +155,7 @@ class ReverseProxy extends List {
this.totalTxValue.style.fontFamily = "monospace";
this.totalTxValue.style.textAlign = "right";
this.totalTxValue.style.lineHeight = "20px";
this.totalTxValue.style.userSelect = "text";

this.stats.append(this.totalRxLabel, this.totalTxLabel, this.totalRxValue, this.totalTxValue);

Expand Down Expand Up @@ -189,7 +191,8 @@ class ReverseProxy extends List {
this.rxRateValue.style.fontFamily = "monospace";
this.rxRateValue.style.textAlign = "right";
this.rxRateValue.style.lineHeight = "20px";

this.rxRateValue.style.userSelect = "text";

this.txRateValue = document.createElement("div");
this.txRateValue.style.position = "absolute";
this.txRateValue.style.left = "350px";
Expand All @@ -202,6 +205,7 @@ class ReverseProxy extends List {
this.txRateValue.style.fontFamily = "monospace";
this.txRateValue.style.textAlign = "right";
this.txRateValue.style.lineHeight = "20px";
this.txRateValue.style.userSelect = "text";

this.stats.append(this.rxRateLabel, this.txRateLabel, this.rxRateValue, this.txRateValue);

Expand Down
16 changes: 5 additions & 11 deletions Protest/Front/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,12 @@ const MENU = {

for (const file in LOADER.devices.data) {
const match = keywords.every(
keyword=> Object.values(LOADER.devices.data[file]).some(
attr=> attr.v.toLowerCase().includes(keyword)
)
keyword=> Object.values(LOADER.devices.data[file]).some(attr=> attr.v.toLowerCase().includes(keyword))
);
if (!match) continue;

const exactMatch = keywords.some(
keyword=> Object.values(LOADER.devices.data[file]).some(
attr=> attr.v.toLowerCase() === keyword
)
keyword=> Object.values(LOADER.devices.data[file]).some(attr=> attr.v.toLowerCase() === keyword)
);

let type = LOADER.devices.data[file].type ? LOADER.devices.data[file].type.v.toLowerCase() : null;
Expand Down Expand Up @@ -706,9 +702,7 @@ const MENU = {
if (!match) continue;

const exactMatch = keywords.some(
keyword=> Object.values(LOADER.users.data[file]).some(
attr=> attr.v.toLowerCase() === keyword
)
keyword=> Object.values(LOADER.users.data[file]).some(attr=> attr.v.toLowerCase() === keyword)
);

let type = LOADER.users.data[file].type ? LOADER.users.data[file].type.v.toLowerCase() : null;
Expand Down Expand Up @@ -761,12 +755,12 @@ const MENU = {
if (++count > 32) break;
}

for (let i=exactMatchUsers.length-1; i >= 0; i--) {
for (let i=exactMatchUsers.length-1; i>=0; i--) {
MENU.list.unshift(exactMatchUsers[i]);
menulist.prepend(exactMatchUsers[i]);
}

for (let i=exactMatchDevices.length-1; i >= 0; i--) {
for (let i=exactMatchDevices.length-1; i>=0; i--) {
MENU.list.unshift(exactMatchDevices[i]);
menulist.prepend(exactMatchDevices[i]);
}
Expand Down
5 changes: 5 additions & 0 deletions Protest/Http/Listener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ private void ListenerCallback(IAsyncResult result) {

string xRealIpHeader = ctx.Request?.Headers?.Get("X-Real-IP");
if (xRealIpHeader is not null && IPAddress.TryParse(xRealIpHeader, out IPAddress realIp)) {
if (IPAddress.IsLoopback(realIp)) {
ctx.Response.StatusCode = 418; //I'm a teapot
ctx.Response.Close();
return;
}
ctx.Request.RemoteEndPoint.Address = realIp;
}

Expand Down
4 changes: 2 additions & 2 deletions Protest/Protocols/Mdns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static byte[] Resolve(Dictionary<string, string> parameters) {
parameters.TryGetValue("additionalrrs", out string additionalString);

if (!int.TryParse(Uri.UnescapeDataString(timeoutString), out int timeout)) {
timeout = 2000;
timeout = 1000;
}

timeout = Math.Max(timeout, 500);
Expand All @@ -65,7 +65,7 @@ public static byte[] Resolve(Dictionary<string, string> parameters) {
return Resolve(query, timeout, type, includeAdditionalRrs);
}

public static byte[] Resolve(string queryString, int timeout = 2000, RecordType type = RecordType.A, bool includeAdditionalRrs = false) {
public static byte[] Resolve(string queryString, int timeout = 1000, RecordType type = RecordType.A, bool includeAdditionalRrs = false) {
byte[] query = ConstructQuery(queryString, type);
List<byte[]> receivedData = new List<byte[]>();
List<IPAddress> sender = new List<IPAddress>();
Expand Down
1 change: 0 additions & 1 deletion Protest/Workers/Issues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Lextm.SharpSnmpLib;

using Protest.Http;
using Protest.Protocols;
using Protest.Tools;

namespace Protest.Workers;
Expand Down

0 comments on commit 88866a8

Please sign in to comment.