java.lang.Object
net.i2p.router.web.helpers.SybilRenderer
Renders Sybil attack analysis and detection information for debugging. Displays router relationships, clustering analysis, and potential attack patterns. Provides visualization of network topology and security metrics. Adapted from
NetDbRenderer; may become periodic router monitor.Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classSybilRenderer.FooComparator<K extends Comparable>Orders keys by how many routers share each.private static classOrders names by how many routers share each.private static classOrders router hashes by sybil points.private static classReverse points, then forward by text.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RouterContextThe router context.private final LogLogger for the sybil page.private static final int[]Day ranges offered on the page.private static final int[]Hour ranges offered on the page.private static final intMaximum points counted per router.private static final doubleMinimum closeness counted as a match.private static final doubleMinimum points shown on the page.private static final intMaximum pairs counted per router.private static final DecimalFormatFormatter for numbers with two decimals.Constructor Summary
ConstructorsConstructorDescriptionRenders the Sybil analysis tables for the console.Method Summary
Modifier and TypeMethodDescriptionprivate StringTranslate a string.private StringTranslate a string with a parameter This is a lot more expensive than _t(s), so use sparingly.private static final StringTag only.private static Stringfmt(double val) Formats a number with two decimals.getNetDbSummary(Writer out, String nonce, int mode, long date) Entry point.private StringgetTranslatedCountry(String code) Countries now in a separate bundle.private voidrenderBackgroundForm(Writer out, StringBuilder buf, String nonce) Render the configuration form for background sybil analysis.private voidrenderCloseSummary(Writer out, StringBuilder buf, Analysis analysis, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) Render the closest floodfills to our routing key.private voidrenderCloseTmrwSummary(Writer out, StringBuilder buf, Analysis analysis, Hash us, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) Render the closest floodfills to tomorrow's routing key.private voidrenderDestSummary(Writer out, StringBuilder buf, Analysis analysis, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) Render the closest floodfills to our published destinations.private voidrenderDHTSummary(Writer out, StringBuilder buf, Analysis analysis, Hash us, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) Render the closest floodfills to our router hash.private voidrenderFamilySummary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the family group summary section.private voidrenderFFSummary(Writer out, StringBuilder buf, List<RouterInfo> ris, double avgMinDist) Render the floodfill summary section.private voidrenderIP16Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the /16 IP group summary.private voidrenderIP24Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the /24 IP group summary.private voidrenderIP32Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the /32 IP group summary.private voidrenderIP48Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the /48 IPv6 group summary.private voidrenderIP64Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the /64 IPv6 group summary.private voidrenderIPGroups16(Writer out, StringBuilder buf, Map<Integer, List<RouterInfo>> map) Render the HTML for /16 IP groups.private voidrenderIPGroups24(Writer out, StringBuilder buf, Map<Integer, List<RouterInfo>> map) Render the HTML for /24 IP groups.private voidrenderIPGroups32(Writer out, StringBuilder buf, Map<Integer, List<RouterInfo>> map) Render the HTML for /32 IP groups (same IPv4 address).private voidrenderIPGroups48(Writer out, StringBuilder buf, Map<Long, List<RouterInfo>> map) Render the HTML for /48 IPv6 groups.private voidrenderIPGroups64(Writer out, StringBuilder buf, Map<Long, List<RouterInfo>> map) Render the HTML for /64 IPv6 groups.private voidrenderIPGroupsFamily(Writer out, StringBuilder buf, Map<String, List<RouterInfo>> map) Render the HTML for router family groups.private voidrenderIPGroupsUs(Writer out, StringBuilder buf, List<RouterInfo> ri32, List<RouterInfo> ri24, List<RouterInfo> ri16, List<RouterInfo> ri64, List<RouterInfo> ri48) Render the HTML for IP groups matching our own IP address.private voidrenderIPUsSummary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the IP group summary for our own IP address.private voidrenderOverview(Writer out, StringBuilder buf, String nonce, Analysis analysis) Render the sybil analysis overview section.private voidrenderPairDistance(Writer out, StringBuilder buf, List<Pair> pairs, double avg) Render the floodfill pairwise distance table.private voidrenderPairSummary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) Render the pairwise distance summary.private doublerenderRouterInfo(StringBuilder buf, RouterInfo info, Hash us, boolean isUs, boolean full) Be careful to use stripHTML for any displayed routerInfo data to prevent vulnerabilities.private voidrenderRouterInfoHTML(Writer out, StringBuilder buf, Hash us, double avgMinDist, List<RouterInfo> ris) Render routers closer than MIN_CLOSE up to MAX routers.private voidrenderRouterInfoHTML(Writer out, String nonce, int mode, long date) The whole thing.private static voidrenderRunForm(Writer out, StringBuilder buf, String nonce) Render the form to start a new sybil analysis scan.static voidrenderSybilHTML(Writer out, RouterContext ctx, List<Hash> sybils, String victim) Called from NetDbRenderer.private voidrenderThreatsHTML(Writer out, StringBuilder buf, long date, Map<Hash, Points> points) Render the threats analysis HTML section.private static voidwriteBuf(Writer out, StringBuilder buf) Writes the buffer out and clears it.private static voidwriteDistance(Writer out, BigInteger dist) Write a network distance in human units.
Field Details
_context
The router context._log
Logger for the sybil page.TWO_DECIMALS
Formatter for numbers with two decimals.PAIRMAX
MAX
MIN_CLOSE
private static final double MIN_CLOSEMinimum closeness counted as a match.- See Also:
MIN_DISPLAY_POINTS
private static final double MIN_DISPLAY_POINTSMinimum points shown on the page.- See Also:
HOURS
private static final int[] HOURSHour ranges offered on the page.DAYS
private static final int[] DAYSDay ranges offered on the page.
Constructor Details
SybilRenderer
Renders the Sybil analysis tables for the console.- Parameters:
ctx- the router context supplying the analysis data and logging
Method Details
fmt
Formats a number with two decimals.- Parameters:
val- the number to format- Returns:
- the formatted text
getNetDbSummary
Entry point.- Parameters:
out- the writer receiving the rendered HTMLnonce- the CSP nonce the emitted markup referencesmode- what tab to showdate- only for mode = 12- Returns:
- the net db summary
- Throws:
IOException- if the HTML cannot be written to the output
renderRouterInfoHTML
The whole thing.- Parameters:
out- the writer receiving the rendered HTMLnonce- the CSP nonce the emitted markup referencesmode- what tab to showdate- only for mode = 12- Throws:
IOException- if the HTML cannot be written to the output
renderOverview
private void renderOverview(Writer out, StringBuilder buf, String nonce, Analysis analysis) throws IOException Render the sybil analysis overview section.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built innonce- the CSP nonce the emitted markup referencesanalysis- supplies the persister the stored analyses are loaded from- Throws:
IOException- if the HTML cannot be written to the output
renderRunForm
Render the form to start a new sybil analysis scan.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built innonce- the CSP nonce the emitted markup references- Throws:
IOException- if the HTML cannot be written to the output
renderBackgroundForm
Render the configuration form for background sybil analysis.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built innonce- the CSP nonce the emitted markup references- Throws:
IOException- if the HTML cannot be written to the output
renderFFSummary
private void renderFFSummary(Writer out, StringBuilder buf, List<RouterInfo> ris, double avgMinDist) throws IOException Render the floodfill summary section.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inris- the known floodfills, counted but not listed hereavgMinDist- the average closest-floodfill hash distance- Throws:
IOException- if the HTML cannot be written to the output
renderFamilySummary
private void renderFamilySummary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the family group summary section.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the family groupsris- the routers to group by family tagpoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderIPUsSummary
private void renderIPUsSummary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the IP group summary for our own IP address.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- groups the routers sharing our IP or prefixris- the routers to test against our addressespoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderIP32Summary
private void renderIP32Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the /32 IP group summary.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the groups of routers sharing one IPv4ris- the routers to group by full IPv4 addresspoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderIP24Summary
private void renderIP24Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the /24 IP group summary.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the groups sharing an IPv4 /24ris- the routers to group by IPv4 /24 prefixpoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderIP16Summary
private void renderIP16Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the /16 IP group summary.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the groups sharing an IPv4 /16ris- the routers to group by IPv4 /16 prefixpoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderIP64Summary
private void renderIP64Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the /64 IPv6 group summary.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the groups sharing an IPv6 /64ris- the routers to group by IPv6 /64 prefixpoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderIP48Summary
private void renderIP48Summary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the /48 IPv6 group summary.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the groups sharing an IPv6 /48ris- the routers to group by IPv6 /48 prefixpoints- updated with threat points for grouped routers- Throws:
IOException- if the HTML cannot be written to the output
renderPairSummary
private void renderPairSummary(Writer out, StringBuilder buf, Analysis analysis, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the pairwise distance summary.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- computes the closest floodfill pairsris- the floodfills whose pairwise hash distances are measuredpoints- updated with threat points for close pairs- Throws:
IOException- if the HTML cannot be written to the output
renderCloseSummary
private void renderCloseSummary(Writer out, StringBuilder buf, Analysis analysis, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the closest floodfills to our routing key.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- scores the floodfills close to our routing keyavgMinDist- the average minimum floodfill hash distanceris- the floodfills, sorted in place by distance to our keypoints- updated with threat points for close floodfills- Throws:
IOException- if the HTML cannot be written to the output
renderCloseTmrwSummary
private void renderCloseTmrwSummary(Writer out, StringBuilder buf, Analysis analysis, Hash us, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the closest floodfills to tomorrow's routing key.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- scores the floodfills close to tomorrow's keyus- our router hash, the base tomorrow's routing key is derived fromavgMinDist- the average minimum floodfill hash distanceris- the floodfills, sorted in place by distance to that keypoints- updated with threat points for close floodfills- Throws:
IOException- if the HTML cannot be written to the output
renderDHTSummary
private void renderDHTSummary(Writer out, StringBuilder buf, Analysis analysis, Hash us, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the closest floodfills to our router hash.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- scores the floodfills close to our router hashus- our router hash, the reference the distances are measured fromavgMinDist- the average minimum floodfill hash distanceris- the floodfills, sorted in place by distance to our hashpoints- updated with threat points for close floodfills- Throws:
IOException- if the HTML cannot be written to the output
renderDestSummary
private void renderDestSummary(Writer out, StringBuilder buf, Analysis analysis, double avgMinDist, List<RouterInfo> ris, Map<Hash, Points> points) throws IOExceptionRender the closest floodfills to our published destinations.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inanalysis- scores the floodfills close to each destination keyavgMinDist- the average minimum floodfill hash distanceris- the floodfills, re-sorted in place for each destination keypoints- updated with threat points for close floodfills- Throws:
IOException- if the HTML cannot be written to the output
renderThreatsHTML
private void renderThreatsHTML(Writer out, StringBuilder buf, long date, Map<Hash, Points> points) throws IOExceptionRender the threats analysis HTML section.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built indate- ms since the epoch of the analysis being displayedpoints- threat points per router hash, only those at or above the display threshold are rendered- Throws:
IOException- if the HTML cannot be written to the output
renderPairDistance
private void renderPairDistance(Writer out, StringBuilder buf, List<Pair> pairs, double avg) throws IOException Render the floodfill pairwise distance table.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inpairs- the closest floodfill pairs, sorted by ascending hash distance and capped at PAIRMAX; the loop breaks once MIN_CLOSE is passedavg- the average pairwise floodfill hash distance, shown in the header- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroupsUs
private void renderIPGroupsUs(Writer out, StringBuilder buf, List<RouterInfo> ri32, List<RouterInfo> ri24, List<RouterInfo> ri16, List<RouterInfo> ri64, List<RouterInfo> ri48) throws IOException Render the HTML for IP groups matching our own IP address.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inri32- routers sharing our exact IPv4 addressri24- routers sharing our IPv4 /24ri16- routers sharing our IPv4 /16ri64- routers sharing our IPv6 /64ri48- routers sharing our IPv6 /48- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroups32
private void renderIPGroups32(Writer out, StringBuilder buf, Map<Integer, List<RouterInfo>> map) throws IOException Render the HTML for /32 IP groups (same IPv4 address).- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inmap- groups of 2 or more routers sharing one IPv4, keyed by that address- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroups24
private void renderIPGroups24(Writer out, StringBuilder buf, Map<Integer, List<RouterInfo>> map) throws IOException Render the HTML for /24 IP groups.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inmap- groups of 2 or more routers sharing an IPv4 /24, keyed by the prefix- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroups16
private void renderIPGroups16(Writer out, StringBuilder buf, Map<Integer, List<RouterInfo>> map) throws IOException Render the HTML for /16 IP groups.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inmap- groups of 4 or more routers sharing an IPv4 /16, keyed by the prefix- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroups64
private void renderIPGroups64(Writer out, StringBuilder buf, Map<Long, List<RouterInfo>> map) throws IOException Render the HTML for /64 IPv6 groups.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inmap- groups of 2 or more routers sharing an IPv6 /64, keyed by the prefix- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroups48
private void renderIPGroups48(Writer out, StringBuilder buf, Map<Long, List<RouterInfo>> map) throws IOException Render the HTML for /48 IPv6 groups.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inmap- groups of 4 or more routers sharing an IPv6 /48, keyed by the prefix- Throws:
IOException- if the HTML cannot be written to the output
renderIPGroupsFamily
private void renderIPGroupsFamily(Writer out, StringBuilder buf, Map<String, List<RouterInfo>> map) throws IOException Render the HTML for router family groups.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inmap- routers grouped by family tag, single-member families not displayed- Throws:
IOException- if the HTML cannot be written to the output
renderRouterInfoHTML
private void renderRouterInfoHTML(Writer out, StringBuilder buf, Hash us, double avgMinDist, List<RouterInfo> ris) throws IOException Render routers closer than MIN_CLOSE up to MAX routers.- Parameters:
out- the writer receiving the rendered HTMLbuf- the scratch buffer the markup is built inus- the reference hash distances are measured from, or null to omit the distance rowavgMinDist- the average minimum floodfill hash distance, the threshold the sybil warnings compare againstris- the routers to render, sorted closest first- Throws:
IOException- if the HTML cannot be written to the output
writeBuf
Writes the buffer out and clears it.- Parameters:
out- where the text is writtenbuf- the buffer to write- Throws:
IOException- if the write fails
getTranslatedCountry
renderRouterInfo
private double renderRouterInfo(StringBuilder buf, RouterInfo info, Hash us, boolean isUs, boolean full) Be careful to use stripHTML for any displayed routerInfo data to prevent vulnerabilities.- Parameters:
buf- the scratch buffer the router-info table markup is built ininfo- the router to renderus- ROUTING KEY or nullisUs- true to render this as our own router info, omitting the family, country and profile-history linksfull- unused; vestigial, every caller passes false and the body never reads it- Returns:
- the log2 hash distance to us, or 0 if us is null
renderSybilHTML
public static void renderSybilHTML(Writer out, RouterContext ctx, List<Hash> sybils, String victim) throws IOException Called from NetDbRenderer.- Parameters:
out- the writer receiving the rendered HTMLctx- the router context supplying the key generator and clocksybils- the hashes to compare, sorted in place by XOR distancevictim- the base64 hash to measure from instead of our own, or null- Throws:
IOException- if the HTML cannot be written to the output
writeDistance
Write a network distance in human units.- Parameters:
out- the writer receiving the formatted distancedist- the raw XOR hash distance, written as log2 and highlighted in red below MIN_CLOSE- Throws:
IOException- if the text cannot be written to the output
_t
_x
_t
Translate a string with a parameter This is a lot more expensive than _t(s), so use sparingly.- Parameters:
s- string to be translated containing {0} The {0} will be replaced by the parameter. Single quotes must be doubled, i.e. ' -> '' in the string.o- parameter, not translated. To translate parameter also, use _t("foo {0} bar", _t("baz")) Do not double the single quotes in the parameter. Use autoboxing to call with ints, longs, floats, etc.- Returns:
- the translated string, with {0} replaced by the parameter