Skip to content

Commit

Permalink
SNMP
Browse files Browse the repository at this point in the history
  • Loading branch information
veniware committed Mar 22, 2024
1 parent 51cd448 commit 195d94e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Protest/Front/snmp.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Snmp extends Window {
snmpInput.appendChild(oidLabel);

this.oidInput = document.createElement("textarea");
this.oidInput.placeholder = "1.3.6.1.2.1.1.5.0";
this.oidInput.placeholder = "1.3.6.1.2.1.1.5.0, 1.3.6.1.2.1.1.3.0";
this.oidInput.style.gridArea = "3 / 2 / 5 / 4";
this.oidInput.style.resize = "none";
this.oidInput.style.minWidth = "50px";
Expand Down Expand Up @@ -178,7 +178,7 @@ class Snmp extends Window {
url = `snmp/get?target=${encodeURIComponent(this.targetInput.value)}&ver=3&cred=${this.credentialsInput.value}`;
}
else {
url = `snmp/get?target=${encodeURIComponent(this.targetInput.value)}&ver=${this.versionInput.value}&community=${encodeURIComponent(this.credentialsInput.value)}`;
url = `snmp/get?target=${encodeURIComponent(this.targetInput.value)}&ver=${this.versionInput.value}&community=${encodeURIComponent(this.communityInput.value)}`;
}

const response = await fetch(url, {
Expand Down Expand Up @@ -227,7 +227,7 @@ class Snmp extends Window {
url = `snmp/set?target=${encodeURIComponent(this.targetInput.value)}&ver=3&cred=${this.credentialsInput.value}&value=${encodeURIComponent(value)}`;
}
else {
url = `snmp/set?target=${encodeURIComponent(this.targetInput.value)}&ver=${this.versionInput.value}&community=${encodeURIComponent(this.credentialsInput.value)}&value=${encodeURIComponent(value)}`;
url = `snmp/set?target=${encodeURIComponent(this.targetInput.value)}&ver=${this.versionInput.value}&community=${encodeURIComponent(this.communityInput.value)}&value=${encodeURIComponent(value)}`;
}

const response = await fetch(url, {
Expand Down
9 changes: 5 additions & 4 deletions Protest/Protocols/Snmp.Polling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public static byte[] GetHandler(HttpListenerContext ctx, Dictionary<string, stri
catch (OperationCanceledException) {
bytes = "{\"error\":\"Operation timed out\"}"u8.ToArray();
}
catch (Exception) {
bytes = "{\"error\":\"Unknown error\"}"u8.ToArray();
catch (Exception ex) {
bytes = Encoding.UTF8.GetBytes($"{{\"error\":\"{ex.Message}\"}}");
}
}).GetAwaiter().GetResult();

Expand Down Expand Up @@ -177,8 +177,9 @@ public static byte[] SetHandler(HttpListenerContext ctx, Dictionary<string, stri
catch (OperationCanceledException) {
bytes = "{\"error\":\"Operation timed out\"}"u8.ToArray();
}
catch (Exception) {
bytes = "{\"error\":\"Unknown error\"}"u8.ToArray();
catch (Exception ex) {
bytes = Encoding.UTF8.GetBytes($"{{\"error\":\"{ex.Message}\"}}");

}
}).GetAwaiter().GetResult();

Expand Down

0 comments on commit 195d94e

Please sign in to comment.