From: Mailing l. f. S. c. m. <jtc...@li...> - 2009-02-27 11:27:46
|
Revision: 3058 http://jtcfrost.svn.sourceforge.net/jtcfrost/?rev=3058&view=rev Author: bback Date: 2009-02-27 11:27:45 +0000 (Fri, 27 Feb 2009) Log Message: ----------- - removed old, now unused code to replace pre-1010 CHK keys Modified Paths: -------------- trunk/frost-wot/source/frost/fcp/FreenetKeys.java trunk/frost-wot/source/frost/fileTransfer/FileListManager.java trunk/frost-wot/source/frost/storage/perst/PerstFrostSharedFileItem.java trunk/frost-wot/source/frost/storage/perst/filelist/FileListStorage.java Modified: trunk/frost-wot/source/frost/fcp/FreenetKeys.java =================================================================== --- trunk/frost-wot/source/frost/fcp/FreenetKeys.java 2009-02-27 10:59:11 UTC (rev 3057) +++ trunk/frost-wot/source/frost/fcp/FreenetKeys.java 2009-02-27 11:27:45 UTC (rev 3058) @@ -136,42 +136,42 @@ return isKeyLenOk; } - /** - * Checks if the provided key is an old 0.7 key (before 1010). - * The old keys were only half encrypted! - * @param key key to check (CHK) - * @return true if the key is an old key - */ - public static boolean isOld07ChkKey(final String key) { - if( key == null || key.length() < 4 ) { - return false; // invalid key - } - try { - if( key.startsWith("CHK@") ) { - - // "CHK@GveS~6H2DnxWpcQL17CljJvmH6d7YicFHzoLvtUKzbk,6sxNSl6r1cl0LuLIsFA7C3oVJIEu4YuoWUJTa4bd7bY,AAIC--8/frost.jar" - // always ends with "," and 7 chars - // look at the first 3 of the 7 chars: - // "AAE" = old key - // "AAI" = new key - - // find 2nd "," in string - int pos = key.indexOf(','); - pos = key.indexOf(',', pos+1); - pos++; - final String s = key.substring(pos, pos+7); - if( s.startsWith("AAE") ) { - return true; // old - } else if( s.startsWith("AAI") ) { - return false; // new - } else { - return false; // invalid - } - } else { - return false; // invalid key type - } - } catch(final Throwable t) { - return false; - } - } +// /** +// * Checks if the provided key is an old 0.7 key (before 1010). +// * The old keys were only half encrypted! +// * @param key key to check (CHK) +// * @return true if the key is an old key +// */ +// public static boolean isOld07ChkKey(final String key) { +// if( key == null || key.length() < 4 ) { +// return false; // invalid key +// } +// try { +// if( key.startsWith("CHK@") ) { +// +// // "CHK@GveS~6H2DnxWpcQL17CljJvmH6d7YicFHzoLvtUKzbk,6sxNSl6r1cl0LuLIsFA7C3oVJIEu4YuoWUJTa4bd7bY,AAIC--8/frost.jar" +// // always ends with "," and 7 chars +// // look at the first 3 of the 7 chars: +// // "AAE" = old key +// // "AAI" = new key +// +// // find 2nd "," in string +// int pos = key.indexOf(','); +// pos = key.indexOf(',', pos+1); +// pos++; +// final String s = key.substring(pos, pos+7); +// if( s.startsWith("AAE") ) { +// return true; // old +// } else if( s.startsWith("AAI") ) { +// return false; // new +// } else { +// return false; // invalid +// } +// } else { +// return false; // invalid key type +// } +// } catch(final Throwable t) { +// return false; +// } +// } } Modified: trunk/frost-wot/source/frost/fileTransfer/FileListManager.java =================================================================== --- trunk/frost-wot/source/frost/fileTransfer/FileListManager.java 2009-02-27 10:59:11 UTC (rev 3057) +++ trunk/frost-wot/source/frost/fileTransfer/FileListManager.java 2009-02-27 11:27:45 UTC (rev 3058) @@ -238,10 +238,10 @@ final FrostFileListFileObject sfo = new FrostFileListFileObject(sfx, localOwner, content.getTimestamp()); - if( isFreenet07 && FreenetKeys.isOld07ChkKey( sfo.getKey() )) { - // ignore old chk keys - continue; - } +// if( isFreenet07 && FreenetKeys.isOld07ChkKey( sfo.getKey() )) { +// // ignore old chk keys +// continue; +// } // before updating the file list object (this overwrites the current lastUploaded time), // check if there is a failed download item for this shared file. If yes, and the lastUpload Modified: trunk/frost-wot/source/frost/storage/perst/PerstFrostSharedFileItem.java =================================================================== --- trunk/frost-wot/source/frost/storage/perst/PerstFrostSharedFileItem.java 2009-02-27 10:59:11 UTC (rev 3057) +++ trunk/frost-wot/source/frost/storage/perst/PerstFrostSharedFileItem.java 2009-02-27 11:27:45 UTC (rev 3058) @@ -26,7 +26,6 @@ import org.garret.perst.*; import frost.*; -import frost.fcp.*; import frost.fileTransfer.sharing.*; import frost.util.gui.*; import frost.util.gui.translation.*; @@ -118,13 +117,13 @@ } } - // check if we share a file with an old CHK key, if yes, remove the key and reset lastUploaded date - if( FcpHandler.isFreenet07() && FreenetKeys.isOld07ChkKey(key) ) { - // reset key, the change is saved to perst during shutdown - key = null; - lastUploaded = 0; - uploadCount = 0; - } +// // check if we share a file with an old CHK key, if yes, remove the key and reset lastUploaded date +// if( FcpHandler.isFreenet07() && FreenetKeys.isOld07ChkKey(key) ) { +// // reset key, the change is saved to perst during shutdown +// key = null; +// lastUploaded = 0; +// uploadCount = 0; +// } final FrostSharedFileItem sfItem = new FrostSharedFileItem( file, Modified: trunk/frost-wot/source/frost/storage/perst/filelist/FileListStorage.java =================================================================== --- trunk/frost-wot/source/frost/storage/perst/filelist/FileListStorage.java 2009-02-27 10:59:11 UTC (rev 3057) +++ trunk/frost-wot/source/frost/storage/perst/filelist/FileListStorage.java 2009-02-27 11:27:45 UTC (rev 3058) @@ -24,7 +24,6 @@ import org.garret.perst.*; import frost.*; -import frost.fcp.*; import frost.fileTransfer.*; import frost.storage.*; import frost.storage.perst.*; @@ -241,14 +240,14 @@ return 0; } - final boolean removeOld07ChkKeys; - if( FcpHandler.isFreenet07() - && (storageRoot.getStorageStatus() & FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED) == 0 ) - { - removeOld07ChkKeys = true; - } else { - removeOld07ChkKeys = false; - } +// final boolean removeOld07ChkKeys; +// if( FcpHandler.isFreenet07() +// && (storageRoot.getStorageStatus() & FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED) == 0 ) +// { +// removeOld07ChkKeys = true; +// } else { +// removeOld07ChkKeys = false; +// } int count = 0; try { @@ -270,10 +269,10 @@ remove = true; } - } else if( removeOld07ChkKeys && FreenetKeys.isOld07ChkKey(o.getKey()) ) { - // we have a key (outdated or not) - // check if the key is an old 0.7 CHK key - remove = true; +// } else if( removeOld07ChkKeys && FreenetKeys.isOld07ChkKey(o.getKey()) ) { +// // we have a key (outdated or not) +// // check if the key is an old 0.7 CHK key +// remove = true; } if( remove ) { @@ -321,14 +320,14 @@ return 0; } - final boolean removeOld07ChkKeys; - if( FcpHandler.isFreenet07() - && (storageRoot.getStorageStatus() & FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED) == 0 ) - { - removeOld07ChkKeys = true; - } else { - removeOld07ChkKeys = false; - } +// final boolean removeOld07ChkKeys; +// if( FcpHandler.isFreenet07() +// && (storageRoot.getStorageStatus() & FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED) == 0 ) +// { +// removeOld07ChkKeys = true; +// } else { +// removeOld07ChkKeys = false; +// } int count = 0; try { @@ -345,12 +344,12 @@ endThreadTransaction(); } - if( removeOld07ChkKeys ) { - // we removed the keys, update flag - final int newStorageStatus = storageRoot.getStorageStatus() | FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED; - storageRoot.setStorageStatus( newStorageStatus ); - storageRoot.modify(); - } +// if( removeOld07ChkKeys ) { +// // we removed the keys, update flag +// final int newStorageStatus = storageRoot.getStorageStatus() | FileListStorageRoot.OLD_07_CHK_KEYS_REMOVED; +// storageRoot.setStorageStatus( newStorageStatus ); +// storageRoot.modify(); +// } return count; } @@ -563,7 +562,7 @@ } } -boolean alwaysUseLatestChkKey = true; // FIXME: add an option! +boolean alwaysUseLatestChkKey = true; // FIXME: must be true as long as the key changes now and then. False prevents fake files. private boolean updateFileListFileFromOtherFileListFile(final FrostFileListFileObject oldFof, final FrostFileListFileObject newFof) { // file is already in FILELIST table, maybe add new FILEOWNER and update fields @@ -573,12 +572,12 @@ oldFof.setKey(newFof.getKey()); doUpdate = true; } else if( alwaysUseLatestChkKey && oldFof.getKey() != null && newFof.getKey() != null ) { oldFof.setKey(newFof.getKey()); doUpdate = true; - } else if( oldFof.getKey() != null && newFof.getKey() != null ) { - // fix to replace 0.7 keys before 1010 on the fly - if( FreenetKeys.isOld07ChkKey(oldFof.getKey()) ) { - // replace old chk key with new one - oldFof.setKey(newFof.getKey()); doUpdate = true; - } +// } else if( oldFof.getKey() != null && newFof.getKey() != null ) { +// // fix to replace 0.7 keys before 1010 on the fly +// if( FreenetKeys.isOld07ChkKey(oldFof.getKey()) ) { +// // replace old chk key with new one +// oldFof.setKey(newFof.getKey()); doUpdate = true; +// } } if( oldFof.getFirstReceived() > newFof.getFirstReceived() ) { oldFof.setFirstReceived(newFof.getFirstReceived()); doUpdate = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |