Skip to content

Commit cb8f23b

Browse files
committed
System Touch
1 parent d6a4a3e commit cb8f23b

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

configuration/nwe-config.xml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,46 @@
235235
</description>
236236
</server>
237237

238+
<!-- ═══════════════════════════════════════════════════════════════════
239+
BASE SERVER CLASS SELECTION
240+
═══════════════════════════════════════════════════════════════════
241+
Selects which server implementation handles inbound connections.
242+
Only one may be active at a time. Set selected="true" on the
243+
desired class; all others must be "false".
244+
245+
BaseServer — standard server, no connection caps or
246+
weight balancing. Default.
247+
HardenedBaseServer — connection caps (512), per-IP limit (10),
248+
reduced timeout (30 min), port whitelist.
249+
Premium option.
250+
NationalAwareHardService — weight-based request balancing, 5040 max
251+
connections, 1-per-IP, 58-min timeout,
252+
cost-aware ejection of heavy consumers.
253+
Premium option.
254+
════════════════════════════════════════════════════════════════════ -->
255+
<server-class>
256+
<option id="BASE_SERVER" selected="true" premium="false">
257+
<class>server.base.BaseServer</class>
258+
<description>Standard BaseServer. No connection limits or weight balancing.</description>
259+
</option>
260+
<option id="HARDENED_BASE_SERVER" selected="false" premium="true">
261+
<class>server.experimental.HardenedBaseServer</class>
262+
<description>
263+
Hardened server with 512 max connections, 10 per-IP limit,
264+
30-minute socket timeout, port whitelist, and graceful shutdown.
265+
</description>
266+
</option>
267+
<option id="NATIONAL_AWARE_HARD_SERVICE" selected="false" premium="true">
268+
<class>server.hardened.experimental.m.NationalAwareHardService</class>
269+
<description>
270+
Weight-balanced hardened server. 5040 max connections, 1 per-IP,
271+
58-minute timeout. Long/heavy requests cost more weight and are
272+
ejected when budget is exceeded — protecting lightweight requests
273+
from starvation.
274+
</description>
275+
</option>
276+
</server-class>
277+
238278
<!-- ═══════════════════════════════════════════════════════════════════
239279
REMOTE / EXTERNAL SERVERS (for outbound connections)
240280
════════════════════════════════════════════════════════════════════ -->

source/configuration/NitroWebExpressConfig.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,52 @@ public static boolean isEnabled(final String SERVER_ID)
6262
public static String antivirusSchedule() { return get().ANTIVIRUS_SCHEDULE; }
6363
public static String antivirusScanPath() { return get().ANTIVIRUS_SCAN_PATH; }
6464

65+
/** Returns the fully-qualified class name of the selected server-class option.
66+
* Defaults to "server.base.BaseServer" if not configured. */
67+
public static String selectedServerClass()
68+
{
69+
if (INSTANCE == null) load();
70+
try
71+
{
72+
Document doc = DocumentBuilderFactory.newInstance()
73+
.newDocumentBuilder().parse(new File(CONFIG_FILE));
74+
doc.getDocumentElement().normalize();
75+
NodeList options = doc.getElementsByTagName("option");
76+
for (int i = 0; i < options.getLength(); i++)
77+
{
78+
Element el = (Element) options.item(i);
79+
if ("true".equalsIgnoreCase(el.getAttribute("selected")))
80+
{
81+
NodeList cls = el.getElementsByTagName("class");
82+
if (cls.getLength() > 0) return cls.item(0).getTextContent().trim();
83+
}
84+
}
85+
}
86+
catch (Exception ignored) {}
87+
return "server.base.BaseServer";
88+
}
89+
90+
/** Returns true if the selected server-class option is marked premium="true". */
91+
public static boolean isSelectedServerPremium()
92+
{
93+
if (INSTANCE == null) load();
94+
try
95+
{
96+
Document doc = DocumentBuilderFactory.newInstance()
97+
.newDocumentBuilder().parse(new File(CONFIG_FILE));
98+
doc.getDocumentElement().normalize();
99+
NodeList options = doc.getElementsByTagName("option");
100+
for (int i = 0; i < options.getLength(); i++)
101+
{
102+
Element el = (Element) options.item(i);
103+
if ("true".equalsIgnoreCase(el.getAttribute("selected")))
104+
return "true".equalsIgnoreCase(el.getAttribute("premium"));
105+
}
106+
}
107+
catch (Exception ignored) {}
108+
return false;
109+
}
110+
65111
/** Return the text content of the first top-level &lt;key&gt; element, or null. */
66112
public static String get(final String KEY)
67113
{

0 commit comments

Comments
 (0)