Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Exonerator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is archived. Its data is
read-only
.
Show more breadcrumbs
Legacy
gitolite
user
karsten
Exonerator
Commits
d165e4a1
Commit
d165e4a1
authored
Jan 14, 2020
by
Karsten Loesing
Browse files
Options
Downloads
Patches
Plain Diff
Use configured base URL for permanent link.
Turn absolute links into relative links. Fixes
#27925
.
parent
a4187326
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+6
-0
6 additions, 0 deletions
CHANGELOG.md
src/main/java/org/torproject/metrics/exonerator/ExoneraTorServlet.java
+30
-23
30 additions, 23 deletions
.../org/torproject/metrics/exonerator/ExoneraTorServlet.java
with
36 additions
and
23 deletions
CHANGELOG.md
+
6
−
0
View file @
d165e4a1
# Changes in version 4.?.? - 2019-1?-??
*
Medium changes
-
Turn absolute links to nearby addresses and translations into
relative links to avoid falling back to http://. Use the base URL
from the deployment descriptor for the printed permanent link,
also to avoid falling back to http://.
# Changes in version 4.2.0 - 2019-11-09
...
...
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/torproject/metrics/exonerator/ExoneraTorServlet.java
+
30
−
23
View file @
d165e4a1
...
...
@@ -140,8 +140,14 @@ public class ExoneraTorServlet extends HttpServlet {
PrintWriter
out
=
new
PrintWriter
(
so
);
this
.
writeHeader
(
out
,
rb
,
langStr
);
/* Obtain request URL without query string parameters for links. */
String
requestUrl
=
request
.
getRequestURL
().
toString
();
/* Obtain the current request URI for relative links and the configured
* base URL for absolute links like the printed permanent link. If no base
* URL has been configured, use the current request URL for the permanent
* link. */
String
requestUri
=
request
.
getRequestURI
();
String
baseUrl
=
this
.
getServletContext
().
getInitParameter
(
"baseUrl"
);
String
permanentLinkUrl
=
(
null
!=
baseUrl
)
?
(
baseUrl
+
requestUri
)
:
request
.
getRequestURL
().
toString
();
/* Write form. */
boolean
timestampOutOfRange
=
requestedDate
.
valid
...
...
@@ -157,43 +163,43 @@ public class ExoneraTorServlet extends HttpServlet {
/* If both parameters are empty, don't print any summary and exit.
* This is the start page. */
if
(
""
.
equals
(
relayIp
)
&&
requestedDate
.
empty
)
{
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
/* If only one parameter is empty and the other is not, print summary
* with warning message and exit. */
}
else
if
(
""
.
equals
(
relayIp
))
{
this
.
writeSummaryNoIp
(
out
,
rb
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
}
else
if
(
requestedDate
.
empty
)
{
this
.
writeSummaryNoTimestamp
(
out
,
rb
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
/* If there's an issue with parsing either of the parameters, print
* summary with error message and exit. */
}
else
if
(
relayIpHasError
)
{
this
.
writeSummaryInvalidIp
(
out
,
rb
,
ipParameter
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
}
else
if
(!
requestedDate
.
valid
)
{
this
.
writeSummaryInvalidTimestamp
(
out
,
rb
,
requestedDate
.
asRequested
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
/* If the timestamp is too recent, print summary with error message and
* exit. */
}
else
if
(
requestedDate
.
tooRecent
)
{
this
.
writeSummaryTimestampTooRecent
(
out
,
rb
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
/* If we were unable to connect to the database,
* write an error message. */
}
else
if
(!
successfullyConnectedToBackend
)
{
this
.
writeSummaryUnableToConnectToBackend
(
out
,
rb
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
/* Similarly, if we found the database to be empty,
* write an error message, too. */
}
else
if
(
firstDate
.
empty
||
lastDate
.
empty
)
{
this
.
writeSummaryNoData
(
out
,
rb
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
null
,
null
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
null
,
null
);
/* If the requested date is out of range, tell the user. */
}
else
if
(
timestampOutOfRange
)
{
...
...
@@ -201,11 +207,11 @@ public class ExoneraTorServlet extends HttpServlet {
this
.
writeSummaryTimestampOutsideRange
(
out
,
rb
,
requestedDate
.
asString
,
firstDate
.
asString
,
lastDate
.
date
.
isBefore
(
dayBeforeYesterday
)
?
lastDate
.
asString
:
dayBeforeYesterday
.
format
(
ISO_LOCAL_DATE
));
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
relayIp
,
requestedDate
.
asString
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
relayIp
,
requestedDate
.
asString
);
}
else
if
(
noRelevantConsensuses
)
{
this
.
writeSummaryNoDataForThisInterval
(
out
,
rb
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
relayIp
,
requestedDate
.
asString
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
relayIp
,
requestedDate
.
asString
);
/* Print out result. */
}
else
{
...
...
@@ -215,14 +221,14 @@ public class ExoneraTorServlet extends HttpServlet {
statusEntries
);
}
else
if
(
addressesInSameNetwork
!=
null
&&
!
addressesInSameNetwork
.
isEmpty
())
{
this
.
writeSummaryAddressesInSameNetwork
(
out
,
rb
,
requestUr
l
,
relayIp
,
this
.
writeSummaryAddressesInSameNetwork
(
out
,
rb
,
requestUr
i
,
relayIp
,
requestedDate
.
asString
,
langStr
,
addressesInSameNetwork
);
}
else
{
this
.
writeSummaryNegative
(
out
,
rb
,
relayIp
,
requestedDate
.
asString
);
}
this
.
writePermanentLink
(
out
,
rb
,
request
Url
,
relayIp
,
this
.
writePermanentLink
(
out
,
rb
,
permanentLink
Url
,
relayIp
,
requestedDate
.
asString
,
langStr
);
this
.
writeFooter
(
out
,
rb
,
requestUr
l
,
relayIp
,
requestedDate
.
asString
);
this
.
writeFooter
(
out
,
rb
,
requestUr
i
,
relayIp
,
requestedDate
.
asString
);
}
/* Forward to the JSP that adds header and footer. */
...
...
@@ -464,7 +470,7 @@ public class ExoneraTorServlet extends HttpServlet {
}
void
writeSummaryAddressesInSameNetwork
(
PrintWriter
out
,
ResourceBundle
rb
,
String
requestUr
l
,
String
relayIp
,
String
timestampStr
,
ResourceBundle
rb
,
String
requestUr
i
,
String
relayIp
,
String
timestampStr
,
String
langStr
,
List
<
String
>
addressesInSameNetwork
)
{
Object
[][]
panelItems
=
new
Object
[
addressesInSameNetwork
.
size
()][];
for
(
int
i
=
0
;
i
<
addressesInSameNetwork
.
size
();
i
++)
{
...
...
@@ -474,11 +480,11 @@ public class ExoneraTorServlet extends HttpServlet {
if
(
addressInSameNetwork
.
contains
(
":"
))
{
address
=
addressInSameNetwork
.
replaceAll
(
"[\\[\\]]"
,
""
);
link
=
String
.
format
(
"%s?ip=[%s]×tamp=%s&lang=%s"
,
requestUr
l
,
address
.
replaceAll
(
":"
,
"%3A"
),
timestampStr
,
langStr
);
requestUr
i
,
address
.
replaceAll
(
":"
,
"%3A"
),
timestampStr
,
langStr
);
address
=
"["
+
address
+
"]"
;
}
else
{
link
=
String
.
format
(
"%s?ip=%s×tamp=%s&lang=%s"
,
requestUr
l
,
addressInSameNetwork
,
timestampStr
,
langStr
);
requestUr
i
,
addressInSameNetwork
,
timestampStr
,
langStr
);
address
=
addressInSameNetwork
;
}
panelItems
[
i
]
=
new
Object
[]
{
link
,
address
};
...
...
@@ -600,7 +606,8 @@ public class ExoneraTorServlet extends HttpServlet {
}
private
void
writePermanentLink
(
PrintWriter
out
,
ResourceBundle
rb
,
String
requestUrl
,
String
relayIp
,
String
timestampStr
,
String
langStr
)
{
String
permanentLinkUrl
,
String
relayIp
,
String
timestampStr
,
String
langStr
)
{
String
encodedAddress
=
relayIp
.
contains
(
":"
)
?
"["
+
relayIp
.
replaceAll
(
":"
,
"%3A"
)
+
"]"
:
relayIp
;
out
.
printf
(
" <div class=\"row\">\n"
...
...
@@ -610,12 +617,12 @@ public class ExoneraTorServlet extends HttpServlet {
+
"timestamp=%s&lang=%s</pre>\n"
+
" </div><!-- col -->\n"
+
" </div><!-- row -->\n"
,
rb
.
getString
(
"permanentlink.heading"
),
request
Url
,
rb
.
getString
(
"permanentlink.heading"
),
permanentLink
Url
,
encodedAddress
,
timestampStr
,
langStr
);
}
private
void
writeFooter
(
PrintWriter
out
,
ResourceBundle
rb
,
String
requestUr
l
,
String
relayIp
,
String
timestampStr
)
{
String
requestUr
i
,
String
relayIp
,
String
timestampStr
)
{
out
.
printf
(
" </div><!-- container -->\n"
+
" <div class=\"container\">\n"
+
" <div class=\"row\">\n"
...
...
@@ -644,11 +651,11 @@ public class ExoneraTorServlet extends HttpServlet {
:
this
.
availableLanguageNames
.
entrySet
())
{
if
(
null
!=
relayIp
&&
null
!=
timestampStr
)
{
out
.
printf
(
" <a href=\"%s?ip=%s×tamp=%s&lang=%s\">%s</a>"
,
requestUr
l
,
relayIp
,
timestampStr
,
entry
.
getKey
(),
requestUr
i
,
relayIp
,
timestampStr
,
entry
.
getKey
(),
entry
.
getValue
());
}
else
{
out
.
printf
(
" <a href=\"%s?lang=%s\">%s</a>"
,
requestUr
l
,
entry
.
getKey
(),
entry
.
getValue
());
requestUr
i
,
entry
.
getKey
(),
entry
.
getValue
());
}
}
out
.
printf
(
"</p>\n"
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment