Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trivuele-batch-1-reviewed-v3' in…
Browse files Browse the repository at this point in the history
…to next
  • Loading branch information
ArneBab committed Jun 18, 2022
2 parents d1e8481 + 8c71425 commit a65b766
Show file tree
Hide file tree
Showing 33 changed files with 335 additions and 157 deletions.
11 changes: 11 additions & 0 deletions build-offline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

cp gradle/wrapper/gradle-wrapper.properties gradle/wrapper/gradle-wrapper.properties.orig
sed -i 's,^distributionUrl=.*,distributionUrl=../../lib/gradle-4.10.3-bin.zip,' gradle/wrapper/gradle-wrapper.properties
cp build.gradle build.gradle.orig
sed -i '/com.android.tools.build/d' build.gradle

./gradlew jar --offline --no-daemon

mv gradle/wrapper/gradle-wrapper.properties.orig gradle/wrapper/gradle-wrapper.properties
mv build.gradle.orig build.gradle
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'java'
apply plugin: 'maven-publish'

repositories {
mavenLocal() // TODO: use lib/ instead?
flatDir { dirs uri("${projectDir}/lib") }
maven { url 'https://mvn.freenetproject.org' }
jcenter()
}
Expand Down Expand Up @@ -236,6 +236,8 @@ dependencies {
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
testCompile "org.hamcrest:hamcrest-library:1.3"
testCompile "org.hamcrest:hamcrest-core:1.3"
testCompile "org.objenesis:objenesis:1.0"
}

dependencyVerification {
Expand Down
File renamed without changes.
12 changes: 10 additions & 2 deletions src/freenet/clients/http/FirstTimeWizardToadlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,19 @@ public void handleMethodPOST(URI uri, HTTPRequest request, ToadletContext ctx) t
super.writeTemporaryRedirect(ctx, "Wizard set preset", redirectTo.toString());
return;
} else if (request.isPartSet("back")) {
//User chose back, return to previous page.
redirectTarget = getPreviousStep(currentStep, persistFields.preset).name();
//User chose back, return to previous page, or cancel if single step.
if (request.isPartSet("singlestep")) {
redirectTarget = WIZARD_STEP.COMPLETE.name();
} else {
redirectTarget = getPreviousStep(currentStep, persistFields.preset).name();
}
} else {
try {
redirectTarget = steps.get(currentStep).postStep(request);
//Go to complete rather than go to next if single step.
if (request.isPartSet("singlestep") && !redirectTarget.startsWith(currentStep.name())) {
redirectTarget = WIZARD_STEP.COMPLETE.name();
}

//Opennet step can change the persisted value for opennet.
if (currentStep == WIZARD_STEP.OPENNET) {
Expand Down
49 changes: 38 additions & 11 deletions src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import freenet.support.SizeUtil;
import freenet.support.api.HTTPRequest;

import java.io.File;

/**
* Allows the user to select datastore size, considering available storage space when offering options.
*/
Expand All @@ -37,7 +39,7 @@ public void getStep(HTTPRequest request, PageHelper helper) {
HTMLNode bandwidthForm = helper.addFormChild(bandwidthInfoboxContent, ".", "dsForm");
HTMLNode result = bandwidthForm.addChild("select", "name", "ds");

long maxSize = maxDatastoreSize();
long maxSize = maxDatastoreSize(core.node);

long autodetectedSize = canAutoconfigureDatastoreSize();
if(maxSize < autodetectedSize) autodetectedSize = maxSize;
Expand Down Expand Up @@ -93,11 +95,20 @@ public void getStep(HTTPRequest request, PageHelper helper) {
@Override
public String postStep(HTTPRequest request) {
// drop down options may be 6 chars or less, but formatted ones e.g. old value if re-running can be more
_setDatastoreSize(request.getPartAsStringFailsafe("ds", 20));
return FirstTimeWizardToadlet.WIZARD_STEP.BANDWIDTH.name();
boolean firsttime = true;

if (request.isPartSet("singlestep")) {
firsttime = false;
}
_setDatastoreSize(request.getPartAsStringFailsafe("ds", 20), firsttime);
if (firsttime) {
return FirstTimeWizardToadlet.WIZARD_STEP.BANDWIDTH.name();
} else {
return FirstTimeWizardToadlet.WIZARD_STEP.COMPLETE.name();
}
}

private void _setDatastoreSize(String selectedStoreSize) {
private void _setDatastoreSize(String selectedStoreSize, boolean firsttime) {
try {
long size = Fields.parseLong(selectedStoreSize);
// client cache: 10% up to 200MB
Expand All @@ -107,7 +118,7 @@ private void _setDatastoreSize(String selectedStoreSize) {
int downstreamLimit = config.get("node").getInt("inputBandwidthLimit");
// is used for remote stuff, so go by the minimum of the two
int limit;
if(downstreamLimit <= 0) limit = upstreamLimit;
if (downstreamLimit <= 0) limit = upstreamLimit;
else limit = Math.min(downstreamLimit, upstreamLimit);
// 35KB/sec limit has been seen to have 0.5 store writes per second.
// So saying we want to have space to cache everything is only doubling that ...
Expand All @@ -121,12 +132,10 @@ private void _setDatastoreSize(String selectedStoreSize) {

System.out.println("Setting datastore size to "+Fields.longToString(storeSize, true));
config.get("node").set("storeSize", Fields.longToString(storeSize, true));
if(config.get("node").getString("storeType").equals("ram"))
config.get("node").set("storeType", "salt-hash");
if (firsttime) config.get("node").set("storeType", "salt-hash");
System.out.println("Setting client cache size to "+Fields.longToString(clientCacheSize, true));
config.get("node").set("clientCacheSize", Fields.longToString(clientCacheSize, true));
if(config.get("node").getString("clientCacheType").equals("ram"))
config.get("node").set("clientCacheType", "salt-hash");
if (firsttime) config.get("node").set("clientCacheType", "salt-hash");
System.out.println("Setting slashdot/ULPR/recent requests cache size to "+Fields.longToString(slashdotCacheSize, true));
config.get("node").set("slashdotCacheSize", Fields.longToString(slashdotCacheSize, true));

Expand All @@ -137,7 +146,7 @@ private void _setDatastoreSize(String selectedStoreSize) {
}
}

private long maxDatastoreSize() {
public static long maxDatastoreSize(Node node) {
long maxMemory = NodeStarter.getMemoryLimitBytes();
if(maxMemory == Long.MAX_VALUE) return 1024*1024*1024; // Treat as don't know.
if(maxMemory < 128*1024*1024) return 1024*1024*1024; // 1GB default if don't know or very small memory.
Expand All @@ -151,7 +160,25 @@ private long maxDatastoreSize() {
slots /= 3;
// We return the total size, so we don't need to worry about cache vs store or even client cache.
// One key of all 3 types combined uses Node.sizePerKey bytes on disk. So we get a size.
return slots * Node.sizePerKey;
long maxSize =slots * Node.sizePerKey;

// Datastore can never be larger than free disk space, assuming datastore is zero now.
File storeDir = node.getStoreDir();
long freeSpace = storeDir.getUsableSpace();
File[] files = storeDir.listFiles();

for (int i = 0; i < files.length; i++) {
freeSpace += files[i].length();
}

if (freeSpace < maxSize) {
maxSize = freeSpace;
}

// Leave some margin.
maxSize = maxSize - 1024*1024*1024;

return maxSize;
}

private long canAutoconfigureDatastoreSize() {
Expand Down
7 changes: 6 additions & 1 deletion src/freenet/clients/http/wizardsteps/PageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public HTMLNode addFormChild(HTMLNode parentNode, String target, String id, bool
new String[] { "type", "name", "value" },
new String[] { "hidden", "preset", persistFields.preset.name() });
}
if (persistFields.isSingleStep()) {
form.addChild("input",
new String[] { "type", "name", "value" },
new String[] { "hidden", "singlestep", "true" });
}
if (includeOpennet) {
form.addChild("input",
new String[] { "type", "name", "value" },
Expand All @@ -81,4 +86,4 @@ public HTMLNode addFormChild(HTMLNode parentNode, String target, String id, bool
new String[] { "hidden", "step", step.name() });
return form;
}
}
}
23 changes: 23 additions & 0 deletions src/freenet/clients/http/wizardsteps/PersistFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ public class PersistFields {

public final FirstTimeWizardToadlet.WIZARD_PRESET preset;
public final boolean opennet;
public final boolean singleStep;

/**
* @param request Parsed for persistence fields, checking parameters (GET) first, then parts (POST).
*/
public PersistFields(HTTPRequest request) {
this.preset = parsePreset(request);
this.opennet = parseOpennet(request);
this.singleStep = parseSingleStep(request);
}

/**
Expand All @@ -28,6 +30,7 @@ public PersistFields(HTTPRequest request) {
public PersistFields(boolean opennet, HTTPRequest request) {
this.preset = parsePreset(request);
this.opennet = opennet;
this.singleStep = parseSingleStep(request);
}

/**
Expand All @@ -37,6 +40,7 @@ public PersistFields(boolean opennet, HTTPRequest request) {
public PersistFields(FirstTimeWizardToadlet.WIZARD_PRESET preset, HTTPRequest request) {
this.preset = preset;
this.opennet = parseOpennet(request);
this.singleStep = parseSingleStep(request);
}

private FirstTimeWizardToadlet.WIZARD_PRESET parsePreset(HTTPRequest request) {
Expand Down Expand Up @@ -70,10 +74,26 @@ private boolean parseOpennet(HTTPRequest request) {
return Fields.stringToBool(opennetRaw, false);
}

private boolean parseSingleStep(HTTPRequest request) {
String singleStepRaw;

if (request.hasParameters()) {
singleStepRaw = request.getParam("singlestep", "false");
} else {
singleStepRaw = request.getPartAsStringFailsafe("singlestep", 5);
}

return Fields.stringToBool(singleStepRaw, false);
}

public boolean isUsingPreset() {
return preset != null;
}

public boolean isSingleStep() {
return singleStep;
}

/**
* Appends any defined persistence fields to the given URL.
* @param baseURL The URL to append fields to.
Expand All @@ -84,6 +104,9 @@ public String appendTo(String baseURL) {
if (isUsingPreset()) {
url.append("&preset=").append(preset);
}
if (isSingleStep()) {
url.append("&singlestep=").append(singleStep);
}
return url.toString();
}
}
13 changes: 0 additions & 13 deletions src/freenet/io/xfer/BlockTransmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,19 +418,6 @@ public void execute() {
};
}

/** Abort the send, and then send the sendAborted message. Don't do anything if the
* send has already been aborted. */
public void abortSend(int reason, String desc) throws NotConnectedException {
if(logMINOR) Logger.minor(this, "Aborting send on "+this);
Future fail;
synchronized(_senderThread) {
_failed = true;
fail = maybeFail(reason, desc);
}
fail.execute();
cancelItemsPending();
}

public void innerSendAborted(int reason, String desc) throws NotConnectedException {
_usm.send(_destination, DMT.createSendAborted(_uid, reason, desc), _ctr);
}
Expand Down
4 changes: 1 addition & 3 deletions src/freenet/l10n/freenet.l10n.de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,6 @@ FirstTimeWizardToadlet.step2Title=Freenet-Einrichtungs-Assistent! - Wählen Sie
FirstTimeWizardToadlet.step3Title=Freenet-Einrichtungs-Assistent! - Bandbreiten-Limits
FirstTimeWizardToadlet.step4Title=Freenet-Einrichtungs-Assistent! - Größe des Datenspeichers
FirstTimeWizardToadlet.stepMiscTitle=Freenet-Einrichtungs-Assistent! - Updates und Plugins
FirstTimeWizardToadlet.tenPercentDisk=(= 10% des freien Speicherplatzes)
FirstTimeWizardToadlet.fivePercentDisk=(= 5% des freien Speicherplatzes)
FirstTimeWizardToadlet.backToSecurityLevels=Passwort nicht setzen und zurück zum Einrichtungs-Assistenten gehen.
FProxyToadlet.abortToHomepage=Abbrechen und zur Freenet-Startseite zurückkehren
FProxyToadlet.addFriendTitle=Einen Freund hinzufügen
Expand Down Expand Up @@ -1148,7 +1146,7 @@ Node.usingOracle=Sie verwenden Freenet mit der offiziellen Oracle Java Virtual M
Node.withAnnouncement=Freenet erlauben, sich mit Hilfe von Seednodes selbst aufzusetzen?
Node.withAnnouncementLong=Dem Knoten erlauben, sich mit Hilfe von Seednodes (Start-Knoten) automatisch zu verbinden? Obwohl dies die Standard-Einstellung darstellt, ist es prinzip-bedingt unsicher. Um in das Opennet zu gelangen, nimmt Freenet Kontakt auf zu öffentlichen Knoten. Diese Knoten sind in einer kleinen Datei enthalten, die mit Freenet zusammen installiert wird (seednodes.fref). Das Opennet ist die Freenet-Verbindung, die automatisch gewählt wird, wenn der Sicherheitslevel für das Netzwerk auf NIEDRIG oder NORMAL eingestellt wird. Offensichtlich ist dies in gewisser Weise unsicher, für das Opennet wird man das aber so machen müssen. Wenn Ihr Freenet-Knoten eine zeitlang abgeschaltet war, insbesondere wenn er sich hinter einem Router befindet und/oder seine IP-Adresse hat sich geändert, dann muß er erstmal in das Freenet hineinfinden. Wenn Sie eine höhere Sicherheitsstufe möchten, sollten Sie sich nur über Freunde zu Freenet verbinden und den Netzwerk-Sicherheitslevel auf "HOCH" stellen.
Node.writeLocalToDatastore=Lokale und nahe Anfragen in den Datenspeicher schreiben?
Node.writeLocalToDatastoreLong=Ob Daten, die von Anfragen mit hohen HTL (lokale und nahe) zurückgegeben wurden, in den permanenten Haupt-Datenspeicher geschrieben werden sollen. Wir empfehlen eindringlich, dass Sie diese Option ausgeschaltet lassen, außer wenn Sie sich weder um Datenspeicher-Beschlagnahmung noch um Probe-Angriffe auf den Speicher Sorgen machen. Diese wird standardmäßig nur eingeschaltet, wenn der Sicherheitslevel für das Netzwerk und der physische Sicherheitslevel beide auf NIEDRIG sind.
Node.writeLocalToDatastoreLong=Ob Daten, die von Anfragen mit hohen HTL (lokale und nahe) zurückgegeben wurden, in den permanenten Haupt-Datenspeicher geschrieben werden sollen. Wir empfehlen eindringlich, dass Sie diese Option ausgeschaltet lassen, außer wenn Sie sich weder um Datenspeicher-Beschlagnahmung noch um Probe-Angriffe auf den Speicher Sorgen machen.
NodeClientCore.alwaysCommit=Speichern nach jeder Veränderung der Datenbank?
NodeClientCore.alwaysCommitLong=Wenn diese Option ausgeschaltet ist, werden Veränderungen der Datenbank höchstens alle 30 Sekunden auf die Festplatte gespeichert. Wenn sie eingeschaltet ist, wird nach jeder Veränderung gespeichert. Dadurch wird die Geschwindigkeit reduziert und es entstehen mehr Festplattenzugriffe. Es wird jedoch sichergestellt, dass bei einem Absturz (z.B. durch Stromausfall) kein Fortschritt verloren geht; zudem wird der Speicherverbrauch leicht reduziert. Normalerweise sollte diese Option ausgeschaltet bleiben um die Zahl der Festplattenzugriffe zu reduzieren.
NodeClientCore.maxArchiveSize=Maximale Größe eines Archivs
Expand Down
11 changes: 8 additions & 3 deletions src/freenet/l10n/freenet.l10n.en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ DarknetConnectionsToadlet.numOfResults=Number of results
DarknetConnectionsToadlet.visibilityTitle=Visible to friends?
DarknetConnectionsToadlet.visibilityMessageSimple=Is this friend visible to our other friends? (We use the stricter of our setting and theirs, see more in advanced mode)
DarknetConnectionsToadlet.visibilityMessageAdvanced=Is this friend visible to our other friends? (We use the stricter of our setting and theirs, theirs is in brackets)
DataStoreTooSmallAlert.title=Your datastore is smaller than recommended
DataStoreTooSmallAlert.description=You are recommended to contribute at least ${size} GiB of disk space to the network. The more space everyone contributes, the more files the network can hold, and for longer times.
DataStoreTooSmallAlert.current=Your current datastore size: ${size}
DataStoreTooSmallAlert.available=Total available disk space: ${size}
DataStoreTooSmallAlert.submit=Go to datastore size configuration
DiskSpaceUserAlert.title=Please free up some disk space!
DiskSpaceUserAlert.notEnoughSpaceIn=There is not enough free space available in ${where}.
DiskSpaceUserAlert.action=Please delete or move some files. Alternatively you can change the disk space limit on the Configuration page ("Minimum free disk space" etc under Core Settings in advanced mode).
Expand Down Expand Up @@ -618,8 +623,6 @@ FirstTimeWizardToadlet.step2Title=Name Your Node
FirstTimeWizardToadlet.step3Title=Bandwidth Limits
FirstTimeWizardToadlet.step4Title=Datastore Size
FirstTimeWizardToadlet.stepMiscTitle=Updating And Plugins
FirstTimeWizardToadlet.tenPercentDisk=(= 10% of free disk space)
FirstTimeWizardToadlet.fivePercentDisk=(= 5% of free disk space)
FirstTimeWizardToadlet.backToSecurityLevels=Don't set a password and return to the wizard.
FLAC.InvalidFLACStreamTitle=Invalid FLAC stream
FLAC.InvalidFLACStreamMessage=The FLAC stream was found to be corrupt or malformed, and was unable to sanitized.
Expand Down Expand Up @@ -1158,6 +1161,8 @@ Node.probeLocationShort=Respond to probe requests for location
Node.probeLocationLong=If true Freenet will respond to probe requests for low-precision location. This is to allow measurement of the network location distribution, and contains no information other than location. If false it will respond with a refusal.
Node.peersOffersDismissed=Dismiss peers' offers
Node.peersOffersDismissedLong=Do not check *.fref files in a peers-offers/ folder, don't ask user whether to connect to them.
Node.datastoreTooSmallDismissed=Dismiss datastore too small alert
Node.datastoreTooSmallDismissedLong=The version at which the datastore too small user alert was last dismissed. Do not show user alert again while running this version.
Node.respondOverallBulkOutputCapacityUsage=Respond to probe requests for overall capacity usage and very approximate bandwidth limit
Node.respondOverallBulkOutputCapacityUsageLong=If true Freenet will respond to probe requests for the overall capacity usage (bandwidth liability, this is a guesstimate of how much bandwidth would be used if all running requests succeeded), and a rough idea of the bandwidth limit (as an integer, divided by 10KB/s, min 1 max 10).
Node.probeStoreSizeShort=Respond to probe requests for store size
Expand Down Expand Up @@ -1235,7 +1240,7 @@ Node.usingOracle=You are running Freenet under the official Oracle Java Virtual
Node.withAnnouncement=Allow Freenet to bootstrap itself using seednodes?
Node.withAnnouncementLong=Allow your Freenet node to bootstrap itself using seednodes? To get onto the opennet (the Strangers network, automatic Freenet connection on low/normal network security level), we contact public nodes chosen from a small list shipped with Freenet. Obviously this is somewhat insecure, but if you are using opennet, you probably need it: if your node is down for a while, especially if it is NATed and/or changes its IP address, it will probably need to reseed. If you want better security, you need to connect to your friends and enable high network security.
Node.writeLocalToDatastore=Write local and nearby requests to the datastore?
Node.writeLocalToDatastoreLong=Whether to write data returned by high HTL (local and nearby) requests to the main persistent datastore. We strongly recommend you keep this option disabled unless you don't care about either datastore seizure or store probing attacks. This will be enabled by default only if the network security level and physical security level are both LOW.
Node.writeLocalToDatastoreLong=Whether to write data returned by high HTL (local and nearby) requests to the main persistent datastore. We strongly recommend you keep this option disabled unless you don't care about either datastore seizure or store probing attacks.
NodeClientCore.alwaysCommit=Commit after every database job?
NodeClientCore.alwaysCommitLong=If this option is false, we commit the database to disk every 30 seconds. If it is true we commit it after every database job. This will reduce performance but will ensure that no progress is lost on an unclean shutdown, and slightly reduce memory usage. Normally this should be false, to reduce disk access.
NodeClientCore.maxArchiveSize=Maximum size of any given archive
Expand Down
Loading

0 comments on commit a65b766

Please sign in to comment.