From 6766293c7f1c88bda07fd274616eeb6be4670f1a Mon Sep 17 00:00:00 2001 From: Bogo Date: Thu, 22 Feb 2024 08:51:01 +0100 Subject: [PATCH 1/2] Create HighlightListenerPort.bambda Just a highlighter in case you use more listener ports. --- Proxy/HTTP/HighlightListenerPort.bambda | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Proxy/HTTP/HighlightListenerPort.bambda diff --git a/Proxy/HTTP/HighlightListenerPort.bambda b/Proxy/HTTP/HighlightListenerPort.bambda new file mode 100644 index 0000000..38fb2b5 --- /dev/null +++ b/Proxy/HTTP/HighlightListenerPort.bambda @@ -0,0 +1,31 @@ +/** + * Highlight different listener port + * @author Bogo-6 (https://github.com/Bogo-6) + **/ + +boolean manualColorHighlightEnabled = true; + +var listenerPort = requestResponse.listenerPort(); + + +if (listenerPort == 8080) { + if (manualColorHighlightEnabled){ + requestResponse.annotations().setHighlightColor(HighlightColor.BLUE); + + //Optionally, add a note to the request. + requestResponse.annotations().setNotes("User 1"); + } + return true; +} + +if (listenerPort == 8082) { + if (manualColorHighlightEnabled){ + requestResponse.annotations().setHighlightColor(HighlightColor.YELLOW); + + //Optionally, add a note to the request. + requestResponse.annotations().setNotes("User 2"); + } + return true; +} + +return false; \ No newline at end of file From 0d27cf6777ee1ab60ee8e8459d97b3bf25f8b3f7 Mon Sep 17 00:00:00 2001 From: Bogo Date: Thu, 22 Feb 2024 13:11:18 +0100 Subject: [PATCH 2/2] Update HighlightListenerPort.bambda --- Proxy/HTTP/HighlightListenerPort.bambda | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/Proxy/HTTP/HighlightListenerPort.bambda b/Proxy/HTTP/HighlightListenerPort.bambda index 38fb2b5..0ba6004 100644 --- a/Proxy/HTTP/HighlightListenerPort.bambda +++ b/Proxy/HTTP/HighlightListenerPort.bambda @@ -5,27 +5,26 @@ boolean manualColorHighlightEnabled = true; -var listenerPort = requestResponse.listenerPort(); +var colorMap = Map.of( + 8080, HighlightColor.BLUE, + 8082, HighlightColor.YELLOW +); +var notesMap = Map.of( + 8080, "User 1", + 8082, "User 2" +); -if (listenerPort == 8080) { - if (manualColorHighlightEnabled){ - requestResponse.annotations().setHighlightColor(HighlightColor.BLUE); +var listenerPort = requestResponse.listenerPort(); +var color = colorMap.get(listenerPort); +var notes = notesMap.get(listenerPort); - //Optionally, add a note to the request. - requestResponse.annotations().setNotes("User 1"); - } - return true; +if (manualColorHighlightEnabled && color != null) { + requestResponse.annotations().setHighlightColor(color); } -if (listenerPort == 8082) { - if (manualColorHighlightEnabled){ - requestResponse.annotations().setHighlightColor(HighlightColor.YELLOW); - - //Optionally, add a note to the request. - requestResponse.annotations().setNotes("User 2"); - } - return true; +if (manualColorHighlightEnabled && notes != null) { + requestResponse.annotations().setNotes(notes); } -return false; \ No newline at end of file +return color != null || notes != null;