41
41
import net .i2p .data .router .RouterInfo ;
42
42
import net .i2p .data .router .RouterKeyGenerator ;
43
43
import net .i2p .router .JobImpl ;
44
+ import net .i2p .router .NetworkDatabaseFacade ;
44
45
import net .i2p .router .RouterContext ;
45
46
import net .i2p .router .TunnelPoolSettings ;
46
47
import net .i2p .router .crypto .FamilyKeyCrypto ;
47
- import net .i2p .router .networkdb .kademlia .FloodfillNetworkDatabaseSegmentor ;
48
- import net .i2p .router .networkdb .kademlia .SegmentedNetworkDatabaseFacade ;
49
- import net .i2p .router .util .HashDistance ; // debug
50
48
import net .i2p .router .networkdb .kademlia .FloodfillNetworkDatabaseFacade ;
49
+ import net .i2p .router .util .HashDistance ; // debug
51
50
import static net .i2p .router .sybil .Util .biLog2 ;
52
51
import net .i2p .router .transport .GeoIP ;
53
52
import net .i2p .router .web .HelperBase ;
@@ -115,34 +114,9 @@ public void renderRouterInfoHTML(Writer out, int pageSize, int page,
115
114
String ip , String sybil , int port , int highPort , SigType type , EncType etype ,
116
115
String mtu , String ipv6 , String ssucaps ,
117
116
String tr , int cost , int icount ) throws IOException {
118
- renderRouterInfoHTML (out , pageSize , page ,
119
- routerPrefix , version ,
120
- country , family , caps ,
121
- ip , sybil , port , highPort , type , etype ,
122
- mtu , ipv6 , ssucaps ,
123
- tr , cost , icount , null , false );
124
- }
125
- public void renderRouterInfoHTML (Writer out , int pageSize , int page ,
126
- String routerPrefix , String version ,
127
- String country , String family , String caps ,
128
- String ip , String sybil , int port , int highPort , SigType type , EncType etype ,
129
- String mtu , String ipv6 , String ssucaps ,
130
- String tr , int cost , int icount , Hash client , boolean allClients ) throws IOException {
131
117
StringBuilder buf = new StringBuilder (4 *1024 );
132
118
List <Hash > sybils = sybil != null ? new ArrayList <Hash >(128 ) : null ;
133
- FloodfillNetworkDatabaseFacade netdb = _context .netDb ();
134
- if (allClients ) {
135
- netdb = _context .netDb ();
136
- }else {
137
- if (client != null ) {
138
- Log _log = _context .logManager ().getLog (NetDbRenderer .class );
139
- if (_log .shouldLog (Log .DEBUG ))
140
- _log .debug ("client subdb for: " + client );
141
- netdb = _context .clientNetDb (client );
142
- }
143
- else
144
- netdb = _context .netDb ();
145
- }
119
+ NetworkDatabaseFacade netdb = _context .netDb ();
146
120
147
121
if ("." .equals (routerPrefix )) {
148
122
buf .append ("<table><tr><td class=\" infohelp\" >" )
@@ -234,15 +208,7 @@ public void renderRouterInfoHTML(Writer out, int pageSize, int page,
234
208
}
235
209
boolean notFound = true ;
236
210
Set <RouterInfo > routers = new HashSet <RouterInfo >();
237
- if (allClients ){
238
- routers .addAll (_context .netDbSegmentor ().getRoutersKnownToClients ());
239
- } else {
240
- if (client == null )
241
- routers .addAll (_context .netDb ().getRouters ());
242
- else
243
- routers .addAll (_context .clientNetDb (client ).getRouters ());
244
-
245
- }
211
+ routers .addAll (_context .netDb ().getRouters ());
246
212
int ipMode = 0 ;
247
213
String ipArg = ip ; // save for error message
248
214
String altIPv6 = null ;
@@ -611,27 +577,20 @@ private static boolean hasCap(RouterInfo ri, String caps) {
611
577
*
612
578
* @param debug @since 0.7.14 sort by distance from us, display
613
579
* median distance, and other stuff, useful when floodfill
580
+ * @param client null for main db; non-null for client db
614
581
*/
615
- public void renderLeaseSetHTML (Writer out , boolean debug , Hash client , boolean clientsOnly ) throws IOException {
582
+ public void renderLeaseSetHTML (Writer out , boolean debug , Hash client ) throws IOException {
616
583
StringBuilder buf = new StringBuilder (4 *1024 );
617
584
if (debug )
618
585
buf .append ("<p id=\" debugmode\" >Debug mode - Sorted by hash distance, closest first</p>\n " );
619
586
Hash ourRKey ;
620
587
Set <LeaseSet > leases ;
621
588
DecimalFormat fmt ;
622
- FloodfillNetworkDatabaseFacade netdb = null ;
623
- if (clientsOnly ){
589
+ NetworkDatabaseFacade netdb ;
590
+ if (client == null )
624
591
netdb = _context .netDb ();
625
- }else {
626
- if (client != null ) {
627
- Log _log = _context .logManager ().getLog (NetDbRenderer .class );
628
- if (_log .shouldLog (Log .DEBUG ))
629
- _log .debug ("client subdb for: " + client );
630
- netdb = _context .clientNetDb (client );
631
- }
632
- else
633
- netdb = _context .netDb ();
634
- }
592
+ else
593
+ netdb = _context .clientNetDb (client );
635
594
if (debug ) {
636
595
ourRKey = _context .routerHash ();
637
596
leases = new TreeSet <LeaseSet >(new LeaseSetRoutingKeyComparator (ourRKey ));
@@ -641,11 +600,7 @@ public void renderLeaseSetHTML(Writer out, boolean debug, Hash client, boolean c
641
600
leases = new TreeSet <LeaseSet >(new LeaseSetComparator ());
642
601
fmt = null ;
643
602
}
644
- if (clientsOnly )
645
- leases .addAll (_context .netDbSegmentor ().getLeasesKnownToClients ());
646
- else {
647
- leases .addAll (netdb .getLeases ());
648
- }
603
+ leases .addAll (netdb .getLeases ());
649
604
int medianCount = 0 ;
650
605
int rapCount = 0 ;
651
606
BigInteger median = null ;
@@ -658,16 +613,15 @@ public void renderLeaseSetHTML(Writer out, boolean debug, Hash client, boolean c
658
613
} else {
659
614
buf .append ("<table id=\" leasesetsummary\" >\n " );
660
615
}
661
- if (clientsOnly )
662
- buf .append ("<tr><th colspan=\" 3\" >Leaseset Summary for All Clients: " ).append (client ).append ("</th>" );
663
- else if (client != null )
664
- buf .append ("<tr><th colspan=\" 3\" >Leaseset Summary for Client: " ).append (client ).append ("</th>" );
665
- else
666
- buf .append ("<tr><th colspan=\" 3\" >Leaseset Summary for Floodfill</th>" );
667
- buf .append ("<th><a href=\" /configadvanced\" title=\" " ).append (_t ("Manually Configure Floodfill Participation" )).append ("\" >[" )
668
- .append (_t ("Configure Floodfill Participation" ))
669
- .append ("]</a></th></tr>\n " )
670
- .append ("<tr><td><b>Total Leasesets:</b></td><td colspan=\" 3\" >" ).append (leases .size ()).append ("</td></tr>\n " );
616
+ if (client != null ) {
617
+ buf .append ("<tr><th colspan=\" 3\" >Leasesets for Client: " ).append (client .toBase32 ()).append ("</th><th></th></tr>\n " );
618
+ } else {
619
+ buf .append ("<tr><th colspan=\" 3\" >Leaseset Summary for Floodfill</th>" +
620
+ "<th><a href=\" /configadvanced\" title=\" " ).append (_t ("Manually Configure Floodfill Participation" )).append ("\" >[" )
621
+ .append (_t ("Configure Floodfill Participation" ))
622
+ .append ("]</a></th></tr>\n " );
623
+ }
624
+ buf .append ("<tr><td><b>Total Leasesets:</b></td><td colspan=\" 3\" >" ).append (leases .size ()).append ("</td></tr>\n " );
671
625
if (debug ) {
672
626
RouterKeyGenerator gen = _context .routerKeyGenerator ();
673
627
buf .append ("<tr><td><b>Published (RAP) Leasesets:</b></td><td colspan=\" 3\" >" ).append (leases ).append ("</td></tr>\n " )
@@ -676,17 +630,17 @@ else if (client != null)
676
630
.append ("<tr><td><b>Next Mod Data:</b></td><td>" ).append (DataHelper .getUTF8 (gen .getNextModData ())).append ("</td>" )
677
631
.append ("<td><b>Change in:</b></td><td>" ).append (DataHelper .formatDuration (gen .getTimeTillMidnight ())).append ("</td></tr>\n " );
678
632
}
679
- int ff = 0 ;
680
633
if (client == null ) {
681
- ff = _context .peerManager ().getPeersByCapability (FloodfillNetworkDatabaseFacade .CAPABILITY_FLOODFILL ).size ();
634
+ int ff = _context .peerManager ().getPeersByCapability (FloodfillNetworkDatabaseFacade .CAPABILITY_FLOODFILL ).size ();
682
635
buf .append ("<tr><td><b>Known Floodfills:</b></td><td colspan=\" 3\" >" ).append (ff ).append ("</td></tr>\n " );
683
636
buf .append ("<tr><td><b>Currently Floodfill?</b></td><td>" ).append (netdb .floodfillEnabled () ? "yes" : "no" );
637
+ if (debug )
638
+ buf .append ("</td><td><b>Routing Key:</b></td><td>" ).append (ourRKey .toBase64 ());
639
+ else
640
+ buf .append ("</td><td colspan=\" 2\" >" );
641
+ buf .append ("</td></tr>\n " );
684
642
}
685
- if (debug )
686
- buf .append ("</td><td><b>Routing Key:</b></td><td>" ).append (ourRKey .toBase64 ());
687
- else
688
- buf .append ("</td><td colspan=\" 2\" >" );
689
- buf .append ("</td></tr>\n </table>\n " );
643
+ buf .append ("</table>\n " );
690
644
691
645
if (leases .isEmpty ()) {
692
646
//if (!debug)
@@ -960,7 +914,7 @@ private void renderLeaseSet(StringBuilder buf, LeaseSet ls, boolean debug, long
960
914
* @param mode 0: charts only; 1: full routerinfos; 2: abbreviated routerinfos
961
915
* mode 3: Same as 0 but sort countries by count
962
916
*/
963
- public void renderStatusHTML (Writer out , int pageSize , int page , int mode , Hash client , boolean clientsOnly ) throws IOException {
917
+ public void renderStatusHTML (Writer out , int pageSize , int page , int mode ) throws IOException {
964
918
if (!_context .netDb ().isInitialized ()) {
965
919
out .write ("<div id=\" notinitialized\" >" );
966
920
out .write (_t ("Not initialized" ));
@@ -977,13 +931,7 @@ public void renderStatusHTML(Writer out, int pageSize, int page, int mode, Hash
977
931
Hash us = _context .routerHash ();
978
932
979
933
Set <RouterInfo > routers = new TreeSet <RouterInfo >(new RouterInfoComparator ());
980
- if (client != null ) {
981
- routers .addAll (_context .clientNetDb (client ).getRouters ());
982
- } else if (clientsOnly ) {
983
- routers .addAll (_context .netDbSegmentor ().getRoutersKnownToClients ());
984
- } else {
985
- routers .addAll (_context .netDb ().getRouters ());
986
- }
934
+ routers .addAll (_context .netDb ().getRouters ());
987
935
int toSkip = pageSize * page ;
988
936
boolean nextpg = routers .size () > toSkip + pageSize ;
989
937
StringBuilder buf = new StringBuilder (8192 );
@@ -1071,19 +1019,9 @@ public void renderStatusHTML(Writer out, int pageSize, int page, int mode, Hash
1071
1019
if (!showStats ) {
1072
1020
1073
1021
// the summary table
1074
- if (client != null ) {
1075
- buf .append ("<table id=\" netdboverview\" border=\" 0\" cellspacing=\" 30\" ><tr><th colspan=\" 3\" >" )
1076
- .append (_t ("Network Database Router Statistics for Client " + client ))
1077
- .append ("</th></tr><tr><td style=\" vertical-align: top;\" >" );
1078
- } else if (clientsOnly ) {
1079
- buf .append ("<table id=\" netdboverview\" border=\" 0\" cellspacing=\" 30\" ><tr><th colspan=\" 3\" >" )
1080
- .append (_t ("Network Database Router Statistics for all Clients" ))
1081
- .append ("</th></tr><tr><td style=\" vertical-align: top;\" >" );
1082
- } else {
1083
- buf .append ("<table id=\" netdboverview\" border=\" 0\" cellspacing=\" 30\" ><tr><th colspan=\" 3\" >" )
1084
- .append (_t ("Network Database Router Statistics for Floodfill Router" ))
1085
- .append ("</th></tr><tr><td style=\" vertical-align: top;\" >" );
1086
- }
1022
+ buf .append ("<table id=\" netdboverview\" border=\" 0\" cellspacing=\" 30\" ><tr><th colspan=\" 3\" >" );
1023
+ buf .append (_t ("Network Database Router Statistics" ));
1024
+ buf .append ("</th></tr><tr><td style=\" vertical-align: top;\" >" );
1087
1025
// versions table
1088
1026
List <String > versionList = new ArrayList <String >(versions .objects ());
1089
1027
if (!versionList .isEmpty ()) {
0 commit comments