@Override public int hashCode() { int hash = super.hashCode(); hash = 31 * hash + this.key.setSuggestedEdition(0).hashCode(); hash = 31 * hash + (this.hasAnActivelink ? 1 : 0); hash = 31 * hash + (this.desc != null ? this.desc.hashCode() : 0); return hash; }
OfficialPluginDescription(String name, String group, boolean essential, long minVer, long recVer, boolean alwaysFetchLatestVersion, boolean usesXML, FreenetURI uri, boolean deprecated, boolean experimental, boolean advanced, boolean unsupported) { this.name = name; this.group = group; this.essential = essential; this.minimumVersion = minVer; this.recommendedVersion = recVer; this.alwaysFetchLatestVersion = alwaysFetchLatestVersion; this.usesXML = usesXML; this.deprecated = deprecated; this.experimental = experimental; this.advanced = advanced; this.unsupported = unsupported; if (alwaysFetchLatestVersion && uri != null) { assert(uri.isUSK()) : "Non-USK URIs do not support updates!"; // Force fetching the latest edition by setting a negative USK edition. long edition = uri.getSuggestedEdition(); if (edition >= 0) { edition = Math.min(-1, -edition); } uri = uri.setSuggestedEdition(edition); } this.uri = uri; }
/** @return True if we updated the edition */ public synchronized boolean setEdition(long ed, NodeClientCore node) { if (key.getSuggestedEdition() >= ed) { if(logMINOR) Logger.minor(this, "Edition "+ed+" is too old, not updating "+key); return false; } key = key.setSuggestedEdition(ed); enableBookmark(); return true; }
protected void maybeProcessOldBlob() { File oldBlob = getBlobFile(currentVersion); if(oldBlob.exists()) { File temp; try { temp = File.createTempFile(blobFilenamePrefix + availableVersion + "-", ".fblob.tmp", manager.node.clientCore.getPersistentTempDir()); } catch (IOException e) { Logger.error(this, "Unable to process old blob: "+e, e); return; } if(oldBlob.renameTo(temp)) { FreenetURI uri = URI.setSuggestedEdition(currentVersion); uri = uri.sskForUSK(); try { manager.uom.processMainJarBlob(temp, null, currentVersion, uri); } catch (Throwable t) { // Don't disrupt startup. Logger.error(this, "Unable to process old blob, caught "+t, t); } temp.delete(); } else { Logger.error(this, "Unable to rename old blob file "+oldBlob+" to "+temp+" so can't process it."); } } }
if (!b.key.setSuggestedEdition(key.getSuggestedEdition()).equals(key)) { return false;
/** * Returns the request URI of this Sone. * * @return The request URI of this Sone */ @Nonnull public FreenetURI getRequestUri() { try { return new FreenetURI(getIdentity().getRequestUri()) .setKeyType("USK") .setDocName("Sone") .setMetaString(new String[0]) .setSuggestedEdition(latestEdition); } catch (MalformedURLException e) { throw new IllegalStateException( format("Identity %s's request URI is incorrect.", getIdentity()), e); } }
void kill() { try { ClientGetter c; synchronized(this) { isRunning = false; USK myUsk = USK.create(URI.setSuggestedEdition(currentVersion)); core.uskManager.unsubscribe(myUsk, this); c = cg; cg = null; } c.cancel(core.clientContext); } catch(Exception e) { Logger.minor(this, "Cannot kill NodeUpdater", e); } }
/** * Returns the insert URI of this Sone. * * @return The insert URI of this Sone */ @Nullable public FreenetURI getInsertUri() { if (!isLocal()) { return null; } try { return new FreenetURI(((OwnIdentity) getIdentity()).getInsertUri()) .setDocName("Sone") .setMetaString(new String[0]) .setSuggestedEdition(latestEdition); } catch (MalformedURLException e) { throw new IllegalStateException(format("Own identity %s's insert URI is incorrect.", getIdentity()), e); } }
void start() { try { // because of UoM, this version is actually worth having as well USK myUsk = USK.create(URI.setSuggestedEdition(currentVersion)); core.uskManager.subscribe(myUsk, this, true, getRequestClient()); } catch(MalformedURLException e) { Logger.error(this, "The auto-update URI isn't valid and can't be used"); manager.blow("The auto-update URI isn't valid and can't be used", true); } }
/** * Set the URfrenet.jar should be updated from. * * @param uri * The URI to set. */ public void setURI(FreenetURI uri) { // FIXME plugins!! NodeUpdater updater; Map<String, PluginJarUpdater> oldPluginUpdaters = null; synchronized (this) { if (updateURI.equals(uri)) return; updateURI = uri; updateURI = updateURI.setSuggestedEdition(Version.buildNumber()); updater = mainUpdater; oldPluginUpdaters = pluginUpdaters; pluginUpdaters = new HashMap<String, PluginJarUpdater>(); if (updater == null) return; } updater.onChangeURI(uri); stopPluginUpdaters(oldPluginUpdaters); startPluginUpdaters(); }
NodeUpdater(NodeUpdateManager manager, FreenetURI URI, int current, int min, int max, String blobFilenamePrefix) { logMINOR = Logger.shouldLog(LogLevel.MINOR, this); this.manager = manager; this.node = manager.node; this.URI = URI.setSuggestedEdition(Version.buildNumber() + 1); this.ticker = node.ticker; this.core = node.clientCore; this.currentVersion = current; this.availableVersion = -1; this.isRunning = true; this.cg = null; this.isFetching = false; this.blobFilenamePrefix = blobFilenamePrefix; this.maxDeployVersion = max; this.minDeployVersion = min; FetchContext tempContext = core.makeClient((short) 0, true, false).getFetchContext(); tempContext.allowSplitfiles = true; tempContext.dontEnterImplicitArchives = false; this.ctx = tempContext; }
@Override public FreenetURI checkSource(String source) throws PluginNotFoundException { OfficialPluginDescription desc = node.getPluginManager().getOfficialPlugin(source); if(desc == null) throw new PluginNotFoundException("Not in the official plugins list: "+source); if(desc.uri != null) return desc.uri; else { return node.nodeUpdater.getURI().setDocName(source).setSuggestedEdition(desc.recommendedVersion).sskForUSK(); } }
FreenetURI uri = updateURI.setDocName(name).setSuggestedEdition(minVer); PluginJarUpdater updater = new PluginJarUpdater(this, uri, (int) minVer, -1, (plugin.essential ? (int)minVer : Integer.MAX_VALUE)
/** * Add links to the changelog for the given version to the given node. * @param version USK edition to point to * @param node to add links to */ public synchronized void addChangelogLinks(long version, HTMLNode node) { String changelogUri = getChangelogURI().setSuggestedEdition(version).sskForUSK().toASCIIString(); String developerDetailsUri = getDeveloperChangelogURI().setSuggestedEdition(version).sskForUSK().toASCIIString(); node.addChild("a", "href", '/' + changelogUri + "?type=text/plain", NodeL10n.getBase().getString("UpdatedVersionAvailableUserAlert.changelog")); node.addChild("br"); node.addChild("a", "href", '/' + developerDetailsUri + "?type=text/plain", NodeL10n.getBase().getString("UpdatedVersionAvailableUserAlert.devchangelog")); }
FreenetURI mainJarURI = new FreenetURI(jarKey).setSuggestedEdition(mainJarVersion); if(mainJarURI.equals(updateManager.getURI().setSuggestedEdition(mainJarVersion))) sendUOMRequest(source, true); else
final FreenetURI jarURI; try { jarURI = new FreenetURI(key).setSuggestedEdition(version); } catch(MalformedURLException e) { Logger.error(this, "Failed receiving main jar " + version + " because URI not parsable: " + e + " for " + key, e); if(!jarURI.equals(updateManager.getURI().setSuggestedEdition(version))) { System.err.println("Node sending us a main jar update (" + version + ") from the wrong URI:\n" + "Node: " + source.userToString() + "\n" +
if((cg == null) || cg.isCancelled()) { if(logMINOR) Logger.minor(this, "Scheduling request for " + URI.setSuggestedEdition(availableVersion)); if(availableVersion > currentVersion) System.err.println("Starting " + jarName() + " fetch for " + availableVersion); tempBlobFile = File.createTempFile(blobFilenamePrefix + availableVersion + "-", ".fblob.tmp", manager.node.clientCore.getPersistentTempDir()); FreenetURI uri = URI.setSuggestedEdition(availableVersion); uri = uri.sskForUSK(); cg = new ClientGetter(this,
if(originalURI.isUSK()) { newURI = newURI.uskForSSK(); newURI = newURI.setSuggestedEdition(originalURI.getSuggestedEdition());
FreenetURI uri = ark.getInsertURI().setKeyType("USK").setSuggestedEdition(number);
updateURI = updateURI.setSuggestedEdition(Version.buildNumber()); if(updateURI.hasMetaStrings()) throw new InvalidConfigValueException(l10n("updateURIMustHaveNoMetaStrings"));