Skip to content

Commit 764c817

Browse files
Issue #10388 - fix InetAccessHandler module
Signed-off-by: Lachlan Roberts <[email protected]>
1 parent 0411e1f commit 764c817

File tree

4 files changed

+15
-45
lines changed

4 files changed

+15
-45
lines changed

jetty-server/src/main/config/modules/inetaccess.mod

+5-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[description]
44
Enables the InetAccessHandler.
5-
Applies a include/exclude control of the remote IP of requests.
5+
Applies an include/exclude control of the remote IP of requests.
66

77
[tags]
88
connector
@@ -18,15 +18,9 @@ etc/jetty-inetaccess.xml
1818

1919
[ini-template]
2020

21-
## List of InetAddress patterns to include
22-
#jetty.inetaccess.include=127.0.0.1,127.0.0.2
21+
## List of InetAddress patterns to include (connectorName@addressPattern|pathSpec)
22+
#jetty.inetaccess.include=http@127.0.0.1-127.0.0.2|/pathSpec,tls@,|/pathSpec2,127.0.0.20
2323

24-
## List of InetAddress patterns to exclude
25-
#jetty.inetaccess.exclude=127.0.0.1,127.0.0.2
26-
27-
## List of Connector names to include
28-
#jetty.inetaccess.includeConnectors=http
29-
30-
## List of Connector names to exclude
31-
#jetty.inetaccess.excludeConnectors=tls
24+
## List of InetAddress patterns to exclude (connectorName@addressPattern|pathSpec)
25+
#[email protected]|/pathSpec,tls@,|/pathSpec2,127.0.0.20
3226

jetty-server/src/main/config/modules/inetaccess/inetaccess.xml

-13
This file was deleted.

jetty-server/src/main/config/modules/inetaccess/jetty-inetaccess.xml

-14
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@
1919
</Call>
2020
</Arg>
2121
</Call>
22-
<Call name="includeConnectors">
23-
<Arg>
24-
<Call class="org.eclipse.jetty.util.StringUtil" name="csvSplit">
25-
<Arg><Property name="jetty.inetaccess.includeConnectors" default="" /></Arg>
26-
</Call>
27-
</Arg>
28-
</Call>
29-
<Call name="excludeConnectors">
30-
<Arg>
31-
<Call class="org.eclipse.jetty.util.StringUtil" name="csvSplit">
32-
<Arg><Property name="jetty.inetaccess.excludeConnectors" default="" /></Arg>
33-
</Call>
34-
</Arg>
35-
</Call>
3622
</New>
3723
</Arg>
3824
</Call>

jetty-server/src/main/java/org/eclipse/jetty/server/handler/InetAccessSet.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class InetAccessSet extends AbstractSet<InetAccessSet.PatternTuple> implements Set<InetAccessSet.PatternTuple>, Predicate<InetAccessSet.AccessTuple>
2929
{
30-
private ArrayList<PatternTuple> tuples = new ArrayList<>();
30+
private final ArrayList<PatternTuple> tuples = new ArrayList<>();
3131

3232
@Override
3333
public boolean add(PatternTuple storageTuple)
@@ -67,7 +67,7 @@ public boolean test(AccessTuple entry)
6767
return false;
6868
}
6969

70-
static class PatternTuple implements Predicate<AccessTuple>
70+
public static class PatternTuple implements Predicate<AccessTuple>
7171
{
7272
private final String connector;
7373
private final InetAddressPattern address;
@@ -110,19 +110,22 @@ public boolean test(AccessTuple entry)
110110
if ((connector != null) && !connector.equals(entry.getConnector()))
111111
return false;
112112

113-
// If we have a path we must must be at this path to match for an address.
113+
// If we have a path we must be at this path to match for an address.
114114
if ((pathSpec != null) && !pathSpec.matches(entry.getPath()))
115115
return false;
116116

117117
// Match for InetAddress.
118-
if ((address != null) && !address.test(entry.getAddress()))
119-
return false;
118+
return (address == null) || address.test(entry.getAddress());
119+
}
120120

121-
return true;
121+
@Override
122+
public String toString()
123+
{
124+
return String.format("%s@%x{connector=%s, addressPattern=%s, pathSpec=%s}", getClass().getSimpleName(), hashCode(), connector, address, pathSpec);
122125
}
123126
}
124127

125-
static class AccessTuple
128+
public static class AccessTuple
126129
{
127130
private final String connector;
128131
private final InetAddress address;

0 commit comments

Comments
 (0)