Created
June 27, 2012 13:50
-
-
Save ThomasLocke/3004185 to your computer and use it in GitHub Desktop.
Ada Web Server patch to show WebSocket configuration parameters on the AWS status page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From d08f5587c354e8e58b837dfe2d1f8dca8d8ef376 Mon Sep 17 00:00:00 2001 | |
| From: =?UTF-8?q?Thomas=20L=C3=B8cke?= <[email protected]> | |
| Date: Wed, 27 Jun 2012 15:46:27 +0200 | |
| Subject: [PATCH] Added the WebSocket configuration parameters to the AWS | |
| status page. | |
| --- | |
| demos/runme/aws_status.thtml | 42 +++++++++++++++++++++++++++++++++------ | |
| src/core/aws-config-set.adb | 2 + | |
| src/core/aws-config.adb | 9 ++++++++ | |
| src/core/aws-config.ads | 7 +++++- | |
| src/core/aws-server-status.adb | 9 ++++++++ | |
| 5 files changed, 61 insertions(+), 8 deletions(-) | |
| diff --git a/demos/runme/aws_status.thtml b/demos/runme/aws_status.thtml | |
| index 14b94aa..9ff0016 100644 | |
| --- a/demos/runme/aws_status.thtml | |
| +++ b/demos/runme/aws_status.thtml | |
| @@ -383,7 +383,7 @@ | |
| @_FREE_SLOTS_KEEP_ALIVE_LIMIT_@ | |
| </td> | |
| </tr> | |
| - <tr class="background"> | |
| + <tr> | |
| <td class="key"> | |
| Hotplug Port: | |
| </td> | |
| @@ -391,7 +391,7 @@ | |
| @_HOTPLUG_PORT_@ | |
| </td> | |
| </tr> | |
| - <tr> | |
| + <tr class="background"> | |
| <td class="key"> | |
| Input Line Size Limit: | |
| </td> | |
| @@ -399,7 +399,7 @@ | |
| @_INPUT_LINE_SIZE_LIMIT_@ | |
| </td> | |
| </tr> | |
| - <tr class="background"> | |
| + <tr> | |
| <td class="key"> | |
| Keep Alive Force Limit: | |
| </td> | |
| @@ -407,7 +407,7 @@ | |
| @_KEEP_ALIVE_FORCE_LIMIT_@ | |
| </td> | |
| </tr> | |
| - <tr> | |
| + <tr class="background"> | |
| <td class="key"> | |
| Key (RSA): | |
| </td> | |
| @@ -419,7 +419,7 @@ | |
| @@END_IF@@ | |
| </td> | |
| </tr> | |
| - <tr class="background"> | |
| + <tr> | |
| <td class="key"> | |
| Line Stack Size: | |
| </td> | |
| @@ -427,7 +427,7 @@ | |
| @_LINE_STACK_SIZE_@ bytes | |
| </td> | |
| </tr> | |
| - <tr> | |
| + <tr class="background"> | |
| <td class="key"> | |
| Max Concurrent Download: | |
| </td> | |
| @@ -435,6 +435,14 @@ | |
| @_MAX_CONCURRENT_DOWNLOAD_@ | |
| </td> | |
| </tr> | |
| + <tr> | |
| + <td class="key"> | |
| + Max WebSocket Handler: | |
| + </td> | |
| + <td class="data_color"> | |
| + @_MAX_WEBSOCKET_HANDLER_@ | |
| + </td> | |
| + </tr> | |
| <tr class="background"> | |
| <td class="key"> | |
| Maximum Connections: | |
| @@ -486,7 +494,7 @@ | |
| @_YES_NO:SESSION_@ | |
| </td> | |
| </tr> | |
| - <tr class="background"> | |
| + <tr class="background"> | |
| <td class="key"> | |
| Server Host: | |
| </td> | |
| @@ -583,6 +591,26 @@ | |
| </tr> | |
| <tr> | |
| <td class="key"> | |
| + WebSocket Message Queue Size: | |
| + </td> | |
| + <td class="data_color"> | |
| + @_WEBSOCKET_MESSAGE_QUEUE_SIZE_@ | |
| + </td> | |
| + </tr> | |
| + <tr class="background"> | |
| + <td class="key"> | |
| + WebSocket Origin: | |
| + </td> | |
| + <td class="data_color"> | |
| + @@IF@@ @_WEBSOCKET_ORIGIN_@ /= "" | |
| + @_WEBSOCKET_ORIGIN_@ | |
| + @@ELSE@@ | |
| + Any origin | |
| + @@END_IF@@ | |
| + </td> | |
| + </tr> | |
| + <tr> | |
| + <td class="key"> | |
| WWW Root: | |
| </td> | |
| <td class="data_color"> | |
| diff --git a/src/core/aws-config-set.adb b/src/core/aws-config-set.adb | |
| index 716c251..160819a 100644 | |
| --- a/src/core/aws-config-set.adb | |
| +++ b/src/core/aws-config-set.adb | |
| @@ -602,6 +602,8 @@ package body AWS.Config.Set is | |
| Process_Options (WebSocket_Origin).Is_Set := True; | |
| Process_Options (WebSocket_Origin).Pattern := | |
| GNAT.Regexp.Compile (Value); | |
| + Process_Options (WebSocket_Origin).Regexp_Str := | |
| + To_Unbounded_String (Value); | |
| end WebSocket_Origin; | |
| -------------- | |
| diff --git a/src/core/aws-config.adb b/src/core/aws-config.adb | |
| index 9f2d9b0..533d956 100644 | |
| --- a/src/core/aws-config.adb | |
| +++ b/src/core/aws-config.adb | |
| @@ -658,6 +658,15 @@ package body AWS.Config is | |
| return Process_Options (WebSocket_Origin).Pattern; | |
| end WebSocket_Origin; | |
| + ---------------------- | |
| + -- WebSocket_Origin -- | |
| + ---------------------- | |
| + | |
| + function WebSocket_Origin return String is | |
| + begin | |
| + return To_String (Process_Options (WebSocket_Origin).Regexp_Str); | |
| + end WebSocket_Origin; | |
| + | |
| -------------- | |
| -- WWW_Root -- | |
| -------------- | |
| diff --git a/src/core/aws-config.ads b/src/core/aws-config.ads | |
| index d358dc0..856c33d 100644 | |
| --- a/src/core/aws-config.ads | |
| +++ b/src/core/aws-config.ads | |
| @@ -405,6 +405,10 @@ package AWS.Config is | |
| function WebSocket_Origin return GNAT.Regexp.Regexp; | |
| -- This is regular expression to restrict WebSocket to a specific origin | |
| + function WebSocket_Origin return String; | |
| + -- This is the string regular expression to restrict WebSocket to a | |
| + -- specific origin | |
| + | |
| private | |
| package SV renames AWS.Containers.String_Vectors; | |
| @@ -512,6 +516,7 @@ private | |
| when Regexp => | |
| Is_Set : Boolean; | |
| Pattern : GNAT.Regexp.Regexp; | |
| + Regexp_Str : Unbounded_String; | |
| end case; | |
| end record; | |
| @@ -706,7 +711,7 @@ private | |
| (Pos, Default.WebSocket_Message_Queue_Size), | |
| WebSocket_Origin => | |
| - (Regexp, False, Pattern => <>), | |
| + (Regexp, False, Pattern => <>, Regexp_Str => Null_Unbounded_String), | |
| Context_Lifetime => | |
| (Dur, Default.Context_Lifetime)); | |
| diff --git a/src/core/aws-server-status.adb b/src/core/aws-server-status.adb | |
| index 1947db0..888fa93 100644 | |
| --- a/src/core/aws-server-status.adb | |
| +++ b/src/core/aws-server-status.adb | |
| @@ -536,6 +536,15 @@ package body AWS.Server.Status is | |
| Insert (Result, Assoc ("RESOURCES_SERVED", | |
| Resources_Served (Server))); | |
| + Insert (Result, Assoc ("MAX_WEBSOCKET_HANDLER", | |
| + CNF.Max_WebSocket_Handler)); | |
| + | |
| + Insert (Result, Assoc ("WEBSOCKET_MESSAGE_QUEUE_SIZE", | |
| + Utils.Image (CNF.WebSocket_Message_Queue_Size))); | |
| + | |
| + Insert (Result, Assoc ("WEBSOCKET_ORIGIN", | |
| + CNF.WebSocket_Origin)); | |
| + | |
| Log_Extended_Fields : declare | |
| Extended_Fields : Ada.Strings.Unbounded.Unbounded_String; | |
| -- | |
| 1.7.4.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment