Changeset b89720e
- Timestamp:
- May 19, 2019 6:38:21 PM (22 months ago)
- Branches:
- master
- Children:
- 099cacd
- Parents:
- 1ffc006
- Location:
- apps/routerconsole/java/src/net/i2p/router
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/routerconsole/java/src/net/i2p/router/sybil/Analysis.java
r1ffc006 rb89720e 68 68 public static final String PROP_NONFF = "router.sybilAnalyzeAll"; 69 69 public static final String PROP_BLOCKTIME = "router.sybilBlockPeriod"; 70 public static final String PROP_REMOVETIME = "router.sybilDeleteOld"; 70 71 private static final long MIN_FREQUENCY = 60*60*1000L; 71 72 private static final long MIN_UPTIME = 75*60*1000L; … … 134 135 _log.info("Storing analysis"); 135 136 _persister.store(now, points); 137 _persister.removeOld(); 136 138 _log.info("Store complete"); 137 139 } catch (IOException ioe) { … … 152 154 changeState(RUNNING); 153 155 _cmgr.register(this); 156 _persister.removeOld(); 154 157 schedule(); 155 158 } -
apps/routerconsole/java/src/net/i2p/router/sybil/PersistSybil.java
r1ffc006 rb89720e 169 169 return rv; 170 170 } 171 172 /** 173 * Remove all files older than configured threshold 174 * Inline for now, thread later if necessary 175 * 176 * @since 0.9.41 177 */ 178 public synchronized void removeOld() { 179 long age = _context.getProperty(Analysis.PROP_REMOVETIME, 0L); 180 if (age < 60*1000) 181 return; 182 long cutoff = _context.clock().now() - age; 183 File dir = new File(_context.getConfigDir(), DIR); 184 File[] files = dir.listFiles(new FileSuffixFilter(PFX, SFX)); 185 if (files == null) 186 return; 187 int deleted = 0; 188 for (File file : files) { 189 try { 190 String name = file.getName(); 191 long d = Long.parseLong(name.substring(PFX.length(), name.length() - SFX.length())); 192 if (d < cutoff) { 193 if (file.delete()) 194 deleted++; 195 } 196 } catch (NumberFormatException nfe) {} 197 } 198 if (deleted > 0 && _log.shouldWarn()) 199 _log.warn("Deleted " + deleted + " old analysis files"); 200 } 201 171 202 172 203 /** -
apps/routerconsole/java/src/net/i2p/router/web/helpers/NetDbHelper.java
r1ffc006 rb89720e 240 240 long val = 24*60*60*1000L * Integer.parseInt(days); 241 241 toSave.put(Analysis.PROP_BLOCKTIME, Long.toString(val)); 242 } 243 String age = getJettyString("deleteAge"); 244 if (age != null && age.length() > 0) { 245 long val = 24*60*60*1000L * Integer.parseInt(age); 246 toSave.put(Analysis.PROP_REMOVETIME, Long.toString(val)); 242 247 } 243 248 String enable = getJettyString("block"); -
apps/routerconsole/java/src/net/i2p/router/web/helpers/SybilRenderer.java
r1ffc006 rb89720e 71 71 private static final double MIN_DISPLAY_POINTS = 12.01; 72 72 private static final int[] HOURS = { 1, 6, 24, 7*24, 30*24, 0 }; 73 private static final int[] DAYS = { 2, 7, 30, 90, 365, 0 }; 73 74 74 75 public SybilRenderer(RouterContext ctx) { … … 135 136 Analysis analysis = Analysis.getInstance(_context); 136 137 List<RouterInfo> ris = null; 137 if (mode != 0 && mode != 12 && mode != 13 && mode != 14 && mode != 16) {138 if (mode != 0 && mode < 12) { 138 139 if (mode >= 2 && mode <= 6) { 139 140 // review all routers for family and IP analysis … … 303 304 for (int i = 0; i < HOURS.length; i++) { 304 305 buf.append("<option value=\""); 305 buf.append( Integer.toString(HOURS[i]));306 buf.append(HOURS[i]); 306 307 buf.append('"'); 307 308 long time = HOURS[i] * 60*60*1000L; … … 329 330 buf.append("></td></tr>\n<tr><td>" + 330 331 "Minimum threat points to block:</td><td><input type=\"text\" name=\"threshold\" value=\"").append(thresh).append("\"></td></tr>\n<tr><td>" + 331 "Days to block:</td><td><input type=\"text\" name=\"days\" value=\"").append(days).append("\"></td></tr>\n<tr><td></td><td>" + 332 "Days to block:</td><td><input type=\"text\" name=\"days\" value=\"").append(days).append("\"></td></tr>\n<tr><td>" + 333 "Delete stored analysis older than:</td><td><select name=\"deleteAge\">"); 334 long age = _context.getProperty(Analysis.PROP_REMOVETIME, 0L); 335 for (int i = 0; i <DAYS.length; i++) { 336 buf.append("<option value=\""); 337 buf.append(DAYS[i]); 338 buf.append('"'); 339 long time = DAYS[i] * 24*60*60*1000L; 340 if (time == age) 341 buf.append(" selected=\"selected\""); 342 buf.append('>'); 343 if (DAYS[i] > 0) 344 buf.append(DataHelper.formatDuration2(time)); 345 else 346 buf.append(_t("Never")); 347 buf.append("</option>\n"); 348 } 349 buf.append("</td></tr>\n<tr><td></td><td>" + 332 350 "<input type=\"submit\" name=\"action\" class=\"accept\" value=\"Save\" />" + 333 351 "</td></tr></table></form>\n");
Note: See TracChangeset
for help on using the changeset viewer.