From df925c20733d278b456e83592369e4f590d25228 Mon Sep 17 00:00:00 2001 From: Matthew Toseland Date: Mon, 18 Jan 2016 18:01:32 +0000 Subject: [PATCH 001/500] Don't relay noderefs at high HTL --- src/freenet/node/RequestSender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index 98f9d23e14e..02d067a9137 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1716,7 +1716,7 @@ private boolean finishOpennet(PeerNode next) { // RequestHandler will send a noderef back up, eventually, and will unlockHandler() after that point. // But if this is a local request, we need to send the ack now. // Serious race condition not possible here as we set it. - if(source == null) + if(!node.canWriteDatastoreRequest(origHTL)) ackOpennet(next); else if(origTag.shouldStop()) { // Can't pass it on. From 6ac3d5a5c49ab74e26d277c430b46d6445e15fd6 Mon Sep 17 00:00:00 2001 From: Matthew Toseland Date: Mon, 18 Jan 2016 18:05:13 +0000 Subject: [PATCH 002/500] Don't accept noderefs either at high HTL --- src/freenet/node/RequestSender.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index 02d067a9137..fbc85f5a930 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1707,6 +1707,9 @@ private boolean finishOpennet(PeerNode next) { return false; } + if(!node.canWriteDatastoreRequest(origHTL)) + ackOpennet(next); + if(node.addNewOpennetNode(ref, ConnectionType.PATH_FOLDING) == null) { if(logMINOR) Logger.minor(this, "Don't want noderef on "+this); // If we don't want it let somebody else have it @@ -1716,9 +1719,7 @@ private boolean finishOpennet(PeerNode next) { // RequestHandler will send a noderef back up, eventually, and will unlockHandler() after that point. // But if this is a local request, we need to send the ack now. // Serious race condition not possible here as we set it. - if(!node.canWriteDatastoreRequest(origHTL)) - ackOpennet(next); - else if(origTag.shouldStop()) { + if(origTag.shouldStop()) { // Can't pass it on. origTag.finishedWaitingForOpennet(next); } From 21c094c68f3cb3d861b2619f05299521a4e769d4 Mon Sep 17 00:00:00 2001 From: Matthew Toseland Date: Mon, 18 Jan 2016 18:24:00 +0000 Subject: [PATCH 003/500] Missing return, oops --- src/freenet/node/RequestSender.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index fbc85f5a930..83bf5218aa9 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1707,8 +1707,10 @@ private boolean finishOpennet(PeerNode next) { return false; } - if(!node.canWriteDatastoreRequest(origHTL)) + if(!node.canWriteDatastoreRequest(origHTL)) { ackOpennet(next); + return false; + } if(node.addNewOpennetNode(ref, ConnectionType.PATH_FOLDING) == null) { if(logMINOR) Logger.minor(this, "Don't want noderef on "+this); From 0e7bb08c41e8cd2e87a7caabc520c65286cc3c45 Mon Sep 17 00:00:00 2001 From: Matthew Toseland Date: Mon, 18 Jan 2016 18:24:30 +0000 Subject: [PATCH 004/500] Comments --- src/freenet/node/RequestSender.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index 83bf5218aa9..bd9d64be1a9 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1708,6 +1708,7 @@ private boolean finishOpennet(PeerNode next) { } if(!node.canWriteDatastoreRequest(origHTL)) { + // Do not path fold at all at high HTL. ackOpennet(next); return false; } From b9d0c0422a7fb70cfdae1a920b81d00cb0d3cfd3 Mon Sep 17 00:00:00 2001 From: Matthew Toseland Date: Tue, 19 Jan 2016 10:38:41 +0000 Subject: [PATCH 005/500] Replace outdated comment with an assertion --- src/freenet/node/RequestSender.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index bd9d64be1a9..809a5fb5cfb 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1720,8 +1720,7 @@ private boolean finishOpennet(PeerNode next) { opennetNoderef = noderef; } // RequestHandler will send a noderef back up, eventually, and will unlockHandler() after that point. - // But if this is a local request, we need to send the ack now. - // Serious race condition not possible here as we set it. + assert(source != null); if(origTag.shouldStop()) { // Can't pass it on. origTag.finishedWaitingForOpennet(next); From ba4660ea42539378de75d1db3a4b061d4b831d38 Mon Sep 17 00:00:00 2001 From: DC* Date: Thu, 19 May 2022 17:49:07 +0100 Subject: [PATCH 006/500] Debian package continuation --- .gitignore | 14 ++- debian/changelog | 5 + debian/compat | 1 + debian/control | 28 +++++ debian/copyright | 203 ++++++++++++++++++++++++++++++ debian/files | 2 + debian/freenet.default | 13 ++ debian/freenet.dirs | 5 + debian/freenet.docs | 2 + debian/freenet.ini | 14 +++ debian/freenet.init | 213 ++++++++++++++++++++++++++++++++ debian/freenet.install | 3 + debian/freenet.postint | 59 +++++++++ debian/freenet.postrm | 84 +++++++++++++ debian/freenet.preinst | 100 +++++++++++++++ debian/freenet.service.params | 32 +++++ debian/rules | 38 ++++++ debian/seednodes.fref | 162 ++++++++++++++++++++++++ debian/source/format | 1 + debian/source/lintian-overrides | 0 debian/wrapper.conf | 19 +++ freenet.ini | 14 +++ 22 files changed, 1011 insertions(+), 1 deletion(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/files create mode 100644 debian/freenet.default create mode 100644 debian/freenet.dirs create mode 100644 debian/freenet.docs create mode 100644 debian/freenet.ini create mode 100644 debian/freenet.init create mode 100644 debian/freenet.install create mode 100644 debian/freenet.postint create mode 100644 debian/freenet.postrm create mode 100644 debian/freenet.preinst create mode 100644 debian/freenet.service.params create mode 100755 debian/rules create mode 100644 debian/seednodes.fref create mode 100644 debian/source/format create mode 100644 debian/source/lintian-overrides create mode 100644 debian/wrapper.conf create mode 100644 freenet.ini diff --git a/.gitignore b/.gitignore index 48cba0bb50a..69d371b20fb 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,20 @@ *.iml *.ipr *.iws -.* *~ \#*\# /override.properties /gradle.properties +debhelper-build-stamp +.debhelper +*.deb +*.dsc +*.build +*.buildinfo +*.changes +*.tar.gz +*.log +*.substvars +/debian/freenet/* +.gradle +gradle diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000000..099637b7abf --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +freenet (0.7.5+1493-1) unstable; urgency=medium + + * Initial Release. + + -- Dario Cavuotti Wed, 18 May 2022 00:00:00 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000000..b4de3947675 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +11 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000000..de77af98ccd --- /dev/null +++ b/debian/control @@ -0,0 +1,28 @@ +Source: freenet +Section: net +Priority: optional +Maintainer: Dario Cavuotti +Build-Depends: debhelper (>= 9), javahelper, quilt, adduser (>= 3.11), + git-core, default-jdk +Standards-Version: 4.5.1 +Homepage: http://freenetproject.org/ + +Package: freenet +Architecture: any +Depends: adduser, default-jre-headless, libservice-wrapper-java, service-wrapper + ${shlibs:Depends}, ${misc:Depends}, ${java:Depends} +Replaces: fred +Conflicts: fred +Tag: interface::daemon, network::server +Description: Lets you anonymously share files, browse and publish "freesites" (web + sites accessible only through Freenet) and chat on forums, without fear of + censorship. Freenet is decentralised to make it less vulnerable to attack, and + if used in "darknet" mode, where users only connect to their friends, is very + difficult to detect. Communications by Freenet nodes are encrypted and are + routed through other nodes to make it extremely difficult to determine who is + requesting the information and what its content is. + . + This package contains the Freenet REference Daemon (fred), which provides low + level access to data stored on Freenet, and a web proxy for viewing freesites. + Note that fred creates a datastore of at least 256 MB on first startup. + . diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000000..d1b2a11acd1 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,203 @@ +This package was debianized by: + + Masayuki Hatta (mhatta) on Fri, 10 Jul 2009 13:48:38 +0900 + +It was downloaded from: + + http://freenetproject.org/developer.html + +Upstream Author: + + The Freenet Project + +Copyright: + + Copyright (C) 2009 The Freenet Project + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Note that a large portion of Freenet is distributed under GPL2 *or + later*. + +On Debian systems, the complete text of the GNU General +Public License version 2 can be found in `/usr/share/common-licenses/GPL-2'. + +The Debian packaging is: + + Copyright (C) 2009 Masayuki Hatta (mhatta) + +and is licensed under the GPL version 3, +see `/usr/share/common-licenses/GPL-3'. + +This distribution contains several portions which bear licenses +different from GPL2: + +Mantissa: + +Copyright (c) 2001-2004, Luc Maisonobe All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + Redistributions of source code must retain the + above copyright notice, this list of conditions and + the following disclaimer. + + Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and + the following disclaimer in the documentation + and/or other materials provided with the + distribution. + + Neither the names of spaceroots.org, spaceroots.com + nor the names of their contributors may be used to + endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +contrib/bdb: + +The following is the license that applies to this copy of the Berkeley +DB Java Edition software. For a license to use the Berkeley DB Java +Edition software under conditions other than those described here, or +to purchase support for this software, please contact Oracle at +berkeleydb-info_us@oracle.com. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +/* + * Copyright (c) 2002,2008 Oracle. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Redistributions in any form must be accompanied by information on + * how to obtain complete source code for the DB software and any + * accompanying software that uses the DB software. The source code + * must either be included in the distribution or be available for no + * more than the cost of distribution plus a nominal fee, and must be + * freely redistributable under reasonable conditions. For an + * executable file, complete source code means the source code for all + * modules it contains. It does not include source code for modules or + * files that typically accompany the major components of the operating + * system on which the executable file runs. + * + * THIS SOFTWARE IS PROVIDED BY ORACLE ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR + * NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL ORACLE BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +/*** + * ASM: a very small and fast Java bytecode manipulation framework + * Copyright (c) 2000-2005 INRIA, France Telecom + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +contrib/fec: + +/* + * Java Forward Error Correction Library + * Copyright (C) 2001 Onion Networks + * Copyright (C) 2000 OpenCola + * + * Portions derived from code by Luigi Rizzo: + * fec.c -- forward error correction based on Vandermonde matrices + * 980624 + * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it) + * + * Portions derived from code by Phil Karn (karn@ka9q.ampr.org), + * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and Hari + * Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995 + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + */ + +contrib/java/net/contrapuctus/lzma: + +// Copyright (c)2008 Christopher League + +// This is free software, but it comes with ABSOLUTELY NO WARRANTY. +// GNU Lesser General Public License 2.1 or Common Public License 1.0 diff --git a/debian/files b/debian/files new file mode 100644 index 00000000000..2b12e82cb44 --- /dev/null +++ b/debian/files @@ -0,0 +1,2 @@ +freenet_0.7.5+1493-1_amd64.buildinfo net optional +freenet_0.7.5+1493-1_amd64.deb net optional diff --git a/debian/freenet.default b/debian/freenet.default new file mode 100644 index 00000000000..5c71cf728f6 --- /dev/null +++ b/debian/freenet.default @@ -0,0 +1,13 @@ +# Defaults for freenet-daemon initscript +# sourced by /etc/init.d/freenet-daemon +# installed at /etc/default/freenet-daemon by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# Do you really want to run freenet-daemon(fred)? +RUN=yes + +# Nice level +NICE=10 diff --git a/debian/freenet.dirs b/debian/freenet.dirs new file mode 100644 index 00000000000..4cfe7dec582 --- /dev/null +++ b/debian/freenet.dirs @@ -0,0 +1,5 @@ +etc/freenet/noderef +usr/share/java +usr/share/freenet +var/log/freenet +var/lib/freenet diff --git a/debian/freenet.docs b/debian/freenet.docs new file mode 100644 index 00000000000..0b6e0f3219b --- /dev/null +++ b/debian/freenet.docs @@ -0,0 +1,2 @@ +AUTHORS +README.md diff --git a/debian/freenet.ini b/debian/freenet.ini new file mode 100644 index 00000000000..3f6aaa604a5 --- /dev/null +++ b/debian/freenet.ini @@ -0,0 +1,14 @@ +node.install.nodeDir=/etc/freenet/noderef +node.install.cfgDir=/etc/freenet +node.install.userDir=/var/lib/freenet/state +node.install.runDir=/var/run/freenet +node.install.storeDir=/var/lib/freenet/store +node.install.pluginDir=/var/lib/freenet/plugins +node.install.tempDir=/tmp/freenet +node.downloadsDir=/var/lib/freenet/complete +logger.dirname=/var/log/freenet +logger.priority=NORMAL +node.updater.enabled=false +node.updater.autoupdate=false +node.updater.updateInstallers=false +End diff --git a/debian/freenet.init b/debian/freenet.init new file mode 100644 index 00000000000..dd8b87d81d3 --- /dev/null +++ b/debian/freenet.init @@ -0,0 +1,213 @@ +#! /bin/sh + +# +# Copyright (c) 1999, 2016 Tanuki Software, Ltd. +# http://www.tanukisoftware.com +# All rights reserved. +# +# This software is the proprietary information of Tanuki Software. +# You shall use it only in accordance with the terms of the +# license agreement you entered into with Tanuki Software. +# http://wrapper.tanukisoftware.com/doc/english/licenseOverview.html +# +# Java Service Wrapper sh script. Suitable for starting and stopping +# wrapped Java applications on UNIX platforms. +# + +#----------------------------------------------------------------------------- +# These settings can be modified to fit the needs of your application +# Optimized for use with version 3.5.30 of the Wrapper. + +# IMPORTANT - Please always stop and uninstall an application before making +# any changes to this file. Failure to do so could remove the +# script's ability to control the application. + +# Initialization block for the install_initd and remove_initd scripts used by +# SUSE linux, CentOS and RHEL distributions. +# Note: From CentOS 6, make sure the BEGIN INIT INFO section is before any line +# of code otherwise the service won't be displayed in the Service +# Configuration GUI. +### BEGIN INIT INFO +# Provides: freenet +# Required-Start: $local_fs $network $syslog +# Should-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Freenet 0.7.5 build 1493 (experimental release) +# Description: Freenet reference daemon +### END INIT INFO + +# Application +APP_NAME="freenet" +APP_LONG_NAME="Freenet 0.7.5 build 1493 (experimental release)" + +# If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer +# be passed to the wrapper. See documentation for details. +#APP_NAME_PASS_TO_WRAPPER=false + +# Wrapper +WRAPPER_CMD="/usr/sbin/wrapper" +WRAPPER_CONF="/etc/freenet/wrapper.conf" + +# Priority at which to run the wrapper. See "man nice" for valid priorities. +# nice is only used if a priority is specified. +PRIORITY="10" + +# Location of the pid file. +PIDDIR="/var/run/freenet" + +# PIDFILE_CHECK_PID tells the script to double check whether the pid in the pid +# file actually exists and belongs to this application. When not set, only +# check the pid, but not what it is. This is only needed when multiple +# applications need to share the same pid file. +PIDFILE_CHECK_PID=true + +# FIXED_COMMAND tells the script to use a hard coded action rather than +# expecting the first parameter of the command line to be the command. +# By default the command will will be expected to be the first parameter. +#FIXED_COMMAND=console + +# PASS_THROUGH tells the script to pass all arguments through to the JVM +# as is. If FIXED_COMMAND is specified then all arguments will be passed. +# If not set then all arguments starting with the second will be passed. +#PASS_THROUGH=true + +# If uncommented, causes the Wrapper to be shutdown using an anchor file. +# When launched with the 'start' command, it will also ignore all INT and +# TERM signals. +#IGNORE_SIGNALS=true + +# Wrapper will start the JVM asynchronously. Your application may have some +# initialization tasks and it may be desirable to wait a few seconds +# before returning. For example, to delay the invocation of following +# startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will +# cause the start command to delay for the indicated period of time +# (in seconds). +# +WAIT_AFTER_STARTUP=0 + +# If set, wait for the wrapper to report that the daemon has started +WAIT_FOR_STARTED_STATUS=true +WAIT_FOR_STARTED_TIMEOUT=120 + +# If set, the status, start_msg and stop_msg commands will print out detailed +# state information on the Wrapper and Java processes. +#DETAIL_STATUS=true + +# If set, the 'pause' and 'resume' commands will be enabled. These make it +# possible to pause the JVM or Java application without completely stopping +# the Wrapper. See the wrapper.pausable and wrapper.pausable.stop_jvm +# properties for more information. +#PAUSABLE=true + +# If specified, the Wrapper will be run as the specified user. +# IMPORTANT - Make sure that the user has the required privileges to write +# the PID file and wrapper.log files. Failure to be able to write the log +# file will cause the Wrapper to exit without any way to write out an error +# message. +# NOTE - This will set the user which is used to run the Wrapper as well as +# the JVM and is not useful in situations where a privileged resource or +# port needs to be allocated prior to the user being changed. +RUN_AS_USER="freenet" + +# Set the full path to the 'su' command (substitute user). +# NOTE - In case 'su' is not in the PATH, you can set the absolute path here, +# for example: +# SU_BIN=/bin/su +# NOTE - For Red Hat, the script will use '/sbin/runuser' if it is present and +# ignore the value of SU_BIN. +SU_BIN=su + +# Set option for 'su'. +# In case the user set in RUN_AS_USER has no bash set, the 'su' command will fail. +# The workaround for GNU/Linux system is to specify which bash to use with +# the '-s' option. +#SU_OPTS="-s /bin/bash" + +# Set the full path to the 'id' command. +# For example: +# ID_BIN=/usr/bin/id +ID_BIN=id + +# By default we show a detailed usage block. Uncomment to show brief usage. +#BRIEF_USAGE=true + +# OS service management tool: flag for using Upstart when installing (rather than init.d rc.d). +USE_UPSTART= + +# OS service management tool: flag for using systemd when installing. +USE_SYSTEMD= + +# Flag for AIX to start/stop the Wrapper without using the System Resource +# Controller (SRC).This is useful when you want to start the Wrapper as a +# daemon without installation or when APP_NAME is longer than 14 chars. +SKIP_SRC= + +# When installing on Mac OSX platforms, the following domain will be used to +# prefix the plist file name. +PLIST_DOMAIN=org.tanukisoftware.wrapper + +# When installing on Mac OSX platforms, this parameter controls whether the daemon +# is to be kept continuously running or to let demand and conditions control the +# invocation. +MACOSX_KEEP_RUNNING="false" + +# The following two lines are used by the chkconfig command. Change as is +# appropriate for your application. They should remain commented. +# chkconfig: 2345 20 80 +# description: Freenet 0.7.5 build 1493 (experimental release) + +# Set run level to use when installing the application to start and stop on +# system startup and shutdown. It is important that the application always +# be uninstalled before making any changes to the run levels. +# It is also possible to specify different run levels based on the individual +# platform. When doing so this script will look for defined run levels in +# the following order: +# 1) "RUN_LEVEL_S_$DIST_OS" or "RUN_LEVEL_K_$DIST_OS", where "$DIST_OS" is +# the value of DIST_OS. "RUN_LEVEL_S_solaris=20" for example. +# 2) RUN_LEVEL_S or RUN_LEVEL_K, to specify specify start or stop run levels. +# 3) RUN_LEVEL, to specify a general run level. +RUN_LEVEL=20 + +# List of files to source prior to executing any commands. Use ';' as delimiter. +# For example: +# FILES_TO_SOURCE="/home/user/.bashrc;anotherfile;../file3" +FILES_TO_SOURCE= + +# Do not modify anything beyond this point +#----------------------------------------------------------------------------- + +if [ -f "/etc/default/$APP_NAME" ]; then + . "/etc/default/$APP_NAME" +fi + +# WRAPPER_PREINIT START +# do we want to run at all? + +if [ "$RUN" != "yes" ]; then echo >&2 "RUN is not yes; abort"; exit 1; fi + +# set PRIORITY from /etc/default + +if [ -n "$NICE" ]; then PRIORITY="$NICE"; fi + +# copy default config files, if necessary + +ensure_exists() { if [ ! -f "$1" ]; then cp "$2" "$1"; fi; } + +ensure_exists /etc/freenet/wrapper.conf /usr/share/freenet/wrapper.conf +ensure_exists /etc/freenet/freenet.ini /usr/share/freenet/freenet.ini +ensure_exists /etc/freenet/noderef/seednodes.fref /usr/share/freenet/seednodes.fref + +[ -z "$SERVER_USER" ] && SERVER_USER=freenet +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=freenet + +if [ ! -d "$PIDDIR" ]; then + mkdir "$PIDDIR" || exit 1 + chown $SERVER_USER:$SERVER_GROUP "$PIDDIR" || exit 1 + chmod 2750 "$PIDDIR" || exit 1 +fi +# WRAPPER_PREINIT END + +. "/usr/share/wrapper/daemon.sh" + diff --git a/debian/freenet.install b/debian/freenet.install new file mode 100644 index 00000000000..a53d3cfdbf5 --- /dev/null +++ b/debian/freenet.install @@ -0,0 +1,3 @@ +debian/seednodes.fref usr/share/freenet +debian/freenet.ini usr/share/freenet +debian/wrapper.conf usr/share/freenet diff --git a/debian/freenet.postint b/debian/freenet.postint new file mode 100644 index 00000000000..f8ed7b7bd93 --- /dev/null +++ b/debian/freenet.postint @@ -0,0 +1,59 @@ +#!/bin/sh +# postinst script for freenet +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + + # If the package has default file it could be sourced, so that + # the local $SERVER_GROUPin can overwrite the defaults + + [ -f "/etc/default/freenet" ] && . /etc/default/freenet + + # Sane defaults: + + [ -z "$SERVER_USER" ] && SERVER_USER=freenet + [ -z "$SERVER_GROUP" ] && SERVER_GROP=freenet + + # Make sure that all existing processes are stopped + PID=$(ps -eo pid,user|grep freenet|cut -d ' ' -f 2) + kill -s KILL ${PID} > /dev/null 2>&1 || true + + # Set file and directory permissions + chown root:$SERVER_USER /etc/freenet /etc/freenet/noderef + chmod 2775 /etc/freenet /etc/freenet/noderef + chown $SERVER_USER:$SERVER_GROUP /var/log/freenet + chmod 2750 /var/log/freenet + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/freenet.postrm b/debian/freenet.postrm new file mode 100644 index 00000000000..413521e0c5a --- /dev/null +++ b/debian/freenet.postrm @@ -0,0 +1,84 @@ +#!/bin/sh +# postrm script for freenet +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge) + # find first and last SYSTEM_UID numbers + for LINE in `grep SYSTEM_UID /etc/adduser.conf | grep -v "^#"`; do + case $LINE in + FIRST_SYSTEM_UID*) + FIRST_SYSTEM_UID=`echo $LINE | cut -f2 -d '='` + ;; + LAST_SYSTEM_UID*) + LAST_SYSTEM_UID=`echo $LINE | cut -f2 -d '='` + ;; + *) + ;; + esac + done + # Remove system account if necessary + CREATEDUSER="freenet" + DIETIME=10 # Time to wait for the server to die + if [ -n "$FIRST_SYSTEM_UID" ] && [ -n "$LAST_SYSTEM_UID" ]; then + if USERID=`getent passwd $CREATEDUSER | cut -f 3 -d ':'`; then + if [ -n "$USERID" ]; then + if [ "$FIRST_SYSTEM_UID" -le "$USERID" ] && \ + [ "$USERID" -le "$LAST_SYSTEM_UID" ]; then + echo -n "Removing $CREATEDUSER system user.." + sleep "$DIETIME"s + deluser --quiet --remove-home $CREATEDUSER || true + echo "..done" + fi + fi + fi + fi + # Remove system group if necessary + CREATEDGROUP=freenet + FIRST_USER_GID=`grep ^USERS_GID /etc/adduser.conf | cut -f2 -d '='` + if [ -n "$FIRST_USER_GID" ]; then + if GROUPGID=`getent group $CREATEDGROUP | cut -f 3 -d ':'`; then + if [ -n "$GROUPGID" ]; then + if [ "$FIRST_USER_GID" -gt "$GROUPGID" ]; then + echo -n "Removing $CREATEDGROUP group.." + delgroup --only-if-empty $CREATEDGROUP || true + echo "..done" + fi + fi + fi + fi + rm -rf /var/lib/freenet + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/freenet.preinst b/debian/freenet.preinst new file mode 100644 index 00000000000..b574618c5fb --- /dev/null +++ b/debian/freenet.preinst @@ -0,0 +1,100 @@ +#!/bin/sh +# preinst script for freenet +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + # If the package has default file it could be sourced, so that + # the local $SERVER_GROUPin can overwrite the defaults + + [ -f "/etc/default/freenet" ] && . /etc/default/freenet + + # Sane defaults: + + [ -z "$SERVER_HOME" ] && SERVER_HOME="/var/lib/freenet" + [ -z "$SERVER_USER" ] && SERVER_USER=freenet + [ -z "$SERVER_GROUP" ] && SERVER_GROUP=freenet + [ -z "$SERVER_NAME" ] && SERVER_NAME="Freenet REference Daemon" + [ -z "$SERVER_LOG" ] && SERVER_LOG="/var/log/freenet" + [ -z "$SERVER_ETC" ] && SERVER_ETC="/etc/freenet" + + # Groups that the user will be added to, if undefined, then none. + ADDGROUP="freenet" + + # create user to avoid running server as root + # 1. create group if not existing + if ! getent group | grep -q "^$SERVER_GROUP:" ; then + echo -n "Adding group $SERVER_GROUP.." + addgroup --quiet --system $SERVER_GROUP 2>/dev/null ||true + echo "..done" + fi + # 2. create homedir if not existing + test -d $SERVER_HOME || mkdir $SERVER_HOME + test -d $SERVER_LOG || mkdir $SERVER_LOG + test -d $SERVER_ETC || mkdir $SERVER_ETC + # 3. create user if not existing + if ! getent passwd | grep -q "^$SERVER_USER:"; then + echo -n "Adding system user $SERVER_USER.." + adduser --quiet \ + --system \ + --shell /bin/sh \ + --ingroup $SERVER_GROUP \ + --no-create-home \ + --home /nonexistent \ + --disabled-password \ + $SERVER_USER 2>/dev/null || true + echo "..done" + fi + # 4. adjust passwd entry + usermod -c "$SERVER_NAME" \ + -d $SERVER_HOME \ + -g $SERVER_GROUP \ + $SERVER_USER + # 5. adjust file and directory permissions + if ! dpkg-statoverride --list $SERVER_HOME >/dev/null + then + chown -f -R $SERVER_USER:$SERVER_GROUP $SERVER_HOME + chmod -f u=rwx,g=rxs,o= $SERVER_HOME + chown -f -R $SERVER_USER:$SERVER_GROUP $SERVER_LOG + chmod -f u=rwx,g=rxs,o= $SERVER_LOG + chown -f -R $SERVER_USER:$SERVER_GROUP $SERVER_ETC + chmod -f u=rwx,g=rxs,o= $SERVER_ETC + + fi + # 6. Add the user to the ADDGROUP group + if test -n $ADDGROUP + then + if ! groups $SERVER_USER | cut -d: -f2 | \ + grep -qw $ADDGROUP; then + adduser $SERVER_USER $ADDGROUP + fi + fi + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/freenet.service.params b/debian/freenet.service.params new file mode 100644 index 00000000000..9dd4cae297d --- /dev/null +++ b/debian/freenet.service.params @@ -0,0 +1,32 @@ +freenet +Freenet @version@ build @build@ (experimental release) +Freenet reference daemon +WRAPPER_CONF /etc/freenet/wrapper.conf +PRIORITY 10 +RUN_AS_USER freenet +PIDDIR /var/run/freenet + +# do we want to run at all? + +if [ "$RUN" != "yes" ]; then echo >&2 "RUN is not yes; abort"; exit 1; fi + +# set PRIORITY from /etc/default + +if [ -n "$NICE" ]; then PRIORITY="$NICE"; fi + +# copy default config files, if necessary + +ensure_exists() { if [ ! -f "$1" ]; then cp "$2" "$1"; fi; } + +ensure_exists /etc/freenet/wrapper.conf /usr/share/freenet/wrapper.conf +ensure_exists /etc/freenet/freenet.ini /usr/share/freenet/freenet.ini +ensure_exists /etc/freenet/noderef/seednodes.fref /usr/share/freenet/seednodes.fref + +[ -z "$SERVER_USER" ] && SERVER_USER=freenet +[ -z "$SERVER_GROUP" ] && SERVER_GROUP=freenet + +if [ ! -d "$PIDDIR" ]; then + mkdir "$PIDDIR" || exit 1 + chown $SERVER_USER:$SERVER_GROUP "$PIDDIR" || exit 1 + chmod 2750 "$PIDDIR" || exit 1 +fi diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000000..fbc1941fb75 --- /dev/null +++ b/debian/rules @@ -0,0 +1,38 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=0 +FREENET_VERSION := 0.7.5 +FREENET_BUILD := 1493 +WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh + +%: + dh $@ --with javahelper + +override_dh_auto_build: + export GRADLE_USER_HOME="`pwd`/gradle"; \ + export GRADLE_OPTS="-Dorg.gradle.daemon=false -Xmx512m"; \ + ./gradlew assemble; \ + ./gradlew copyRuntimeLibs + + sed -e 's/@version@/$(FREENET_VERSION)/' -e 's/@build@/$(FREENET_BUILD)/' $(CURDIR)/debian/freenet.service.params | \ + $(WRAPPER_INIT) -q > "$(CURDIR)/debian/freenet.init" + +override_dh_builddeb: + dh_builddeb -- -Zgzip + +override_dh_auto_install: + dh_auto_install + jh_installlibs $(CURDIR)/build/libs/freenet.jar + +override_dh_auto_test: + export GRADLE_USER_HOME="`pwd`/gradle"; \ + export GRADLE_OPTS="-Dorg.gradle.daemon=false -Xmx512m"; \ + ./gradlew test + +override_jh_installlibs: + jh_installlibs $(CURDIR)/build/output/freenet-ext-29.jar + jh_installlibs $(CURDIR)/build/output/jna-4.5.2.jar + jh_installlibs $(CURDIR)/build/output/jna-platform-4.5.2.jar + jh_installlibs $(CURDIR)/build/output/bcprov-jdk15on-1.59.jar diff --git a/debian/seednodes.fref b/debian/seednodes.fref new file mode 100644 index 00000000000..a3e44615322 --- /dev/null +++ b/debian/seednodes.fref @@ -0,0 +1,162 @@ +identity=t0uY~zsjQMfuD2IKtJhKZv5AfgAUdyyCgdp7fzFFXvE +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC43MTYzNjgwNDQ4NjAyOTQy +opennet=true +sigP256=MEYCIQCcJWZEwT7YNAwIY08ZEFbMGgb2hFZF2Uhrjuyu7H-6PgIhAPvakaT-AFIb-hhTOjo3TELhJ3FQaS5VaubXYDbCTCdu +version==RnJlZCwwLjcsMS4wLDE0Nzk +ark.number=91 +ark.pubURI=SSK@62CCpYejO1jeoLy7b~01Zu2iRQPJfa8NuJ4Zgz6WSV4,mveCh0IkiER8KeHV5S8i2ooBAOB1WYGEKk3M3SktUYU,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnwm~Hm2yGWRCfhmX2tJu3M-2cmaKIfsS9oXJTmdZ6kRq3tU~bBwFQY4Fabb44q~vXyIq9O4vNysvtGGV5qHXpA +physical.udp==ZnJlZW5ldC5udWxsdm9pZC5tZTo2MTQ1NTsyNjA3OjUzMDA6MjAxOjMwMDA6MDowOjA6MTdkMzo2MTQ1NTsxNDkuNTYuNDUuMjAwOjYxNDU1 +End + +identity=AMJNW1zpC2TSVeyRI~rLq8Yb~9py2NSNefblrlECx2M +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC4zMTIzNTIxNzYwMjI4MDg3NA +opennet=true +sigP256=MEYCIQDqDwNkkVNtEqRWKlLFyXnfDnZpR4KJUgUH74xiMVqYxAIhAKFlnEygH0T5reHpIDGGTUyk~BnZaBZGFeF4YMo9WXsc +version==RnJlZCwwLjcsMS4wLDE0NzU +ark.number=1871 +ark.pubURI=SSK@OYfh3dlhh4CER4IjZPq6e06ug8ipehlYdS4pSnE00Tw,i3axPVzOkl7Iy568wzqTXAESYjTiKltripHlK4hqTJk,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmaH8K8bKR8Hvvhxjr-TPUe4R4yItj-Dcr5vfmwg1j0wu4mWD10Z5S9rN2ZUYNFYoiwwFd8LdAGSRDtQFoHE~3g +physical.udp==ZDYuZ251dGVsbGEyLmluZm86MzI2ODU7ODUuMjEyLjMuMTMwOjMyNjg1Ozg1LjIxMi4yNi4yNDI6MzI2ODU7ODUuMjEyLjI2LjI0Mjo2MTk3OA +End + +identity=7EoZpRvanX5WdT1aWg82SZjf0wVQd-Xmg8KAPT-sXDE +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY +location==MC4wMDE5NTUyMDQwNDc0MTQzMzg0 +opennet=true +sig=008cc800f6eb9980d158335a65fa329607d5a4e9dae11cb5ce2cefeb687822ca6a,0090d4e3ce64ee8bd25d07b76dd1eb30b873d2fca6299100fa2a5776783559d85e +sigP256=MEUCIQD2MgvLdSf8PKpoMswU8spq~QEM-zvRBOlPs2hsRKzjaAIgDE1orFTZvENtgoCpqRa4M~iybl4tf99PB3QbExJviMM +version==RnJlZCwwLjcsMS4wLDE0Njc +ark.number=225 +ark.pubURI=SSK@UeoCoRROTtuyuZqABq2-Sm1gZWfivCANAaCV9VzAdt8,wdbeYeRBh4uz2aexTbjUJ0VpYlZNMihn9lTM1w~qdEc,AQACAAE/ark +auth.negTypes==OTsxMA +dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg +dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk +dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 +dsaPubKey.y=Q-RXw568J3~j6i5W4Nr2oIm~Vejx8dClz7ULBJGH2RWdmlUVWE~8Jg4FJeTwYItawFDAx0DadKsT-MsVKVINyPQ4i8u9MDybkp~ELiRNdqa3px09QkPH28kLSKenhj7uRpGuiHHxh0Pw~sD4mLbBT1J7XV57rQ7he3wmcNHf0Jdg-WnKnju7ref8BjDs28HeV59bfub1qGNvJxPrjHUT4O73Z2TUepqsJsvEAas1E-~sb9W64OVksPcKJ8oN45ptFHxsQ8o6mwexSUHHiwAX-viu5gXpCw5NzvyGtAAtJDLfebEN3X9BPHzkl2wX4U94Rd4xmuxHU2jxl~hPMujJpg +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE~Eo5a~5zfJhSnkNx2VpJnEFWpjwjmgO7-Tt-4rgDJ1LwxAKKKxwbSlJDUTkd0RMGDQCGxOedvYrOclYuF3-FjQ +physical.udp==ZnJlZW5ldC5uZXJkeWJsb2tlLm5ldDozNDE1OzI1LjE1NC4xNjguMTY0OjM0MTU7MjEyLjE1OS4xNzcuMTk4OjM0MTU +End + +identity=6W8b11Iy5jjW2WmLN-wQIPcwnzHLdsrKDTbpO2nbQoA +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY +location==MC40NTY1NDI5OTIzMTY0OTE4Nw +opennet=true +sig=3b83f7a1a0a7f880d06a4870737d6d2e33155ff41672110c1ae4cdfd9757a3d2,4cb9f21fba50a9b68b3f5b8985f0ce961ed98575dab4b1dc30dd317ac57c32f9 +sigP256=MEUCIA9j0gwf5qQdXO-cgXN8RX9JmGZuShkRilHpdrY4oBCcAiEAwEQi48X-g9vJXJ9E0SDJpCkj~YOIIcLfVNpcpyXXKOE +version==RnJlZCwwLjcsMS4wLDE0NjY +ark.number=257 +ark.pubURI=SSK@ZiyMbzGNd09DCasOpcV7nSdsd99EyCS6ETU1hHmbH0k,i7Qi1zl-MpkiWg7MtouORGZsXaGx0wkDswG-DAmU3s8,AQACAAE/ark +auth.negTypes==OTsxMA +dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg +dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk +dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 +dsaPubKey.y=fAkSEP5sc4QwSD9OhES1jxJ8PqnUIMaCCJ6Rdl8uHtYKv2jDTlBrhnxs7Waxpowtxjeuk~GMkq-AoJkHbtfqMfe1otpTRO6l0zDGpkkw1MCxSGGcHPAb2WD1XVicixuIS~qdyRCDl~odaT2yQVASUC9nQEsurON7~ZhIsVMC18nV05f0BL4Z4clI-9w2FWaVbJVCjbnUJAEvErD4~yFvJ9z1EYFEjSDycKFQn9Lyj8czjv7UaInsRgJYm-5S-xoCjytVJ328Co8C71PvyhXElDyt03odA2MWfQEsi2NDBY90kY1zKV7u6366~e~AxZ0uuu5M8NG0wKHbaOND2xOMKA +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEak4~fhdD5gTCnOkmyfJNt95yYtY3NkoRB-x6aMydjZT4D~Ppjh5o~NX7NEyI9ShiPj6S5HAoDnYlbCOKuqdjTw +physical.udp==NzguNDYuNjMuMjA6MTI4Ng +End + +identity=2vh9tO8Z8B9djfsEDf0~5J~sw9paO0T1gNy2eaG7BF4 +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC4yMTI2NjU4MDQ0NjA0MDA5NQ +opennet=true +sigP256=MEUCIQDxOq56sYIA0VSEOA08rummiL54NY7mIbm~NVPZNH1zOwIgfVOjKTL3FNTTxsupj4JenUvMtPgGbYoj18t9Fu7pbrU +version==RnJlZCwwLjcsMS4wLDE0ODQ +ark.number=583 +ark.pubURI=SSK@ouMmz8KcGUbci~qdLTJDFSg~RkaV0vFHxDCJsLuzWMI,0vy-y7yDa5vRtmA475LIX-5KqDPmy9xattXBc1QgSrk,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9r4SocX5yq1icEMJn8c85JlJM0i6ifDbEypEdE3WMu6VoDxcCGyElZLpvhtMRzAzsin6kTHvtTi-A~uLGb6zAg +physical.udp==a2F0aXNrYS5vcmc6NDk1MzI7ODAuNzUuMTAzLjg5OjQ5NTMy +End + +identity=skCoNetjkg0rBksZE-cvoZ9~IXhno6RW5SDtAO8TNXs +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY +location==MC4zMjc3NTc2NTUzNTY1NTg5 +opennet=true +sig=582ffa8f1b3cfa1297c1a63f24fb808ac716b372f787c298785bdecebe17b4b4,00834cd587d3bb2d7557f323fe73b8bc05af1f91371370dce3359e2feef07c9c81 +sigP256=MEUCIQC4a0rVLctowjUMTmspQvghbptUotsELLfmJzu69CaHGQIgbqtH0X46DOqdod99BTIYqEgY4nVvTVP1-LbF3LNXJuA +version==RnJlZCwwLjcsMS4wLDE0Njc +ark.number=2409 +ark.pubURI=SSK@tDjqJMxBPaRzOTQE~r3LAkL~jgxql637l1MY59wyxrw,CeTvd0XTtazWIA73Itk~h4QmmxHYhFFNQk3sBmjgLns,AQACAAE/ark +auth.negTypes==OTsxMA +dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg +dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk +dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 +dsaPubKey.y=HHGmoASQb6hDv~CCQX38DFyWQvoihXmdcCT8dUFwRdVXEdBBplxZTC7JLIh9Ct34aEPThCE5VHz~Y~nEkO7GcP1wFFbnIqSwdP8hbRtuGoFauWWpPIsUofo-WYay8J1TF-~Mmb3lKuyp4HbkGaFdFiQzOK~~78wsPnuVYpfPXXa2w~c6Q2hrKENbdq~jU0Ili4t1CiGkZ6-aQaw5B6PIZWe10By~AcvLT1vCYBhB0W~FXHFDPgJ9hN8yga-NxPzkTMX58pwxu6UcRSZ2Hl3lSvfhAsNYGS-VPrA7ejKKyIjxnI7vJi7FO6Ac2a2p1nzxaxecTVxsJvCUSne4W-yc3g +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAI5mk35~trhSVzDEJ8~ylQHuxvZTTcq7Df0eD7VaMeMtSLcjkbXR~xiNF~l~RMbyo9Qe6qToH2zDZiqLy6LoWQ +physical.udp==Zm5ldC5tb29vLmNvbToxNDQxNjs5NS4yNS4xMjUuMjMxOjE0NDE2OzEwMC44MC4yMi4xMjQ6MTQ0MTY +End + +identity=FuS~37Rro5JRvwfLfJQlWSyE4dlNsXFohoNACS6c6dE +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY +location==MC44MTcxODkxMzQ5NjAyNTY2 +opennet=true +sig=0d0404194092fa17b06e8198236c116c28d87c75dbc7934e61912d67247258b5,0086fe4c23980aa702d5395eca70250e95e3173c620f056493c489687a9579e041 +sigP256=MEYCIQD7mKSoQAfFcmfCCTYGa-ikXA6P8jL4RC4XD-usHbgFSQIhAJIprPAJvPemykB5vLVZHVUMrVniZ7dBgR2R5qzBWjDW +version==RnJlZCwwLjcsMS4wLDE0Njc +ark.number=1063 +ark.pubURI=SSK@cmYYw-EA8wiQabmQzezvmETmuawJj2FNfjpboI9QUaI,2PI1w1PlKkIo5ujBxTZWVEhfUqAO~4ZqIujjbIZ300A,AQACAAE/ark +auth.negTypes==OTsxMA +dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg +dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk +dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 +dsaPubKey.y=Uljye0KvEBtQ6xCaj6VhCEl-z4C6b7if0qSzvx6aqn0rxOeFVnbEKAZwHu~fLA8mpUwAhFLw9vfrE6U0ni5GFwzRnppP2kAg4XHgOgK8EVr-yK1pZ5UkmXsD5MmFNTSsPeapi1QqfVgO0Meq16jpFZsVyENtFZieB7CRlHmns9rkwp1iMuI1OiMktjkf2coTBAifkAQs0QHntOUmOl5fYSCF4pdyE1ZLJt6NFBqe7eJ5ng-f5FUIcXUDdI-aBWYj3viOqa0fJKN637IQh5PoF-A-ZWsEWzG2GGlo6hWf-wgTjTCAqr1MfmpQOTFaJZo1pkQGIsArcBFC1eysO4OwrQ +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnFZUXRtj6eaHBCZqhilMRsnLDqCTRIkPDm5zpfjNdL7oOVcq07QuVeyyJAf9v6vOrjlzxv2w194i3ger31-YLA +physical.udp==MTQ5LjE1NC4xNTkuMTcyOjYxMDc4 +End + +identity=-X2GrYYfJsKd0nAEMN6Bm79w~nljbKbR-x09eF8Rj2o +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC4xNTY0OTk4NTYyODUzNTMxMg +opennet=true +sigP256=MEUCIQCERzO3ox7n0LrZzCIVvly9tGURjAstcQzApuwGxP-PwgIgLZUJajhqVKydkcFmY9H3gjlULUyy8m8acd2AY-iYcHk +version==RnJlZCwwLjcsMS4wLDE0ODU +ark.number=157 +ark.pubURI=SSK@f4zWd-e3t8Hc2wvkhGJdull2Iv1qCojENF3lN0Wt9L8,utyaE3HYWhIz-SZS745ONrDMt2yRo8BpEGoh-NGCjoY,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9AhL1-WGRb0O8HYFxj0VeyYiGgCSHmTcO-fJ4ep6-1CnWlPv7Gxju~tVqNHNkTLQMlwCGYbFj2~lIXoIA5~zPQ +physical.udp==MTM4LjE5Ny4xNzMuNjg6Mjc0NTk +End + +identity=9KMO9Hrd7Jc4r8DCKCu2ZqlAZjAWCB5mhLi~A5n7wSM +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC40NDgyODA1MDg0MDQ4ODIx +opennet=true +sigP256=MEYCIQC1ESpmXToMiX3jC8irHuGU3DDm0YjqTadCkYYo0NrZDQIhAJDdSjlrXMSdhLZbnFdT0ZaQ2EIzUM0cVzT2IeFIhOy7 +version==RnJlZCwwLjcsMS4wLDE0OTI +ark.number=29 +ark.pubURI=SSK@BeeoOzd-7PE~YFHiaVKLsYZoVT9BcbK-1Wcnkv4YlO8,3B~RxAwHwtORzVEOU71kiKlt1ci590T-EhycWoivTmA,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE3oQ0lNMwEdKWApYyeNkDBfgzOXi5-eFUpoG7BomRHYGaWFSdWB4nTCZXrFUb1yJ4rl-d6yW98NynaMXGIDlCfg +physical.udp==MTk4LjUwLjIyMy4yMCwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMDo1OTc0NzsxOTguNTAuMjIzLjIwOjU5NzQ3 +End + +identity=y885-nLCItbw5qD7Qq5xHKjwTm9RU6wrXM5t3BmCnUY +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC42MzI1NTYxNDE0MDg0NjQ3 +opennet=true +sigP256=MEUCIQDHqiAbDzX-uUFSoYP02k2WiCvvUdP1YmGv9d27hEEwkAIgBJ0Jigcj2dQHTPqdBKpK0XKfN0YqsM3WjMDRik6TlZs +version==RnJlZCwwLjcsMS4wLDE0OTI +ark.number=27 +ark.pubURI=SSK@AR2Fo2FDtZz~uYQzwopDgpCiHeCpzKXysohBhGnP9uQ,tJBUBJxaSGwx4DkYfTNiU5~9voibnV1jjgTHE2hHTOU,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEiKkpl1ukJO2eBn7O3QbY4RL7Iqy26Sa75xHnI2dlDuEkZMgBn2zPn0li16j6J-0hN8cxrfw9P~VARBSXPoNuOg +physical.udp==MTk4LjUwLjIyMy4yMSwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMTo2MzYxMDsxOTguNTAuMjIzLjIxOjYzNjEw +End + +identity=y885-nLCItbw5qD7Qq5xHKjwTm9RU6wrXM5t3BmCnUY +lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU +location==MC42MzI1NTYxNDE0MDg0NjQ3 +opennet=true +sigP256=MEUCIQDHqiAbDzX-uUFSoYP02k2WiCvvUdP1YmGv9d27hEEwkAIgBJ0Jigcj2dQHTPqdBKpK0XKfN0YqsM3WjMDRik6TlZs +version==RnJlZCwwLjcsMS4wLDE0OTI +ark.number=27 +ark.pubURI=SSK@AR2Fo2FDtZz~uYQzwopDgpCiHeCpzKXysohBhGnP9uQ,tJBUBJxaSGwx4DkYfTNiU5~9voibnV1jjgTHE2hHTOU,AQACAAE/ark +auth.negTypes=10 +ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEiKkpl1ukJO2eBn7O3QbY4RL7Iqy26Sa75xHnI2dlDuEkZMgBn2zPn0li16j6J-0hN8cxrfw9P~VARBSXPoNuOg +physical.udp==MTk4LjUwLjIyMy4yMSwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMTo2MzYxMDsxOTguNTAuMjIzLjIxOjYzNjEw +End diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000000..89ae9db8f88 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides new file mode 100644 index 00000000000..e69de29bb2d diff --git a/debian/wrapper.conf b/debian/wrapper.conf new file mode 100644 index 00000000000..5cbf4dfe993 --- /dev/null +++ b/debian/wrapper.conf @@ -0,0 +1,19 @@ +encoding=UTF-8 +#include /usr/share/wrapper/wrapper.conf + +wrapper.java.command=java +wrapper.working.dir=/var/lib/freenet +wrapper.java.classpath.1=/usr/share/java/freenet.jar +wrapper.java.classpath.2=/usr/share/java/freenet-ext-29.jar +wrapper.java.classpath.3=/usr/share/java/jna-4.5.2.jar +wrapper.java.classpath.4=/usr/share/java/jna-platform-4.5.2.jar +wrapper.java.classpath.5=/usr/share/java/bcprov-jdk15on-1.59.jar +wrapper.java.library.path.1=/usr/lib/jni +wrapper.java.mainclass=freenet.node.NodeStarter +wrapper.java.additional.1=-Dnetworkaddress.cache.ttl=0 +wrapper.java.additional.2=-Dnetworkaddress.cache.negative.ttl=0 +#wrapper.java.additional.3=-enableassertions:freenet +# You might want to set the following line if you have changed java.maxmemory +#wrapper.java.additional.4=-XX:MaxPermSize= +wrapper.app.parameter.1=/etc/freenet/freenet.ini +wrapper.logfile=/var/log/freenet/wrapper.log diff --git a/freenet.ini b/freenet.ini new file mode 100644 index 00000000000..3f6aaa604a5 --- /dev/null +++ b/freenet.ini @@ -0,0 +1,14 @@ +node.install.nodeDir=/etc/freenet/noderef +node.install.cfgDir=/etc/freenet +node.install.userDir=/var/lib/freenet/state +node.install.runDir=/var/run/freenet +node.install.storeDir=/var/lib/freenet/store +node.install.pluginDir=/var/lib/freenet/plugins +node.install.tempDir=/tmp/freenet +node.downloadsDir=/var/lib/freenet/complete +logger.dirname=/var/log/freenet +logger.priority=NORMAL +node.updater.enabled=false +node.updater.autoupdate=false +node.updater.updateInstallers=false +End From 6569f137bf35330a62743abbd40cd70887b1da04 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 21 May 2022 21:08:51 +0100 Subject: [PATCH 007/500] Delete freenet.ini --- freenet.ini | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 freenet.ini diff --git a/freenet.ini b/freenet.ini deleted file mode 100644 index 3f6aaa604a5..00000000000 --- a/freenet.ini +++ /dev/null @@ -1,14 +0,0 @@ -node.install.nodeDir=/etc/freenet/noderef -node.install.cfgDir=/etc/freenet -node.install.userDir=/var/lib/freenet/state -node.install.runDir=/var/run/freenet -node.install.storeDir=/var/lib/freenet/store -node.install.pluginDir=/var/lib/freenet/plugins -node.install.tempDir=/tmp/freenet -node.downloadsDir=/var/lib/freenet/complete -logger.dirname=/var/log/freenet -logger.priority=NORMAL -node.updater.enabled=false -node.updater.autoupdate=false -node.updater.updateInstallers=false -End From 212eeaf3f638ccdfaa45baefd5dda4b1d1138fe2 Mon Sep 17 00:00:00 2001 From: DC* Date: Sun, 29 May 2022 20:04:33 +0100 Subject: [PATCH 008/500] Add functions to retrieve seednodes --- debian/rules | 17 ++++++++++++++++- debian/seednodes.fref | 22 ---------------------- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/debian/rules b/debian/rules index fbc1941fb75..aff28ceb9e2 100755 --- a/debian/rules +++ b/debian/rules @@ -7,10 +7,25 @@ FREENET_VERSION := 0.7.5 FREENET_BUILD := 1493 WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh +REFS := https://github.com/freenet/seedrefs/archive/refs/heads/master.zip +REFS_NAME := seedrefs-master +REFS_DIR := /tmp/seeds/ + %: dh $@ --with javahelper -override_dh_auto_build: +$(REFS_DIR): + mkdir -p $(REFS_DIR) + wget -q $(REFS) -O $(REFS_DIR)/$(REFS_NAME).zip + unzip $(REFS_DIR)/$(REFS_NAME).zip -d $(REFS_DIR) + +build_seed_file: $(REFS_DIR) + cat $(REFS_DIR)/$(REFS_NAME)/* > seednodes.fref + +clean: + rm -rf $(REFS_DIR) + +override_dh_auto_build: build_seed_file export GRADLE_USER_HOME="`pwd`/gradle"; \ export GRADLE_OPTS="-Dorg.gradle.daemon=false -Xmx512m"; \ ./gradlew assemble; \ diff --git a/debian/seednodes.fref b/debian/seednodes.fref index a3e44615322..db15c3cfd78 100644 --- a/debian/seednodes.fref +++ b/debian/seednodes.fref @@ -10,7 +10,6 @@ auth.negTypes=10 ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnwm~Hm2yGWRCfhmX2tJu3M-2cmaKIfsS9oXJTmdZ6kRq3tU~bBwFQY4Fabb44q~vXyIq9O4vNysvtGGV5qHXpA physical.udp==ZnJlZW5ldC5udWxsdm9pZC5tZTo2MTQ1NTsyNjA3OjUzMDA6MjAxOjMwMDA6MDowOjA6MTdkMzo2MTQ1NTsxNDkuNTYuNDUuMjAwOjYxNDU1 End - identity=AMJNW1zpC2TSVeyRI~rLq8Yb~9py2NSNefblrlECx2M lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU location==MC4zMTIzNTIxNzYwMjI4MDg3NA @@ -23,7 +22,6 @@ auth.negTypes=10 ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmaH8K8bKR8Hvvhxjr-TPUe4R4yItj-Dcr5vfmwg1j0wu4mWD10Z5S9rN2ZUYNFYoiwwFd8LdAGSRDtQFoHE~3g physical.udp==ZDYuZ251dGVsbGEyLmluZm86MzI2ODU7ODUuMjEyLjMuMTMwOjMyNjg1Ozg1LjIxMi4yNi4yNDI6MzI2ODU7ODUuMjEyLjI2LjI0Mjo2MTk3OA End - identity=7EoZpRvanX5WdT1aWg82SZjf0wVQd-Xmg8KAPT-sXDE lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY location==MC4wMDE5NTUyMDQwNDc0MTQzMzg0 @@ -41,7 +39,6 @@ dsaPubKey.y=Q-RXw568J3~j6i5W4Nr2oIm~Vejx8dClz7ULBJGH2RWdmlUVWE~8Jg4FJeTwYItawFDA ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE~Eo5a~5zfJhSnkNx2VpJnEFWpjwjmgO7-Tt-4rgDJ1LwxAKKKxwbSlJDUTkd0RMGDQCGxOedvYrOclYuF3-FjQ physical.udp==ZnJlZW5ldC5uZXJkeWJsb2tlLm5ldDozNDE1OzI1LjE1NC4xNjguMTY0OjM0MTU7MjEyLjE1OS4xNzcuMTk4OjM0MTU End - identity=6W8b11Iy5jjW2WmLN-wQIPcwnzHLdsrKDTbpO2nbQoA lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY location==MC40NTY1NDI5OTIzMTY0OTE4Nw @@ -59,7 +56,6 @@ dsaPubKey.y=fAkSEP5sc4QwSD9OhES1jxJ8PqnUIMaCCJ6Rdl8uHtYKv2jDTlBrhnxs7Waxpowtxjeu ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEak4~fhdD5gTCnOkmyfJNt95yYtY3NkoRB-x6aMydjZT4D~Ppjh5o~NX7NEyI9ShiPj6S5HAoDnYlbCOKuqdjTw physical.udp==NzguNDYuNjMuMjA6MTI4Ng End - identity=2vh9tO8Z8B9djfsEDf0~5J~sw9paO0T1gNy2eaG7BF4 lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU location==MC4yMTI2NjU4MDQ0NjA0MDA5NQ @@ -72,7 +68,6 @@ auth.negTypes=10 ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9r4SocX5yq1icEMJn8c85JlJM0i6ifDbEypEdE3WMu6VoDxcCGyElZLpvhtMRzAzsin6kTHvtTi-A~uLGb6zAg physical.udp==a2F0aXNrYS5vcmc6NDk1MzI7ODAuNzUuMTAzLjg5OjQ5NTMy End - identity=skCoNetjkg0rBksZE-cvoZ9~IXhno6RW5SDtAO8TNXs lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY location==MC4zMjc3NTc2NTUzNTY1NTg5 @@ -90,7 +85,6 @@ dsaPubKey.y=HHGmoASQb6hDv~CCQX38DFyWQvoihXmdcCT8dUFwRdVXEdBBplxZTC7JLIh9Ct34aEPT ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAI5mk35~trhSVzDEJ8~ylQHuxvZTTcq7Df0eD7VaMeMtSLcjkbXR~xiNF~l~RMbyo9Qe6qToH2zDZiqLy6LoWQ physical.udp==Zm5ldC5tb29vLmNvbToxNDQxNjs5NS4yNS4xMjUuMjMxOjE0NDE2OzEwMC44MC4yMi4xMjQ6MTQ0MTY End - identity=FuS~37Rro5JRvwfLfJQlWSyE4dlNsXFohoNACS6c6dE lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY location==MC44MTcxODkxMzQ5NjAyNTY2 @@ -108,7 +102,6 @@ dsaPubKey.y=Uljye0KvEBtQ6xCaj6VhCEl-z4C6b7if0qSzvx6aqn0rxOeFVnbEKAZwHu~fLA8mpUwA ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnFZUXRtj6eaHBCZqhilMRsnLDqCTRIkPDm5zpfjNdL7oOVcq07QuVeyyJAf9v6vOrjlzxv2w194i3ger31-YLA physical.udp==MTQ5LjE1NC4xNTkuMTcyOjYxMDc4 End - identity=-X2GrYYfJsKd0nAEMN6Bm79w~nljbKbR-x09eF8Rj2o lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU location==MC4xNTY0OTk4NTYyODUzNTMxMg @@ -121,7 +114,6 @@ auth.negTypes=10 ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9AhL1-WGRb0O8HYFxj0VeyYiGgCSHmTcO-fJ4ep6-1CnWlPv7Gxju~tVqNHNkTLQMlwCGYbFj2~lIXoIA5~zPQ physical.udp==MTM4LjE5Ny4xNzMuNjg6Mjc0NTk End - identity=9KMO9Hrd7Jc4r8DCKCu2ZqlAZjAWCB5mhLi~A5n7wSM lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU location==MC40NDgyODA1MDg0MDQ4ODIx @@ -134,20 +126,6 @@ auth.negTypes=10 ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE3oQ0lNMwEdKWApYyeNkDBfgzOXi5-eFUpoG7BomRHYGaWFSdWB4nTCZXrFUb1yJ4rl-d6yW98NynaMXGIDlCfg physical.udp==MTk4LjUwLjIyMy4yMCwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMDo1OTc0NzsxOTguNTAuMjIzLjIwOjU5NzQ3 End - -identity=y885-nLCItbw5qD7Qq5xHKjwTm9RU6wrXM5t3BmCnUY -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC42MzI1NTYxNDE0MDg0NjQ3 -opennet=true -sigP256=MEUCIQDHqiAbDzX-uUFSoYP02k2WiCvvUdP1YmGv9d27hEEwkAIgBJ0Jigcj2dQHTPqdBKpK0XKfN0YqsM3WjMDRik6TlZs -version==RnJlZCwwLjcsMS4wLDE0OTI -ark.number=27 -ark.pubURI=SSK@AR2Fo2FDtZz~uYQzwopDgpCiHeCpzKXysohBhGnP9uQ,tJBUBJxaSGwx4DkYfTNiU5~9voibnV1jjgTHE2hHTOU,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEiKkpl1ukJO2eBn7O3QbY4RL7Iqy26Sa75xHnI2dlDuEkZMgBn2zPn0li16j6J-0hN8cxrfw9P~VARBSXPoNuOg -physical.udp==MTk4LjUwLjIyMy4yMSwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMTo2MzYxMDsxOTguNTAuMjIzLjIxOjYzNjEw -End - identity=y885-nLCItbw5qD7Qq5xHKjwTm9RU6wrXM5t3BmCnUY lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU location==MC42MzI1NTYxNDE0MDg0NjQ3 From ec7e8d73016a9c3216de2729c124d0818e2c1b1d Mon Sep 17 00:00:00 2001 From: DC* Date: Sun, 29 May 2022 20:05:26 +0100 Subject: [PATCH 009/500] Remove seednodes.fref --- debian/seednodes.fref | 140 ------------------------------------------ 1 file changed, 140 deletions(-) delete mode 100644 debian/seednodes.fref diff --git a/debian/seednodes.fref b/debian/seednodes.fref deleted file mode 100644 index db15c3cfd78..00000000000 --- a/debian/seednodes.fref +++ /dev/null @@ -1,140 +0,0 @@ -identity=t0uY~zsjQMfuD2IKtJhKZv5AfgAUdyyCgdp7fzFFXvE -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC43MTYzNjgwNDQ4NjAyOTQy -opennet=true -sigP256=MEYCIQCcJWZEwT7YNAwIY08ZEFbMGgb2hFZF2Uhrjuyu7H-6PgIhAPvakaT-AFIb-hhTOjo3TELhJ3FQaS5VaubXYDbCTCdu -version==RnJlZCwwLjcsMS4wLDE0Nzk -ark.number=91 -ark.pubURI=SSK@62CCpYejO1jeoLy7b~01Zu2iRQPJfa8NuJ4Zgz6WSV4,mveCh0IkiER8KeHV5S8i2ooBAOB1WYGEKk3M3SktUYU,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnwm~Hm2yGWRCfhmX2tJu3M-2cmaKIfsS9oXJTmdZ6kRq3tU~bBwFQY4Fabb44q~vXyIq9O4vNysvtGGV5qHXpA -physical.udp==ZnJlZW5ldC5udWxsdm9pZC5tZTo2MTQ1NTsyNjA3OjUzMDA6MjAxOjMwMDA6MDowOjA6MTdkMzo2MTQ1NTsxNDkuNTYuNDUuMjAwOjYxNDU1 -End -identity=AMJNW1zpC2TSVeyRI~rLq8Yb~9py2NSNefblrlECx2M -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC4zMTIzNTIxNzYwMjI4MDg3NA -opennet=true -sigP256=MEYCIQDqDwNkkVNtEqRWKlLFyXnfDnZpR4KJUgUH74xiMVqYxAIhAKFlnEygH0T5reHpIDGGTUyk~BnZaBZGFeF4YMo9WXsc -version==RnJlZCwwLjcsMS4wLDE0NzU -ark.number=1871 -ark.pubURI=SSK@OYfh3dlhh4CER4IjZPq6e06ug8ipehlYdS4pSnE00Tw,i3axPVzOkl7Iy568wzqTXAESYjTiKltripHlK4hqTJk,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEmaH8K8bKR8Hvvhxjr-TPUe4R4yItj-Dcr5vfmwg1j0wu4mWD10Z5S9rN2ZUYNFYoiwwFd8LdAGSRDtQFoHE~3g -physical.udp==ZDYuZ251dGVsbGEyLmluZm86MzI2ODU7ODUuMjEyLjMuMTMwOjMyNjg1Ozg1LjIxMi4yNi4yNDI6MzI2ODU7ODUuMjEyLjI2LjI0Mjo2MTk3OA -End -identity=7EoZpRvanX5WdT1aWg82SZjf0wVQd-Xmg8KAPT-sXDE -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY -location==MC4wMDE5NTUyMDQwNDc0MTQzMzg0 -opennet=true -sig=008cc800f6eb9980d158335a65fa329607d5a4e9dae11cb5ce2cefeb687822ca6a,0090d4e3ce64ee8bd25d07b76dd1eb30b873d2fca6299100fa2a5776783559d85e -sigP256=MEUCIQD2MgvLdSf8PKpoMswU8spq~QEM-zvRBOlPs2hsRKzjaAIgDE1orFTZvENtgoCpqRa4M~iybl4tf99PB3QbExJviMM -version==RnJlZCwwLjcsMS4wLDE0Njc -ark.number=225 -ark.pubURI=SSK@UeoCoRROTtuyuZqABq2-Sm1gZWfivCANAaCV9VzAdt8,wdbeYeRBh4uz2aexTbjUJ0VpYlZNMihn9lTM1w~qdEc,AQACAAE/ark -auth.negTypes==OTsxMA -dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg -dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk -dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 -dsaPubKey.y=Q-RXw568J3~j6i5W4Nr2oIm~Vejx8dClz7ULBJGH2RWdmlUVWE~8Jg4FJeTwYItawFDAx0DadKsT-MsVKVINyPQ4i8u9MDybkp~ELiRNdqa3px09QkPH28kLSKenhj7uRpGuiHHxh0Pw~sD4mLbBT1J7XV57rQ7he3wmcNHf0Jdg-WnKnju7ref8BjDs28HeV59bfub1qGNvJxPrjHUT4O73Z2TUepqsJsvEAas1E-~sb9W64OVksPcKJ8oN45ptFHxsQ8o6mwexSUHHiwAX-viu5gXpCw5NzvyGtAAtJDLfebEN3X9BPHzkl2wX4U94Rd4xmuxHU2jxl~hPMujJpg -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE~Eo5a~5zfJhSnkNx2VpJnEFWpjwjmgO7-Tt-4rgDJ1LwxAKKKxwbSlJDUTkd0RMGDQCGxOedvYrOclYuF3-FjQ -physical.udp==ZnJlZW5ldC5uZXJkeWJsb2tlLm5ldDozNDE1OzI1LjE1NC4xNjguMTY0OjM0MTU7MjEyLjE1OS4xNzcuMTk4OjM0MTU -End -identity=6W8b11Iy5jjW2WmLN-wQIPcwnzHLdsrKDTbpO2nbQoA -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY -location==MC40NTY1NDI5OTIzMTY0OTE4Nw -opennet=true -sig=3b83f7a1a0a7f880d06a4870737d6d2e33155ff41672110c1ae4cdfd9757a3d2,4cb9f21fba50a9b68b3f5b8985f0ce961ed98575dab4b1dc30dd317ac57c32f9 -sigP256=MEUCIA9j0gwf5qQdXO-cgXN8RX9JmGZuShkRilHpdrY4oBCcAiEAwEQi48X-g9vJXJ9E0SDJpCkj~YOIIcLfVNpcpyXXKOE -version==RnJlZCwwLjcsMS4wLDE0NjY -ark.number=257 -ark.pubURI=SSK@ZiyMbzGNd09DCasOpcV7nSdsd99EyCS6ETU1hHmbH0k,i7Qi1zl-MpkiWg7MtouORGZsXaGx0wkDswG-DAmU3s8,AQACAAE/ark -auth.negTypes==OTsxMA -dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg -dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk -dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 -dsaPubKey.y=fAkSEP5sc4QwSD9OhES1jxJ8PqnUIMaCCJ6Rdl8uHtYKv2jDTlBrhnxs7Waxpowtxjeuk~GMkq-AoJkHbtfqMfe1otpTRO6l0zDGpkkw1MCxSGGcHPAb2WD1XVicixuIS~qdyRCDl~odaT2yQVASUC9nQEsurON7~ZhIsVMC18nV05f0BL4Z4clI-9w2FWaVbJVCjbnUJAEvErD4~yFvJ9z1EYFEjSDycKFQn9Lyj8czjv7UaInsRgJYm-5S-xoCjytVJ328Co8C71PvyhXElDyt03odA2MWfQEsi2NDBY90kY1zKV7u6366~e~AxZ0uuu5M8NG0wKHbaOND2xOMKA -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEak4~fhdD5gTCnOkmyfJNt95yYtY3NkoRB-x6aMydjZT4D~Ppjh5o~NX7NEyI9ShiPj6S5HAoDnYlbCOKuqdjTw -physical.udp==NzguNDYuNjMuMjA6MTI4Ng -End -identity=2vh9tO8Z8B9djfsEDf0~5J~sw9paO0T1gNy2eaG7BF4 -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC4yMTI2NjU4MDQ0NjA0MDA5NQ -opennet=true -sigP256=MEUCIQDxOq56sYIA0VSEOA08rummiL54NY7mIbm~NVPZNH1zOwIgfVOjKTL3FNTTxsupj4JenUvMtPgGbYoj18t9Fu7pbrU -version==RnJlZCwwLjcsMS4wLDE0ODQ -ark.number=583 -ark.pubURI=SSK@ouMmz8KcGUbci~qdLTJDFSg~RkaV0vFHxDCJsLuzWMI,0vy-y7yDa5vRtmA475LIX-5KqDPmy9xattXBc1QgSrk,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9r4SocX5yq1icEMJn8c85JlJM0i6ifDbEypEdE3WMu6VoDxcCGyElZLpvhtMRzAzsin6kTHvtTi-A~uLGb6zAg -physical.udp==a2F0aXNrYS5vcmc6NDk1MzI7ODAuNzUuMTAzLjg5OjQ5NTMy -End -identity=skCoNetjkg0rBksZE-cvoZ9~IXhno6RW5SDtAO8TNXs -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY -location==MC4zMjc3NTc2NTUzNTY1NTg5 -opennet=true -sig=582ffa8f1b3cfa1297c1a63f24fb808ac716b372f787c298785bdecebe17b4b4,00834cd587d3bb2d7557f323fe73b8bc05af1f91371370dce3359e2feef07c9c81 -sigP256=MEUCIQC4a0rVLctowjUMTmspQvghbptUotsELLfmJzu69CaHGQIgbqtH0X46DOqdod99BTIYqEgY4nVvTVP1-LbF3LNXJuA -version==RnJlZCwwLjcsMS4wLDE0Njc -ark.number=2409 -ark.pubURI=SSK@tDjqJMxBPaRzOTQE~r3LAkL~jgxql637l1MY59wyxrw,CeTvd0XTtazWIA73Itk~h4QmmxHYhFFNQk3sBmjgLns,AQACAAE/ark -auth.negTypes==OTsxMA -dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg -dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk -dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 -dsaPubKey.y=HHGmoASQb6hDv~CCQX38DFyWQvoihXmdcCT8dUFwRdVXEdBBplxZTC7JLIh9Ct34aEPThCE5VHz~Y~nEkO7GcP1wFFbnIqSwdP8hbRtuGoFauWWpPIsUofo-WYay8J1TF-~Mmb3lKuyp4HbkGaFdFiQzOK~~78wsPnuVYpfPXXa2w~c6Q2hrKENbdq~jU0Ili4t1CiGkZ6-aQaw5B6PIZWe10By~AcvLT1vCYBhB0W~FXHFDPgJ9hN8yga-NxPzkTMX58pwxu6UcRSZ2Hl3lSvfhAsNYGS-VPrA7ejKKyIjxnI7vJi7FO6Ac2a2p1nzxaxecTVxsJvCUSne4W-yc3g -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAI5mk35~trhSVzDEJ8~ylQHuxvZTTcq7Df0eD7VaMeMtSLcjkbXR~xiNF~l~RMbyo9Qe6qToH2zDZiqLy6LoWQ -physical.udp==Zm5ldC5tb29vLmNvbToxNDQxNjs5NS4yNS4xMjUuMjMxOjE0NDE2OzEwMC44MC4yMi4xMjQ6MTQ0MTY -End -identity=FuS~37Rro5JRvwfLfJQlWSyE4dlNsXFohoNACS6c6dE -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NjY -location==MC44MTcxODkxMzQ5NjAyNTY2 -opennet=true -sig=0d0404194092fa17b06e8198236c116c28d87c75dbc7934e61912d67247258b5,0086fe4c23980aa702d5395eca70250e95e3173c620f056493c489687a9579e041 -sigP256=MEYCIQD7mKSoQAfFcmfCCTYGa-ikXA6P8jL4RC4XD-usHbgFSQIhAJIprPAJvPemykB5vLVZHVUMrVniZ7dBgR2R5qzBWjDW -version==RnJlZCwwLjcsMS4wLDE0Njc -ark.number=1063 -ark.pubURI=SSK@cmYYw-EA8wiQabmQzezvmETmuawJj2FNfjpboI9QUaI,2PI1w1PlKkIo5ujBxTZWVEhfUqAO~4ZqIujjbIZ300A,AQACAAE/ark -auth.negTypes==OTsxMA -dsaGroup.g=UaRatnDByf0QvTlaaAXTMzn1Z15LDTXe-J~gOqXCv0zpz83CVngSkb--bVRuZ9R65OFg~ATKcuw8VJJwn1~A9p5jRt2NPj2EM7bu72O85-mFdBhcav8WHJtTbXb4cxNzZaQkbPQUv~gEnuEeMTc80KZVjilQ7wlTIM6GIY~ZJVHMKSIkEU87YBRtIt1R~BJcnaDAKBJv~oXv1PS-6iwQRFMynMEmipfpqDXBTkqaQ8ahiGWA41rY8d4jDhrzIgjvkzfxkkcCpFFOldwW8w8MEecUoRLuhKnY1sm8nnTjNlYLtc1Okeq-ba0mvwygSAf4wxovwY6n1Fuqt8yZe1PDVg -dsaGroup.p=AIYIrE9VNhM38qPjirGGT-PJjWZBHY0q-JxSYyDFQfZQeOhrx4SUpdc~SppnWD~UHymT7WyX28eV3YjwkVyc~--H5Tc83hPjx8qQc7kQbrMb~CJy7QBX~YSocKGfioO-pwfRZEDDguYtOJBHPqeenVDErGsfHTCxDDKgL2hYM8Ynj8Kes0OcUzOIVhShFSGbOAjJKjeg82XNXmG1hhdh2tnv8M4jJQ9ViEj425Mrh6O9jXovfPmcdYIr3C~3waHXjQvPgUiK4N5Saf~FOri48fK-PmwFZFc-YSgI9o2-70nVybSnBXlM96QkzU6x4CYFUuZ7-B~je0ofeLdX7xhehuk -dsaGroup.q=ALFDNoq81R9Y1kQNVBc5kzmk0VvvCWosXY5t9E9S1tN5 -dsaPubKey.y=Uljye0KvEBtQ6xCaj6VhCEl-z4C6b7if0qSzvx6aqn0rxOeFVnbEKAZwHu~fLA8mpUwAhFLw9vfrE6U0ni5GFwzRnppP2kAg4XHgOgK8EVr-yK1pZ5UkmXsD5MmFNTSsPeapi1QqfVgO0Meq16jpFZsVyENtFZieB7CRlHmns9rkwp1iMuI1OiMktjkf2coTBAifkAQs0QHntOUmOl5fYSCF4pdyE1ZLJt6NFBqe7eJ5ng-f5FUIcXUDdI-aBWYj3viOqa0fJKN637IQh5PoF-A-ZWsEWzG2GGlo6hWf-wgTjTCAqr1MfmpQOTFaJZo1pkQGIsArcBFC1eysO4OwrQ -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnFZUXRtj6eaHBCZqhilMRsnLDqCTRIkPDm5zpfjNdL7oOVcq07QuVeyyJAf9v6vOrjlzxv2w194i3ger31-YLA -physical.udp==MTQ5LjE1NC4xNTkuMTcyOjYxMDc4 -End -identity=-X2GrYYfJsKd0nAEMN6Bm79w~nljbKbR-x09eF8Rj2o -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC4xNTY0OTk4NTYyODUzNTMxMg -opennet=true -sigP256=MEUCIQCERzO3ox7n0LrZzCIVvly9tGURjAstcQzApuwGxP-PwgIgLZUJajhqVKydkcFmY9H3gjlULUyy8m8acd2AY-iYcHk -version==RnJlZCwwLjcsMS4wLDE0ODU -ark.number=157 -ark.pubURI=SSK@f4zWd-e3t8Hc2wvkhGJdull2Iv1qCojENF3lN0Wt9L8,utyaE3HYWhIz-SZS745ONrDMt2yRo8BpEGoh-NGCjoY,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE9AhL1-WGRb0O8HYFxj0VeyYiGgCSHmTcO-fJ4ep6-1CnWlPv7Gxju~tVqNHNkTLQMlwCGYbFj2~lIXoIA5~zPQ -physical.udp==MTM4LjE5Ny4xNzMuNjg6Mjc0NTk -End -identity=9KMO9Hrd7Jc4r8DCKCu2ZqlAZjAWCB5mhLi~A5n7wSM -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC40NDgyODA1MDg0MDQ4ODIx -opennet=true -sigP256=MEYCIQC1ESpmXToMiX3jC8irHuGU3DDm0YjqTadCkYYo0NrZDQIhAJDdSjlrXMSdhLZbnFdT0ZaQ2EIzUM0cVzT2IeFIhOy7 -version==RnJlZCwwLjcsMS4wLDE0OTI -ark.number=29 -ark.pubURI=SSK@BeeoOzd-7PE~YFHiaVKLsYZoVT9BcbK-1Wcnkv4YlO8,3B~RxAwHwtORzVEOU71kiKlt1ci590T-EhycWoivTmA,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE3oQ0lNMwEdKWApYyeNkDBfgzOXi5-eFUpoG7BomRHYGaWFSdWB4nTCZXrFUb1yJ4rl-d6yW98NynaMXGIDlCfg -physical.udp==MTk4LjUwLjIyMy4yMCwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMDo1OTc0NzsxOTguNTAuMjIzLjIwOjU5NzQ3 -End -identity=y885-nLCItbw5qD7Qq5xHKjwTm9RU6wrXM5t3BmCnUY -lastGoodVersion==RnJlZCwwLjcsMS4wLDE0NzU -location==MC42MzI1NTYxNDE0MDg0NjQ3 -opennet=true -sigP256=MEUCIQDHqiAbDzX-uUFSoYP02k2WiCvvUdP1YmGv9d27hEEwkAIgBJ0Jigcj2dQHTPqdBKpK0XKfN0YqsM3WjMDRik6TlZs -version==RnJlZCwwLjcsMS4wLDE0OTI -ark.number=27 -ark.pubURI=SSK@AR2Fo2FDtZz~uYQzwopDgpCiHeCpzKXysohBhGnP9uQ,tJBUBJxaSGwx4DkYfTNiU5~9voibnV1jjgTHE2hHTOU,AQACAAE/ark -auth.negTypes=10 -ecdsa.P256.pub=MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEiKkpl1ukJO2eBn7O3QbY4RL7Iqy26Sa75xHnI2dlDuEkZMgBn2zPn0li16j6J-0hN8cxrfw9P~VARBSXPoNuOg -physical.udp==MTk4LjUwLjIyMy4yMSwyNjA3OjUzMDA6MjAzOjdhYzU6MTk4OjUwOjIyMzoyMTo2MzYxMDsxOTguNTAuMjIzLjIxOjYzNjEw -End From 989cdfb8cbc18b1debdf5a15a4c4ec13d14cf875 Mon Sep 17 00:00:00 2001 From: DC* Date: Sun, 29 May 2022 20:07:48 +0100 Subject: [PATCH 010/500] Update clean target --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index aff28ceb9e2..2c24b505980 100755 --- a/debian/rules +++ b/debian/rules @@ -24,6 +24,7 @@ build_seed_file: $(REFS_DIR) clean: rm -rf $(REFS_DIR) + rm seednodes.fref override_dh_auto_build: build_seed_file export GRADLE_USER_HOME="`pwd`/gradle"; \ From 61e41a4f817619ae73abef6837e2a6a9832e1a5d Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 18 Jun 2022 19:18:28 +0100 Subject: [PATCH 011/500] Lintian warning and error fix ups --- debian/control | 2 +- debian/freenet.preinst | 6 +++--- debian/rules | 9 ++++++++- debian/source/format | 2 +- debian/source/include-binaries | 4 ++++ debian/source/lintian-overrides | 1 + 6 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 debian/source/include-binaries diff --git a/debian/control b/debian/control index de77af98ccd..7a2746a16bc 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Homepage: http://freenetproject.org/ Package: freenet Architecture: any -Depends: adduser, default-jre-headless, libservice-wrapper-java, service-wrapper +Depends: adduser, default-jre-headless, libservice-wrapper-java, service-wrapper, ${shlibs:Depends}, ${misc:Depends}, ${java:Depends} Replaces: fred Conflicts: fred diff --git a/debian/freenet.preinst b/debian/freenet.preinst index b574618c5fb..a1a8cd132f6 100644 --- a/debian/freenet.preinst +++ b/debian/freenet.preinst @@ -65,11 +65,11 @@ case "$1" in # 5. adjust file and directory permissions if ! dpkg-statoverride --list $SERVER_HOME >/dev/null then - chown -f -R $SERVER_USER:$SERVER_GROUP $SERVER_HOME + chown -f $SERVER_USER:$SERVER_GROUP $SERVER_HOME chmod -f u=rwx,g=rxs,o= $SERVER_HOME - chown -f -R $SERVER_USER:$SERVER_GROUP $SERVER_LOG + chown -f $SERVER_USER:$SERVER_GROUP $SERVER_LOG chmod -f u=rwx,g=rxs,o= $SERVER_LOG - chown -f -R $SERVER_USER:$SERVER_GROUP $SERVER_ETC + chown -f $SERVER_USER:$SERVER_GROUP $SERVER_ETC chmod -f u=rwx,g=rxs,o= $SERVER_ETC fi diff --git a/debian/rules b/debian/rules index 2c24b505980..ce71ef3df2a 100755 --- a/debian/rules +++ b/debian/rules @@ -24,7 +24,14 @@ build_seed_file: $(REFS_DIR) clean: rm -rf $(REFS_DIR) - rm seednodes.fref + rm -rf debian/freenet + rm -rf build + rm -rf .gradle + rm -f seednodes.fref + rm -rf gradle/caches + rm -rf gradle/notifications + rm -rf gradle/native + rm -rf gradle/wrapper/dists override_dh_auto_build: build_seed_file export GRADLE_USER_HOME="`pwd`/gradle"; \ diff --git a/debian/source/format b/debian/source/format index 89ae9db8f88..163aaf8d82b 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -3.0 (native) +3.0 (quilt) diff --git a/debian/source/include-binaries b/debian/source/include-binaries new file mode 100644 index 00000000000..80c91bfa8e1 --- /dev/null +++ b/debian/source/include-binaries @@ -0,0 +1,4 @@ +debian/freenet/usr/share/doc/freenet/changelog.Debian.gz +debian/freenet/usr/share/java/freenet.jar +debian/freenet/usr/share/java/freenet-0.7.5+1493.jar +gradle/** diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index e69de29bb2d..9331edea763 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -0,0 +1 @@ +freenet source: source-is-missing src/freenet/clients/http/staticfiles/freenetjs/* From 5fd59ab145ae104c2aef6f7bcc5abc081d583453 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 02:42:50 +0100 Subject: [PATCH 012/500] Add missing dependencies for debian bookworm --- .gitignore | 1 + debian/control | 2 +- debian/rules | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 69d371b20fb..fd13d826f15 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ debhelper-build-stamp /debian/freenet/* .gradle gradle +debian/seednodes.fref diff --git a/debian/control b/debian/control index 7a2746a16bc..fe63ef7f5fb 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Homepage: http://freenetproject.org/ Package: freenet Architecture: any -Depends: adduser, default-jre-headless, libservice-wrapper-java, service-wrapper, +Depends: adduser, procps, gettext, default-jre-headless, libservice-wrapper-java, service-wrapper, ${shlibs:Depends}, ${misc:Depends}, ${java:Depends} Replaces: fred Conflicts: fred diff --git a/debian/rules b/debian/rules index ce71ef3df2a..9c7fd718793 100755 --- a/debian/rules +++ b/debian/rules @@ -9,7 +9,7 @@ WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh REFS := https://github.com/freenet/seedrefs/archive/refs/heads/master.zip REFS_NAME := seedrefs-master -REFS_DIR := /tmp/seeds/ +REFS_DIR := /tmp/seeds %: dh $@ --with javahelper @@ -20,14 +20,14 @@ $(REFS_DIR): unzip $(REFS_DIR)/$(REFS_NAME).zip -d $(REFS_DIR) build_seed_file: $(REFS_DIR) - cat $(REFS_DIR)/$(REFS_NAME)/* > seednodes.fref + cat $(REFS_DIR)/$(REFS_NAME)/* > debian/seednodes.fref clean: rm -rf $(REFS_DIR) rm -rf debian/freenet rm -rf build rm -rf .gradle - rm -f seednodes.fref + rm -f debian/seednodes.fref rm -rf gradle/caches rm -rf gradle/notifications rm -rf gradle/native From 8ca925f43b45328ddf79a8e4a8e545bb8e1e97c0 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 02:43:54 +0100 Subject: [PATCH 013/500] Add github action --- .github/workflows/package.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/package.yml diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 00000000000..90f6e435bb4 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,18 @@ +name: Build debian package +on: + push: + branches: [ '**' ] + pull_request: + branches: [ '**' ] + +jobs: + build-deb: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: singingwolfboy/build-dpkg-buster@v1 + id: build + with: + args: --unsigned-source --unsigned-changes + From 61cf8252ddb57c9a96d4ce3f38e559997b424e5a Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 03:02:22 +0100 Subject: [PATCH 014/500] Build binary package only, add build dependencies --- .github/workflows/package.yml | 3 +-- debian/control | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 90f6e435bb4..4efc21a9233 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -14,5 +14,4 @@ jobs: - uses: singingwolfboy/build-dpkg-buster@v1 id: build with: - args: --unsigned-source --unsigned-changes - + args: --unsigned-source --unsigned-changes -b diff --git a/debian/control b/debian/control index fe63ef7f5fb..059b3738052 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: net Priority: optional Maintainer: Dario Cavuotti Build-Depends: debhelper (>= 9), javahelper, quilt, adduser (>= 3.11), - git-core, default-jdk + git-core, default-jdk, wget, service-wrapper Standards-Version: 4.5.1 Homepage: http://freenetproject.org/ From 20631e61baf4f2fe387006d0da4ec14d921ad3ab Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:23:38 +0100 Subject: [PATCH 015/500] Use gbp build package --- .github/workflows/package.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 4efc21a9233..bc7205d5724 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -10,8 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - - uses: singingwolfboy/build-dpkg-buster@v1 - id: build - with: - args: --unsigned-source --unsigned-changes -b + - run: | + sudo apt install -y git-buildpackage + gbp buildpackage --git-upstream-tag=debian-pkg -us -uc + dpkg -I ../freenet*.deb From 8c24ac818e2930952a7622484009084c1e195a99 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:24:20 +0100 Subject: [PATCH 016/500] apt update --- .github/workflows/package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index bc7205d5724..00581118d2e 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -11,6 +11,7 @@ jobs: steps: - uses: actions/checkout@v2 - run: | + sudo apt update sudo apt install -y git-buildpackage gbp buildpackage --git-upstream-tag=debian-pkg -us -uc dpkg -I ../freenet*.deb From acdfbb5ac9c6022876468df6863cd81ab23d11f5 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:38:09 +0100 Subject: [PATCH 017/500] Custom action and install deps --- .github/workflows/package.yml | 6 +++--- debian/control | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 00581118d2e..549bcef15fa 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v2 - run: | - sudo apt update - sudo apt install -y git-buildpackage - gbp buildpackage --git-upstream-tag=debian-pkg -us -uc + install_tool="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes" + mk-build-deps --install --tool="${install_tool}" debian/control + gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc dpkg -I ../freenet*.deb diff --git a/debian/control b/debian/control index 059b3738052..a05cd8a7972 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: net Priority: optional Maintainer: Dario Cavuotti Build-Depends: debhelper (>= 9), javahelper, quilt, adduser (>= 3.11), - git-core, default-jdk, wget, service-wrapper + git-core, default-jdk, wget, service-wrapper, git-buildpackage Standards-Version: 4.5.1 Homepage: http://freenetproject.org/ From 7667ec86026255352661cb3df1cd84ea6d262eec Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:42:35 +0100 Subject: [PATCH 018/500] Install build script dependencies --- .github/workflows/package.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 549bcef15fa..fb92cae29fa 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -9,9 +9,24 @@ jobs: build-deb: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - run: | + - name: Checkout + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + apt update + apt install build-essential debhelper devscripts -y + + - name: Install package build dependencies + run: | install_tool="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes" mk-build-deps --install --tool="${install_tool}" debian/control + + - name: Build package + run: | gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc + + - name: Get package info + run: | dpkg -I ../freenet*.deb + From a444886ba81d6319bebcc141aa811aee5173d105 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:43:45 +0100 Subject: [PATCH 019/500] Missing sudo for apt-get on GH actions --- .github/workflows/package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index fb92cae29fa..4377780c52c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -14,8 +14,8 @@ jobs: - name: Install dependencies run: | - apt update - apt install build-essential debhelper devscripts -y + sudo apt update + sudo apt install build-essential debhelper devscripts -y - name: Install package build dependencies run: | From e8024452fef36d095da3e9a27d8e025b0ad3bab6 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:45:33 +0100 Subject: [PATCH 020/500] Missing equivs dependency --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 4377780c52c..dd75f2b5c73 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -15,7 +15,7 @@ jobs: - name: Install dependencies run: | sudo apt update - sudo apt install build-essential debhelper devscripts -y + sudo apt install build-essential debhelper devscripts equivs -y - name: Install package build dependencies run: | From 379a4b640e52e650c6323ab828b852bd8b652a7c Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 05:50:00 +0100 Subject: [PATCH 021/500] Missing privileges in GH actions --- .github/workflows/package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index dd75f2b5c73..aff19f178b3 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -20,11 +20,11 @@ jobs: - name: Install package build dependencies run: | install_tool="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes" - mk-build-deps --install --tool="${install_tool}" debian/control + sudo mk-build-deps --install --tool="${install_tool}" debian/control - name: Build package run: | - gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc - name: Get package info run: | From 46fb0cc69ee21ec4d3ddb6b437df8fd16fdd9a34 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 06:06:48 +0100 Subject: [PATCH 022/500] Remove freenet deps .deb package --- .github/workflows/package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index aff19f178b3..41a774b9f59 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -20,7 +20,7 @@ jobs: - name: Install package build dependencies run: | install_tool="apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends --yes" - sudo mk-build-deps --install --tool="${install_tool}" debian/control + sudo mk-build-deps --install -r --tool="${install_tool}" debian/control - name: Build package run: | @@ -29,4 +29,5 @@ jobs: - name: Get package info run: | dpkg -I ../freenet*.deb + file ../freenet*.deb From e967e67089ffda4d264b635fd286796038731356 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 16:28:46 +0100 Subject: [PATCH 023/500] Cache steps and gradle configuration --- .github/workflows/package.yml | 27 ++++++++++++++++++++++++++- debian/rules | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 41a774b9f59..7c5e95262e2 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -7,11 +7,36 @@ on: jobs: build-deb: + strategy: + matrix: + os: [ ubuntu-latest ] + distribution: [temurin] + java: [8, 11] + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 + - name: Wrapper validation + uses: gradle/wrapper-validation-action@v1 + + - name: Setup java + uses: actions/setup-java@v3 + with: + cache: 'gradle' + distribution: '${{ matrix.distribution }}' + java-version: '${{ matrix.java }}' + + - name: Configure gradle.properties + run: | + echo "" > gradle.properties # Force empty gradle.properties file + echo "org.gradle.configureondemand=true" >> gradle.properties + echo "org.gradle.jvmargs=-Xms256m -Xmx1024m" >> gradle.properties + echo "org.gradle.parallel = true" >> gradle.properties + echo "tasks.withType(Test) { maxParallelForks = Runtime.runtime.availableProcessors() }" >> gradle.properties + cat gradle.properties + - name: Install dependencies run: | sudo apt update @@ -24,7 +49,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc --git-ignore-new - name: Get package info run: | diff --git a/debian/rules b/debian/rules index 9c7fd718793..1468b05cf12 100755 --- a/debian/rules +++ b/debian/rules @@ -36,7 +36,7 @@ clean: override_dh_auto_build: build_seed_file export GRADLE_USER_HOME="`pwd`/gradle"; \ export GRADLE_OPTS="-Dorg.gradle.daemon=false -Xmx512m"; \ - ./gradlew assemble; \ + ./gradlew jar; \ ./gradlew copyRuntimeLibs sed -e 's/@version@/$(FREENET_VERSION)/' -e 's/@build@/$(FREENET_BUILD)/' $(CURDIR)/debian/freenet.service.params | \ From a6c426df10213819cbeeb0e45c259c71061390a9 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 16:34:16 +0100 Subject: [PATCH 024/500] Remove gradle.properties generation --- .github/workflows/package.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 7c5e95262e2..c18c0f46232 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -28,15 +28,6 @@ jobs: distribution: '${{ matrix.distribution }}' java-version: '${{ matrix.java }}' - - name: Configure gradle.properties - run: | - echo "" > gradle.properties # Force empty gradle.properties file - echo "org.gradle.configureondemand=true" >> gradle.properties - echo "org.gradle.jvmargs=-Xms256m -Xmx1024m" >> gradle.properties - echo "org.gradle.parallel = true" >> gradle.properties - echo "tasks.withType(Test) { maxParallelForks = Runtime.runtime.availableProcessors() }" >> gradle.properties - cat gradle.properties - - name: Install dependencies run: | sudo apt update From 4e037e3d22b60fadb199c5260dc3fe2016097fab Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 25 Jun 2022 16:44:01 +0100 Subject: [PATCH 025/500] Streamline clean up task --- build.gradle | 8 ++++---- debian/rules | 33 ++++++++++++++------------------- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index 644fe5f9897..5b901568ce1 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,6 @@ sourceSets { test.compileClasspath += configurations.provided } -def version_buildir = "$projectDir/build/tmp/compileVersion/" def version_src = 'freenet/node/Version.java' sourceSets { @@ -69,7 +68,7 @@ tasks.withType(Javadoc) { task compileVersion (type: JavaCompile) { copy { from sourceSets.main.java.srcDirs - into "${version_buildir}" + into "${buildDir}/build/tmp/compileVersion/" include "${version_src}" filter { String line -> line.replaceAll("@custom@","${gitrev}") @@ -77,11 +76,12 @@ task compileVersion (type: JavaCompile) { } sourceCompatibility = 1.8 targetCompatibility = 1.8 - source = "${version_buildir}" + source = "${buildDir}/build/tmp/compileVersion/" include "${version_src}" classpath = files(sourceSets.main.compileClasspath, sourceSets.main.output.classesDir) destinationDir = file("${buildDir}/java/version/") } + compileVersion.dependsOn buildInfo compileVersion.dependsOn compileJava processResources.dependsOn compileVersion @@ -94,7 +94,7 @@ task jar (type: Jar, overwrite: true) { exclude 'freenet/node/Version.class' exclude 'freenet/node/Version$1.class' } - preserveFileTimestamps = false + preserveFileTimestamps = true reproducibleFileOrder = true duplicatesStrategy = "warn" archivesBaseName = "freenet" diff --git a/debian/rules b/debian/rules index 1468b05cf12..9ebfd1a6e1e 100755 --- a/debian/rules +++ b/debian/rules @@ -7,9 +7,14 @@ FREENET_VERSION := 0.7.5 FREENET_BUILD := 1493 WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh +BUILD_DIR := /tmp/fred-build + REFS := https://github.com/freenet/seedrefs/archive/refs/heads/master.zip REFS_NAME := seedrefs-master -REFS_DIR := /tmp/seeds +REFS_DIR := $(BUILD_DIR)/seeds + +export GRADLE_OPTS := -Dorg.gradle.daemon=true -Xmx512m -Dorg.gradle.project.buildDir=$(BUILD_DIR) +export GRADLE_USER_HOME := $(BUILD_DIR)/gradle %: dh $@ --with javahelper @@ -23,19 +28,10 @@ build_seed_file: $(REFS_DIR) cat $(REFS_DIR)/$(REFS_NAME)/* > debian/seednodes.fref clean: - rm -rf $(REFS_DIR) - rm -rf debian/freenet - rm -rf build - rm -rf .gradle rm -f debian/seednodes.fref - rm -rf gradle/caches - rm -rf gradle/notifications - rm -rf gradle/native - rm -rf gradle/wrapper/dists + rm -rf .gradle gradle/wrapper/dists debian/freenet override_dh_auto_build: build_seed_file - export GRADLE_USER_HOME="`pwd`/gradle"; \ - export GRADLE_OPTS="-Dorg.gradle.daemon=false -Xmx512m"; \ ./gradlew jar; \ ./gradlew copyRuntimeLibs @@ -47,15 +43,14 @@ override_dh_builddeb: override_dh_auto_install: dh_auto_install - jh_installlibs $(CURDIR)/build/libs/freenet.jar + jh_installlibs $(BUILD_DIR)/libs/freenet.jar override_dh_auto_test: - export GRADLE_USER_HOME="`pwd`/gradle"; \ - export GRADLE_OPTS="-Dorg.gradle.daemon=false -Xmx512m"; \ - ./gradlew test + +override_jh_depends: override_jh_installlibs: - jh_installlibs $(CURDIR)/build/output/freenet-ext-29.jar - jh_installlibs $(CURDIR)/build/output/jna-4.5.2.jar - jh_installlibs $(CURDIR)/build/output/jna-platform-4.5.2.jar - jh_installlibs $(CURDIR)/build/output/bcprov-jdk15on-1.59.jar + jh_installlibs $(BUILD_DIR)/output/freenet-ext-29.jar + jh_installlibs $(BUILD_DIR)/output/jna-4.5.2.jar + jh_installlibs $(BUILD_DIR)/output/jna-platform-4.5.2.jar + jh_installlibs $(BUILD_DIR)/output/bcprov-jdk15on-1.59.jar From 75a1b51e7d71ac8f707434f1bc24f64e7ad46a28 Mon Sep 17 00:00:00 2001 From: DC* Date: Fri, 1 Jul 2022 23:25:36 +0100 Subject: [PATCH 026/500] Update changelog --- debian/changelog | 8 +++++++- debian/files | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 099637b7abf..aedc8a6b125 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,11 @@ +freenet (0.7.5+1494-1) unstable; urgency=medium + + * Build 1494 + + -- DC* Sat, 02 Jul 2022 00:00:49 +0100 + freenet (0.7.5+1493-1) unstable; urgency=medium * Initial Release. - -- Dario Cavuotti Wed, 18 May 2022 00:00:00 +0100 + -- DC* Fri, 01 Jul 2022 23:25:13 +0100 diff --git a/debian/files b/debian/files index 2b12e82cb44..2cbc4d89990 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,2 @@ -freenet_0.7.5+1493-1_amd64.buildinfo net optional -freenet_0.7.5+1493-1_amd64.deb net optional +freenet_0.7.5+1494-1_amd64.buildinfo net optional +freenet_0.7.5+1494-1_amd64.deb net optional From ad98241395c531561ff05ae9e1a4f23e36bf1055 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 2 Jul 2022 00:18:02 +0100 Subject: [PATCH 027/500] Update maintainer name --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index a05cd8a7972..b644ffd9e6f 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ Source: freenet Section: net Priority: optional -Maintainer: Dario Cavuotti +Maintainer: DC* Build-Depends: debhelper (>= 9), javahelper, quilt, adduser (>= 3.11), git-core, default-jdk, wget, service-wrapper, git-buildpackage Standards-Version: 4.5.1 From 75b9d505aae600bb16ad075e7d8826029fe13d20 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 2 Jul 2022 00:21:36 +0100 Subject: [PATCH 028/500] Update maintainer name --- debian/changelog | 6 ++++++ debian/files | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index aedc8a6b125..d3b30f766a9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +freenet (0.7.5+1494-2) unstable; urgency=medium + + * Update maintainer + + -- DC* Sat, 02 Jul 2022 00:19:27 +0100 + freenet (0.7.5+1494-1) unstable; urgency=medium * Build 1494 diff --git a/debian/files b/debian/files index 2cbc4d89990..e35119fecf1 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,3 @@ freenet_0.7.5+1494-1_amd64.buildinfo net optional -freenet_0.7.5+1494-1_amd64.deb net optional +freenet_0.7.5+1494-2_amd64.buildinfo net optional +freenet_0.7.5+1494-2_amd64.deb net optional From 4b79a0d9364e1542ac0eec63241e16bae8e740f4 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 2 Jul 2022 00:27:52 +0100 Subject: [PATCH 029/500] Add attribution to original work --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index d3b30f766a9..854597c026f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +freenet (0.7.5+1494-3) unstable; urgency=medium + + * Add attribution to original work + + -- DC* Sat, 02 Jul 2022 00:26:57 +0100 + freenet (0.7.5+1494-2) unstable; urgency=medium * Update maintainer @@ -13,5 +19,6 @@ freenet (0.7.5+1494-1) unstable; urgency=medium freenet (0.7.5+1493-1) unstable; urgency=medium * Initial Release. + Packaged originally by Ximin Luo : https://github.com/freenet/debian -- DC* Fri, 01 Jul 2022 23:25:13 +0100 From 3cf607b99ca34b5ad1f805bcea8a9a988ab103b6 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 2 Jul 2022 00:38:13 +0100 Subject: [PATCH 030/500] Update package build descriptions --- debian/changelog | 6 ++++++ debian/files | 4 +++- debian/freenet.init | 6 +++--- debian/rules | 2 +- debian/source/include-binaries | 4 ---- 5 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 debian/source/include-binaries diff --git a/debian/changelog b/debian/changelog index 854597c026f..c7876f1a539 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +freenet (0.7.5+1494-4) unstable; urgency=medium + + * Update package build descriptions + + -- DC Sat, 02 Jul 2022 00:36:27 +0100 + freenet (0.7.5+1494-3) unstable; urgency=medium * Add attribution to original work diff --git a/debian/files b/debian/files index e35119fecf1..6381ee49a70 100644 --- a/debian/files +++ b/debian/files @@ -1,3 +1,5 @@ freenet_0.7.5+1494-1_amd64.buildinfo net optional freenet_0.7.5+1494-2_amd64.buildinfo net optional -freenet_0.7.5+1494-2_amd64.deb net optional +freenet_0.7.5+1494-3_amd64.buildinfo net optional +freenet_0.7.5+1494-4_amd64.buildinfo net optional +freenet_0.7.5+1494-4_amd64.deb net optional diff --git a/debian/freenet.init b/debian/freenet.init index dd8b87d81d3..5432eaac92d 100644 --- a/debian/freenet.init +++ b/debian/freenet.init @@ -34,13 +34,13 @@ # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Freenet 0.7.5 build 1493 (experimental release) +# Short-Description: Freenet 0.7.5 build 1494 (experimental release) # Description: Freenet reference daemon ### END INIT INFO # Application APP_NAME="freenet" -APP_LONG_NAME="Freenet 0.7.5 build 1493 (experimental release)" +APP_LONG_NAME="Freenet 0.7.5 build 1494 (experimental release)" # If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer # be passed to the wrapper. See documentation for details. @@ -156,7 +156,7 @@ MACOSX_KEEP_RUNNING="false" # The following two lines are used by the chkconfig command. Change as is # appropriate for your application. They should remain commented. # chkconfig: 2345 20 80 -# description: Freenet 0.7.5 build 1493 (experimental release) +# description: Freenet 0.7.5 build 1494 (experimental release) # Set run level to use when installing the application to start and stop on # system startup and shutdown. It is important that the application always diff --git a/debian/rules b/debian/rules index 9ebfd1a6e1e..981de548a74 100755 --- a/debian/rules +++ b/debian/rules @@ -4,7 +4,7 @@ # Uncomment this to turn on verbose mode. export DH_VERBOSE=0 FREENET_VERSION := 0.7.5 -FREENET_BUILD := 1493 +FREENET_BUILD := 1494 WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh BUILD_DIR := /tmp/fred-build diff --git a/debian/source/include-binaries b/debian/source/include-binaries deleted file mode 100644 index 80c91bfa8e1..00000000000 --- a/debian/source/include-binaries +++ /dev/null @@ -1,4 +0,0 @@ -debian/freenet/usr/share/doc/freenet/changelog.Debian.gz -debian/freenet/usr/share/java/freenet.jar -debian/freenet/usr/share/java/freenet-0.7.5+1493.jar -gradle/** From 5b99c291c249f0f8267bb3e35acfefaebe073dd4 Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 2 Jul 2022 01:34:51 +0100 Subject: [PATCH 031/500] Update github action to test package generation only on tags and master --- .github/workflows/package.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index c18c0f46232..a282f8c63e2 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,10 +1,10 @@ name: Build debian package on: push: - branches: [ '**' ] - pull_request: - branches: [ '**' ] - + branches: [ 'master' ] + tags: + - build** + - testing-** jobs: build-deb: strategy: From e28153340e11fe2cce20ef40eefcb6d4738e3e4b Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 2 Jul 2022 02:05:14 +0100 Subject: [PATCH 032/500] Remove unnecessary file entries --- debian/files | 3 --- 1 file changed, 3 deletions(-) diff --git a/debian/files b/debian/files index 6381ee49a70..56ed1b498c5 100644 --- a/debian/files +++ b/debian/files @@ -1,5 +1,2 @@ -freenet_0.7.5+1494-1_amd64.buildinfo net optional -freenet_0.7.5+1494-2_amd64.buildinfo net optional -freenet_0.7.5+1494-3_amd64.buildinfo net optional freenet_0.7.5+1494-4_amd64.buildinfo net optional freenet_0.7.5+1494-4_amd64.deb net optional From 516a87d21dc9b85cebf611458b76fd86062e6a9c Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 17 Sep 2022 12:57:34 +0100 Subject: [PATCH 033/500] Lintian overrides --- debian/changelog | 6 ++++++ debian/files | 3 ++- debian/freenet.lintian-overrides | 4 ++++ debian/freenet/usr/share/lintian/overrides/freenet | 4 ++++ debian/source/lintian-overrides | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 debian/freenet.lintian-overrides create mode 100644 debian/freenet/usr/share/lintian/overrides/freenet diff --git a/debian/changelog b/debian/changelog index c7876f1a539..e3de37faba4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +freenet (0.7.5+1494-6) unstable; urgency=medium + + * Lintian binary overrides + + -- DC Sat, 17 Sep 2022 13:57:51 +0100 + freenet (0.7.5+1494-4) unstable; urgency=medium * Update package build descriptions diff --git a/debian/files b/debian/files index 56ed1b498c5..db2b723c8ab 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,3 @@ freenet_0.7.5+1494-4_amd64.buildinfo net optional -freenet_0.7.5+1494-4_amd64.deb net optional +freenet_0.7.5+1494-5_amd64.buildinfo net optional +freenet_0.7.5+1494-5_amd64.deb net optional diff --git a/debian/freenet.lintian-overrides b/debian/freenet.lintian-overrides new file mode 100644 index 00000000000..8b68d74645d --- /dev/null +++ b/debian/freenet.lintian-overrides @@ -0,0 +1,4 @@ +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet force-reload +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet restart +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet start +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet stop diff --git a/debian/freenet/usr/share/lintian/overrides/freenet b/debian/freenet/usr/share/lintian/overrides/freenet new file mode 100644 index 00000000000..8b68d74645d --- /dev/null +++ b/debian/freenet/usr/share/lintian/overrides/freenet @@ -0,0 +1,4 @@ +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet force-reload +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet restart +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet start +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet stop diff --git a/debian/source/lintian-overrides b/debian/source/lintian-overrides index 9331edea763..763f2e44a15 100644 --- a/debian/source/lintian-overrides +++ b/debian/source/lintian-overrides @@ -1 +1,5 @@ freenet source: source-is-missing src/freenet/clients/http/staticfiles/freenetjs/* +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet force-reload +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet restart +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet start +freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet stop From 5c4a051746a30a06133c347a0ae2f92e2de9826d Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 17 Sep 2022 14:12:04 +0100 Subject: [PATCH 034/500] Build on debian-pkg branch --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index a282f8c63e2..268fa172aa8 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,7 +1,7 @@ name: Build debian package on: push: - branches: [ 'master' ] + branches: [ 'master', 'debian-pkg' ] tags: - build** - testing-** From a2f314b9ae740bdcb225349ed83a8236695290ec Mon Sep 17 00:00:00 2001 From: DC* Date: Sat, 17 Sep 2022 15:48:23 +0100 Subject: [PATCH 035/500] Update changelog --- debian/changelog | 10 ++++++++-- debian/files | 5 ++--- debian/freenet/usr/share/lintian/overrides/freenet | 4 ---- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 debian/freenet/usr/share/lintian/overrides/freenet diff --git a/debian/changelog b/debian/changelog index e3de37faba4..a7d7dbd19ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,12 @@ -freenet (0.7.5+1494-6) unstable; urgency=medium +freenet (0.7.5+1494-7) unstable; urgency=medium - * Lintian binary overrides + * Remove outdated files + + -- DC Sat, 17 Sep 2022 15:46:23 +0100 + +freenet (0.7.5+1494-7) unstable; urgency=medium + + * Lintian binary overrides -- DC Sat, 17 Sep 2022 13:57:51 +0100 diff --git a/debian/files b/debian/files index db2b723c8ab..cc40908ba31 100644 --- a/debian/files +++ b/debian/files @@ -1,3 +1,2 @@ -freenet_0.7.5+1494-4_amd64.buildinfo net optional -freenet_0.7.5+1494-5_amd64.buildinfo net optional -freenet_0.7.5+1494-5_amd64.deb net optional +freenet_0.7.5+1494-7_amd64.buildinfo net optional +freenet_0.7.5+1494-7_amd64.deb net optional diff --git a/debian/freenet/usr/share/lintian/overrides/freenet b/debian/freenet/usr/share/lintian/overrides/freenet deleted file mode 100644 index 8b68d74645d..00000000000 --- a/debian/freenet/usr/share/lintian/overrides/freenet +++ /dev/null @@ -1,4 +0,0 @@ -freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet force-reload -freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet restart -freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet start -freenet: init.d-script-does-not-implement-required-option etc/init.d/freenet stop From 36bb8df3edc7c926545a3aac7471548b649ed150 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 10 Dec 2022 18:07:28 +0100 Subject: [PATCH 036/500] refactor the browser warning wizard page --- .../http/wizardsteps/BROWSER_WARNING.java | 55 +++++++++++++------ 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java b/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java index 1606fc7380d..6729d30e282 100644 --- a/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java +++ b/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java @@ -1,5 +1,8 @@ package freenet.clients.http.wizardsteps; +import java.util.List; +import java.util.ArrayList; + import freenet.clients.http.FirstTimeWizardToadlet; import freenet.l10n.NodeL10n; import freenet.support.HTMLNode; @@ -53,25 +56,17 @@ public void getStep(HTTPRequest request, PageHelper helper) { HTMLNode contentNode = helper.getPageContent(WizardL10n.l10n("browserWarningPageTitle")); - String infoBoxHeader; - if(incognito) { - infoBoxHeader = WizardL10n.l10n("browserWarningIncognitoShort"); - } else if (isRelativelySafe) { - infoBoxHeader = WizardL10n.l10n("browserWarningShortRelativelySafe"); - } else { - infoBoxHeader = WizardL10n.l10n("browserWarningShort"); - } - + String infoBoxHeader = infoBoxHeaderText(incognito, isRelativelySafe); HTMLNode infoboxContent = helper.getInfobox("infobox-normal", infoBoxHeader, contentNode, null, false); - if(isOldFirefox) { + List oldBrowserWarnings = oldBrowserWarnings( + incognito, + isOldFirefox, + showTabWarning); + if(!oldBrowserWarnings.isEmpty()) { HTMLNode p = infoboxContent.addChild("p"); - p.addChild("#", WizardL10n.l10n("browserWarningOldFirefox")); - if (showTabWarning) { - p.addChild("#", " " + WizardL10n.l10n("browserWarningFirefoxMightHaveClobberedTabs")); - } else if(!incognito) { - p.addChild("#", " " + WizardL10n.l10n("browserWarningOldFirefoxNewerHasPrivacyMode")); - } + p.addChild("#", oldBrowserWarnings.remove(0)); + oldBrowserWarnings.forEach(s -> p.addChild("#", " " + s)); } if(isRelativelySafe) { @@ -104,6 +99,34 @@ public void getStep(HTTPRequest request, PageHelper helper) { new String[] { "submit", "next", NodeL10n.getBase().getString("Toadlet.next")}); } + public List oldBrowserWarnings( + boolean incognito, + boolean isOldFirefox, + boolean showTabWarning) { + ArrayList oldBrowserWarnings = new ArrayList<>(); + if(isOldFirefox) { + oldBrowserWarnings.add(WizardL10n.l10n("browserWarningOldFirefox")); + if (showTabWarning) { + oldBrowserWarnings.add(WizardL10n.l10n("browserWarningFirefoxMightHaveClobberedTabs")); + } else if(!incognito) { + oldBrowserWarnings.add(WizardL10n.l10n("browserWarningOldFirefoxNewerHasPrivacyMode")); + } + } + return oldBrowserWarnings; + } + + public String infoBoxHeaderText(boolean incognito, boolean isRelativelySafe) { + String infoBoxHeader; + if(incognito) { + infoBoxHeader = WizardL10n.l10n("browserWarningIncognitoShort"); + } else if (isRelativelySafe) { + infoBoxHeader = WizardL10n.l10n("browserWarningShortRelativelySafe"); + } else { + infoBoxHeader = WizardL10n.l10n("browserWarningShort"); + } + return infoBoxHeader; + } + /** * This POST side just continues to the next step. * @param request Unused. From 5d6a822373e1ab8c218470d9725fe3b7a53120ac Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 13 Dec 2022 20:44:33 +0100 Subject: [PATCH 037/500] clean up auto-refactored method --- .../clients/http/wizardsteps/BROWSER_WARNING.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java b/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java index 6729d30e282..f3b915c1028 100644 --- a/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java +++ b/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java @@ -116,15 +116,12 @@ public List oldBrowserWarnings( } public String infoBoxHeaderText(boolean incognito, boolean isRelativelySafe) { - String infoBoxHeader; if(incognito) { - infoBoxHeader = WizardL10n.l10n("browserWarningIncognitoShort"); + return WizardL10n.l10n("browserWarningIncognitoShort"); } else if (isRelativelySafe) { - infoBoxHeader = WizardL10n.l10n("browserWarningShortRelativelySafe"); - } else { - infoBoxHeader = WizardL10n.l10n("browserWarningShort"); + return WizardL10n.l10n("browserWarningShortRelativelySafe"); } - return infoBoxHeader; + return WizardL10n.l10n("browserWarningShort"); } /** From 8c85fdc99b6cfcc4a678dae5f1b6ffb60ee693e3 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 13 Dec 2022 20:45:30 +0100 Subject: [PATCH 038/500] clean up more --- src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java b/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java index f3b915c1028..4cb5f5f812b 100644 --- a/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java +++ b/src/freenet/clients/http/wizardsteps/BROWSER_WARNING.java @@ -118,7 +118,8 @@ public List oldBrowserWarnings( public String infoBoxHeaderText(boolean incognito, boolean isRelativelySafe) { if(incognito) { return WizardL10n.l10n("browserWarningIncognitoShort"); - } else if (isRelativelySafe) { + } + if (isRelativelySafe) { return WizardL10n.l10n("browserWarningShortRelativelySafe"); } return WizardL10n.l10n("browserWarningShort"); From ea28797363b534c3cedcece8a7461f7ad876cd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 9 Jan 2023 12:45:45 +0100 Subject: [PATCH 039/500] =?UTF-8?q?=F0=9F=90=9B=20Fix=20JarClassLoader?= =?UTF-8?q?=E2=80=99s=20ability=20to=20work=20with=20ServiceLoader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ServiceLoader uses the findResources() method to locate its service definition files. The default implementation of findResources() returns an empty enumeration, making it impossible to use ServiceLoader from plugins. --- src/freenet/support/JarClassLoader.java | 42 +++++++- test/freenet/support/JarClassLoaderTest.java | 108 +++++++++++++++++++ 2 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 test/freenet/support/JarClassLoaderTest.java diff --git a/src/freenet/support/JarClassLoader.java b/src/freenet/support/JarClassLoader.java index fabd50b1e96..95211a0c0a1 100644 --- a/src/freenet/support/JarClassLoader.java +++ b/src/freenet/support/JarClassLoader.java @@ -26,11 +26,13 @@ import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.Enumeration; +import java.util.NoSuchElementException; import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; -import java.util.jar.Attributes.Name; import java.util.zip.ZipEntry; import freenet.support.io.FileUtil; @@ -170,7 +172,43 @@ protected URL findResource(String name) { } return null; } - + + @Override + protected Enumeration findResources(String name) { + return new Enumeration() { + private final Enumeration jarFileEntries = tempJarFile.entries(); + private URL nextElement = null; + + @Override + public boolean hasMoreElements() { + if (nextElement != null) { + return true; + } + while ((nextElement == null) && jarFileEntries.hasMoreElements()) { + JarEntry jarEntry = jarFileEntries.nextElement(); + if (jarEntry.getName().equals(name)) { + try { + nextElement = new URL("jar:" + new File(tempJarFile.getName()).toURI().toURL() + "!/" + name); + } catch (MalformedURLException e) { + /* ignore. */ + } + } + } + return nextElement != null; + } + + @Override + public URL nextElement() { + if (!hasMoreElements()) { + throw new NoSuchElementException(); + } + URL elementToReturn = nextElement; + nextElement = null; + return elementToReturn; + } + }; + } + /** * {@inheritDoc} *

diff --git a/test/freenet/support/JarClassLoaderTest.java b/test/freenet/support/JarClassLoaderTest.java new file mode 100644 index 00000000000..56323b780c9 --- /dev/null +++ b/test/freenet/support/JarClassLoaderTest.java @@ -0,0 +1,108 @@ +package freenet.support; + +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.jar.JarOutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import org.junit.Test; + +import static java.io.File.createTempFile; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.nio.file.Files.newOutputStream; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.instanceOf; + +/** + * Unit test for {@link JarClassLoader}. + */ +public class JarClassLoaderTest { + + @Test + public void serviceLoaderCanLocateTestImplementation() throws Exception { + JarClassLoader classLoader = new JarClassLoader(createJarFileWithTwoServiceLoaderEntries()); + ServiceLoader testInterface = ServiceLoader.load(TestInterface.class, classLoader); + List implementations = new ArrayList<>(); + testInterface.iterator().forEachRemaining(implementations::add); + assertThat(implementations, containsInAnyOrder( + instanceOf(TestImplementation1.class), + instanceOf(TestImplementation2.class) + )); + } + + /** + * Create a temporary JAR file that contains two files that will be used by + * {@link ServiceLoader} in order to provide two different implementations + * of {@link TestInterface}. + * + * @return A temporary JAR file containing two service loader entries + * @throws Exception if an error occurs + */ + private File createJarFileWithTwoServiceLoaderEntries() throws Exception { + File temporaryFile = createTempFile("jar-class-loader-test-", ".jar"); + temporaryFile.deleteOnExit(); + try ( + OutputStream fileOutputStream = newOutputStream(temporaryFile.toPath()); + JarOutputStream jarFileStream = new JarOutputStream(fileOutputStream)) { + createServiceLoaderEntryFor(TestImplementation1.class, jarFileStream); + clearNames(jarFileStream); + createServiceLoaderEntryFor(TestImplementation2.class, jarFileStream); + } + return temporaryFile; + } + + /** + * Creates a service loader entry that will provide an instance of the given class. + * + * @param implementationClass The class of implementation to provide + * @param zipOutputStream The ZIP output stream + * @throws IOException if an I/O error occurs + */ + private static void createServiceLoaderEntryFor(Class implementationClass, ZipOutputStream zipOutputStream) throws IOException { + ZipEntry serviceFileEntry = new ZipEntry("META-INF/services/" + TestInterface.class.getName()); + zipOutputStream.putNextEntry(serviceFileEntry); + zipOutputStream.write((implementationClass.getName() + "\n").getBytes(UTF_8)); + } + + /** + * Clears the names of already written entries of the given {@link ZipOutputStream}. + * This is necessary to prevent exceptions because of duplicate file entries because + * we absolutely do want multiple files with the same name here. + * + * @param zipOutputStream The ZIP output stream to process + * @throws Exception if there’s a reflection error + */ + private void clearNames(ZipOutputStream zipOutputStream) throws Exception { + Field namesField = ZipOutputStream.class.getDeclaredField("names"); + namesField.setAccessible(true); + Set names = (Set) namesField.get(zipOutputStream); + names.clear(); + } + + /** + * Interface for use with the {@link ServiceLoader}. + */ + public interface TestInterface { + } + + /** + * First implementation of the {@link TestInterface} interface. + */ + public static class TestImplementation1 implements TestInterface { + } + + /** + * Second implementation of the {@link TestInterface} interface. + */ + public static class TestImplementation2 implements TestInterface { + } + +} From 28a63ab168b46ff1b829fce7088e577d60b75d50 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 16 Jan 2023 23:44:14 +0100 Subject: [PATCH 040/500] Update links in CONTRIBUTING.md and add a contact-section in README.md --- CONTRIBUTING.md | 6 +++--- README.md | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9a6d18de93d..1bec731947a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,9 +11,9 @@ start with: List only bugs filed against this repository by selecting "Freenet" in the "Project" drop-down in the upper right. Do any of these look interesting? * Check the [projects](https://wiki.freenetproject.org/Projects) page. -* Ask the [development mailing list](https://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl) - or join us in [IRC](https://freenetproject.org/irc.html) - `#freenet` on - `chat.freenode.net`. +* Ask the [development mailing list](https://freenetproject.org/pages/help.html#mailing-lists) + or join us in [IRC](https://web.libera.chat/?nick=Rabbit|?#freenet) - `#freenet` on + `irc.libera.chat`. # Code review diff --git a/README.md b/README.md index d1ea80a4c90..2db6a4c3f78 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,13 @@ To override values set in `build.gradle` put them into [the file](https://docs.g See our [contributor guidelines](CONTRIBUTING.md). +### Get in contact + +* Ask the [development mailing list](https://freenetproject.org/pages/help.html#mailing-lists) + or join us in [IRC](https://web.libera.chat/?nick=Rabbit|?#freenet) - `#freenet` on + `irc.libera.chat`. +* You can file problems in the [bug tracker](https://bugs.freenetproject.org/my_view_page.php). + ## Add a new dependency All dependencies must be available via Freenet, so it must be added to From effbb60a015d322c97bf3a5104fb9d9d6dd85734 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 22 Jan 2023 17:14:24 +0200 Subject: [PATCH 041/500] Update junit to version 4.13.2 Newer version of junit has some enhancements. https://github.com/junit-team/junit4/blob/HEAD/doc/ReleaseNotes4.13.md One of the needed things is the assertThrows() method, which helps to improve try-catch blocks from the test code. https://junit.org/junit4/javadoc/latest/org/junit/Assert.html#assertThrows(java.lang.Class,%20org.junit.function.ThrowingRunnable) Some improvements are required in the tests code. This update is a minor preparation for this work. Signed-off-by: Veniamin Fernandes --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 634dcd89801..c40cef93f1f 100644 --- a/build.gradle +++ b/build.gradle @@ -242,7 +242,7 @@ dependencies { compile "org.unbescape:unbescape:1.1.6.RELEASE" compile "org.slf4j:slf4j-api:1.7.25" - testCompile 'junit:junit:4.12' + testCompile 'junit:junit:4.13.2' testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.hamcrest:hamcrest-library:1.3" testCompile "org.hamcrest:hamcrest-core:1.3" @@ -257,7 +257,7 @@ dependencyVerification { 'net.java.dev.jna:jna-platform:f1d00c167d8921c6e23c626ef9f1c3ae0be473c95c68ffa012bc7ae55a87e2d6', 'net.java.dev.jna:jna:0c8eb7acf67261656d79005191debaba3b6bf5dd60a43735a245429381dbecff', 'org.freenetproject:freenet-ext:32f2b3d6beedf54137ea2f9a3ebef67666d769f0966b08cd17fd7db59ba4d79f', - 'junit:junit:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a', + 'junit:junit:8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3', 'org.mockito:mockito-core:f97483ba0944b9fa133aa29638764ddbeadb51ec3dbc02074c58fa2caecd07fa', 'org.hamcrest:hamcrest-library:711d64522f9ec410983bd310934296da134be4254a125080a0416ec178dfad1c', 'org.hamcrest:hamcrest-core:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9', From b65167ebedadef5835c4a8653e9a2f5396c0ce4b Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 22 Jan 2023 17:23:42 +0200 Subject: [PATCH 042/500] Change deprecated jcenter() maven repo to mavenCentral() jcenter() repo was closed by the jfrog company and operates in the read-only mode. Gradle is also planning to deprecate this in the future releases. For details see: https://blog.gradle.org/jcenter-shutdown All used lib dependencies seem to be available from the mavenCentral() as well. Signed-off-by: Veniamin Fernandes --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c40cef93f1f..6361eb5e805 100644 --- a/build.gradle +++ b/build.gradle @@ -20,7 +20,7 @@ apply plugin: 'maven-publish' repositories { flatDir { dirs uri("${projectDir}/lib") } maven { url 'https://mvn.freenetproject.org' } - jcenter() + mavenCentral() } sourceSets { From 207b21e781637f4f85af2a28676523ab30b3a3db Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 22 Jan 2023 17:14:41 +0100 Subject: [PATCH 043/500] fix regression: default security level is normal --- src/freenet/clients/http/FirstTimeWizardNewToadlet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freenet/clients/http/FirstTimeWizardNewToadlet.java b/src/freenet/clients/http/FirstTimeWizardNewToadlet.java index 8ccb30646ed..e9955352be5 100644 --- a/src/freenet/clients/http/FirstTimeWizardNewToadlet.java +++ b/src/freenet/clients/http/FirstTimeWizardNewToadlet.java @@ -293,8 +293,8 @@ private Map toModel() { private void save() { if (knowSomeone.isEmpty()) { - // Opennet - core.node.securityLevels.setThreatLevel(SecurityLevels.NETWORK_THREAT_LEVEL.LOW); + // Opennet + Darknet (possible) + core.node.securityLevels.setThreatLevel(SecurityLevels.NETWORK_THREAT_LEVEL.NORMAL); } else { if (connectToStrangers.isEmpty()) { // Darknet From a1ab1a685d85fe3aea9fd076cbeb29fdc2be4f9c Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 22 Jan 2023 18:37:39 +0200 Subject: [PATCH 044/500] remove unused code from ClientRequestSelectorTest Signed-off-by: Veniamin Fernandes --- .../async/ClientRequestSelectorTest.java | 193 +++--------------- 1 file changed, 23 insertions(+), 170 deletions(-) diff --git a/test/freenet/client/async/ClientRequestSelectorTest.java b/test/freenet/client/async/ClientRequestSelectorTest.java index 4630c6fcf65..4c93888fa1b 100644 --- a/test/freenet/client/async/ClientRequestSelectorTest.java +++ b/test/freenet/client/async/ClientRequestSelectorTest.java @@ -16,7 +16,6 @@ import freenet.client.Metadata; import freenet.client.InsertException.InsertExceptionMode; import freenet.client.async.SplitFileInserterSegmentStorage.BlockInsert; -import freenet.client.async.SplitFileInserterSegmentStorage.MissingKeyException; import freenet.client.async.SplitFileInserterStorage.Status; import freenet.client.events.SimpleEventProducer; import freenet.crypt.CRCChecksumChecker; @@ -26,15 +25,7 @@ import freenet.crypt.HashType; import freenet.crypt.MultiHashInputStream; import freenet.crypt.RandomSource; -import freenet.keys.ClientKey; -import freenet.keys.FreenetURI; import freenet.keys.Key; -import freenet.node.KeysFetchingLocally; -import freenet.node.LowLevelPutException; -import freenet.node.RequestClient; -import freenet.node.SendableInsert; -import freenet.node.SendableRequestItem; -import freenet.node.SendableRequestSender; import freenet.support.CheatingTicker; import freenet.support.DummyJobRunner; import freenet.support.MemoryLimitedJobRunner; @@ -55,12 +46,11 @@ import freenet.support.io.PooledFileRandomAccessBufferFactory; import freenet.support.io.RAFInputStream; import freenet.support.io.ReadOnlyRandomAccessBuffer; -import freenet.support.io.ResumeFailedException; import freenet.support.io.TempBucketFactory; import freenet.support.io.TrivialPersistentFileTracker; public class ClientRequestSelectorTest { - + final LockableRandomAccessBufferFactory smallRAFFactory = new ByteArrayRandomAccessBufferFactory(); final FilenameGenerator fg; final PersistentFileTracker persistentFileTracker; @@ -76,16 +66,7 @@ public class ClientRequestSelectorTest { final ChecksumChecker checker; final MemoryLimitedJobRunner memoryLimitedJobRunner; final PersistentJobRunner jobRunner; - final KeySalter salt = new KeySalter() { - @Override - public byte[] saltKey(Key key) { - return key.getRoutingKey(); - } - - }; - private final FreenetURI URI; - public ClientRequestSelectorTest() throws IOException { dir = new File("split-file-inserter-storage-test"); dir.mkdir(); @@ -101,23 +82,15 @@ public ClientRequestSelectorTest() throws IOException { cryptoKey = new byte[32]; r.nextBytes(cryptoKey); checker = new CRCChecksumChecker(); - memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 20, executor, NativeThread.JAVA_PRIORITY_RANGE); + memoryLimitedJobRunner = new MemoryLimitedJobRunner(9 * 1024 * 1024L, 20, executor, NativeThread.JAVA_PRIORITY_RANGE); jobRunner = new DummyJobRunner(executor, null); - URI = FreenetURI.generateRandomCHK(r); } - - class MyCallback implements SplitFileInserterStorageCallback { - - MyCallback(SendableInsert sender) { - this.sender = sender; - } - + + private static class MyCallback implements SplitFileInserterStorageCallback { + private boolean finishedEncode; - private boolean hasKeys; private boolean succeededInsert; private InsertException failed; - private Metadata metadata; - private final SendableInsert sender; @Override public synchronized void onFinishedEncode() { @@ -127,33 +100,21 @@ public synchronized void onFinishedEncode() { @Override public synchronized void onHasKeys() { - hasKeys = true; notifyAll(); } - + @Override public void encodingProgress() { // Ignore. } - + private void checkFailed() throws InsertException { - if(failed != null) + if (failed != null) throw failed; } public synchronized void waitForFinishedEncode() throws InsertException { - while(!finishedEncode) { - checkFailed(); - try { - wait(); - } catch (InterruptedException e) { - // Ignore. - } - } - } - - public synchronized void waitForHasKeys() throws InsertException { - while(!hasKeys) { + while (!finishedEncode) { checkFailed(); try { wait(); @@ -166,12 +127,11 @@ public synchronized void waitForHasKeys() throws InsertException { @Override public synchronized void onSucceeded(Metadata metadata) { succeededInsert = true; - this.metadata = metadata; notifyAll(); } - - public synchronized Metadata waitForSucceededInsert() throws InsertException { - while(!succeededInsert) { + + public synchronized void waitForSucceededInsert() throws InsertException { + while (!succeededInsert) { checkFailed(); try { wait(); @@ -179,7 +139,6 @@ public synchronized Metadata waitForSucceededInsert() throws InsertException { // Ignore. } } - return metadata; } @Override @@ -198,21 +157,13 @@ public void clearCooldown() { // Ignore. } - public synchronized boolean hasFailed() { - return failed != null; - } - - public synchronized boolean hasFinishedEncode() { - return finishedEncode; - } - @Override public short getPriorityClass() { return 0; } } - + private HashResult[] getHashes(LockableRandomAccessBuffer data) throws IOException { InputStream is = new RAFInputStream(data, 0, data.size()); MultiHashInputStream hashStream = new MultiHashInputStream(is, HashType.SHA256.bitmask); @@ -222,115 +173,19 @@ private HashResult[] getHashes(LockableRandomAccessBuffer data) throws IOExcepti } private LockableRandomAccessBuffer generateData(Random random, long size, - LockableRandomAccessBufferFactory smallRAFFactory) throws IOException { + LockableRandomAccessBufferFactory smallRAFFactory) throws IOException { LockableRandomAccessBuffer thing = smallRAFFactory.makeRAF(size); BucketTools.fill(thing, random, 0, size); return new ReadOnlyRandomAccessBuffer(thing); } - - class NullSendableInsert extends SendableInsert { - - public NullSendableInsert(boolean persistent, boolean realTimeFlag) { - super(persistent, realTimeFlag); - } - @Override - public void onSuccess(SendableRequestItem keyNum, ClientKey key, ClientContext context) { - // Ignore - } - - @Override - public void onFailure(LowLevelPutException e, SendableRequestItem keyNum, - ClientContext context) { - // Ignore - } - - @Override - public boolean canWriteClientCache() { - return false; - } - - @Override - public boolean localRequestOnly() { - return false; - } - - @Override - public boolean forkOnCacheable() { - return false; - } - - @Override - public void onEncode(SendableRequestItem token, ClientKey key, ClientContext context) { - // Ignore - } - - @Override - public boolean isEmpty() { - return false; - } - - @Override - protected void innerOnResume(ClientContext context) throws InsertException, - ResumeFailedException { - // Ignore - } - - @Override - public short getPriorityClass() { - return 0; - } - - @Override - public SendableRequestItem chooseKey(KeysFetchingLocally keys, ClientContext context) { - return null; - } - - @Override - public long countAllKeys(ClientContext context) { - return 0; - } - - @Override - public long countSendableKeys(ClientContext context) { - return 0; - } - - @Override - public SendableRequestSender getSender(ClientContext context) { - return null; - } - - @Override - public boolean isCancelled() { - return false; - } - - @Override - public RequestClient getClient() { - return null; - } - - @Override - public ClientRequester getClientRequest() { - return null; - } - - @Override - public boolean isSSK() { - return false; - } - - } - @Test - public void testSmallSplitfileChooseCompletion() throws IOException, InsertException, MissingKeyException { + public void testSmallSplitfileChooseCompletion() throws IOException, InsertException { Random r = new Random(12121); long size = 65536; // Exact multiple, so no last block LockableRandomAccessBuffer data = generateData(r, size, smallRAFFactory); HashResult[] hashes = getHashes(data); - NullSendableInsert insert = new NullSendableInsert(false, false); - MyCallback cb = new MyCallback(insert); + MyCallback cb = new MyCallback(); InsertContext context = baseContext.clone(); context.maxInsertRetries = 2; ClientRequestSelector keys = new ClientRequestSelector(true, false, false, null); @@ -348,24 +203,25 @@ public void testSmallSplitfileChooseCompletion() throws IOException, InsertExcep assertEquals(storage.getStatus(), Status.ENCODED); boolean[] chosenBlocks = new boolean[segment.totalBlockCount]; // Choose and fail all blocks. - for(int i=0;i Date: Sun, 22 Jan 2023 18:59:05 +0200 Subject: [PATCH 045/500] make inner classes to be static in PersistentJobRunnerImplTest Signed-off-by: Veniamin Fernandes --- .../async/PersistentJobRunnerImplTest.java | 68 ++++++++----------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/test/freenet/client/async/PersistentJobRunnerImplTest.java b/test/freenet/client/async/PersistentJobRunnerImplTest.java index 6d106c4027f..87d5ac3b6e2 100644 --- a/test/freenet/client/async/PersistentJobRunnerImplTest.java +++ b/test/freenet/client/async/PersistentJobRunnerImplTest.java @@ -12,12 +12,12 @@ import freenet.support.io.NativeThread; public class PersistentJobRunnerImplTest { - + final WaitableExecutor exec = new WaitableExecutor(new PooledExecutor()); final Ticker ticker = new CheatingTicker(exec); final JobRunner jobRunner; final ClientContext context; - + public PersistentJobRunnerImplTest() { jobRunner = new JobRunner(exec, ticker, 1000); context = new ClientContext(0, null, exec, null, null, null, null, null, null, null, null, ticker, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null); @@ -26,18 +26,18 @@ public PersistentJobRunnerImplTest() { exec.waitForIdle(); jobRunner.grabHasCheckpointed(); } - - private class WakeableJob implements PersistentJob { + + private static class WakeableJob implements PersistentJob { private boolean wake; private boolean started; private boolean finished; @Override public boolean run(ClientContext context) { - synchronized(this) { + synchronized (this) { started = true; notifyAll(); - while(!wake) { + while (!wake) { try { wait(); } catch (InterruptedException e) { @@ -49,22 +49,22 @@ public boolean run(ClientContext context) { } return false; } - + public synchronized void wakeUp() { wake = true; notifyAll(); } - + public synchronized boolean started() { return started; } - + public synchronized boolean finished() { return finished; } public synchronized void waitForStarted() { - while(!started) { + while (!started) { try { wait(); } catch (InterruptedException e) { @@ -72,11 +72,10 @@ public synchronized void waitForStarted() { } } } - } - - private class JobRunner extends PersistentJobRunnerImpl { - + + private static class JobRunner extends PersistentJobRunnerImpl { + private boolean hasCheckpointed; public JobRunner(Executor executor, Ticker ticker, long interval) { @@ -95,7 +94,7 @@ protected synchronized void innerCheckpoint(boolean shutdown) { hasCheckpointed = true; notifyAll(); } - + public synchronized boolean grabHasCheckpointed() { boolean ret = hasCheckpointed; hasCheckpointed = false; @@ -103,42 +102,40 @@ public synchronized boolean grabHasCheckpointed() { } } - - private class WaitAndCheckpoint implements Runnable { + + private static class WaitAndCheckpoint implements Runnable { private final JobRunner jobRunner; private boolean started; private boolean finished; - + public WaitAndCheckpoint(JobRunner jobRunner2) { jobRunner = jobRunner2; } @Override public void run() { - synchronized(this) { + synchronized (this) { started = true; notifyAll(); } try { jobRunner.waitAndCheckpoint(); } catch (PersistenceDisabledException e) { - System.err.println("Impossible: "+e); - return; + throw new IllegalStateException( + JobRunner.class.getSimpleName() + " has failed with unexpected exception", + e + ); } assertTrue(jobRunner.grabHasCheckpointed()); - synchronized(this) { + synchronized (this) { finished = true; notifyAll(); } } - public synchronized boolean hasStarted() { - return started; - } - public synchronized void waitForFinished() { - while(!finished) { + while (!finished) { try { wait(); } catch (InterruptedException e) { @@ -148,7 +145,7 @@ public synchronized void waitForFinished() { } public synchronized void waitForStarted() { - while(!started) { + while (!started) { try { wait(); } catch (InterruptedException e) { @@ -156,9 +153,8 @@ public synchronized void waitForStarted() { } } } - } - + @Test public void testWaitForCheckpoint() throws PersistenceDisabledException { jobRunner.onLoading(); @@ -172,7 +168,7 @@ public void testWaitForCheckpoint() throws PersistenceDisabledException { checkpointer.waitForFinished(); assertTrue(w.finished()); } - + @Test public void testDisabledCheckpointing() throws PersistenceDisabledException { jobRunner.setCheckpointASAP(); @@ -182,16 +178,10 @@ public void testDisabledCheckpointing() throws PersistenceDisabledException { assertFalse(jobRunner.mustCheckpoint()); jobRunner.setCheckpointASAP(); assertFalse(jobRunner.mustCheckpoint()); - + // Run a job which will request a checkpoint. - jobRunner.queue(new PersistentJob() { + jobRunner.queue(context -> true, NativeThread.NORM_PRIORITY); - @Override - public boolean run(ClientContext context) { - return true; - } - - }, NativeThread.NORM_PRIORITY); // Wait for the job to complete. exec.waitForIdle(); assertFalse(jobRunner.mustCheckpoint()); From 2997613d7cdc5cf7e2edf2ed1ebfde726a47cfb5 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Mon, 23 Jan 2023 00:45:24 +0200 Subject: [PATCH 046/500] improve SplitFileFetcherStorageTest and SplitFileInserterStorageTest remove duplication reformat fix assertion methods Signed-off-by: Veniamin Fernandes --- .../async/SplitFileFetcherStorageTest.java | 592 ++++--- .../async/SplitFileInserterStorageTest.java | 1510 ++++++++--------- 2 files changed, 1001 insertions(+), 1101 deletions(-) diff --git a/test/freenet/client/async/SplitFileFetcherStorageTest.java b/test/freenet/client/async/SplitFileFetcherStorageTest.java index 1ef8adea368..3389da31e4e 100644 --- a/test/freenet/client/async/SplitFileFetcherStorageTest.java +++ b/test/freenet/client/async/SplitFileFetcherStorageTest.java @@ -11,6 +11,7 @@ import java.util.HashSet; import java.util.List; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -57,24 +58,17 @@ import freenet.support.io.StorageFormatException; public class SplitFileFetcherStorageTest { - + // Setup code is considerable. See below for actual tests ... - - static DummyRandomSource random; - static final KeySalter salt = new KeySalter() { - @Override - public byte[] saltKey(Key key) { - return key.getRoutingKey(); - } - - }; + static DummyRandomSource random; + static final KeySalter salt = Key::getRoutingKey; static BucketFactory bf = new ArrayBucketFactory(); static LockableRandomAccessBufferFactory rafFactory = new ByteArrayRandomAccessBufferFactory(); static final WaitableExecutor exec = new WaitableExecutor(new PooledExecutor()); static final PersistentJobRunner jobRunner = new DummyJobRunner(exec, null); static final Ticker ticker = new CheatingTicker(exec); - static MemoryLimitedJobRunner memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 20, exec, NativeThread.JAVA_PRIORITY_RANGE); + static MemoryLimitedJobRunner memoryLimitedJobRunner = new MemoryLimitedJobRunner(9 * 1024 * 1024L, 20, exec, NativeThread.JAVA_PRIORITY_RANGE); static final int BLOCK_SIZE = CHKBlock.DATA_LENGTH; private static final OnionFECCodec codec = new OnionFECCodec(); private static final int MAX_SEGMENT_SIZE = 256; @@ -82,15 +76,15 @@ public byte[] saltKey(Key key) { static final CompatibilityMode COMPATIBILITY_MODE = InsertContext.CompatibilityMode.COMPAT_1416; static FreenetURI URI; private static final List NO_DECOMPRESSORS = Collections.emptyList(); - + @Before public void setUp() { // Reset RNG for each test (it's static so not reset by junit). random = new DummyRandomSource(1234); URI = FreenetURI.generateRandomCHK(random); } - - static class TestSplitfile { + + private static class TestSplitfile { final Bucket originalData; final Metadata metadata; final byte[][] dataBlocks; @@ -103,11 +97,11 @@ static class TestSplitfile { private final int[] segmentCheckBlockCount; private final boolean persistent; final MyKeysFetchingLocally fetchingKeys; - + private TestSplitfile(Bucket data, Metadata m, byte[][] originalDataBlocks, - byte[][] originalCheckBlocks, ClientCHK[] dataKeys, ClientCHK[] checkKeys, - byte[] cryptoKey, byte cryptoAlgorithm, int[] segmentDataBlockCount, - int[] segmentCheckBlockCount, boolean persistent) { + byte[][] originalCheckBlocks, ClientCHK[] dataKeys, ClientCHK[] checkKeys, + byte[] cryptoKey, byte cryptoAlgorithm, int[] segmentDataBlockCount, + int[] segmentCheckBlockCount, boolean persistent) { this.originalData = data; this.metadata = m; this.dataBlocks = originalDataBlocks; @@ -121,14 +115,14 @@ private TestSplitfile(Bucket data, Metadata m, byte[][] originalDataBlocks, this.persistent = persistent; this.fetchingKeys = new MyKeysFetchingLocally(); } - + void free() { originalData.free(); } - static TestSplitfile constructSingleSegment(long size, int checkBlocks, String mime, boolean persistent) throws IOException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException { + static TestSplitfile constructSingleSegment(long size, int checkBlocks, boolean persistent) throws IOException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException { assertTrue(checkBlocks <= MAX_SEGMENT_SIZE); - assertTrue(size < MAX_SEGMENT_SIZE * (long)BLOCK_SIZE); + assertTrue(size < MAX_SEGMENT_SIZE * (long) BLOCK_SIZE); Bucket data = makeRandomBucket(size); byte[][] originalDataBlocks = splitAndPadBlocks(data, size); int dataBlocks = originalDataBlocks.length; @@ -136,17 +130,18 @@ static TestSplitfile constructSingleSegment(long size, int checkBlocks, String m assertTrue(dataBlocks + checkBlocks <= MAX_SEGMENT_SIZE); byte[][] originalCheckBlocks = constructBlocks(checkBlocks); codec.encode(originalDataBlocks, originalCheckBlocks, falseArray(checkBlocks), BLOCK_SIZE); - ClientMetadata cm = new ClientMetadata(mime); + ClientMetadata cm = new ClientMetadata(null); // FIXME no hashes for now. // FIXME no compression for now. byte[] cryptoKey = randomKey(); byte cryptoAlgorithm = Key.ALGO_AES_CTR_256_SHA256; ClientCHK[] dataKeys = makeKeys(originalDataBlocks, cryptoKey, cryptoAlgorithm); ClientCHK[] checkKeys = makeKeys(originalCheckBlocks, cryptoKey, cryptoAlgorithm); - Metadata m = new Metadata(SplitfileAlgorithm.ONION_STANDARD, dataKeys, checkKeys, dataBlocks, - checkBlocks, 0, cm, size, null, null, size, false, null, null, size, size, dataBlocks, - dataBlocks + checkBlocks, false, COMPATIBILITY_MODE, - cryptoAlgorithm, cryptoKey, true, 0); + Metadata m = new Metadata(SplitfileAlgorithm.ONION_STANDARD, dataKeys, checkKeys, dataBlocks, + checkBlocks, 0, cm, size, null, null, size, false, null, null, size, size, dataBlocks, + dataBlocks + checkBlocks, false, COMPATIBILITY_MODE, + cryptoAlgorithm, cryptoKey, true, 0 + ); // Make sure the metadata is reusable. // FIXME also necessary as the above constructor doesn't set segments. Bucket metaBucket = m.toBucket(bf); @@ -155,36 +150,37 @@ static TestSplitfile constructSingleSegment(long size, int checkBlocks, String m assertTrue(BucketTools.equalBuckets(metaBucket, copyBucket)); metaBucket.free(); copyBucket.free(); - return new TestSplitfile(data, m1, originalDataBlocks, originalCheckBlocks, dataKeys, checkKeys, - cryptoKey, cryptoAlgorithm, null, null, persistent); + return new TestSplitfile(data, m1, originalDataBlocks, originalCheckBlocks, dataKeys, checkKeys, + cryptoKey, cryptoAlgorithm, null, null, persistent + ); } /** - * Create a multi-segment test splitfile. The main complication with multi-segment is that we can't + * Create a multi-segment test splitfile. The main complication with multi-segment is that we can't * choose the number of blocks in each segment arbitrarily; that depends on the metadata format; the * caller must ensure that the number are consistent. + * * @param size - * @param segmentDataBlockCount The actual number of data blocks in each segment. Must be consistent - * with the other parameters; this cannot be chosen freely due to the metadata format. - * @param segmentCheckBlockCount The actual number of check blocks in each segment. Must be consistent - * with the other parameters; this cannot be chosen freely due to the metadata format. - * @param segmentSize The "typical" number of data blocks in a segment. - * @param checkSegmentSize The "typical" number of check blocks in a segment. + * @param segmentDataBlockCount The actual number of data blocks in each segment. Must be consistent + * with the other parameters; this cannot be chosen freely due to the metadata format. + * @param segmentCheckBlockCount The actual number of check blocks in each segment. Must be consistent + * with the other parameters; this cannot be chosen freely due to the metadata format. + * @param segmentSize The "typical" number of data blocks in a segment. + * @param checkSegmentSize The "typical" number of check blocks in a segment. * @param deductBlocksFromSegments The number of segments from which a single block has been deducted. - * This is used when the number of data blocks isn't an exact multiple of the number of segments. - * @param topCompatibilityMode The "short" value of the definitive compatibility mode used to create - * the splitfile. This must again be consistent with the rest, as it is sometimes used in decoding. - * @param mime + * This is used when the number of data blocks isn't an exact multiple of the number of segments. + * @param topCompatibilityMode The "short" value of the definitive compatibility mode used to create + * the splitfile. This must again be consistent with the rest, as it is sometimes used in decoding. * @return * @throws IOException * @throws CHKEncodeException * @throws MetadataUnresolvedException * @throws MetadataParseException */ - static TestSplitfile constructMultipleSegments(long size, int[] segmentDataBlockCount, - int[] segmentCheckBlockCount, int segmentSize, int checkSegmentSize, - int deductBlocksFromSegments, CompatibilityMode topCompatibilityMode, String mime, boolean persistent) - throws IOException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException { + static TestSplitfile constructMultipleSegments(long size, int[] segmentDataBlockCount, + int[] segmentCheckBlockCount, int segmentSize, int checkSegmentSize, + int deductBlocksFromSegments, CompatibilityMode topCompatibilityMode) + throws IOException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException { int dataBlocks = sum(segmentDataBlockCount); int checkBlocks = sum(segmentCheckBlockCount); int segments = segmentDataBlockCount.length; @@ -195,25 +191,26 @@ static TestSplitfile constructMultipleSegments(long size, int[] segmentDataBlock byte[][] originalCheckBlocks = constructBlocks(checkBlocks); int startDataBlock = 0; int startCheckBlock = 0; - for(int seg=0;seg= size); - TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, false); + assertTrue(dataBlocks * (long) BLOCK_SIZE >= size); + TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, false); testDataBlocksOnly(test); - if(checkBlocks >= dataBlocks) + if (checkBlocks >= dataBlocks) { testCheckBlocksOnly(test); + } testRandomMixture(test); test.free(); } @@ -646,10 +668,10 @@ private void testDataBlocksOnly(TestSplitfile test) throws IOException, CHKEncod StorageCallback cb = test.createStorageCallback(); SplitFileFetcherStorage storage = test.createStorage(cb); SplitFileFetcherSegmentStorage segment = storage.segments[0]; - for(int i=0;i keys = new HashSet(); @Override @@ -886,27 +911,27 @@ public void add(Key k) { public void clear() { keys.clear(); } - + } - + @Test public void testChooseKeyOneTry() throws CHKEncodeException, IOException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 3, checkBlocks = 3; - TestSplitfile test = TestSplitfile.constructSingleSegment(dataBlocks*BLOCK_SIZE, checkBlocks, null, false); + TestSplitfile test = TestSplitfile.constructSingleSegment(dataBlocks * BLOCK_SIZE, checkBlocks, false); StorageCallback cb = test.createStorageCallback(); FetchContext ctx = test.makeFetchContext(); ctx.maxSplitfileBlockRetries = 0; SplitFileFetcherStorage storage = test.createStorage(cb, ctx); - boolean[] tried = new boolean[dataBlocks+checkBlocks]; + boolean[] tried = new boolean[dataBlocks + checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, false); - assertEquals(storage.chooseRandomKey(), null); + assertNull(storage.chooseRandomKey()); cb.waitForFailed(); } - + private void innerChooseKeyTest(int dataBlocks, int checkBlocks, SplitFileFetcherSegmentStorage storage, boolean[] tried, TestSplitfile test, boolean cooldown) { final MyKeysFetchingLocally keys = test.fetchingKeys; keys.clear(); - for(int i=0;i now); - assertFalse(storage.segments[0].getOverallCooldownTime() == Long.MAX_VALUE); + assertNotEquals(Long.MAX_VALUE, storage.segments[0].getOverallCooldownTime()); // Now in cooldown. test.fetchingKeys.clear(); - assertEquals(storage.chooseRandomKey(), null); - Thread.sleep((long)(COOLDOWN_TIME+COOLDOWN_TIME/2+1)); + assertNull(storage.chooseRandomKey()); + Thread.sleep(COOLDOWN_TIME + COOLDOWN_TIME / 2 + 1); cb.checkFailed(); // Should be out of cooldown now. - for(int i=0;i<3;i++) { - boolean[] tried = new boolean[dataBlocks+checkBlocks]; + for (int i = 0; i < 3; i++) { + boolean[] tried = new boolean[dataBlocks + checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, true); } // Now it should fail. cb.waitForFailed(); } - + @Test public void testWriteReadSegmentKeys() throws FetchException, MetadataParseException, IOException, CHKEncodeException, MetadataUnresolvedException, ChecksumFailedException { int dataBlocks = 3, checkBlocks = 3; - TestSplitfile test = TestSplitfile.constructSingleSegment(dataBlocks*BLOCK_SIZE, checkBlocks, null, true); + TestSplitfile test = TestSplitfile.constructSingleSegment(dataBlocks*BLOCK_SIZE, checkBlocks, true); StorageCallback cb = test.createStorageCallback(); SplitFileFetcherStorage storage = test.createStorage(cb); SplitFileFetcherSegmentStorage segment = storage.segments[0]; SplitFileSegmentKeys keys = segment.getSegmentKeys(); SplitFileSegmentKeys moreKeys = segment.readSegmentKeys(); - assertTrue(keys.equals(moreKeys)); + assertEquals(keys, moreKeys); storage.close(); } - /** Test persistence: Create and then reload. Don't do anything. */ + /** + * Test persistence: Create and then reload. Don't do anything. + */ @Test public void testPersistenceReload() throws CHKEncodeException, IOException, MetadataUnresolvedException, MetadataParseException, FetchException, StorageFormatException { int dataBlocks = 2; int checkBlocks = 3; - long size = 32768*2-1; - assertTrue(dataBlocks * (long)BLOCK_SIZE >= size); - TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, true); + long size = 32768 * 2 - 1; + assertTrue(dataBlocks * (long) BLOCK_SIZE >= size); + TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, true); StorageCallback cb = test.createStorageCallback(); - SplitFileFetcherStorage storage = test.createStorage(cb); - // No need to shutdown the old storage. - storage = test.createStorage(cb, test.makeFetchContext(), cb.getRAF()); + SplitFileFetcherStorage storage = createSplitFileFetcherStorageTwice(test, cb); storage.close(); } - + @Test public void testPersistenceReloadThenFetch() throws IOException, StorageFormatException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 2; int checkBlocks = 3; - long size = 32768*2-1; - assertTrue(dataBlocks * (long)BLOCK_SIZE >= size); - TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, true); + long size = 32768 * 2 - 1; + assertTrue(dataBlocks * (long) BLOCK_SIZE >= size); + TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, true); StorageCallback cb = test.createStorageCallback(); - SplitFileFetcherStorage storage = test.createStorage(cb); - // No need to shutdown the old storage. - storage = test.createStorage(cb, test.makeFetchContext(), cb.getRAF()); + SplitFileFetcherStorage storage = createSplitFileFetcherStorageTwice(test, cb); SplitFileFetcherSegmentStorage segment = storage.segments[0]; assertFalse(segment.corruptMetadata()); - int total = test.dataBlocks.length+test.checkBlocks.length; - for(int i=0;i= size); - TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, true); + long size = 32768 * 2 - 1; + assertTrue(dataBlocks * (long) BLOCK_SIZE >= size); + TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, true); StorageCallback cb = test.createStorageCallback(); FetchContext ctx = test.makeFetchContext(); ctx.maxSplitfileBlockRetries = 2; - SplitFileFetcherStorage storage = test.createStorage(cb, ctx); + test.createStorage(cb, ctx); // No need to shutdown the old storage. - storage = test.createStorage(cb, ctx, cb.getRAF()); - for(int i=0;i<3;i++) { - boolean[] tried = new boolean[dataBlocks+checkBlocks]; + SplitFileFetcherStorage storage = test.createStorage(cb, ctx, cb.getRAF()); + for (int i = 0; i < 3; i++) { + boolean[] tried = new boolean[dataBlocks + checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, false); } test.fetchingKeys.clear(); - assertEquals(storage.chooseRandomKey(), null); + assertNull(storage.chooseRandomKey()); cb.waitForFailed(); } - + @Test public void testPersistenceReloadBetweenChooseKey() throws IOException, StorageFormatException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 2; int checkBlocks = 3; - long size = 32768*2-1; - assertTrue(dataBlocks * (long)BLOCK_SIZE >= size); - TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, true); + long size = 32768 * 2 - 1; + assertTrue(dataBlocks * (long) BLOCK_SIZE >= size); + TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, true); StorageCallback cb = test.createStorageCallback(); FetchContext ctx = test.makeFetchContext(); ctx.maxSplitfileBlockRetries = 2; - SplitFileFetcherStorage storage = test.createStorage(cb, ctx); + test.createStorage(cb, ctx); // No need to shutdown the old storage. - storage = test.createStorage(cb, ctx, cb.getRAF()); - for(int i=0;i<3;i++) { - boolean[] tried = new boolean[dataBlocks+checkBlocks]; + SplitFileFetcherStorage storage = test.createStorage(cb, ctx, cb.getRAF()); + for (int i = 0; i < 3; i++) { + boolean[] tried = new boolean[dataBlocks + checkBlocks]; innerChooseKeyTest(dataBlocks, checkBlocks, storage.segments[0], tried, test, false); // Reload. exec.waitForIdle(); @@ -1106,33 +1130,32 @@ public void testPersistenceReloadBetweenChooseKey() throws IOException, StorageF assertTrue(i != 2); storage.start(false); } catch (FetchException e) { - if(i != 2) throw e; // Already failed on the final iteration, otherwise is an error. + if (i != 2) throw e; // Already failed on the final iteration, otherwise is an error. return; } } test.fetchingKeys.clear(); - assertEquals(storage.chooseRandomKey(), null); + assertNull(storage.chooseRandomKey()); cb.waitForFailed(); } - + @Test public void testPersistenceReloadBetweenFetches() throws IOException, StorageFormatException, CHKEncodeException, MetadataUnresolvedException, MetadataParseException, FetchException { int dataBlocks = 2; int checkBlocks = 3; - long size = 32768*2-1; - assertTrue(dataBlocks * (long)BLOCK_SIZE >= size); - TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, null, true); + long size = 32768 * 2 - 1; + assertTrue(dataBlocks * (long) BLOCK_SIZE >= size); + TestSplitfile test = TestSplitfile.constructSingleSegment(size, checkBlocks, true); StorageCallback cb = test.createStorageCallback(); - SplitFileFetcherStorage storage = test.createStorage(cb); - // No need to shutdown the old storage. - storage = test.createStorage(cb, test.makeFetchContext(), cb.getRAF()); + SplitFileFetcherStorage storage = createSplitFileFetcherStorageTwice(test, cb); SplitFileFetcherSegmentStorage segment = storage.segments[0]; assertFalse(segment.corruptMetadata()); - int total = test.dataBlocks.length+test.checkBlocks.length; - for(int i=0;i cb.waitForSucceededInsert()); + + assertEquals(InsertExceptionMode.TOO_MANY_RETRIES_IN_BLOCKS, e.mode); + assertNotNull(e.errorCodes); + assertEquals(3, e.errorCodes.getErrorCount(InsertExceptionMode.ROUTE_NOT_FOUND)); + assertEquals(3, e.errorCodes.totalCount()); + assertEquals(Status.FAILED, storage.getStatus()); } @Test - public void testSmallSplitfileFailureFatalError() throws IOException, InsertException, MissingKeyException { - Random r = new Random(12121); - long size = 65536; // Exact multiple, so no last block - LockableRandomAccessBuffer data = generateData(r, size); - HashResult[] hashes = getHashes(data); - MyCallback cb = new MyCallback(); - InsertContext context = baseContext.clone(); + public void testSmallSplitfileFailureFatalError() throws Exception { context.maxInsertRetries = 2; - KeysFetchingLocally keys = new MyKeysFetchingLocally(); - SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null, - new ClientMetadata(), false, null, smallRAFFactory, false, context, - cryptoAlgorithm, cryptoKey, null, hashes, smallBucketFactory, checker, - r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0); - storage.start(); - cb.waitForFinishedEncode(); - assertEquals(storage.segments.length, 1); - SplitFileInserterSegmentStorage segment = storage.segments[0]; - assertEquals(segment.dataBlockCount, 2); - assertEquals(segment.checkBlockCount, 3); - assertEquals(segment.crossCheckBlockCount, 0); - assertEquals(storage.getStatus(), Status.ENCODED); + SplitFileInserterStorage storage = createSplitFileInserterStorage(data, size, cb, false, context, cryptoAlgorithm, cryptoKey, hashes, random, memoryLimitedJobRunner, keys); + SplitFileInserterSegmentStorage segment = assertProperSegmentStateAndGet(storage); assertTrue(InsertException.isFatal(InsertExceptionMode.INTERNAL_ERROR)); segment.onFailure(0, new InsertException(InsertExceptionMode.INTERNAL_ERROR)); - try { - cb.waitForSucceededInsert(); - assertTrue(false); - } catch (InsertException e) { - assertEquals(e.mode, InsertExceptionMode.FATAL_ERRORS_IN_BLOCKS); - assertTrue(e.errorCodes != null); - assertEquals(e.errorCodes.getErrorCount(InsertExceptionMode.INTERNAL_ERROR), 1); - assertEquals(e.errorCodes.totalCount(), 1); - assertEquals(storage.getStatus(), Status.FAILED); - } + + InsertException e = assertThrows(InsertException.class, () -> cb.waitForSucceededInsert()); + assertEquals(InsertExceptionMode.FATAL_ERRORS_IN_BLOCKS, e.mode); + assertNotNull(e.errorCodes); + assertEquals(1, e.errorCodes.getErrorCount(InsertExceptionMode.INTERNAL_ERROR)); + assertEquals(1, e.errorCodes.totalCount()); + assertEquals(Status.FAILED, storage.getStatus()); } private HashResult[] getHashes(LockableRandomAccessBuffer data) throws IOException { - InputStream is = new RAFInputStream(data, 0, data.size()); - MultiHashInputStream hashStream = new MultiHashInputStream(is, HashType.SHA256.bitmask); - FileUtil.copy(is, new NullOutputStream(), data.size()); - is.close(); - return hashStream.getResults(); + try ( + InputStream is = new RAFInputStream(data, 0, data.size()); + MultiHashInputStream hashStream = new MultiHashInputStream(is, HashType.SHA256.bitmask) + ) { + FileUtil.copy(is, new NullOutputStream(), data.size()); + return hashStream.getResults(); + } } private LockableRandomAccessBuffer generateData(Random random, long size) throws IOException { @@ -671,64 +476,64 @@ private LockableRandomAccessBuffer generateData(Random random, long size) throws } private LockableRandomAccessBuffer generateData(Random random, long size, - LockableRandomAccessBufferFactory factory) throws IOException { + LockableRandomAccessBufferFactory factory) throws IOException { LockableRandomAccessBuffer thing = factory.makeRAF(size); BucketTools.fill(thing, random, 0, size); return new ReadOnlyRandomAccessBuffer(thing); } - + @Test - public void testRoundTripSimple() throws FetchException, MetadataParseException, Exception { - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*2, CompatibilityMode.COMPAT_CURRENT); - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*2-1, CompatibilityMode.COMPAT_CURRENT); - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*128, CompatibilityMode.COMPAT_CURRENT); - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*128+1, CompatibilityMode.COMPAT_CURRENT); - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*192, CompatibilityMode.COMPAT_CURRENT); - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*192+1, CompatibilityMode.COMPAT_CURRENT); + public void testRoundTripSimple() throws Exception { + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * 2, CompatibilityMode.COMPAT_CURRENT); + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * 2 - 1, CompatibilityMode.COMPAT_CURRENT); + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * 128, CompatibilityMode.COMPAT_CURRENT); + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * 128 + 1, CompatibilityMode.COMPAT_CURRENT); + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * 192, CompatibilityMode.COMPAT_CURRENT); + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * 192 + 1, CompatibilityMode.COMPAT_CURRENT); } - + @Test - public void testRoundTripOneBlockSegment() throws IOException, InsertException, MissingKeyException, FetchException, MetadataParseException, Exception { - testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH*(128+1)-1, CompatibilityMode.COMPAT_1250_EXACT); + public void testRoundTripOneBlockSegment() throws Exception { + testRoundTripSimpleRandom(CHKBlock.DATA_LENGTH * (128 + 1) - 1, CompatibilityMode.COMPAT_1250_EXACT); } - + @Test - public void testRoundTripCrossSegment() throws IOException, InsertException, MissingKeyException, FetchException, MetadataParseException, Exception { - if(!TestProperty.EXTENSIVE) return; + public void testRoundTripCrossSegment() throws Exception { + if (!TestProperty.EXTENSIVE) return; // Test cross-segment: - testRoundTripCrossSegmentRandom(CHKBlock.DATA_LENGTH*128*21); + testRoundTripCrossSegmentRandom(CHKBlock.DATA_LENGTH * 128 * 21); } - + @Test - public void testRoundTripDataBlocksOnly() throws IOException, InsertException, MissingKeyException, FetchException, MetadataParseException, Exception { - testRoundTripCrossSegmentDataBlocks(CHKBlock.DATA_LENGTH*128*5); - if(!TestProperty.EXTENSIVE) return; + public void testRoundTripDataBlocksOnly() throws Exception { + testRoundTripCrossSegmentDataBlocks(CHKBlock.DATA_LENGTH * 128 * 5); + if (!TestProperty.EXTENSIVE) return; // Test cross-segment: - testRoundTripCrossSegmentDataBlocks(CHKBlock.DATA_LENGTH*128*21); + testRoundTripCrossSegmentDataBlocks(CHKBlock.DATA_LENGTH * 128 * 21); } - + @Test - public void testResumeCrossSegment() throws InsertException, IOException, MissingKeyException, StorageFormatException, ChecksumFailedException, ResumeFailedException, MetadataUnresolvedException { - if(!TestProperty.EXTENSIVE) return; - testResumeCrossSegment(CHKBlock.DATA_LENGTH*128*21); + public void testResumeCrossSegment() throws Exception { + if (!TestProperty.EXTENSIVE) return; + testResumeCrossSegment(CHKBlock.DATA_LENGTH * 128 * 21); } - + @Test - public void testEncodeAfterShutdownCrossSegment() throws InsertException, IOException, MissingKeyException, StorageFormatException, ChecksumFailedException, ResumeFailedException, MetadataUnresolvedException { - if(!TestProperty.EXTENSIVE) return; - testEncodeAfterShutdownCrossSegment(CHKBlock.DATA_LENGTH*128*21); + public void testEncodeAfterShutdownCrossSegment() throws Exception { + if (!TestProperty.EXTENSIVE) return; + testEncodeAfterShutdownCrossSegment(CHKBlock.DATA_LENGTH * 128 * 21); } - + @Test - public void testRepeatedEncodeAfterShutdown() throws InsertException, IOException, MissingKeyException, StorageFormatException, ChecksumFailedException, ResumeFailedException, MetadataUnresolvedException { - testRepeatedEncodeAfterShutdownCrossSegment(CHKBlock.DATA_LENGTH*128*5); // Not cross-segment. - if(!TestProperty.EXTENSIVE) return; - testRepeatedEncodeAfterShutdownCrossSegment(CHKBlock.DATA_LENGTH*128*21); // Cross-segment. + public void testRepeatedEncodeAfterShutdown() throws Exception { + testRepeatedEncodeAfterShutdownCrossSegment(CHKBlock.DATA_LENGTH * 128 * 5); // Not cross-segment. + if (!TestProperty.EXTENSIVE) return; + testRepeatedEncodeAfterShutdownCrossSegment(CHKBlock.DATA_LENGTH * 128 * 21); // Cross-segment. } - - static class MyKeysFetchingLocally implements KeysFetchingLocally { - private final HashSet keys = new HashSet(); - private final HashSet inserts = new HashSet(); + + private static class MyKeysFetchingLocally implements KeysFetchingLocally { + private final HashSet keys = new HashSet<>(); + private final HashSet inserts = new HashSet<>(); @Override public long checkRecentlyFailed(Key key, boolean realTime) { @@ -757,10 +562,9 @@ public void clear() { keys.clear(); inserts.clear(); } - } - - private void testRoundTripSimpleRandom(long size, CompatibilityMode cmode) throws IOException, InsertException, MissingKeyException, FetchException, MetadataParseException, Exception { + + private void testRoundTripSimpleRandom(long size, CompatibilityMode cmode) throws Exception { RandomSource r = new DummyRandomSource(12123); LockableRandomAccessBuffer data = generateData(r, size); Bucket dataBucket = new RAFBucket(data); @@ -772,18 +576,14 @@ private void testRoundTripSimpleRandom(long size, CompatibilityMode cmode) throw cmode = context.getCompatibilityMode(); KeysFetchingLocally keys = new MyKeysFetchingLocally(); boolean old = cmode.code < CompatibilityMode.COMPAT_1255.code; - byte cryptoAlgorithm = this.cryptoAlgorithm; - if(!(cmode == CompatibilityMode.COMPAT_CURRENT || cmode.ordinal() >= CompatibilityMode.COMPAT_1416.ordinal())) + byte cryptoAlgorithm; + if (!(cmode == CompatibilityMode.COMPAT_CURRENT || cmode.ordinal() >= CompatibilityMode.COMPAT_1416.ordinal())) { cryptoAlgorithm = Key.ALGO_AES_PCFB_256_SHA256; - else + } else { cryptoAlgorithm = Key.ALGO_AES_CTR_256_SHA256; - SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null, - new ClientMetadata(), false, null, smallRAFFactory, false, context, - cryptoAlgorithm, old ? null : cryptoKey, null, hashes, smallBucketFactory, checker, - r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0); - storage.start(); - cb.waitForFinishedEncode(); - assertTrue(storage.getStatus() == Status.ENCODED); + } + SplitFileInserterStorage storage = createSplitFileInserterStorage(data, size, cb, false, context, cryptoAlgorithm, old ? null : cryptoKey, hashes, r, memoryLimitedJobRunner, keys); + assertEquals(Status.ENCODED, storage.getStatus()); // Encoded. Now try to decode it ... cb.waitForHasKeys(); Metadata metadata = storage.encodeMetadata(); @@ -794,29 +594,27 @@ private void testRoundTripSimpleRandom(long size, CompatibilityMode cmode) throw Metadata m1 = Metadata.construct(metaBucket); Bucket copyBucket = m1.toBucket(smallBucketFactory); assertTrue(BucketTools.equalBuckets(metaBucket, copyBucket)); - + FetchCallbackForTestingSplitFileInserter fcb = new FetchCallbackForTestingSplitFileInserter(); - - FetchContext fctx = HighLevelSimpleClientImpl.makeDefaultFetchContext(size*2, size*2, smallBucketFactory, new SimpleEventProducer()); - - SplitFileFetcherStorage fetcherStorage = new SplitFileFetcherStorage(m1, fcb, new ArrayList(), - new ClientMetadata(), false, cmode.code, fctx, false, salt, URI, URI, true, new byte[0], - r, smallBucketFactory, smallRAFFactory, jobRunner, ticker, memoryLimitedJobRunner, - checker, false, null, null, keys); - + + FetchContext fctx = HighLevelSimpleClientImpl.makeDefaultFetchContext(size * 2, size * 2, smallBucketFactory, new SimpleEventProducer()); + + SplitFileFetcherStorage fetcherStorage = createFetcherStorage(m1, fcb, new ArrayList<>(), cmode.code, fctx, r); + fetcherStorage.start(false); - + // Fully decode one segment at a time, ignore cross-segment. - - for(int i=0;i(), - new ClientMetadata(), false, cmode, fctx, false, salt, URI, URI, true, new byte[0], - r, smallBucketFactory, smallRAFFactory, jobRunner, ticker, memoryLimitedJobRunner, - checker, false, null, null, keysFetching); - + + SplitFileFetcherStorage fetcherStorage = createFetcherStorage(m1, fcb, new ArrayList<>(), cmode, fctx, r); + fetcherStorage.start(false); - + int segments = storage.segments.length; - for(int i=0;i(), - new ClientMetadata(), false, cmode, fctx, false, salt, URI, URI, true, new byte[0], - r, smallBucketFactory, smallRAFFactory, jobRunner, ticker, memoryLimitedJobRunner, - checker, false, null, null, keysFetching); - + + SplitFileFetcherStorage fetcherStorage = createFetcherStorage(m1, fcb, new ArrayList<>(), cmode, fctx, r); + fetcherStorage.start(false); - - if(storage.crossSegments != null) { + + if (storage.crossSegments != null) { int segments = storage.segments.length; - for(int i=0;i cb.waitForFinishedEncode()); + assertFalse(segment.isEncoding()); + assertEquals(Status.FAILED, storage.getStatus()); } - + @Test - public void testCancelAlt() throws IOException, InsertException, MissingKeyException { + public void testCancelAlt() throws Exception { // We need to check that onFailed() isn't called until after all the cross segment encode threads have finished. - Random r = new Random(12124); - testCancelAlt(r, 32768*6); + testCancelAlt(random, 32768 * 6); } - + @Test - public void testCancelAltCrossSegment() throws IOException, InsertException, MissingKeyException { + public void testCancelAltCrossSegment() throws Exception { // We need to check that onFailed() isn't called until after all the cross segment encode threads have finished. - Random r = new Random(0xb395f44d); - testCancelAlt(r, CHKBlock.DATA_LENGTH*128*21); + testCancelAlt(random, CHKBlock.DATA_LENGTH*128*21); } - private void testCancelAlt(Random r, long size) throws IOException, InsertException { + private void testCancelAlt(Random r, long size) throws Exception { // FIXME tricky to wait for "all threads are in pread()", when # threads != # segments. // So just set max threads to 1 (only affects this test). memoryLimitedJobRunner.setMaxThreads(1); BarrierRandomAccessBuffer data = new BarrierRandomAccessBuffer(generateData(r, size)); HashResult[] hashes = getHashes(data); data.pause(); - MyCallback cb = new MyCallback(); InsertContext context = baseContext.clone(); context.earlyEncode = true; - KeysFetchingLocally keys = new MyKeysFetchingLocally(); - SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null, - new ClientMetadata(), false, null, smallRAFFactory, false, context, - cryptoAlgorithm, cryptoKey, null, hashes, smallBucketFactory, checker, - r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0); + SplitFileInserterStorage storage = new SplitFileInserterStorage( + data, + size, + cb, + null, + new ClientMetadata(), + false, + null, + smallRAFFactory, + false, + context, + cryptoAlgorithm, + cryptoKey, + null, + hashes, + smallBucketFactory, + checker, + r, + memoryLimitedJobRunner, + jobRunner, + ticker, + keys, + false, + 0, + 0, + 0, + 0 + ); storage.start(); - assertEquals(storage.getStatus(), Status.STARTED); - if(storage.crossSegments != null) + assertEquals(Status.STARTED, storage.getStatus()); + if (storage.crossSegments != null) { assertTrue(allCrossSegmentsEncoding(storage)); - else + } else { assertTrue(allSegmentsEncoding(storage)); + } SplitFileInserterSegmentStorage segment = storage.segments[0]; assertTrue(memoryLimitedJobRunner.getRunningThreads() > 0); // Wait for one segment to be in pread(). @@ -1427,83 +1269,85 @@ private void testCancelAlt(Random r, long size) throws IOException, InsertExcept segment.onFailure(0, new InsertException(InsertExceptionMode.INTERNAL_ERROR)); assertFalse(cb.hasFailed()); // Callback must not have been called yet. data.proceed(); // Now it will complete encoding, and then report in, and then fail. - try { - cb.waitForFinishedEncode(); - assertFalse(true); // Should have failed now. - } catch (InsertException e) { - if(storage.segments.length > 2) { - assertFalse(cb.hasFinishedEncode()); - assertTrue(anySegmentNotEncoded(storage)); - } - assertEquals(memoryLimitedJobRunner.getRunningThreads(), 0); - assertFalse(anySegmentEncoding(storage)); - assertEquals(storage.getStatus(), Status.FAILED); + + assertThrows(InsertException.class, ()-> cb.waitForFinishedEncode()); + if (storage.segments.length > 2) { + assertFalse(cb.hasFinishedEncode()); + assertTrue(anySegmentNotEncoded(storage)); } + assertEquals(0, memoryLimitedJobRunner.getRunningThreads()); + assertFalse(anySegmentEncoding(storage)); + assertEquals(Status.FAILED, storage.getStatus()); } - + private boolean allSegmentsEncoding(SplitFileInserterStorage storage) { - for(SplitFileInserterSegmentStorage segment : storage.segments) - if(!segment.isEncoding()) return false; + for (SplitFileInserterSegmentStorage segment : storage.segments) { + if (!segment.isEncoding()) { + return false; + } + } return true; } - + private boolean allCrossSegmentsEncoding(SplitFileInserterStorage storage) { - if(storage.crossSegments != null) { - for(SplitFileInserterCrossSegmentStorage segment : storage.crossSegments) - if(!segment.isEncoding()) return false; + if (storage.crossSegments != null) { + for (SplitFileInserterCrossSegmentStorage segment : storage.crossSegments) { + if (!segment.isEncoding()) { + return false; + } + } } return true; } private boolean anySegmentEncoding(SplitFileInserterStorage storage) { - for(SplitFileInserterSegmentStorage segment : storage.segments) - if(segment.isEncoding()) return true; - if(storage.crossSegments != null) { - for(SplitFileInserterCrossSegmentStorage segment : storage.crossSegments) - if(segment.isEncoding()) return true; + for (SplitFileInserterSegmentStorage segment : storage.segments) { + if (segment.isEncoding()) { + return true; + } + } + if (storage.crossSegments != null) { + for (SplitFileInserterCrossSegmentStorage segment : storage.crossSegments) { + if (segment.isEncoding()) { + return true; + } + } } return false; } private boolean anySegmentNotEncoded(SplitFileInserterStorage storage) { - for(SplitFileInserterSegmentStorage segment : storage.segments) - if(!segment.hasEncoded()) return true; - if(storage.crossSegments != null) { - for(SplitFileInserterCrossSegmentStorage segment : storage.crossSegments) - if(!segment.hasEncodedSuccessfully()) return true; + for (SplitFileInserterSegmentStorage segment : storage.segments) { + if (!segment.hasEncoded()) { + return true; + } + } + if (storage.crossSegments != null) { + for (SplitFileInserterCrossSegmentStorage segment : storage.crossSegments) { + if (!segment.hasEncodedSuccessfully()) { + return true; + } + } } return false; } @Test - public void testPersistentSmallSplitfileNoLastBlockCompletion() throws IOException, InsertException, StorageFormatException, ChecksumFailedException, ResumeFailedException { - Random r = new Random(12121); - long size = 65536; // Exact multiple, so no last block - LockableRandomAccessBuffer data = generateData(r, size, bigRAFFactory); + public void testPersistentSmallSplitfileNoLastBlockCompletion() throws Exception { + LockableRandomAccessBuffer data = generateData(random, size, bigRAFFactory); HashResult[] hashes = getHashes(data); - MyCallback cb = new MyCallback(); - KeysFetchingLocally keys = new MyKeysFetchingLocally(); - SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null, - new ClientMetadata(), false, null, smallRAFFactory, true, baseContext.clone(), - cryptoAlgorithm, cryptoKey, null, hashes, smallBucketFactory, checker, - r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0); - storage.start(); - cb.waitForFinishedEncode(); - assertEquals(storage.segments.length, 1); - assertEquals(storage.segments[0].dataBlockCount, 2); - assertEquals(storage.segments[0].checkBlockCount, 3); - assertEquals(storage.segments[0].crossCheckBlockCount, 0); - assertTrue(storage.getStatus() == Status.ENCODED); + SplitFileInserterStorage storage = createSplitFileInserterStorage(data, size, cb, true, baseContext.clone(), cryptoAlgorithm, cryptoKey, hashes, random, memoryLimitedJobRunner, keys); + assertProperSegmentStateAndGet(storage); executor.waitForIdle(); - SplitFileInserterStorage resumed = new SplitFileInserterStorage(storage.getRAF(), data, cb, r, - memoryLimitedJobRunner, jobRunner, ticker, keys, fg, persistentFileTracker, null); - assertEquals(resumed.segments.length, 1); - SplitFileInserterSegmentStorage segment = resumed.segments[0]; - assertEquals(segment.dataBlockCount, 2); - assertEquals(segment.checkBlockCount, 3); - assertEquals(segment.crossCheckBlockCount, 0); - assertTrue(resumed.getStatus() == Status.ENCODED); - for(int i=0;i cb.waitForSucceededInsert()); + assertEquals(InsertExceptionMode.TOO_MANY_RETRIES_IN_BLOCKS, e.mode); + assertNotNull(e.errorCodes); + assertEquals(3, e.errorCodes.getErrorCount(InsertExceptionMode.ROUTE_NOT_FOUND)); + assertEquals(3, e.errorCodes.totalCount()); assertEquals(Status.FAILED, resumed.getStatus()); } @Test - public void testPersistentSmallSplitfileNoLastBlockChooseAfterResume() throws IOException, InsertException, StorageFormatException, ChecksumFailedException, ResumeFailedException { - Random r = new Random(12121); - long size = 65536; // Exact multiple, so no last block - LockableRandomAccessBuffer data = generateData(r, size, bigRAFFactory); + public void testPersistentSmallSplitfileNoLastBlockChooseAfterResume() throws Exception { + LockableRandomAccessBuffer data = generateData(random, size, bigRAFFactory); HashResult[] hashes = getHashes(data); - MyCallback cb = new MyCallback(); - MyKeysFetchingLocally keys = new MyKeysFetchingLocally(); - InsertContext context = baseContext.clone(); context.consecutiveRNFsCountAsSuccess = 0; context.maxInsertRetries = 1; - SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null, - new ClientMetadata(), false, null, smallRAFFactory, true, context, - cryptoAlgorithm, cryptoKey, null, hashes, smallBucketFactory, checker, - r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0); - storage.start(); - cb.waitForFinishedEncode(); - assertEquals(storage.segments.length, 1); - assertEquals(storage.segments[0].dataBlockCount, 2); - assertEquals(storage.segments[0].checkBlockCount, 3); - assertEquals(storage.segments[0].crossCheckBlockCount, 0); - assertTrue(storage.getStatus() == Status.ENCODED); + SplitFileInserterStorage storage = createSplitFileInserterStorage(data, size, cb, true, context, cryptoAlgorithm, cryptoKey, hashes, random, memoryLimitedJobRunner, keys); + assertProperSegmentStateAndGet(storage); SplitFileInserterStorage resumed = null; int totalBlockCount = storage.segments[0].totalBlockCount; - + boolean[] chosenBlocks = new boolean[totalBlockCount]; // Choose and fail all blocks. - for(int i=0;i decompressors, + short cmode, + FetchContext fctx, + RandomSource r + ) throws FetchException, MetadataParseException, IOException { + return new SplitFileFetcherStorage( + m1, + fcb, + decompressors, + new ClientMetadata(), + false, + cmode, + fctx, + false, + salt, + URI, + URI, + true, + new byte[0], + r, + smallBucketFactory, + smallRAFFactory, + jobRunner, + ticker, + memoryLimitedJobRunner, + checker, + false, + null, + null, + keys + ); + } + + private SplitFileInserterSegmentStorage assertProperSegmentStateAndGet(SplitFileInserterStorage storage) { + assertEquals(1, storage.segments.length); + SplitFileInserterSegmentStorage segment = storage.segments[0]; + assertEquals(2, segment.dataBlockCount); + assertEquals(3, segment.checkBlockCount); + assertEquals(0, segment.crossCheckBlockCount); + assertEquals(Status.ENCODED, storage.getStatus()); + return segment; + } } From 583e8885966f196a44a1e1db9aab95194fea0b7d Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Mon, 23 Jan 2023 19:29:27 +0200 Subject: [PATCH 047/500] Improve other tests in the freenet.client package wrap input/output streams with try-with-resources remove duplication use better assertion methods create helper utility ResourceFileUtil Signed-off-by: Veniamin Fernandes --- test/freenet/client/CodeTest.java | 262 +++---- test/freenet/client/DefaultMIMETypesTest.java | 26 +- .../client/FailureCodeTrackerTest.java | 18 +- test/freenet/client/FetchContextTest.java | 36 +- test/freenet/client/OnionFECCodecTest.java | 181 ++--- test/freenet/client/filter/BMPFilterTest.java | 318 ++++---- test/freenet/client/filter/CSSParserTest.java | 336 ++++---- .../client/filter/ContentFilterTest.java | 722 +++++++++--------- .../client/filter/FilterUtilsTest.java | 2 +- test/freenet/client/filter/GIFFilterTest.java | 19 +- .../freenet/client/filter/JPEGFilterTest.java | 11 +- test/freenet/client/filter/M3UFilterTest.java | 28 +- test/freenet/client/filter/MP3FilterTest.java | 33 +- .../client/filter/OggBitStreamFilterTest.java | 49 +- test/freenet/client/filter/OggFilterTest.java | 87 ++- test/freenet/client/filter/OggPageTest.java | 66 +- test/freenet/client/filter/PNGFilterTest.java | 22 +- .../client/filter/ResourceFileUtil.java | 41 + .../client/filter/TagVerifierTest.java | 63 +- .../filter/TheoraBitstreamFilterTest.java | 22 +- 20 files changed, 1186 insertions(+), 1156 deletions(-) create mode 100644 test/freenet/client/filter/ResourceFileUtil.java diff --git a/test/freenet/client/CodeTest.java b/test/freenet/client/CodeTest.java index 181b4feec41..439dd4e3aca 100644 --- a/test/freenet/client/CodeTest.java +++ b/test/freenet/client/CodeTest.java @@ -15,133 +15,137 @@ public class CodeTest { - public static FECMath fecMath = new FECMath(8); - - public static final int KK = 192; - public static final int PACKET_SIZE = 4096; - - /** - * Creates k packets of size sz of random data, encodes them, and tries to decode. Index - * contains the permutation entry. - */ - private static final void encodeDecode(FECCode encode, FECCode decode, int index[]) { - byte[] src = new byte[KK * PACKET_SIZE]; - Util.rand.nextBytes(src); - Buffer[] srcBufs = new Buffer[KK]; - for (int i = 0; i < srcBufs.length; i++) - srcBufs[i] = new Buffer(src, i * PACKET_SIZE, PACKET_SIZE); - - byte[] repair = new byte[KK * PACKET_SIZE]; - Buffer[] repairBufs = new Buffer[KK]; - for (int i = 0; i < repairBufs.length; i++) { - repairBufs[i] = new Buffer(repair, i * PACKET_SIZE, PACKET_SIZE); - } - - encode.encode(srcBufs, repairBufs, index); - decode.decode(repairBufs, index); - - for (int i = 0; i < src.length; i++) - assertEquals(src[i], repair[i]); - } - - @Test - public void testBenchmark() { - if(!TestProperty.BENCHMARK) return; - - int lim = fecMath.gfSize + 1; - FECCode maybeNative = FECCodeFactory.getDefault().createFECCode(KK, lim); - FECCode pureCode = new PureCode(KK, lim); - int[] index = new int[KK]; - - for (int i = 0; i < KK; i++) - index[i] = lim - i - 1; - - byte[] src = new byte[KK * PACKET_SIZE]; - Util.rand.nextBytes(src); - Buffer[] srcBufs = new Buffer[KK]; - for (int i = 0; i < srcBufs.length; i++) - srcBufs[i] = new Buffer(src, i * PACKET_SIZE, PACKET_SIZE); - - byte[] repair = new byte[KK * PACKET_SIZE]; - Buffer[] repairBufs = new Buffer[KK]; - for (int i = 0; i < repairBufs.length; i++) { - repairBufs[i] = new Buffer(repair, i * PACKET_SIZE, PACKET_SIZE); - } - - int[] indexBackup = new int[index.length]; - System.arraycopy(index,0,indexBackup,0,index.length); - - System.out.println("Getting ready for benchmarking encode()"); - long t1 = System.currentTimeMillis(); - maybeNative.encode(srcBufs, repairBufs, index); - long t2 = System.currentTimeMillis(); - pureCode.encode(srcBufs, repairBufs, indexBackup); - long t3 = System.currentTimeMillis(); - - float dNativeEncode = t2 - t1; - float dPureEncode = t3 - t2; - - Buffer[] repairBufs2 = repairBufs.clone(); - System.arraycopy(repairBufs, 0, repairBufs2, 0, repairBufs.length); - System.out.println("Getting ready for benchmarking decode()"); - t1 = System.currentTimeMillis(); - maybeNative.decode(repairBufs, index); - t2 = System.currentTimeMillis(); - pureCode.decode(repairBufs2, indexBackup); - t3 = System.currentTimeMillis(); - - float dNativeDecode = t2 - t1; - float dPureDecode = t3 - t2; - - System.out.println(maybeNative); - System.out.println(pureCode); - System.out.println("Native code took "+dNativeEncode+"ms whereas java's code took "+dPureEncode+"ms to encode()"); - System.out.println("Native code took "+dNativeDecode+"ms whereas java's code took "+dPureDecode+"ms to decode()"); - } - - @Test - public void testSimpleRev() { - int lim = fecMath.gfSize + 1; - FECCode code = FECCodeFactory.getDefault().createFECCode(KK, lim); - FECCode code2 = new PureCode(KK, lim); - int[] index = new int[KK]; - - for (int i = 0; i < KK; i++) - index[i] = lim - i - 1; - - encodeDecode(code, code2, index); - encodeDecode(code2, code, index); - } - - @Test - public void testSimple() { - int lim = fecMath.gfSize + 1; - FECCode code = FECCodeFactory.getDefault().createFECCode(KK, lim); - FECCode code2 = new PureCode(KK, lim); - int[] index = new int[KK]; - - for (int i = 0; i < KK; i++) - index[i] = KK - i; - encodeDecode(code, code2, index); - encodeDecode(code2, code, index); - } - - @Test - public void testShifted() { - int lim = fecMath.gfSize + 1; - FECCode code = FECCodeFactory.getDefault().createFECCode(KK, lim); - FECCode code2 = new PureCode(KK, lim); - int[] index = new int[KK]; - - int max_i0 = KK / 2; - if (max_i0 + KK > lim) - max_i0 = lim - KK; - - for (int s = max_i0 - 2; s <= max_i0; s++) { - for (int i = 0; i < KK; i++) - index[i] = i + s; - encodeDecode(code, code2, index); - encodeDecode(code2, code, index); - } - } + public static FECMath fecMath = new FECMath(8); + + public static final int KK = 192; + public static final int PACKET_SIZE = 4096; + + /** + * Creates k packets of size sz of random data, encodes them, and tries to decode. Index + * contains the permutation entry. + */ + private static void encodeDecode(FECCode encode, FECCode decode, int[] index) { + byte[] src = new byte[KK * PACKET_SIZE]; + Util.rand.nextBytes(src); + Buffer[] srcBufs = createBuffers(src); + + byte[] repair = new byte[KK * PACKET_SIZE]; + Buffer[] repairBufs = createBuffers(repair); + + encode.encode(srcBufs, repairBufs, index); + decode.decode(repairBufs, index); + + assertArrayEquals(src, repair); + } + + @Test + public void testBenchmark() { + if (!TestProperty.BENCHMARK) { + return; + } + + int lim = fecMath.gfSize + 1; + FECCode maybeNative = FECCodeFactory.getDefault().createFECCode(KK, lim); + FECCode pureCode = new PureCode(KK, lim); + int[] index = new int[KK]; + + for (int i = 0; i < KK; i++) { + index[i] = lim - i - 1; + } + + byte[] src = new byte[KK * PACKET_SIZE]; + Util.rand.nextBytes(src); + Buffer[] srcBufs = createBuffers(src); + + byte[] repair = new byte[KK * PACKET_SIZE]; + Buffer[] repairBufs = createBuffers(repair); + + int[] indexBackup = new int[index.length]; + System.arraycopy(index, 0, indexBackup, 0, index.length); + + System.out.println("Getting ready for benchmarking encode()"); + long t1 = System.currentTimeMillis(); + maybeNative.encode(srcBufs, repairBufs, index); + long t2 = System.currentTimeMillis(); + pureCode.encode(srcBufs, repairBufs, indexBackup); + long t3 = System.currentTimeMillis(); + + float dNativeEncode = t2 - t1; + float dPureEncode = t3 - t2; + + Buffer[] repairBufs2 = repairBufs.clone(); + System.arraycopy(repairBufs, 0, repairBufs2, 0, repairBufs.length); + System.out.println("Getting ready for benchmarking decode()"); + t1 = System.currentTimeMillis(); + maybeNative.decode(repairBufs, index); + t2 = System.currentTimeMillis(); + pureCode.decode(repairBufs2, indexBackup); + t3 = System.currentTimeMillis(); + + float dNativeDecode = t2 - t1; + float dPureDecode = t3 - t2; + + System.out.println(maybeNative); + System.out.println(pureCode); + System.out.println("Native code took " + dNativeEncode + "ms whereas java's code took " + dPureEncode + "ms to encode()"); + System.out.println("Native code took " + dNativeDecode + "ms whereas java's code took " + dPureDecode + "ms to decode()"); + } + + @Test + public void testSimpleRev() { + int lim = fecMath.gfSize + 1; + FECCode code = FECCodeFactory.getDefault().createFECCode(KK, lim); + FECCode code2 = new PureCode(KK, lim); + int[] index = new int[KK]; + + for (int i = 0; i < KK; i++) { + index[i] = lim - i - 1; + } + + encodeDecode(code, code2, index); + encodeDecode(code2, code, index); + } + + @Test + public void testSimple() { + int lim = fecMath.gfSize + 1; + FECCode code = FECCodeFactory.getDefault().createFECCode(KK, lim); + FECCode code2 = new PureCode(KK, lim); + int[] index = new int[KK]; + + for (int i = 0; i < KK; i++) { + index[i] = KK - i; + } + encodeDecode(code, code2, index); + encodeDecode(code2, code, index); + } + + @Test + public void testShifted() { + int lim = fecMath.gfSize + 1; + FECCode code = FECCodeFactory.getDefault().createFECCode(KK, lim); + FECCode code2 = new PureCode(KK, lim); + int[] index = new int[KK]; + + int max_i0 = KK / 2; + if (max_i0 + KK > lim) { + max_i0 = lim - KK; + } + + for (int s = max_i0 - 2; s <= max_i0; s++) { + for (int i = 0; i < KK; i++) { + index[i] = i + s; + } + encodeDecode(code, code2, index); + encodeDecode(code2, code, index); + } + } + + private static Buffer[] createBuffers(byte[] src) { + Buffer[] srcBufs = new Buffer[KK]; + for (int i = 0; i < srcBufs.length; i++) { + srcBufs[i] = new Buffer(src, i * PACKET_SIZE, PACKET_SIZE); + } + return srcBufs; + } } diff --git a/test/freenet/client/DefaultMIMETypesTest.java b/test/freenet/client/DefaultMIMETypesTest.java index 1b9ca9b0b6a..590759f0b72 100644 --- a/test/freenet/client/DefaultMIMETypesTest.java +++ b/test/freenet/client/DefaultMIMETypesTest.java @@ -5,18 +5,18 @@ import org.junit.Test; public class DefaultMIMETypesTest { - - @Test - public void testFullList() { - for(String mimeType : DefaultMIMETypes.getMIMETypes()) { - assertTrue("Failed: \""+mimeType+"\"", DefaultMIMETypes.isPlausibleMIMEType(mimeType)); - } - } - - @Test - public void testParams() { - assertTrue(DefaultMIMETypes.isPlausibleMIMEType("text/xhtml+xml; charset=ISO-8859-1; blah=blah")); - assertTrue(DefaultMIMETypes.isPlausibleMIMEType("multipart/mixed; boundary=\"---this is a silly boundary---\"")); - } + + @Test + public void testFullList() { + for (String mimeType : DefaultMIMETypes.getMIMETypes()) { + assertTrue("Failed: \"" + mimeType + "\"", DefaultMIMETypes.isPlausibleMIMEType(mimeType)); + } + } + + @Test + public void testParams() { + assertTrue(DefaultMIMETypes.isPlausibleMIMEType("text/xhtml+xml; charset=ISO-8859-1; blah=blah")); + assertTrue(DefaultMIMETypes.isPlausibleMIMEType("multipart/mixed; boundary=\"---this is a silly boundary---\"")); + } } diff --git a/test/freenet/client/FailureCodeTrackerTest.java b/test/freenet/client/FailureCodeTrackerTest.java index 18bc0a21c30..cd8690c3144 100644 --- a/test/freenet/client/FailureCodeTrackerTest.java +++ b/test/freenet/client/FailureCodeTrackerTest.java @@ -12,13 +12,15 @@ public class FailureCodeTrackerTest { - /** Test that the fixed size representation really is fixed size */ + /** + * Test that the fixed size representation really is fixed size + */ @Test public void testSize() throws IOException { testSize(false); testSize(true); } - + public void testSize(boolean insert) throws IOException { FailureCodeTracker f = new FailureCodeTracker(insert); int fixedLength = FailureCodeTracker.getFixedLength(insert); @@ -30,11 +32,13 @@ public void testSize(boolean insert) throws IOException { } private int getStoredLength(FailureCodeTracker f) throws IOException { - CountedOutputStream os = new CountedOutputStream(new NullOutputStream()); - DataOutputStream dos = new DataOutputStream(os); - f.writeFixedLengthTo(dos); - dos.close(); - return (int) os.written(); + try ( + CountedOutputStream os = new CountedOutputStream(new NullOutputStream()); + DataOutputStream dos = new DataOutputStream(os) + ) { + f.writeFixedLengthTo(dos); + return (int) os.written(); + } } } diff --git a/test/freenet/client/FetchContextTest.java b/test/freenet/client/FetchContextTest.java index c5051e0c642..2c4ac174f67 100644 --- a/test/freenet/client/FetchContextTest.java +++ b/test/freenet/client/FetchContextTest.java @@ -14,22 +14,28 @@ import freenet.support.io.StorageFormatException; public class FetchContextTest { - + @Test public void testPersistence() throws IOException, StorageFormatException { - FetchContext context = - HighLevelSimpleClientImpl.makeDefaultFetchContext(Long.MAX_VALUE, Long.MAX_VALUE, - new ArrayBucketFactory(), new SimpleEventProducer()); - ArrayBucket bucket = new ArrayBucket(); - DataOutputStream dos = new DataOutputStream(bucket.getOutputStream()); - context.writeTo(dos); - dos.close(); - assert(bucket.size() != 0); - DataInputStream dis = new DataInputStream(bucket.getInputStream()); - FetchContext ctx = new FetchContext(dis); - dis.close(); - assertTrue(ctx.equals(context)); - bucket.free(); + FetchContext context = HighLevelSimpleClientImpl.makeDefaultFetchContext( + Long.MAX_VALUE, + Long.MAX_VALUE, + new ArrayBucketFactory(), + new SimpleEventProducer() + ); + final ArrayBucket bucket = new ArrayBucket(); + try { + try (DataOutputStream dos = new DataOutputStream(bucket.getOutputStream())) { + context.writeTo(dos); + } + assertNotEquals(0, bucket.size()); + FetchContext ctx; + try (DataInputStream dis = new DataInputStream(bucket.getInputStream())) { + ctx = new FetchContext(dis); + } + assertEquals(ctx, context); + } finally { + bucket.free(); + } } - } diff --git a/test/freenet/client/OnionFECCodecTest.java b/test/freenet/client/OnionFECCodecTest.java index 9fcea82999e..75877642dc1 100644 --- a/test/freenet/client/OnionFECCodecTest.java +++ b/test/freenet/client/OnionFECCodecTest.java @@ -5,16 +5,18 @@ import java.util.Arrays; import java.util.Random; +import org.junit.Before; import org.junit.Test; import freenet.support.TestProperty; -/** Test the new (post db4o) high level FEC API */ +/** + * Test the new (post db4o) high level FEC API + */ public class OnionFECCodecTest { - + private static final int BLOCK_SIZE = 4096; - private static final int MAX_SEGMENT_SIZE = 255; - + private final OnionFECCodec codec = new OnionFECCodec(); private byte[][] originalDataBlocks; private byte[][] dataBlocks; @@ -22,150 +24,151 @@ public class OnionFECCodecTest { private byte[][] checkBlocks; private boolean[] checkBlocksPresent; private boolean[] dataBlocksPresent; - + private Random random; + + @Before + public void setUp() throws Exception { + random = new Random(21482106); + } + @Test public void testDecodeRandomSubset() { - Random r = new Random(19412106); int iterations = TestProperty.EXTENSIVE ? 100 : 10; - for(int i=0;i codec.encode(dataBlocks, checkBlocks, checkBlocksPresent, BLOCK_SIZE) + ); } - + @Test public void testDecodeThrowsOnNotPaddedLastBlock() { - Random r = new Random(21482106); - setup(128, 128, r); + setup(128, 128, random); // Now delete a random selection of blocks - deleteRandomBlocks(r); - dataBlocks[127] = new byte[BLOCK_SIZE/2]; - try { - codec.decode(dataBlocks, checkBlocks, dataBlocksPresent, checkBlocksPresent, BLOCK_SIZE); - assertTrue(false); // Should throw - } catch (IllegalArgumentException e) { - // Ok. - } + deleteRandomBlocks(random); + dataBlocks[127] = new byte[BLOCK_SIZE / 2]; + assertThrows( + IllegalArgumentException.class, + () -> codec.encode(dataBlocks, checkBlocks, checkBlocksPresent, BLOCK_SIZE) + ); } - + @Test public void testDecodeAlreadyDecoded() { - Random r = new Random(21482106); - setup(128, 128, r); + setup(128, 128, random); // Now delete a random selection of blocks deleteAllCheckBlocks(); decode(); // Should be a no-op. } - + @Test public void testDecodeNoneDecoded() { - Random r = new Random(21482106); - setup(128, 128, r); + setup(128, 128, random); // Now delete a random selection of blocks deleteAllDataBlocks(); decode(); } - + @Test public void testManyCheckFewData() { - Random r = new Random(21582106); - inner(2, 253, r); - inner(5, 250, r); - inner(50, 200, r); - inner(2, 3, r); // Common case, include it here. + inner(2, 253, random); + inner(5, 250, random); + inner(50, 200, random); + inner(2, 3, random); // Common case, include it here. } - + @Test public void testManyDataFewCheck() { - Random r = new Random(21592106); - inner(200, 55, r); - inner(253, 2, r); + inner(200, 55, random); + inner(253, 2, random); } - + @Test public void testRandomDataCheckCounts() { - Random r = new Random(21602106); int iterations = TestProperty.EXTENSIVE ? 100 : 10; - for(int i=0;i expected) { - BMPFilter objBMPFilter = new BMPFilter(); - Bucket output = new ArrayBucket(); - - InputStream inStream; - OutputStream outStream; - try { - inStream = input.getInputStream(); - outStream = output.getOutputStream(); - } catch (IOException e) { - e.printStackTrace(); - fail("Caugth unexpected IOException: " + e); - return null; //Convince the compiler that we won't continue - } - - try { - objBMPFilter.readFilter(inStream, outStream, "", null, null, null); - - if(expected != null) { - fail("Filter didn't throw expected exception"); - } - } catch (Exception e) { - if((expected == null) || (!expected.equals(e.getClass()))) { - //Exception is not the one we expected - e.printStackTrace(); - fail("Caugth unexpected exception: " + e.getClass() + ": " + e.getMessage()); - } - } - - try { - inStream.close(); - outStream.close(); - } catch(IOException e) { - e.printStackTrace(); - fail("Caugth unexpected IOException: " + e); - return null; //Convince the compiler that we won't continue - } - - return output; - } - - private Bucket resourceToBucket(String filename) throws IOException { - InputStream is = getClass().getResourceAsStream(filename); - if (is == null) throw new FileNotFoundException(); - Bucket ab = new ArrayBucket(); - BucketTools.copyFrom(ab, is, Long.MAX_VALUE); - return ab; - } + /** + * File of size less than 54 bytes + */ + @Test + public void testTooShortImage() throws IOException { + Bucket input = resourceToBucket("./bmp/small.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Illegal start word (AB instead of BM) + */ + @Test + public void testIllegalStartWord() throws IOException { + Bucket input = resourceToBucket("./bmp/one.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid offset i.e. starting address + */ + @Test + public void testInvalidOffset() throws IOException { + Bucket input = resourceToBucket("./bmp/two.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid size of bitmap info header + */ + @Test + public void testInvalidBitmapInfoHeaderSize() throws IOException { + Bucket input = resourceToBucket("./bmp/three.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Negative image width + */ + @Test + public void testNegativeImageWidth() throws IOException { + Bucket input = resourceToBucket("./bmp/four.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid number of planes + */ + @Test + public void testInvalidNumberOfPlanes() throws IOException { + Bucket input = resourceToBucket("./bmp/five.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid bit depth + */ + @Test + public void testInvalidBitDepth() throws IOException { + Bucket input = resourceToBucket("./bmp/six.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid compression type + */ + @Test + public void testInvalidCompressionType() throws IOException { + Bucket input = resourceToBucket("./bmp/seven.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid image data size (i.e. not satisfying fileSize = headerSize + imagedatasize) + */ + @Test + public void testInvalidImageDataSize() throws IOException { + Bucket input = resourceToBucket("./bmp/eight.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Invalid image resolution + */ + @Test + public void testInvalidImageResolution() throws IOException { + Bucket input = resourceToBucket("./bmp/nine.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * File is shorter than expected + */ + @Test + public void testNotEnoughImageData() throws IOException { + Bucket input = resourceToBucket("./bmp/ten.bmp"); + filterImage(input, DataFilterException.class); + } + + /** + * Tests valid image + */ + @Test + public void testValidImage() throws IOException { + Bucket input = resourceToBucket("./bmp/ok.bmp"); + Bucket output = filterImage(input, null); + + //Filter should return the original + assertEquals("Input and output should be the same length", input.size(), output.size()); + assertArrayEquals("Input and output are not identical", BucketTools.toByteArray(input), BucketTools.toByteArray(output)); + } + + /** + * Checks that the image size calculation works for images with padding + */ + @Test + public void testImageSizeCalculationWithPadding() throws IOException { + Bucket input = resourceToBucket("./bmp/sizeCalculationWithPadding.bmp"); + Bucket output = filterImage(input, null); + + //Filter should return the original + assertEquals("Input and output should be the same length", input.size(), output.size()); + assertArrayEquals("Input and output are not identical", BucketTools.toByteArray(input), BucketTools.toByteArray(output)); + } + + /** + * Checks that the image size calculation works for images without padding + */ + @Test + public void testImageSizeCalculationWithoutPadding() throws IOException { + Bucket input = resourceToBucket("./bmp/sizeCalculationWithoutPadding.bmp"); + Bucket output = filterImage(input, null); + + //Filter should return the original + assertEquals("Input and output should be the same length", input.size(), output.size()); + assertArrayEquals("Input and output are not identical", BucketTools.toByteArray(input), BucketTools.toByteArray(output)); + } + + private Bucket filterImage(Bucket input, Class expected) throws IOException { + BMPFilter objBMPFilter = new BMPFilter(); + Bucket output = new ArrayBucket(); + try ( + InputStream inStream = input.getInputStream(); + OutputStream outStream = output.getOutputStream() + ) { + if (expected != null) { + assertThrows(expected, () -> readFilter(objBMPFilter, inStream, outStream)); + } else { + readFilter(objBMPFilter, inStream, outStream); + } + } + return output; + } + + private static void readFilter(BMPFilter objBMPFilter, InputStream inStream, OutputStream outStream) throws IOException { + objBMPFilter.readFilter(inStream, outStream, "", null, null, null); + } } diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index 3830f0b2743..b199c8b5c1e 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -1,5 +1,7 @@ package freenet.client.filter; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalToIgnoringCase; import static org.junit.Assert.*; import java.io.IOException; @@ -9,13 +11,10 @@ import java.io.StringWriter; import java.net.URI; import java.net.URISyntaxException; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; +import java.util.*; import java.util.Map.Entry; +import org.hamcrest.MatcherAssert; import org.junit.Before; import org.junit.Test; @@ -33,9 +32,8 @@ public class CSSParserTest { // FIXME should specify exact output values /** CSS1 Selectors */ - private final static HashMap CSS1_SELECTOR= new HashMap(); - static - { + private final static HashMap CSS1_SELECTOR= new HashMap<>(); + static { CSS1_SELECTOR.put("h1 {}","h1"); CSS1_SELECTOR.put("h1:link {}","h1:link"); CSS1_SELECTOR.put("h1:visited {}",""); @@ -47,17 +45,12 @@ public class CSSParserTest { CSS1_SELECTOR.put("h1:focus {}" ,"h1:focus"); CSS1_SELECTOR.put("h1:first-line {}" ,"h1:first-line"); CSS1_SELECTOR.put("h1:first-letter {}" ,"h1:first-letter"); - - - - } // FIXME should specify exact output values /** CSS2 Selectors */ - private final static HashMap CSS2_SELECTOR= new HashMap(); - static - { + private final static HashMap CSS2_SELECTOR= new HashMap<>(); + static { CSS2_SELECTOR.put("* {}","*"); CSS2_SELECTOR.put("h1[foo] {}","h1[foo]"); CSS2_SELECTOR.put("h1[foo=\"bar\"] {}", "h1[foo=\"bar\"]"); @@ -120,9 +113,8 @@ public class CSSParserTest { // CONFORMANCE: We combine pseudo-classes and pseudo-elements, so we allow pseudo-elements on earlier selectors. This is against the spec, CSS2 section 5.10. } - private final static HashSet CSS2_BAD_SELECTOR= new HashSet(); - static - { + private final static HashSet CSS2_BAD_SELECTOR= new HashSet<>(); + static { // Doubled = CSS2_BAD_SELECTOR.add("h1[foo=bar=bat] {}"); CSS2_BAD_SELECTOR.add("h1[foo~=bar~=bat] {}"); @@ -147,9 +139,8 @@ public class CSSParserTest { /** CSS3 Selectors */ - private final static HashMap CSS3_SELECTOR= new HashMap(); - static - { + private final static HashMap CSS3_SELECTOR= new HashMap<>(); + static { CSS3_SELECTOR.put("tr:nth-child(odd) { background-color: red; }","tr:nth-child(odd) { background-color: red; }"); CSS3_SELECTOR.put("tr:nth-child(even) { background-color: yellow; }","tr:nth-child(even) { background-color: yellow; }"); CSS3_SELECTOR.put("tr:nth-child(1) {}","tr:nth-child(1)"); @@ -183,9 +174,8 @@ public class CSSParserTest { CSS3_SELECTOR.put("h1:nth-last-of-type(even) {}","h1:nth-last-of-type(even)"); } - private final static HashSet CSS3_BAD_SELECTOR= new HashSet(); - static - { + private final static HashSet CSS3_BAD_SELECTOR= new HashSet<>(); + static { CSS3_BAD_SELECTOR.add("tr:nth-child() {}"); CSS3_BAD_SELECTOR.add("tr:nth-child(-) {}"); CSS3_BAD_SELECTOR.add("tr:nth-child(+) {}"); @@ -254,10 +244,10 @@ public class CSSParserTest { private static final String CSS_IMPORT_SPACE_IN_STRING = "@import url(\"/chk@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test page\") screen;"; private static final String CSS_IMPORT_SPACE_IN_STRINGC = "@import url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page?type=text/css&maybecharset=UTF-8\") screen;"; - private static final String CSS_IMPORT_QUOTED_STUFF = "@import url(\"/chk@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test page \\) \\\\ \\\' \\\" \") screen;"; + private static final String CSS_IMPORT_QUOTED_STUFF = "@import url(\"/chk@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test page \\) \\\\ \\' \\\" \") screen;"; private static final String CSS_IMPORT_QUOTED_STUFFC = "@import url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page%20%29%20%5c%20%27%20%22%20?type=text/css&maybecharset=UTF-8\") screen;"; - private static final String CSS_IMPORT_QUOTED_STUFF2 = "@import url(/chk@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test page \\) \\\\ \\\' \\\" ) screen;"; + private static final String CSS_IMPORT_QUOTED_STUFF2 = "@import url(/chk@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test page \\) \\\\ \\' \\\" ) screen;"; private static final String CSS_IMPORT_QUOTED_STUFF2C = "@import url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page%20%29%20%5c%20%27%20%22?type=text/css&maybecharset=UTF-8\") screen;"; private static final String CSS_IMPORT_NOURL_TWOMEDIAS = "@import \"/chk@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/1-1.html\" screen tty;"; @@ -324,7 +314,7 @@ public class CSSParserTest { private static final String CSS_INVALID_MEDIA_CASCADE = "@media blah { h1, h2 { color: green;} }"; - private final static LinkedHashMap propertyTests = new LinkedHashMap(); + private final static LinkedHashMap propertyTests = new LinkedHashMap<>(); static { // Check that the last part of a double bar works propertyTests.put("@media speech { h1 { azimuth: behind }; }", "@media speech { h1 { azimuth: behind }}"); @@ -464,7 +454,6 @@ public class CSSParserTest { propertyTests.put("H3 { BACKGROUND: URL(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test page\") }", "H3 { BACKGROUND: url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }"); propertyTests.put("h3 { background: scroll url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }", "h3 { background: scroll url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }"); propertyTests.put("h3 { background: scroll #f00 url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }", "h3 { background: scroll #f00 url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }"); - propertyTests.put("h3 { background: scroll #f00 url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }", "h3 { background: scroll #f00 url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }"); propertyTests.put("h3 { background: scroll rgb(100%, 2%, 1%) url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }", "h3 { background: scroll rgb(100%, 2%, 1%) url(\"/CHK@~~vxVQDfC9m8sR~M9zWJQKzCxLeZRWy6T1pWLM2XX74,2LY7xwOdUGv0AeJ2WKRXZG6NmiUL~oqVLKnh3XdviZU,AAIC--8/test%20page\") }"); propertyTests.put("h3 { background: 3.3cm 20%;}", "h3 { background: 3.3cm 20%;}"); propertyTests.put("h3 { background: scroll 3.3cm 20%;}", "h3 { background: scroll 3.3cm 20%;}"); @@ -825,11 +814,9 @@ public class CSSParserTest { propertyTests.put("nav > ul { display: flex; }", "nav>ul { display: flex; }"); propertyTests.put("nav > ul > li {\n min-width: 100px;\n /* Prevent items from getting too small for their content. */\n }", "nav>ul>li {\n min-width: 100px;\n \n }"); propertyTests.put("nav > ul > #login {\n margin-left: auto;\n}", "nav>ul>#login {\n margin-left: auto;\n}"); - propertyTests.put("nav > ul { display: flex; }", "nav>ul { display: flex; }"); propertyTests.put("div { flex-flow: row nowrap; }", "div { flex-flow: row nowrap; }"); propertyTests.put("div { flex-grow: 5; }", "div { flex-grow: 5; }"); propertyTests.put("div { flex: 64 content; }", "div { flex: 64 content; }"); - propertyTests.put("div { flex-grow: 5; }", "div { flex-grow: 5; }"); propertyTests.put("div { flex-basis: 5px; }", "div { flex-basis: 5px; }"); propertyTests.put("div { flex-basis: content; }", "div { flex-basis: content; }"); propertyTests.put("div { flex: 64 ; }", "div { flex: 64; }"); @@ -880,8 +867,8 @@ public class CSSParserTest { propertyTests.put("body { nav-left: div.bold ''; }", "body { }"); propertyTests.put("button#foo { nav-left: #bar \"sidebar\"; }", "button#foo { nav-left: #bar \"sidebar\"; }"); propertyTests.put("button#foo { nav-left: invalidSelector \"sidebar\"; }", "button#foo { }"); - - // transition-* + + // transition-* // valid, 1 value propertyTests.put("div { transition-duration: 5s; }", "div { transition-duration: 5s; }"); propertyTests.put("div { transition-delay: 1s; }", "div { transition-delay: 1s; }"); @@ -918,104 +905,99 @@ public void setUp() throws InvalidThresholdException { @Test public void testCSS1Selector() throws IOException, URISyntaxException { + testCssSelectorFiltering(CSS1_SELECTOR); + assertEquals( + "key=\"" + CSS_DELETE_INVALID_SELECTOR + "\" value=\"" + filter(CSS_DELETE_INVALID_SELECTOR) + "\" should be \"" + CSS_DELETE_INVALID_SELECTORC + "\"", + CSS_DELETE_INVALID_SELECTORC, + filter(CSS_DELETE_INVALID_SELECTOR) + ); + assertEquals( + "key=\"" + CSS_INVALID_MEDIA_CASCADE + "\" value=\"" + filter(CSS_INVALID_MEDIA_CASCADE) + "\"", + "", + filter(CSS_INVALID_MEDIA_CASCADE) + ); + } - - Collection c = CSS1_SELECTOR.keySet(); - Iterator itr = c.iterator(); - while(itr.hasNext()) - { - - String key=itr.next(); - String value=CSS1_SELECTOR.get(key); - assertTrue("key=\""+key+"\" value=\""+filter(key)+"\" should be \""+value+"\"", filter(key).contains(value)); + private void testCssSelectorFiltering(Map cssSelectorMap) throws IOException, URISyntaxException { + for (Entry entry : cssSelectorMap.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + assertTrue("key=\"" + key + "\" value=\"" + filter(key) + "\" should be \"" + value + "\"", filter(key).contains(value)); } + } - assertTrue("key=\""+CSS_DELETE_INVALID_SELECTOR+"\" value=\""+filter(CSS_DELETE_INVALID_SELECTOR)+"\" should be \""+CSS_DELETE_INVALID_SELECTORC+"\"", CSS_DELETE_INVALID_SELECTORC.equals(filter(CSS_DELETE_INVALID_SELECTOR))); - assertTrue("key=\""+CSS_INVALID_MEDIA_CASCADE+"\" value=\""+filter(CSS_INVALID_MEDIA_CASCADE)+"\"", "".equals(filter(CSS_INVALID_MEDIA_CASCADE))); + private void testBadSelectorFiltering(Set badSelectorSet) throws IOException, URISyntaxException { + for(String key : badSelectorSet) { + assertEquals( + "Bad selector filtering should produce empty string: '" + key + "'", + "", + filter(key) + ); + } } @Test public void testCSS2Selector() throws IOException, URISyntaxException { - Collection c = CSS2_SELECTOR.keySet(); - Iterator itr = c.iterator(); - int i=0; - while(itr.hasNext()) - { - String key=itr.next(); - String value=CSS2_SELECTOR.get(key); - System.err.println("Test "+(i++)+" : "+key+" -> "+value); - assertTrue("key="+key+" value=\""+filter(key)+"\" should be \""+value+"\"", filter(key).contains(value)); - } - - i=0; - for(String key : CSS2_BAD_SELECTOR) { - System.err.println("Bad selector test "+(i++)); - assertTrue("".equals(filter(key))); - } - + testCssSelectorFiltering(CSS2_SELECTOR); + testBadSelectorFiltering(CSS2_BAD_SELECTOR); } @Test public void testCSS3Selector() throws IOException, URISyntaxException { - Collection c = CSS3_SELECTOR.keySet(); - Iterator itr = c.iterator(); - int i=0; - while(itr.hasNext()) - { - String key=itr.next(); - String value=CSS3_SELECTOR.get(key); - System.err.println("CSS3 test"+(i++)+" : "+key+" -> "+value); - assertTrue("key="+key+" value=\""+filter(key)+"\" should be \""+value+"\"", filter(key).contains(value)); - } - - i=0; - for(String key : CSS3_BAD_SELECTOR) { - System.err.println("CSS3 bad selector test "+(i++)); - assertTrue("".equals(filter(key))); - } - + testCssSelectorFiltering(CSS3_SELECTOR); + testBadSelectorFiltering(CSS3_BAD_SELECTOR); } @Test public void testNewlines() throws IOException, URISyntaxException { - assertTrue("key=\""+CSS_STRING_NEWLINES+"\" value=\""+filter(CSS_STRING_NEWLINES)+"\" should be: \""+CSS_STRING_NEWLINESC+"\"", CSS_STRING_NEWLINESC.equals(filter(CSS_STRING_NEWLINES))); + assertEquals( + "key=\"" + CSS_STRING_NEWLINES + "\" value=\"" + filter(CSS_STRING_NEWLINES) + "\" should be: \"" + CSS_STRING_NEWLINESC + "\"", + CSS_STRING_NEWLINESC, + filter(CSS_STRING_NEWLINES) + ); } @Test public void testBackgroundURL() throws IOException, URISyntaxException { - assertTrue("key="+CSS_BACKGROUND_URL+" value=\""+filter(CSS_BACKGROUND_URL)+"\" should be \""+CSS_BACKGROUND_URLC+"\"", CSS_BACKGROUND_URLC.equals(filter(CSS_BACKGROUND_URL))); - - assertTrue("key="+CSS_LCASE_BACKGROUND_URL+" value=\""+filter(CSS_LCASE_BACKGROUND_URL)+"\"", CSS_LCASE_BACKGROUND_URLC.equals(filter(CSS_LCASE_BACKGROUND_URL))); + assertEquals("key=" + CSS_BACKGROUND_URL + " value=\"" + filter(CSS_BACKGROUND_URL) + "\" should be \"" + CSS_BACKGROUND_URLC + "\"", + CSS_BACKGROUND_URLC, + filter(CSS_BACKGROUND_URL) + ); + assertEquals( + "key=" + CSS_LCASE_BACKGROUND_URL + " value=\"" + filter(CSS_LCASE_BACKGROUND_URL) + "\"", + CSS_LCASE_BACKGROUND_URLC, + filter(CSS_LCASE_BACKGROUND_URL) + ); } @Test public void testImports() throws IOException, URISyntaxException { - assertTrue("key="+CSS_IMPORT+" value=\""+filter(CSS_IMPORT)+"\"", CSS_IMPORTC.equals(filter(CSS_IMPORT))); - assertTrue("key="+CSS_IMPORT2+" value=\""+filter(CSS_IMPORT2)+"\"", CSS_IMPORT2C.equals(filter(CSS_IMPORT2))); - assertTrue("key="+CSS_IMPORT_MULTI_MEDIA+" value=\""+filter(CSS_IMPORT_MULTI_MEDIA)+"\"", CSS_IMPORT_MULTI_MEDIAC.equals(filter(CSS_IMPORT_MULTI_MEDIA))); - assertTrue("key="+CSS_IMPORT_MULTI_MEDIA_BOGUS+" value=\""+filter(CSS_IMPORT_MULTI_MEDIA_BOGUS)+"\"", CSS_IMPORT_MULTI_MEDIA_BOGUSC.equals(filter(CSS_IMPORT_MULTI_MEDIA_BOGUS))); - assertTrue("key="+CSS_IMPORT_MULTI_MEDIA_ALL+" value=\""+filter(CSS_IMPORT_MULTI_MEDIA_ALL)+"\"", CSS_IMPORT_MULTI_MEDIA_ALLC.equals(filter(CSS_IMPORT_MULTI_MEDIA_ALL))); - assertTrue("key="+CSS_IMPORT_TYPE+" value=\""+filter(CSS_IMPORT_TYPE)+"\"", CSS_IMPORT_TYPEC.equals(filter(CSS_IMPORT_TYPE))); - assertTrue("key="+CSS_IMPORT_SPACE_IN_STRING+" value=\""+filter(CSS_IMPORT_SPACE_IN_STRING)+"\"", CSS_IMPORT_SPACE_IN_STRINGC.equals(filter(CSS_IMPORT_SPACE_IN_STRING))); - assertTrue("key="+CSS_IMPORT_QUOTED_STUFF+" value=\""+filter(CSS_IMPORT_QUOTED_STUFF)+"\"", CSS_IMPORT_QUOTED_STUFFC.equals(filter(CSS_IMPORT_QUOTED_STUFF))); - assertTrue("key="+CSS_IMPORT_QUOTED_STUFF2+" value=\""+filter(CSS_IMPORT_QUOTED_STUFF2)+"\"", CSS_IMPORT_QUOTED_STUFF2C.equals(filter(CSS_IMPORT_QUOTED_STUFF2))); - assertTrue("key="+CSS_IMPORT_NOURL_TWOMEDIAS+" value=\""+filter(CSS_IMPORT_NOURL_TWOMEDIAS)+"\"", CSS_IMPORT_NOURL_TWOMEDIASC.equals(filter(CSS_IMPORT_NOURL_TWOMEDIAS))); - assertTrue("key="+CSS_IMPORT_UNQUOTED+" should be empty", "".equals(filter(CSS_IMPORT_UNQUOTED))); - assertTrue("key="+CSS_IMPORT_NOURL+" value=\""+filter(CSS_IMPORT_NOURL)+"\"", CSS_IMPORT_NOURLC.equals(filter(CSS_IMPORT_NOURL))); - assertTrue("key="+CSS_IMPORT_BRACKET+" value=\""+filter(CSS_IMPORT_BRACKET)+"\"", CSS_IMPORT_BRACKETC.equals(filter(CSS_IMPORT_BRACKET))); - assertTrue("key="+CSS_LATE_IMPORT+" value=\""+filter(CSS_LATE_IMPORT)+"\"", CSS_LATE_IMPORTC.equals(filter(CSS_LATE_IMPORT))); - assertTrue("key="+CSS_LATE_IMPORT2+" value=\""+filter(CSS_LATE_IMPORT2)+"\"", CSS_LATE_IMPORT2C.equals(filter(CSS_LATE_IMPORT2))); - assertTrue("key="+CSS_LATE_IMPORT3+" value=\""+filter(CSS_LATE_IMPORT3)+"\"", CSS_LATE_IMPORT3C.equals(filter(CSS_LATE_IMPORT3))); - assertTrue("key="+CSS_BOGUS_AT_RULE+" value=\""+filter(CSS_BOGUS_AT_RULE)+"\"", CSS_BOGUS_AT_RULEC.equals(filter(CSS_BOGUS_AT_RULE))); - assertTrue("key="+PRESERVE_CDO_CDC+" value=\""+filter(PRESERVE_CDO_CDC)+"\"", PRESERVE_CDO_CDCC.equals(filter(PRESERVE_CDO_CDC))); - assertTrue("key="+BROKEN_BEFORE_IMPORT+" value=\""+filter(BROKEN_BEFORE_IMPORT)+"\"", BROKEN_BEFORE_IMPORTC.equals(filter(BROKEN_BEFORE_IMPORT))); - assertTrue("key="+BROKEN_BEFORE_MEDIA+" value=\""+filter(BROKEN_BEFORE_MEDIA)+"\"", BROKEN_BEFORE_MEDIAC.equals(filter(BROKEN_BEFORE_MEDIA))); + assertEquals("key=" + CSS_IMPORT + " value=\"" + filter(CSS_IMPORT) + "\"", CSS_IMPORTC, filter(CSS_IMPORT)); + assertEquals("key=" + CSS_IMPORT2 + " value=\"" + filter(CSS_IMPORT2) + "\"", CSS_IMPORT2C, filter(CSS_IMPORT2)); + assertEquals("key=" + CSS_IMPORT_MULTI_MEDIA + " value=\"" + filter(CSS_IMPORT_MULTI_MEDIA) + "\"", CSS_IMPORT_MULTI_MEDIAC, filter(CSS_IMPORT_MULTI_MEDIA)); + assertEquals("key=" + CSS_IMPORT_MULTI_MEDIA_BOGUS + " value=\"" + filter(CSS_IMPORT_MULTI_MEDIA_BOGUS) + "\"", CSS_IMPORT_MULTI_MEDIA_BOGUSC, filter(CSS_IMPORT_MULTI_MEDIA_BOGUS)); + assertEquals("key=" + CSS_IMPORT_MULTI_MEDIA_ALL + " value=\"" + filter(CSS_IMPORT_MULTI_MEDIA_ALL) + "\"", CSS_IMPORT_MULTI_MEDIA_ALLC, filter(CSS_IMPORT_MULTI_MEDIA_ALL)); + assertEquals("key=" + CSS_IMPORT_TYPE + " value=\"" + filter(CSS_IMPORT_TYPE) + "\"", CSS_IMPORT_TYPEC, filter(CSS_IMPORT_TYPE)); + assertEquals("key=" + CSS_IMPORT_SPACE_IN_STRING + " value=\"" + filter(CSS_IMPORT_SPACE_IN_STRING) + "\"", CSS_IMPORT_SPACE_IN_STRINGC, filter(CSS_IMPORT_SPACE_IN_STRING)); + assertEquals("key=" + CSS_IMPORT_QUOTED_STUFF + " value=\"" + filter(CSS_IMPORT_QUOTED_STUFF) + "\"", CSS_IMPORT_QUOTED_STUFFC, filter(CSS_IMPORT_QUOTED_STUFF)); + assertEquals("key=" + CSS_IMPORT_QUOTED_STUFF2 + " value=\"" + filter(CSS_IMPORT_QUOTED_STUFF2) + "\"", CSS_IMPORT_QUOTED_STUFF2C, filter(CSS_IMPORT_QUOTED_STUFF2)); + assertEquals("key=" + CSS_IMPORT_NOURL_TWOMEDIAS + " value=\"" + filter(CSS_IMPORT_NOURL_TWOMEDIAS) + "\"", CSS_IMPORT_NOURL_TWOMEDIASC, filter(CSS_IMPORT_NOURL_TWOMEDIAS)); + assertEquals("key=" + CSS_IMPORT_UNQUOTED + " should be empty", "", filter(CSS_IMPORT_UNQUOTED)); + assertEquals("key=" + CSS_IMPORT_NOURL + " value=\"" + filter(CSS_IMPORT_NOURL) + "\"", CSS_IMPORT_NOURLC, filter(CSS_IMPORT_NOURL)); + assertEquals("key=" + CSS_IMPORT_BRACKET + " value=\"" + filter(CSS_IMPORT_BRACKET) + "\"", CSS_IMPORT_BRACKETC, filter(CSS_IMPORT_BRACKET)); + assertEquals("key=" + CSS_LATE_IMPORT + " value=\"" + filter(CSS_LATE_IMPORT) + "\"", CSS_LATE_IMPORTC, filter(CSS_LATE_IMPORT)); + assertEquals("key=" + CSS_LATE_IMPORT2 + " value=\"" + filter(CSS_LATE_IMPORT2) + "\"", CSS_LATE_IMPORT2C, filter(CSS_LATE_IMPORT2)); + assertEquals("key=" + CSS_LATE_IMPORT3 + " value=\"" + filter(CSS_LATE_IMPORT3) + "\"", CSS_LATE_IMPORT3C, filter(CSS_LATE_IMPORT3)); + assertEquals("key=" + CSS_BOGUS_AT_RULE + " value=\"" + filter(CSS_BOGUS_AT_RULE) + "\"", CSS_BOGUS_AT_RULEC, filter(CSS_BOGUS_AT_RULE)); + assertEquals("key=" + PRESERVE_CDO_CDC + " value=\"" + filter(PRESERVE_CDO_CDC) + "\"", PRESERVE_CDO_CDCC, filter(PRESERVE_CDO_CDC)); + assertEquals("key=" + BROKEN_BEFORE_IMPORT + " value=\"" + filter(BROKEN_BEFORE_IMPORT) + "\"", BROKEN_BEFORE_IMPORTC, filter(BROKEN_BEFORE_IMPORT)); + assertEquals("key=" + BROKEN_BEFORE_MEDIA + " value=\"" + filter(BROKEN_BEFORE_MEDIA) + "\"", BROKEN_BEFORE_MEDIAC, filter(BROKEN_BEFORE_MEDIA)); } @Test public void testEscape() throws IOException, URISyntaxException { - assertTrue("key="+CSS_ESCAPED_LINK+" value=\""+filter(CSS_ESCAPED_LINK)+"\"", CSS_ESCAPED_LINKC.equals(filter(CSS_ESCAPED_LINK))); - assertTrue("key="+CSS_ESCAPED_LINK2+" value=\""+filter(CSS_ESCAPED_LINK2)+"\"", CSS_ESCAPED_LINK2C.equals(filter(CSS_ESCAPED_LINK2))); + assertEquals("key=" + CSS_ESCAPED_LINK + " value=\"" + filter(CSS_ESCAPED_LINK) + "\"", CSS_ESCAPED_LINKC, filter(CSS_ESCAPED_LINK)); + assertEquals("key=" + CSS_ESCAPED_LINK2 + " value=\"" + filter(CSS_ESCAPED_LINK2) + "\"", CSS_ESCAPED_LINK2C, filter(CSS_ESCAPED_LINK2)); } @Test @@ -1023,7 +1005,7 @@ public void testProperties() throws IOException, URISyntaxException { for(Entry entry : propertyTests.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); - assertTrue("key=\""+key+"\" encoded=\""+filter(key)+"\" should be \""+value+"\"", value.equals(filter(key))); + assertEquals("key=\"" + key + "\" encoded=\"" + filter(key) + "\" should be \"" + value + "\"", value, filter(key)); } } @@ -1039,23 +1021,23 @@ private String filter(String css) throws IOException, URISyntaxException { public void testCharset() throws IOException, URISyntaxException { // Test whether @charset is passed through when it is correct. String test = "@charset \"UTF-8\";\nh2 { color: red;}"; - assertTrue("key=\""+test+"\" value=\""+filter(test)+"\"", filter(test).equals(test)); + assertEquals("key=\"" + test + "\" value=\"" + filter(test) + "\"", filter(test), test); // No quote marks String testUnquoted = "@charset UTF-8;\nh2 { color: red;}"; - assertTrue("key=\""+test+"\" value=\""+filter(test)+"\"", filter(testUnquoted).equals(test)); + assertEquals("key=\"" + test + "\" value=\"" + filter(test) + "\"", filter(testUnquoted), test); // Test whether the parse fails when @charset is not correct. String testFail = "@charset ISO-8859-1;\nh2 { color: red;};"; - try { - filter(test).equals(""); - assertFalse("Bogus @charset should have been deleted, but result is \""+filter(testFail)+"\"", false); - } catch (IOException e) { - // Ok. - } + assertThrows( + "Bogus @charset should have been deleted", + IOException.class, + ()-> filter(testFail) + ); + // Test charset extraction getCharsetTest("UTF-8"); getCharsetTest("UTF-16BE"); getCharsetTest("UTF-16LE"); - // not availiable in java 1.5.0_22 + // FIXME: these next two are not supported or produce errors // getCharsetTest("UTF-32BE"); // getCharsetTest("UTF-32LE"); @@ -1083,37 +1065,33 @@ public void testCharset() throws IOException, URISyntaxException { charsetTestUnsupported("IBM01149"); // Late charset is invalid - assertTrue("key="+LATE_CHARSET+" value=\""+filter(LATE_CHARSET)+"\"", LATE_CHARSETC.equals(filter(LATE_CHARSET))); + assertEquals("key=" + LATE_CHARSET + " value=\"" + filter(LATE_CHARSET) + "\"", LATE_CHARSETC, filter(LATE_CHARSET)); try { String output = filter(WRONG_CHARSET); - assertFalse("Should complain that detected charset differs from real charset, but returned \""+output+"\"", true); + fail("Should complain that detected charset differs from real charset, but returned \"" + output + "\""); } catch (IOException e) { // Ok. // FIXME should have a dedicated exception. } try { String output = filter(NONSENSE_CHARSET); - assertFalse("wrong charset output is \""+output+"\" but it should throw!", true); + fail("wrong charset output is \"" + output + "\" but it should throw!"); } catch (UnsupportedCharsetInFilterException e) { // Ok. } - assertTrue(BOM.equals(filter(BOM))); - assertTrue("output=\""+filter(LATE_BOM)+"\"",LATE_BOMC.equals(filter(LATE_BOM))); + assertEquals(BOM, filter(BOM)); + assertEquals("output=\"" + filter(LATE_BOM) + "\"", LATE_BOMC, filter(LATE_BOM)); } - private void getCharsetTest(String charset) throws DataFilterException, IOException, URISyntaxException { + private void getCharsetTest(String charset) throws IOException, URISyntaxException { getCharsetTest(charset, null); } - private void getCharsetTest(String charset, String family) throws DataFilterException, IOException, URISyntaxException { + private void getCharsetTest(String charset, String family) throws IOException, URISyntaxException { String original = "@charset \""+charset+"\";\nh2 { color: red;}"; byte[] bytes = original.getBytes(charset); CSSReadFilter filter = new CSSReadFilter(); - ArrayBucket inputBucket = new ArrayBucket(bytes); - ArrayBucket outputBucket = new ArrayBucket(); - InputStream inputStream = inputBucket.getInputStream(); - OutputStream outputStream = outputBucket.getOutputStream(); // Detect with original charset. String detectedCharset = filter.getCharset(bytes, bytes.length, charset); assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" even when parsing with correct charset", charset.equalsIgnoreCase(detectedCharset)); @@ -1122,83 +1100,111 @@ private void getCharsetTest(String charset, String family) throws DataFilterExce assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" or \""+family+"\" from getCharsetByBOM", detectedCharset == null || charset.equalsIgnoreCase(detectedCharset) || (family != null && family.equalsIgnoreCase(detectedCharset))); detectedCharset = ContentFilter.detectCharset(bytes, bytes.length, cssMIMEType, null); assertTrue("Charset detected \""+detectedCharset+"\" should be \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", charset.equalsIgnoreCase(detectedCharset)); - FilterStatus filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4oobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), - null, null, null, null); - inputStream.close(); - outputStream.close(); + + ArrayBucket inputBucket = new ArrayBucket(bytes); + ArrayBucket outputBucket = new ArrayBucket(); + FilterStatus filterStatus; + try ( + InputStream inputStream = inputBucket.getInputStream(); + OutputStream outputStream = outputBucket.getOutputStream() + ) { + filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4oobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), + null, null, null, null + ); + } assertEquals("text/css", filterStatus.mimeType); assertEquals(charset, filterStatus.charset); String filtered = new String(BucketTools.toByteArray(outputBucket), charset); - assertTrue("ContentFilter.filter() returns \""+filtered+"\" not original \""+original+"\" for charset \""+charset+"\"", original.equals(filtered)); + assertEquals( + "ContentFilter.filter() returns \"" + filtered + "\" not original \"" + original + "\" for charset \"" + charset + "\"", + original, + filtered + ); } - private void charsetTestUnsupported(String charset) throws DataFilterException, IOException, URISyntaxException { + private void charsetTestUnsupported(String charset) throws IOException, URISyntaxException { String original = "@charset \""+charset+"\";\nh2 { color: red;}"; byte[] bytes = original.getBytes(charset); CSSReadFilter filter = new CSSReadFilter(); - SimpleReadOnlyArrayBucket inputBucket = new SimpleReadOnlyArrayBucket(bytes); - Bucket outputBucket = new ArrayBucket(); - InputStream inputStream = inputBucket.getInputStream(); - OutputStream outputStream = outputBucket.getOutputStream(); String detectedCharset; BOMDetection bom = filter.getCharsetByBOM(bytes, bytes.length); String bomCharset = detectedCharset = bom == null ? null : bom.charset; - assertTrue("Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from getCharsetByBOM", detectedCharset == null); + assertNull( + "Charset detected \"" + detectedCharset + "\" should be unknown testing unsupported charset \"" + charset + "\" from getCharsetByBOM", + detectedCharset + ); detectedCharset = ContentFilter.detectCharset(bytes, bytes.length, cssMIMEType, null); - assertTrue("Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", charset == null || "utf-8".equalsIgnoreCase(detectedCharset)); - try { - FilterStatus filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), - null,null, null, null); - // It is safe to return utf-8, as long as we clobber the actual content; utf-8 is the default, but other stuff decoded to it is unlikely to be coherent... - assertTrue("ContentFilter.filter() returned charset \""+filterStatus.charset+"\" should be unknown testing unsupported charset \""+charset+"\"", filterStatus.charset.equalsIgnoreCase(charset) || filterStatus.charset.equalsIgnoreCase("utf-8"));//If we switch to JUnit 4, this may be replaced with an assertThat - assertEquals("text/css", filterStatus.mimeType); - String filtered = new String(BucketTools.toByteArray(outputBucket), charset); - assertTrue("ContentFilter.filter() returns something: \""+filtered+"\" should be empty as unsupported charset, original: \""+original+"\" for charset \""+charset+"\"", filtered.equals("")); - } catch (UnsupportedCharsetInFilterException e) { - // Ok. - } catch (IOException e) { - // Ok. - } - finally { - inputStream.close(); - outputStream.close(); + assertTrue( + "Charset detected \""+detectedCharset+"\" should be unknown testing unsupported charset \""+charset+"\" from ContentFilter.detectCharset bom=\""+bomCharset+"\"", + "utf-8".equalsIgnoreCase(detectedCharset) + ); + SimpleReadOnlyArrayBucket inputBucket = new SimpleReadOnlyArrayBucket(bytes); + Bucket outputBucket = new ArrayBucket(); + FilterStatus filterStatus; + try ( + InputStream inputStream = inputBucket.getInputStream(); + OutputStream outputStream = outputBucket.getOutputStream() + ) { + filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), + null, null, null, null); } + // It is safe to return utf-8, as long as we clobber the actual content; utf-8 is the default, but other stuff decoded to it is unlikely to be coherent... + MatcherAssert.assertThat( + "ContentFilter.filter() returned charset \""+filterStatus.charset+"\" should be unknown testing unsupported charset \""+charset+"\"", + filterStatus.charset, + anyOf( + equalToIgnoringCase(charset), + equalToIgnoringCase("utf-8") + ) + ); + assertEquals("text/css", filterStatus.mimeType); + String filtered = new String(BucketTools.toByteArray(outputBucket), charset); + assertEquals( + "ContentFilter.filter() returns something: \"" + filtered + "\" should be empty as unsupported charset, original: \"" + original + "\" for charset \"" + charset + "\"", + "", + filtered + ); } @Test - public void testMaybeCharset() throws UnsafeContentTypeException, URISyntaxException, IOException { + public void testMaybeCharset() throws URISyntaxException, IOException { testUseMaybeCharset("UTF-8"); testUseMaybeCharset("UTF-16"); - // not availiable in java 1.5.0_22 - // testUseMaybeCharset("UTF-32LE"); + testUseMaybeCharset("UTF-32LE"); testUseMaybeCharset("IBM01140"); } - private void testUseMaybeCharset(String charset) throws URISyntaxException, UnsafeContentTypeException, IOException { + private void testUseMaybeCharset(String charset) throws URISyntaxException, IOException { String original = "h2 { color: red;}"; byte[] bytes = original.getBytes(charset); SimpleReadOnlyArrayBucket inputBucket = new SimpleReadOnlyArrayBucket(bytes); Bucket outputBucket = new ArrayBucket(); - InputStream inputStream = inputBucket.getInputStream(); - OutputStream outputStream = outputBucket.getOutputStream(); - FilterStatus filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), - null,null, null, charset); - inputStream.close(); - outputStream.close(); + FilterStatus filterStatus; + try ( + InputStream inputStream = inputBucket.getInputStream(); + OutputStream outputStream = outputBucket.getOutputStream() + ) { + filterStatus = ContentFilter.filter(inputStream, outputStream, "text/css", new URI("/CHK@OR904t6ylZOwoobMJRmSn7HsPGefHSP7zAjoLyenSPw,x2EzszO4Kqot8akqmKYXJbkD-fSj6noOVGB-K2YisZ4,AAIC--8/1-works.html"), + null, null, null, charset); + } assertEquals(charset, filterStatus.charset); assertEquals("text/css", filterStatus.mimeType); String filtered = new String(BucketTools.toByteArray(outputBucket), charset); - assertTrue("ContentFilter.filter() returns \""+filtered+"\" not original \""+original+"\" with maybeCharset \""+charset+"\"", original.equals(filtered)); + assertEquals( + "ContentFilter.filter() returns \"" + filtered + "\" not original \"" + original + "\" with maybeCharset \"" + charset + "\"", + original, + filtered + ); } @Test public void testComment() throws IOException, URISyntaxException { - assertTrue("value=\""+filter(COMMENT)+"\"",COMMENTC.equals(filter(COMMENT))); + assertEquals("value=\"" + filter(COMMENT) + "\"", COMMENTC, filter(COMMENT)); } @Test public void testWhitespace() throws IOException, URISyntaxException { - assertTrue("value=\""+filter(CSS_COMMA_WHITESPACE)+"\"", CSS_COMMA_WHITESPACE.equals(filter(CSS_COMMA_WHITESPACE))); + assertEquals("value=\"" + filter(CSS_COMMA_WHITESPACE) + "\"", CSS_COMMA_WHITESPACE, filter(CSS_COMMA_WHITESPACE)); } @Test diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index e25e5eb50a7..9da9cfe2505 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -3,15 +3,20 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.client.filter; +import static org.hamcrest.Matchers.endsWith; +import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.*; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import org.hamcrest.MatcherAssert; import org.junit.Test; import freenet.client.filter.ContentFilter.FilterStatus; @@ -27,360 +32,363 @@ * @author Florent Daignière <nextgens@freenetproject.org> */ public class ContentFilterTest { - private static final String BASE_URI_PROTOCOL = "http"; - private static final String BASE_URI_CONTENT = "localhost:8888"; - private static final String BASE_KEY = "USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/55/"; - private static final String BASE_URI = BASE_URI_PROTOCOL+"://"+BASE_URI_CONTENT+'/'; - private static final String ALT_BASE_URI = BASE_URI_PROTOCOL+"://"+BASE_URI_CONTENT+'/'+BASE_KEY; - - private static final String EXTERNAL_LINK = "www.evilwebsite.gov"; - private static final String EXTERNAL_LINK_OK = ""; - // check that external links are not allowed - private static final String EXTERNAL_LINK_CHECK1 = ""; - private static final String EXTERNAL_LINK_CHECK2 = ""; - private static final String EXTERNAL_LINK_CHECK3 = ""; - - private static final String INTERNAL_RELATIVE_LINK = ""; - private static final String INTERNAL_ABSOLUTE_LINK = ""; - - private static final String INTERNAL_RELATIVE_LINK1 = ""; - - // @see bug #710 - private static final String ANCHOR_TEST = ""; - private static final String ANCHOR_TEST_EMPTY = ""; - private static final String ANCHOR_TEST_SPECIAL = ""; // RFC3986 / RFC 2396 - private static final String ANCHOR_TEST_SPECIAL2 = ""; - private static final String ANCHOR_TEST_SPECIAL2_RESULT = ""; - - // @see bug #2496 - private static final String ANCHOR_RELATIVE1 = ""; - private static final String ANCHOR_RELATIVE2 = ""; - private static final String ANCHOR_FALSE_POS1 = ""; // yes, this is valid - private static final String ANCHOR_FALSE_POS2 = ""; // yes, this is valid too - - // evil hack for #2496 + #2451, <#> give <%23> - private static final String ANCHOR_MIXED = ""; - private static final String ANCHOR_MIXED_RESULT = ""; - - // @see bug #2451 - private static final String POUNT_CHARACTER_ENCODING_TEST = ""; - private static final String POUNT_CHARACTER_ENCODING_TEST_RESULT = ""; - // @see bug #2297 - private static final String PREVENT_FPROXY_ACCESS = ""; - // @see bug #2921 - private static final String PREVENT_EXTERNAL_ACCESS_CSS_SIMPLE = ""; - private static final String PREVENT_EXTERNAL_ACCESS_CSS_CASE = ""; - private static final String PREVENT_EXTERNAL_ACCESS_CSS_ESCAPE = ""; - private static final String WHITELIST_STATIC_CONTENT = ""; - private static final String XHTML_VOIDELEMENT="


"; - private static final String XHTML_VOIDELEMENTC="

"; - private static final String XHTML_INCOMPLETEDOCUMENT="

helloworld

helloworld"; - private static final String XHTML_INCOMPLETEDOCUMENTC="

helloworld

helloworld

"; - private static final String XHTML_IMPROPERNESTING="helloworld"; - private static final String XHTML_IMPROPERNESTINGC="helloworld"; - - private static final String CSS_STRING_NEWLINES = ""; - private static final String CSS_STRING_NEWLINESC = ""; - - private static final String HTML_STYLESHEET_MAYBECHARSET = ""; - private static final String HTML_STYLESHEET_MAYBECHARSETC = ""; - - private static final String HTML_STYLESHEET_CHARSET = ""; - private static final String HTML_STYLESHEET_CHARSETC = ""; - - private static final String HTML_STYLESHEET_CHARSET_BAD = ""; - private static final String HTML_STYLESHEET_CHARSET_BADC = ""; - - private static final String HTML_STYLESHEET_CHARSET_BAD1 = ""; - private static final String HTML_STYLESHEET_CHARSET_BAD1C = ""; - - private static final String HTML_STYLESHEET_WITH_MEDIA = ""; - private static final String HTML_STYLESHEET_WITH_MEDIAC = ""; - - private static final String FRAME_SRC_CHARSET = ""; - private static final String FRAME_SRC_CHARSETC = ""; - - private static final String FRAME_SRC_CHARSET_BAD = ""; - private static final String FRAME_SRC_CHARSET_BADC = ""; - - private static final String FRAME_SRC_CHARSET_BAD1 = ""; - private static final String FRAME_SRC_CHARSET_BAD1C = ""; - - private static final String SPAN_WITH_STYLE = ""; - - private static final String BASE_HREF = ""; - private static final String BAD_BASE_HREF = ""; - private static final String BAD_BASE_HREF2 = ""; - private static final String BAD_BASE_HREF3 = ""; - private static final String BAD_BASE_HREF4 = ""; - private static final String BAD_BASE_HREF5 = ""; - private static final String DELETED_BASE_HREF = ""; - - // From CSS spec - - private static final String CSS_SPEC_EXAMPLE1 = "\n\n \n Bach's home page\n \n \n \n

Bach's home page

\n

Johann Sebastian Bach was a prolific composer.\n \n"; - - @Test - public void testHTMLFilter() throws Exception { - if (TestProperty.VERBOSE) { - Logger.setupStdoutLogging(LogLevel.MINOR, "freenet.client.filter.Generic:DEBUG"); - } - - // General sanity checks - // is "relativization" working? - assertEquals(INTERNAL_RELATIVE_LINK, HTMLFilter(INTERNAL_RELATIVE_LINK)); - assertEquals(INTERNAL_RELATIVE_LINK, HTMLFilter(INTERNAL_RELATIVE_LINK, true)); - assertEquals(INTERNAL_RELATIVE_LINK1, HTMLFilter(INTERNAL_RELATIVE_LINK1, true)); - assertEquals(INTERNAL_RELATIVE_LINK, HTMLFilter(INTERNAL_ABSOLUTE_LINK)); - // are external links stripped out ? - assertTrue(HTMLFilter(EXTERNAL_LINK_CHECK1).startsWith(EXTERNAL_LINK_OK)); - assertTrue(HTMLFilter(EXTERNAL_LINK_CHECK2).contains(ExternalLinkToadlet.PATH)); - assertTrue(HTMLFilter(EXTERNAL_LINK_CHECK3).startsWith(EXTERNAL_LINK_OK)); - - // regression testing - // bug #710 - assertEquals(ANCHOR_TEST, HTMLFilter(ANCHOR_TEST)); - assertEquals(ANCHOR_TEST_EMPTY, HTMLFilter(ANCHOR_TEST_EMPTY)); - assertEquals(ANCHOR_TEST_SPECIAL, HTMLFilter(ANCHOR_TEST_SPECIAL)); - assertEquals(ANCHOR_TEST_SPECIAL2_RESULT, HTMLFilter(ANCHOR_TEST_SPECIAL2)); - // bug #2496 - assertEquals(ANCHOR_RELATIVE1, HTMLFilter(ANCHOR_RELATIVE1)); - assertEquals(ANCHOR_RELATIVE2, HTMLFilter(ANCHOR_RELATIVE2)); - assertEquals(ANCHOR_FALSE_POS1, HTMLFilter(ANCHOR_FALSE_POS1)); - assertEquals(ANCHOR_FALSE_POS2, HTMLFilter(ANCHOR_FALSE_POS2)); - // EVIL HACK TEST for #2496 + #2451 - assertEquals(ANCHOR_MIXED_RESULT, HTMLFilter(ANCHOR_MIXED)); - // bug #2451 - assertEquals(POUNT_CHARACTER_ENCODING_TEST_RESULT, HTMLFilter(POUNT_CHARACTER_ENCODING_TEST)); - // bug #2297 - assertTrue(HTMLFilter(PREVENT_FPROXY_ACCESS).contains(ExternalLinkToadlet.PATH)); - // bug #2921 - assertTrue(HTMLFilter(PREVENT_EXTERNAL_ACCESS_CSS_SIMPLE).contains("div { }")); - assertTrue(HTMLFilter(PREVENT_EXTERNAL_ACCESS_CSS_ESCAPE).contains("div { }")); - assertTrue(HTMLFilter(PREVENT_EXTERNAL_ACCESS_CSS_CASE).contains("div { }")); - assertEquals(WHITELIST_STATIC_CONTENT, HTMLFilter(WHITELIST_STATIC_CONTENT)); - assertEquals(XHTML_VOIDELEMENTC,HTMLFilter(XHTML_VOIDELEMENT)); - assertEquals(XHTML_INCOMPLETEDOCUMENTC,HTMLFilter(XHTML_INCOMPLETEDOCUMENT)); - assertEquals(XHTML_IMPROPERNESTINGC,HTMLFilter(XHTML_IMPROPERNESTING)); - - assertEquals(CSS_STRING_NEWLINESC,HTMLFilter(CSS_STRING_NEWLINES)); - - assertEquals(HTML_STYLESHEET_MAYBECHARSETC, HTMLFilter(HTML_STYLESHEET_MAYBECHARSET, true)); - assertEquals(HTML_STYLESHEET_CHARSETC, HTMLFilter(HTML_STYLESHEET_CHARSET, true)); - assertEquals(HTML_STYLESHEET_CHARSET_BADC, HTMLFilter(HTML_STYLESHEET_CHARSET_BAD, true)); - assertEquals(HTML_STYLESHEET_CHARSET_BAD1C, HTMLFilter(HTML_STYLESHEET_CHARSET_BAD1, true)); - assertEquals(HTML_STYLESHEET_WITH_MEDIAC, HTMLFilter(HTML_STYLESHEET_WITH_MEDIA, true)); - - assertEquals(FRAME_SRC_CHARSETC, HTMLFilter(FRAME_SRC_CHARSET, true)); - assertEquals(FRAME_SRC_CHARSET_BADC, HTMLFilter(FRAME_SRC_CHARSET_BAD, true)); - assertEquals(FRAME_SRC_CHARSET_BAD1C, HTMLFilter(FRAME_SRC_CHARSET_BAD1, true)); - - assertEquals(CSS_SPEC_EXAMPLE1, HTMLFilter(CSS_SPEC_EXAMPLE1)); - - assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); - - assertEquals(BASE_HREF, HTMLFilter(BASE_HREF)); - assertEquals(DELETED_BASE_HREF, HTMLFilter(BAD_BASE_HREF)); - assertEquals(DELETED_BASE_HREF, HTMLFilter(BAD_BASE_HREF2)); - assertEquals(DELETED_BASE_HREF, HTMLFilter(BAD_BASE_HREF3)); - assertEquals(DELETED_BASE_HREF, HTMLFilter(BAD_BASE_HREF4)); - assertEquals(DELETED_BASE_HREF, HTMLFilter(BAD_BASE_HREF5)); - } - - private static final String META_TIME_ONLY = ""; - private static final String META_TIME_ONLY_WRONG_CASE = ""; - private static final String META_TIME_ONLY_TOO_SHORT = ""; - private static final String META_TIME_ONLY_NEGATIVE = ""; - - private static final String META_TIME_ONLY_BADNUM1 = ""; - private static final String META_TIME_ONLY_BADNUM2 = ""; - private static final String META_TIME_ONLY_BADNUM_OUT = ""; - - private static final String META_CHARSET = ""; - private static final String META_CHARSET_LOWER = "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "Some Title"; - private static final String META_CHARSET_LOWER_RES = "\n" - + "\n" - + "\n" - + "\n" // comment has additional spaces after content filter - + "\n" - + "Some Title"; - - private static final String META_VALID_REDIRECT = ""; - private static final String META_VALID_REDIRECT_NOSPACE = ""; - - private static final String META_BOGUS_REDIRECT1 = ""; - private static final String META_BOGUS_REDIRECT2 = ""; - private static final String META_BOGUS_REDIRECT3 = ""; - private static final String META_BOGUS_REDIRECT4 = ""; - private static final String META_BOGUS_REDIRECT5 = ""; - private static final String META_BOGUS_REDIRECT6 = ""; - private static final String META_BOGUS_REDIRECT1_OUT = ""; - private static final String META_BOGUS_REDIRECT3_OUT = ""; - private static final String META_BOGUS_REDIRECT4_OUT = ""; - private static final String META_BOGUS_REDIRECT_NO_URL = ""; - - @Test - public void testMetaRefresh() throws Exception { - HTMLFilter.metaRefreshSamePageMinInterval = 5; - HTMLFilter.metaRefreshRedirectMinInterval = 30; - assertEquals(META_TIME_ONLY, headFilter(META_TIME_ONLY)); - assertEquals(META_TIME_ONLY, headFilter(META_TIME_ONLY_WRONG_CASE)); - assertEquals(META_TIME_ONLY, headFilter(META_TIME_ONLY_TOO_SHORT)); - assertEquals("", headFilter(META_TIME_ONLY_NEGATIVE)); - assertEquals(META_TIME_ONLY_BADNUM_OUT, headFilter(META_TIME_ONLY_BADNUM1)); - assertEquals(META_TIME_ONLY_BADNUM_OUT, headFilter(META_TIME_ONLY_BADNUM2)); - assertEquals(META_VALID_REDIRECT, headFilter(META_VALID_REDIRECT)); - assertEquals(META_VALID_REDIRECT, headFilter(META_VALID_REDIRECT_NOSPACE)); - assertEquals(META_BOGUS_REDIRECT1_OUT, headFilter(META_BOGUS_REDIRECT1)); - assertEquals(META_BOGUS_REDIRECT1_OUT, headFilter(META_BOGUS_REDIRECT2)); - assertEquals(META_BOGUS_REDIRECT3_OUT, headFilter(META_BOGUS_REDIRECT3)); - assertEquals(META_BOGUS_REDIRECT4_OUT, headFilter(META_BOGUS_REDIRECT4)); - assertEquals(META_BOGUS_REDIRECT1_OUT, headFilter(META_BOGUS_REDIRECT5)); - assertEquals(META_BOGUS_REDIRECT_NO_URL, headFilter(META_BOGUS_REDIRECT6)); - HTMLFilter.metaRefreshSamePageMinInterval = -1; - HTMLFilter.metaRefreshRedirectMinInterval = -1; - assertEquals("", headFilter(META_TIME_ONLY)); - assertEquals("", headFilter(META_TIME_ONLY_WRONG_CASE)); - assertEquals("", headFilter(META_TIME_ONLY_TOO_SHORT)); - assertEquals("", headFilter(META_TIME_ONLY_NEGATIVE)); - assertEquals("", headFilter(META_TIME_ONLY_BADNUM1)); - assertEquals("", headFilter(META_TIME_ONLY_BADNUM2)); - assertEquals("", headFilter(META_VALID_REDIRECT)); - assertEquals("", headFilter(META_VALID_REDIRECT_NOSPACE)); - assertEquals("", headFilter(META_BOGUS_REDIRECT1)); - assertEquals("", headFilter(META_BOGUS_REDIRECT2)); - assertEquals("", headFilter(META_BOGUS_REDIRECT3)); - assertEquals("", headFilter(META_BOGUS_REDIRECT4)); - assertEquals("", headFilter(META_BOGUS_REDIRECT5)); - assertEquals("", headFilter(META_BOGUS_REDIRECT6)); - } - - private String headFilter(String data) throws Exception { - String s = HTMLFilter(""+data+""); - if(s == null) return s; - if(!s.startsWith("")) - assertTrue("Head deleted???: "+s, false); - s = s.substring("".length()); - if(!s.endsWith("")) - assertTrue("Head close deleted???: "+s, false); - s = s.substring(0, s.length() - "".length()); - return s; - } - - @Test - public void testThatHtml5MetaCharsetIsPreserved() throws Exception { - assertEquals(META_CHARSET, HTMLFilter(META_CHARSET)); - assertEquals(META_CHARSET_LOWER_RES, HTMLFilter(META_CHARSET_LOWER)); - } - - @Test - public void testEvilCharset() throws IOException { - // This is why we need to disallow characters before !! - String s = "Blah"; - String end = ""; - String alt = "Blah"; - if((s.length()+end.length()) % 2 == 1) - s += " "; - s = s+end; - byte[] buf; - try { - buf = s.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - byte[] utf16bom = new byte[] { (byte)0xFE, (byte)0xFF }; - byte[] bufUTF16 = alt.getBytes("UTF-16"); - byte[] total = new byte[buf.length+utf16bom.length+bufUTF16.length]; - System.arraycopy(utf16bom, 0, total, 0, utf16bom.length); - System.arraycopy(buf, 0, total, utf16bom.length, buf.length); - System.arraycopy(bufUTF16, 0, total, utf16bom.length+buf.length, bufUTF16.length); - HTMLFilter filter = new HTMLFilter(); - boolean failed = false; - FileOutputStream fos; - try { - ArrayBucket out = new ArrayBucket(); - filter.readFilter(new ArrayBucket(total).getInputStream(), out.getOutputStream(), "UTF-16", null, null, null); - fos = new FileOutputStream("output.utf16"); - fos.write(out.toByteArray()); - fos.close(); - failed = true; - assertFalse("Filter accepted dangerous UTF8 text with BOM as UTF16! (HTMLFilter)", true); - } catch (DataFilterException e) { - System.out.println("Failure: "+e); - e.printStackTrace(); - if(e.getCause() != null) { - e.getCause().printStackTrace(); - } - // Ok. - } - try { - ArrayBucket out = new ArrayBucket(); - FilterStatus fo = ContentFilter.filter(new ArrayBucket(total).getInputStream(), out.getOutputStream(), "text/html", null, null, null); - fos = new FileOutputStream("output.filtered"); - fos.write(out.toByteArray()); - fos.close(); - failed = true; - assertFalse("Filter accepted dangerous UTF8 text with BOM as UTF16! (ContentFilter) - Detected charset: "+fo.charset, true); - } catch (DataFilterException e) { - System.out.println("Failure: "+e); - e.printStackTrace(); - if(e.getCause() != null) { - e.getCause().printStackTrace(); - } - // Ok. - } - - if(failed) { - fos = new FileOutputStream("unfiltered"); - fos.write(total); - fos.close(); - } - } - - public static String HTMLFilter(String data) throws Exception { - if(data.startsWith(""+data+"", false); - assertTrue(s.startsWith("")); - s = s.substring("".length()); - assertTrue("s = \""+s+"\"", s.endsWith("")); - s = s.substring(0, s.length() - "".length()); - return s; - } - - public static String HTMLFilter(String data, boolean alt) throws Exception { - String returnValue; - String typeName = "text/html"; - URI baseURI = new URI(alt ? ALT_BASE_URI : BASE_URI); - byte[] dataToFilter = data.getBytes("UTF-8"); - ArrayBucket input = new ArrayBucket(dataToFilter); - ArrayBucket output = new ArrayBucket(); - InputStream inputStream = input.getInputStream(); - OutputStream outputStream = output.getOutputStream(); - ContentFilter.filter(inputStream, outputStream, typeName, baseURI,null,null, null, null); - inputStream.close(); - outputStream.close(); - returnValue = output.toString(); - output.free(); - input.free(); - return returnValue; - } - - @Test - public void testLowerCaseExtensions() { - for(FilterMIMEType type : ContentFilter.mimeTypesByName.values()) { - String ext = type.primaryExtension; - if(ext != null) - assertEquals(ext, ext.toLowerCase()); - String[] exts = type.alternateExtensions; - if(ext != null) - for(String s : exts) - assertEquals(s, s.toLowerCase()); - } - } + private static final String BASE_URI_PROTOCOL = "http"; + private static final String BASE_URI_CONTENT = "localhost:8888"; + private static final String BASE_KEY = "USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/55/"; + private static final String BASE_URI = BASE_URI_PROTOCOL + "://" + BASE_URI_CONTENT + '/'; + private static final String ALT_BASE_URI = BASE_URI_PROTOCOL + "://" + BASE_URI_CONTENT + '/' + BASE_KEY; + + private static final String EXTERNAL_LINK = "www.evilwebsite.gov"; + private static final String EXTERNAL_LINK_OK = ""; + // check that external links are not allowed + private static final String EXTERNAL_LINK_CHECK1 = ""; + private static final String EXTERNAL_LINK_CHECK2 = ""; + private static final String EXTERNAL_LINK_CHECK3 = ""; + + private static final String INTERNAL_RELATIVE_LINK = ""; + private static final String INTERNAL_ABSOLUTE_LINK = ""; + + private static final String INTERNAL_RELATIVE_LINK1 = ""; + + // @see bug #710 + private static final String ANCHOR_TEST = ""; + private static final String ANCHOR_TEST_EMPTY = ""; + private static final String ANCHOR_TEST_SPECIAL = ""; // RFC3986 / RFC 2396 + private static final String ANCHOR_TEST_SPECIAL2 = ""; + private static final String ANCHOR_TEST_SPECIAL2_RESULT = ""; + + // @see bug #2496 + private static final String ANCHOR_RELATIVE1 = ""; + private static final String ANCHOR_RELATIVE2 = ""; + private static final String ANCHOR_FALSE_POS1 = ""; // yes, this is valid + private static final String ANCHOR_FALSE_POS2 = ""; // yes, this is valid too + + // evil hack for #2496 + #2451, <#> give <%23> + private static final String ANCHOR_MIXED = ""; + private static final String ANCHOR_MIXED_RESULT = ""; + + // @see bug #2451 + private static final String POUNT_CHARACTER_ENCODING_TEST = ""; + private static final String POUNT_CHARACTER_ENCODING_TEST_RESULT = ""; + // @see bug #2297 + private static final String PREVENT_FPROXY_ACCESS = ""; + // @see bug #2921 + private static final String PREVENT_EXTERNAL_ACCESS_CSS_SIMPLE = ""; + private static final String PREVENT_EXTERNAL_ACCESS_CSS_CASE = ""; + private static final String PREVENT_EXTERNAL_ACCESS_CSS_ESCAPE = ""; + private static final String WHITELIST_STATIC_CONTENT = ""; + private static final String XHTML_VOIDELEMENT = "


"; + private static final String XHTML_VOIDELEMENTC = "

"; + private static final String XHTML_INCOMPLETEDOCUMENT = "

helloworld

helloworld"; + private static final String XHTML_INCOMPLETEDOCUMENTC = "

helloworld

helloworld

"; + private static final String XHTML_IMPROPERNESTING = "helloworld"; + private static final String XHTML_IMPROPERNESTINGC = "helloworld"; + + private static final String CSS_STRING_NEWLINES = ""; + private static final String CSS_STRING_NEWLINESC = ""; + + private static final String HTML_STYLESHEET_MAYBECHARSET = ""; + private static final String HTML_STYLESHEET_MAYBECHARSETC = ""; + + private static final String HTML_STYLESHEET_CHARSET = ""; + private static final String HTML_STYLESHEET_CHARSETC = ""; + + private static final String HTML_STYLESHEET_CHARSET_BAD = ""; + private static final String HTML_STYLESHEET_CHARSET_BADC = ""; + + private static final String HTML_STYLESHEET_CHARSET_BAD1 = ""; + private static final String HTML_STYLESHEET_CHARSET_BAD1C = ""; + + private static final String HTML_STYLESHEET_WITH_MEDIA = ""; + private static final String HTML_STYLESHEET_WITH_MEDIAC = ""; + + private static final String FRAME_SRC_CHARSET = ""; + private static final String FRAME_SRC_CHARSETC = ""; + + private static final String FRAME_SRC_CHARSET_BAD = ""; + private static final String FRAME_SRC_CHARSET_BADC = ""; + + private static final String FRAME_SRC_CHARSET_BAD1 = ""; + private static final String FRAME_SRC_CHARSET_BAD1C = ""; + + private static final String SPAN_WITH_STYLE = ""; + + private static final String BASE_HREF = ""; + private static final String BAD_BASE_HREF = ""; + private static final String BAD_BASE_HREF2 = ""; + private static final String BAD_BASE_HREF3 = ""; + private static final String BAD_BASE_HREF4 = ""; + private static final String BAD_BASE_HREF5 = ""; + private static final String DELETED_BASE_HREF = ""; + + // From CSS spec + + private static final String CSS_SPEC_EXAMPLE1 = "\n\n \n Bach's home page\n \n \n \n

Bach's home page

\n

Johann Sebastian Bach was a prolific composer.\n \n"; + + @Test + public void testHTMLFilter() throws Exception { + if (TestProperty.VERBOSE) { + Logger.setupStdoutLogging(LogLevel.MINOR, "freenet.client.filter.Generic:DEBUG"); + } + + // General sanity checks + // is "relativization" working? + assertEquals(INTERNAL_RELATIVE_LINK, htmlFilter(INTERNAL_RELATIVE_LINK)); + assertEquals(INTERNAL_RELATIVE_LINK, htmlFilter(INTERNAL_RELATIVE_LINK, true)); + assertEquals(INTERNAL_RELATIVE_LINK1, htmlFilter(INTERNAL_RELATIVE_LINK1, true)); + assertEquals(INTERNAL_RELATIVE_LINK, htmlFilter(INTERNAL_ABSOLUTE_LINK)); + // are external links stripped out ? + assertTrue(htmlFilter(EXTERNAL_LINK_CHECK1).startsWith(EXTERNAL_LINK_OK)); + assertTrue(htmlFilter(EXTERNAL_LINK_CHECK2).contains(ExternalLinkToadlet.PATH)); + assertTrue(htmlFilter(EXTERNAL_LINK_CHECK3).startsWith(EXTERNAL_LINK_OK)); + + // regression testing + // bug #710 + assertEquals(ANCHOR_TEST, htmlFilter(ANCHOR_TEST)); + assertEquals(ANCHOR_TEST_EMPTY, htmlFilter(ANCHOR_TEST_EMPTY)); + assertEquals(ANCHOR_TEST_SPECIAL, htmlFilter(ANCHOR_TEST_SPECIAL)); + assertEquals(ANCHOR_TEST_SPECIAL2_RESULT, htmlFilter(ANCHOR_TEST_SPECIAL2)); + // bug #2496 + assertEquals(ANCHOR_RELATIVE1, htmlFilter(ANCHOR_RELATIVE1)); + assertEquals(ANCHOR_RELATIVE2, htmlFilter(ANCHOR_RELATIVE2)); + assertEquals(ANCHOR_FALSE_POS1, htmlFilter(ANCHOR_FALSE_POS1)); + assertEquals(ANCHOR_FALSE_POS2, htmlFilter(ANCHOR_FALSE_POS2)); + // EVIL HACK TEST for #2496 + #2451 + assertEquals(ANCHOR_MIXED_RESULT, htmlFilter(ANCHOR_MIXED)); + // bug #2451 + assertEquals(POUNT_CHARACTER_ENCODING_TEST_RESULT, htmlFilter(POUNT_CHARACTER_ENCODING_TEST)); + // bug #2297 + assertTrue(htmlFilter(PREVENT_FPROXY_ACCESS).contains(ExternalLinkToadlet.PATH)); + // bug #2921 + assertTrue(htmlFilter(PREVENT_EXTERNAL_ACCESS_CSS_SIMPLE).contains("div { }")); + assertTrue(htmlFilter(PREVENT_EXTERNAL_ACCESS_CSS_ESCAPE).contains("div { }")); + assertTrue(htmlFilter(PREVENT_EXTERNAL_ACCESS_CSS_CASE).contains("div { }")); + assertEquals(WHITELIST_STATIC_CONTENT, htmlFilter(WHITELIST_STATIC_CONTENT)); + assertEquals(XHTML_VOIDELEMENTC, htmlFilter(XHTML_VOIDELEMENT)); + assertEquals(XHTML_INCOMPLETEDOCUMENTC, htmlFilter(XHTML_INCOMPLETEDOCUMENT)); + assertEquals(XHTML_IMPROPERNESTINGC, htmlFilter(XHTML_IMPROPERNESTING)); + + assertEquals(CSS_STRING_NEWLINESC, htmlFilter(CSS_STRING_NEWLINES)); + + assertEquals(HTML_STYLESHEET_MAYBECHARSETC, htmlFilter(HTML_STYLESHEET_MAYBECHARSET, true)); + assertEquals(HTML_STYLESHEET_CHARSETC, htmlFilter(HTML_STYLESHEET_CHARSET, true)); + assertEquals(HTML_STYLESHEET_CHARSET_BADC, htmlFilter(HTML_STYLESHEET_CHARSET_BAD, true)); + assertEquals(HTML_STYLESHEET_CHARSET_BAD1C, htmlFilter(HTML_STYLESHEET_CHARSET_BAD1, true)); + assertEquals(HTML_STYLESHEET_WITH_MEDIAC, htmlFilter(HTML_STYLESHEET_WITH_MEDIA, true)); + + assertEquals(FRAME_SRC_CHARSETC, htmlFilter(FRAME_SRC_CHARSET, true)); + assertEquals(FRAME_SRC_CHARSET_BADC, htmlFilter(FRAME_SRC_CHARSET_BAD, true)); + assertEquals(FRAME_SRC_CHARSET_BAD1C, htmlFilter(FRAME_SRC_CHARSET_BAD1, true)); + + assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1)); + + assertEquals(SPAN_WITH_STYLE, htmlFilter(SPAN_WITH_STYLE)); + + assertEquals(BASE_HREF, htmlFilter(BASE_HREF)); + assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF)); + assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF2)); + assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF3)); + assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF4)); + assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF5)); + } + + private static final String META_TIME_ONLY = ""; + private static final String META_TIME_ONLY_WRONG_CASE = ""; + private static final String META_TIME_ONLY_TOO_SHORT = ""; + private static final String META_TIME_ONLY_NEGATIVE = ""; + + private static final String META_TIME_ONLY_BADNUM1 = ""; + private static final String META_TIME_ONLY_BADNUM2 = ""; + private static final String META_TIME_ONLY_BADNUM_OUT = ""; + + private static final String META_CHARSET = ""; + private static final String META_CHARSET_LOWER = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "Some Title"; + private static final String META_CHARSET_LOWER_RES = "\n" + + "\n" + + "\n" + + "\n" // comment has additional spaces after content filter + + "\n" + + "Some Title"; + + private static final String META_VALID_REDIRECT = ""; + private static final String META_VALID_REDIRECT_NOSPACE = ""; + + private static final String META_BOGUS_REDIRECT1 = ""; + private static final String META_BOGUS_REDIRECT2 = ""; + private static final String META_BOGUS_REDIRECT3 = ""; + private static final String META_BOGUS_REDIRECT4 = ""; + private static final String META_BOGUS_REDIRECT5 = ""; + private static final String META_BOGUS_REDIRECT6 = ""; + private static final String META_BOGUS_REDIRECT1_OUT = ""; + private static final String META_BOGUS_REDIRECT3_OUT = ""; + private static final String META_BOGUS_REDIRECT4_OUT = ""; + private static final String META_BOGUS_REDIRECT_NO_URL = ""; + + @Test + public void testMetaRefresh() throws Exception { + HTMLFilter.metaRefreshSamePageMinInterval = 5; + HTMLFilter.metaRefreshRedirectMinInterval = 30; + assertEquals(META_TIME_ONLY, headFilter(META_TIME_ONLY)); + assertEquals(META_TIME_ONLY, headFilter(META_TIME_ONLY_WRONG_CASE)); + assertEquals(META_TIME_ONLY, headFilter(META_TIME_ONLY_TOO_SHORT)); + assertEquals("", headFilter(META_TIME_ONLY_NEGATIVE)); + assertEquals(META_TIME_ONLY_BADNUM_OUT, headFilter(META_TIME_ONLY_BADNUM1)); + assertEquals(META_TIME_ONLY_BADNUM_OUT, headFilter(META_TIME_ONLY_BADNUM2)); + assertEquals(META_VALID_REDIRECT, headFilter(META_VALID_REDIRECT)); + assertEquals(META_VALID_REDIRECT, headFilter(META_VALID_REDIRECT_NOSPACE)); + assertEquals(META_BOGUS_REDIRECT1_OUT, headFilter(META_BOGUS_REDIRECT1)); + assertEquals(META_BOGUS_REDIRECT1_OUT, headFilter(META_BOGUS_REDIRECT2)); + assertEquals(META_BOGUS_REDIRECT3_OUT, headFilter(META_BOGUS_REDIRECT3)); + assertEquals(META_BOGUS_REDIRECT4_OUT, headFilter(META_BOGUS_REDIRECT4)); + assertEquals(META_BOGUS_REDIRECT1_OUT, headFilter(META_BOGUS_REDIRECT5)); + assertEquals(META_BOGUS_REDIRECT_NO_URL, headFilter(META_BOGUS_REDIRECT6)); + HTMLFilter.metaRefreshSamePageMinInterval = -1; + HTMLFilter.metaRefreshRedirectMinInterval = -1; + assertEquals("", headFilter(META_TIME_ONLY)); + assertEquals("", headFilter(META_TIME_ONLY_WRONG_CASE)); + assertEquals("", headFilter(META_TIME_ONLY_TOO_SHORT)); + assertEquals("", headFilter(META_TIME_ONLY_NEGATIVE)); + assertEquals("", headFilter(META_TIME_ONLY_BADNUM1)); + assertEquals("", headFilter(META_TIME_ONLY_BADNUM2)); + assertEquals("", headFilter(META_VALID_REDIRECT)); + assertEquals("", headFilter(META_VALID_REDIRECT_NOSPACE)); + assertEquals("", headFilter(META_BOGUS_REDIRECT1)); + assertEquals("", headFilter(META_BOGUS_REDIRECT2)); + assertEquals("", headFilter(META_BOGUS_REDIRECT3)); + assertEquals("", headFilter(META_BOGUS_REDIRECT4)); + assertEquals("", headFilter(META_BOGUS_REDIRECT5)); + assertEquals("", headFilter(META_BOGUS_REDIRECT6)); + } + + private String headFilter(String data) throws Exception { + String s = htmlFilter("" + data + ""); + if (s == null) { + return s; + } + + MatcherAssert.assertThat(s, startsWith("")); + MatcherAssert.assertThat(s, endsWith("")); + + s = s.substring("".length()); + s = s.substring(0, s.length() - "".length()); + return s; + } + + @Test + public void testThatHtml5MetaCharsetIsPreserved() throws Exception { + assertEquals(META_CHARSET, htmlFilter(META_CHARSET)); + assertEquals(META_CHARSET_LOWER_RES, htmlFilter(META_CHARSET_LOWER)); + } + + @Test + public void testEvilCharset() throws IOException { + // This is why we need to disallow characters before !! + String s = "Blah"; + String end = ""; + String alt = "Blah"; + if ((s.length() + end.length()) % 2 == 1) { + s += " "; + } + s = s + end; + byte[] buf = s.getBytes(StandardCharsets.UTF_8); + byte[] utf16bom = new byte[]{(byte) 0xFE, (byte) 0xFF}; + byte[] bufUTF16 = alt.getBytes(StandardCharsets.UTF_16); + byte[] total = new byte[buf.length + utf16bom.length + bufUTF16.length]; + System.arraycopy(utf16bom, 0, total, 0, utf16bom.length); + System.arraycopy(buf, 0, total, utf16bom.length, buf.length); + System.arraycopy(bufUTF16, 0, total, utf16bom.length + buf.length, bufUTF16.length); + HTMLFilter filter = new HTMLFilter(); + boolean failed = false; + List failures = new ArrayList<>(); + try ( + FileOutputStream fos = new FileOutputStream("output.utf16") + ){ + ArrayBucket out = new ArrayBucket(); + filter.readFilter(new ArrayBucket(total).getInputStream(), out.getOutputStream(), "UTF-16", null, null, null); + fos.write(out.toByteArray()); + failed = true; + failures.add(new RuntimeException("Filter accepted dangerous UTF8 text with BOM as UTF16! (HTMLFilter)")); + } catch (DataFilterException e) { + System.out.println("Failure: " + e); + e.printStackTrace(); + if (e.getCause() != null) { + e.getCause().printStackTrace(); + } + // Ok. + } + try ( + FileOutputStream fos = new FileOutputStream("output.filtered") + ){ + ArrayBucket out = new ArrayBucket(); + FilterStatus fo = ContentFilter.filter(new ArrayBucket(total).getInputStream(), out.getOutputStream(), "text/html", null, null, null); + fos.write(out.toByteArray()); + failed = true; + failures.add(new RuntimeException("Filter accepted dangerous UTF8 text with BOM as UTF16! (ContentFilter) - Detected charset: " + fo.charset)); + } catch (DataFilterException e) { + System.out.println("Failure: " + e); + e.printStackTrace(); + if (e.getCause() != null) { + e.getCause().printStackTrace(); + } + // Ok. + } + + if (failed) { + try (FileOutputStream fos = new FileOutputStream("unfiltered")) { + fos.write(total); + } + throw failures.get(0); + } + } + + public static String htmlFilter(String data) throws Exception { + if (data.startsWith("" + data + "", false); + assertTrue(s.startsWith("")); + s = s.substring("".length()); + assertTrue("s = \"" + s + "\"", s.endsWith("")); + s = s.substring(0, s.length() - "".length()); + return s; + } + + public static String htmlFilter(String data, boolean alt) throws Exception { + String typeName = "text/html"; + URI baseURI = new URI(alt ? ALT_BASE_URI : BASE_URI); + byte[] dataToFilter = data.getBytes(StandardCharsets.UTF_8); + ArrayBucket input = new ArrayBucket(dataToFilter); + ArrayBucket output = new ArrayBucket(); + try ( + OutputStream outputStream = output.getOutputStream(); + InputStream inputStream = input.getInputStream() + ) { + ContentFilter.filter(inputStream, outputStream, typeName, baseURI, null, null, null, null); + } finally { + input.free(); + } + String returnValue = output.toString(); + output.free(); + return returnValue; + } + + @Test + public void testLowerCaseExtensions() { + for (FilterMIMEType type : ContentFilter.mimeTypesByName.values()) { + String ext = type.primaryExtension; + if (ext != null) { + assertEquals(ext, ext.toLowerCase()); + } + String[] exts = type.alternateExtensions; + if (ext != null) { + for (String s : exts) { + assertEquals(s, s.toLowerCase()); + } + } + } + } } diff --git a/test/freenet/client/filter/FilterUtilsTest.java b/test/freenet/client/filter/FilterUtilsTest.java index fff69705ba5..14177c329fa 100755 --- a/test/freenet/client/filter/FilterUtilsTest.java +++ b/test/freenet/client/filter/FilterUtilsTest.java @@ -6,7 +6,7 @@ public class FilterUtilsTest { @Test - public void testValidLenthUnits() { + public void testValidLengthUnits() { // Test all valid length units for CSS and valid values assertTrue(FilterUtils.isLength("1em", false)); assertTrue(FilterUtils.isLength("1.12em", false)); diff --git a/test/freenet/client/filter/GIFFilterTest.java b/test/freenet/client/filter/GIFFilterTest.java index 0394803eee7..57b6ad1a792 100644 --- a/test/freenet/client/filter/GIFFilterTest.java +++ b/test/freenet/client/filter/GIFFilterTest.java @@ -117,17 +117,16 @@ public void testFilterPairs() throws IOException { @Test public void testReject() throws IOException { + ContentDataFilter filter = new GIFFilter(); for (String reject : REJECT) { try (InputStream inStream = resourceToBucket(reject).getInputStream(); NullOutputStream outStream = new NullOutputStream()) { - ContentDataFilter filter = new GIFFilter(); - try { - filter.readFilter(inStream, outStream, "", null, null, null); - fail("Filter did not fail on reject sample " + reject); - } catch (DataFilterException e) { - // Expected. - } + assertThrows( + "Filter did not fail on reject sample " + reject, + DataFilterException.class, + () -> filter.readFilter(inStream, outStream, "", null, null, null) + ); } } } @@ -180,10 +179,6 @@ private static Bucket filterGIF(Bucket input) throws IOException { * @throws AssertionError on failure */ private static Bucket resourceToBucket(String filename) throws IOException { - InputStream is = GIFFilterTest.class.getResourceAsStream(RESOURCE_PATH + filename); - Bucket ab = new ArrayBucket(); - BucketTools.copyFrom(ab, is, Long.MAX_VALUE); - - return ab; + return ResourceFileUtil.resourceToBucket(RESOURCE_PATH + filename); } } diff --git a/test/freenet/client/filter/JPEGFilterTest.java b/test/freenet/client/filter/JPEGFilterTest.java index 7521660f946..452ac2b4d37 100644 --- a/test/freenet/client/filter/JPEGFilterTest.java +++ b/test/freenet/client/filter/JPEGFilterTest.java @@ -7,7 +7,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.Arrays; import java.util.HashMap; import org.junit.Test; @@ -27,14 +26,14 @@ public void testThatAThumbnailExtensionCodeIsPreserved() throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); jpegFilter.readFilter(inputStream, outputStream, "UTF-8", new HashMap<>(), null, new NullFilterCallback()); byte[] filteredJpegFile = outputStream.toByteArray(); - assertTrue(Arrays.equals(jpegFile, filteredJpegFile)); + assertArrayEquals(jpegFile, filteredJpegFile); } private byte[] createValidJpegFileWithThumbnail() throws IOException { ByteArrayOutputStream jpegFile = new ByteArrayOutputStream(); writeStartOfImageMarker(jpegFile); - writeAppMarker(jpegFile, 0, new byte[]{0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); - writeAppMarker(jpegFile, 0, new byte[]{0x4a, 0x46, 0x58, 0x58, 0x00, 0x13, 0x01, 0x01, 0x00, 0x7f, 0x00}); + writeAppMarker(jpegFile, new byte[]{0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); + writeAppMarker(jpegFile, new byte[]{0x4a, 0x46, 0x58, 0x58, 0x00, 0x13, 0x01, 0x01, 0x00, 0x7f, 0x00}); writeEndOfImageMarker(jpegFile); return jpegFile.toByteArray(); } @@ -43,8 +42,8 @@ private void writeStartOfImageMarker(OutputStream outputStream) throws IOExcepti outputStream.write(new byte[]{(byte) 0xff, (byte) 0xd8}); } - private void writeAppMarker(OutputStream outputStream, int app, byte[] payload) throws IOException { - outputStream.write(new byte[]{(byte) 0xff, (byte) (0xe0 + app)}); + private void writeAppMarker(OutputStream outputStream, byte[] payload) throws IOException { + outputStream.write(new byte[]{(byte) 0xff, (byte) (0xe0)}); int payloadLengthIncludingLength = payload.length + 2; outputStream.write(new byte[]{(byte) ((payloadLengthIncludingLength >> 8) & 0xff), (byte) (payloadLengthIncludingLength & 0xff)}); outputStream.write(payload); diff --git a/test/freenet/client/filter/M3UFilterTest.java b/test/freenet/client/filter/M3UFilterTest.java index 453d748f4a2..6a857b6ef2a 100644 --- a/test/freenet/client/filter/M3UFilterTest.java +++ b/test/freenet/client/filter/M3UFilterTest.java @@ -3,17 +3,13 @@ import static org.junit.Assert.*; import java.io.IOException; -import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; import org.junit.Test; import freenet.support.api.Bucket; import freenet.support.io.ArrayBucket; -import freenet.support.io.BucketTools; public class M3UFilterTest { protected static String[][] testPlaylists = { @@ -34,32 +30,28 @@ public void testSuiteTest() throws IOException { String correct = test[1]; Bucket ibo; Bucket ibprocessed = new ArrayBucket(); - Bucket ibc; - ibo = resourceToBucket(original); - ibc = resourceToBucket(correct); + ArrayBucket ibc; + ibo = ResourceFileUtil.resourceToBucket(original); + ibc = ResourceFileUtil.resourceToBucket(correct); try { filter.readFilter(ibo.getInputStream(), ibprocessed.getOutputStream(), "UTF-8", null, SCHEME_HOST_PORT, new GenericReadFilterCallback(new URI(BASE_URI), null, null, null)); String result = ibprocessed.toString(); - assertTrue(original + " should be filtered as " + correct + " but was filtered as\n" + result + "\ninstead of the correct\n" + bucketToString((ArrayBucket)ibc), result.equals(bucketToString((ArrayBucket)ibc))); + assertEquals( + original + " should be filtered as " + correct + " but was filtered as\n" + result + "\ninstead of the correct\n" + bucketToString(ibc), + bucketToString(ibc), + result + ); } catch (DataFilterException dfe) { - assertTrue("Filtering " + original + " failed", false); + fail("Filtering " + original + " failed"); } catch (URISyntaxException use) { - assertTrue("Creating URI from BASE_URI " + BASE_URI + " failed", false); + fail("Creating URI from BASE_URI " + BASE_URI + " failed"); } } } - protected ArrayBucket resourceToBucket(String filename) throws IOException { - InputStream is = getClass().getResourceAsStream(filename); - if (is == null) throw new java.io.FileNotFoundException(filename); - ArrayBucket ab = new ArrayBucket(); - BucketTools.copyFrom(ab, is, Long.MAX_VALUE); - return ab; - } - protected String bucketToString(ArrayBucket bucket) throws IOException { return new String(bucket.toByteArray()); } diff --git a/test/freenet/client/filter/MP3FilterTest.java b/test/freenet/client/filter/MP3FilterTest.java index 3db95d1bde1..ed9bffd1f71 100644 --- a/test/freenet/client/filter/MP3FilterTest.java +++ b/test/freenet/client/filter/MP3FilterTest.java @@ -106,28 +106,15 @@ private static Bucket filterMP3(Bucket input) { ContentDataFilter filter = new MP3Filter(); Bucket output = new ArrayBucket(); - InputStream inStream; - OutputStream outStream; - try { - inStream = input.getInputStream(); - outStream = output.getOutputStream(); - } catch (IOException e) { - throw new AssertionError(e); - } - - try { + try ( + InputStream inStream = input.getInputStream(); + OutputStream outStream = output.getOutputStream(); + ) { filter.readFilter(inStream, outStream, "", null, null, null); } catch (Exception e) { throw new AssertionError("Unexpected exception in the content filter.", e); } - try { - inStream.close(); - outStream.close(); - } catch (IOException e) { - throw new AssertionError(e); - } - return output; } @@ -137,16 +124,10 @@ private static Bucket filterMP3(Bucket input) { * @throws AssertionError on failure */ private static Bucket resourceToBucket(String filename) { - InputStream is = MP3FilterTest.class.getResourceAsStream(RESOURCE_PATH + filename); - if (is == null) { - throw new AssertionError("Test resource could not be opened: " + filename); - } - Bucket ab = new ArrayBucket(); - try { - BucketTools.copyFrom(ab, is, Long.MAX_VALUE); - } catch (Exception e) { + try { + return ResourceFileUtil.resourceToBucket(RESOURCE_PATH + filename); + } catch (IOException e) { throw new AssertionError(e); } - return ab; } } diff --git a/test/freenet/client/filter/OggBitStreamFilterTest.java b/test/freenet/client/filter/OggBitStreamFilterTest.java index 6e1d843ffcb..da355ca5dfe 100644 --- a/test/freenet/client/filter/OggBitStreamFilterTest.java +++ b/test/freenet/client/filter/OggBitStreamFilterTest.java @@ -1,10 +1,9 @@ package freenet.client.filter; +import static freenet.client.filter.ResourceFileUtil.testResourceFile; import static org.junit.Assert.*; -import java.io.DataInputStream; import java.io.IOException; -import java.io.InputStream; import org.junit.Test; @@ -12,44 +11,42 @@ public class OggBitStreamFilterTest { @Test public void testGetVorbisBitstreamFilter() throws IOException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/vorbis_header.ogg")); - OggPage page = OggPage.readPage(input); - assertEquals(VorbisBitstreamFilter.class, getFilterClass(page)); - input.close(); + testResourceFile("./ogg/vorbis_header.ogg", (input) -> { + OggPage page = OggPage.readPage(input); + assertEquals(VorbisBitstreamFilter.class, getFilterClass(page)); + }); } @Test - public void testGetTheoraBitStreamFilter() throws IOException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/theora_header.ogg")); - OggPage page = OggPage.readPage(input); - assertEquals(TheoraBitstreamFilter.class, getFilterClass(page)); - input.close(); + public void testGetTheoraBitStreamFilter() throws IOException { + testResourceFile("./ogg/theora_header.ogg", (input) -> { + OggPage page = OggPage.readPage(input); + assertEquals(TheoraBitstreamFilter.class, getFilterClass(page)); + }); } @Test public void testGetFilterForInvalidFormat() throws IOException { - InputStream input = getClass().getResourceAsStream("./ogg/invalid_header.ogg"); - DataInputStream dis = new DataInputStream(input); - OggPage page = OggPage.readPage(dis); - assertEquals(null, getFilterClass(page)); - input.close(); + testResourceFile("./ogg/invalid_header.ogg", (input) -> { + OggPage page = OggPage.readPage(input); + assertNull(getFilterClass(page)); + }); } @Test public void testPagesOutOfOrderCausesException() throws IOException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/pages_out_of_order.ogg")); - OggPage page = OggPage.readPage(input); - OggBitstreamFilter filter = new OggBitstreamFilter(page); - page = OggPage.readPage(input); - try { - filter.parse(page); - fail("Expected exception not caught"); - } catch(DataFilterException e) {} - input.close(); + testResourceFile("./ogg/pages_out_of_order.ogg", (input) -> { + OggPage filterPage = OggPage.readPage(input); + OggBitstreamFilter filter = new OggBitstreamFilter(filterPage); + OggPage page = OggPage.readPage(input); + assertThrows(DataFilterException.class, ()-> filter.parse(page)); + }); } private Class getFilterClass(OggPage page) { OggBitstreamFilter filter = OggBitstreamFilter.getBitstreamFilter(page); - if(filter != null) return filter.getClass(); + if(filter != null) { + return filter.getClass(); + } return null; } } diff --git a/test/freenet/client/filter/OggFilterTest.java b/test/freenet/client/filter/OggFilterTest.java index 3f5ef1404e7..317660f0a40 100644 --- a/test/freenet/client/filter/OggFilterTest.java +++ b/test/freenet/client/filter/OggFilterTest.java @@ -1,14 +1,12 @@ package freenet.client.filter; +import static freenet.client.filter.ResourceFileUtil.testResourceFile; import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; import java.io.FileOutputStream; -import java.io.FileWriter; import java.io.IOException; import java.net.URL; -import java.util.Arrays; import org.apache.commons.compress.utils.IOUtils; import org.junit.Before; @@ -24,49 +22,60 @@ public void setUp() { @Test public void testEmptyOutputRaisesException() throws IOException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/invalid_header.ogg")); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - filter.readFilter(input, output, null, null, null, null); - fail("Expected Exception not caught. Output size: "+output.toByteArray().length); - } catch(DataFilterException e) {} + testResourceFile("./ogg/invalid_header.ogg", (input) -> { + assertThrows( + DataFilterException.class, + () -> filter.readFilter(input, new ByteArrayOutputStream(), null, null, null, null) + ); + }); } @Test - public void testValidSubPageStripped() throws IOException, DataFilterException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/contains_subpages.ogg")); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - filter.readFilter(input, output, null, null, null, null); - } catch(DataFilterException e) {} - assertTrue(Arrays.equals(new byte[]{}, output.toByteArray())); - input.close(); - output.close(); + public void testValidSubPageStripped() throws IOException { + testResourceFile("./ogg/contains_subpages.ogg", (input) -> { + try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { + assertThrows( + DataFilterException.class, + () -> filter.readFilter(input, output, null, null, null, null) + ); + assertArrayEquals(new byte[]{}, output.toByteArray()); + } + }); } /** the purpose of this test is to create the testoutputFile so you can check it with a video player. */ @Test - public void testFilterFfmpegEncodedVideoSegment() throws IOException, DataFilterException { - String testoutputFile = getClass().getResource( - "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--filtered-testoutput.ogv") - .getFile(); - DataInputStream inputFileUnchanged = new DataInputStream(getClass().getResourceAsStream( - "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--filtered.ogv")); - ByteArrayOutputStream unchangedData = new ByteArrayOutputStream(); - IOUtils.copy(inputFileUnchanged, unchangedData); - DataInputStream inputFileToParse = new DataInputStream(getClass().getResourceAsStream( - "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--orig.ogv")); - DataInputStream input = inputFileToParse; - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - filter.readFilter(input, output, null, null, null, null); - FileOutputStream newFileStream = new FileOutputStream(testoutputFile); - System.out.println(testoutputFile); + public void testFilterFfmpegEncodedVideoSegment() throws IOException { + try ( + ByteArrayOutputStream unchangedData = new ByteArrayOutputStream(); + ByteArrayOutputStream output = new ByteArrayOutputStream() + ) { + testResourceFile( + "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--filtered.ogv", + (inputFileUnchanged) -> IOUtils.copy(inputFileUnchanged, unchangedData) + ); + testResourceFile( + "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--orig.ogv", + (input) -> { + filter.readFilter(input, output, null, null, null, null); + writeToTestOutputFile(output); + } + ); + assertArrayEquals(unchangedData.toByteArray(), output.toByteArray()); + } + } + + private void writeToTestOutputFile(ByteArrayOutputStream output) throws IOException { + URL resource = getClass().getResource( + "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--filtered-testoutput.ogv" + ); + if (resource == null) { + throw new RuntimeException("Test file is not found"); + } + String testOutputFile = resource.getFile(); + System.out.println(testOutputFile); + try (FileOutputStream newFileStream = new FileOutputStream(testOutputFile)) { output.writeTo(newFileStream); - newFileStream.close(); - } catch(DataFilterException e) {} - assertTrue(Arrays.equals(unchangedData.toByteArray(), output.toByteArray())); - input.close(); - output.close(); + } } } diff --git a/test/freenet/client/filter/OggPageTest.java b/test/freenet/client/filter/OggPageTest.java index 393830bc135..72844204f14 100644 --- a/test/freenet/client/filter/OggPageTest.java +++ b/test/freenet/client/filter/OggPageTest.java @@ -1,59 +1,57 @@ package freenet.client.filter; +import static freenet.client.filter.ResourceFileUtil.testResourceFile; import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; -import java.io.DataOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; import org.junit.Test; public class OggPageTest { @Test public void testStripNonsenseInterruption() throws IOException { - InputStream badData = getClass().getResourceAsStream("./ogg/nonsensical_interruption.ogg"); - ByteArrayOutputStream filteredDataStream = new ByteArrayOutputStream(); - DataOutputStream output = new DataOutputStream(filteredDataStream); - DataInputStream input = new DataInputStream(badData); - OggPage page = OggPage.readPage(input); - if(page.headerValid()) output.write(page.toArray()); - page = OggPage.readPage(input); - if(page.headerValid()) output.write(page.toArray()); - byte[] filteredData = filteredDataStream.toByteArray(); - output.close(); - input.close(); + try ( + ByteArrayOutputStream actualDataStream = new ByteArrayOutputStream(); + ByteArrayOutputStream expectedDataStream = new ByteArrayOutputStream() + ) { + testResourceFile( + "./ogg/nonsensical_interruption_filtered.ogg", + (input) -> readPages(expectedDataStream, input) + ); + testResourceFile( + "./ogg/nonsensical_interruption.ogg", + (input) -> readPages(actualDataStream, input) + ); + assertArrayEquals(expectedDataStream.toByteArray(), actualDataStream.toByteArray()); + } + } - InputStream goodData = getClass().getResourceAsStream("./ogg/nonsensical_interruption_filtered.ogg"); - input = new DataInputStream(goodData); - ByteArrayOutputStream expectedDataStream = new ByteArrayOutputStream(); - output = new DataOutputStream(expectedDataStream); - page = OggPage.readPage(input); - if(page.headerValid()) output.write(page.toArray()); + private static void readPages(ByteArrayOutputStream output, DataInputStream input) throws IOException { + OggPage page = OggPage.readPage(input); + if (page.headerValid()) { + output.write(page.toArray()); + } page = OggPage.readPage(input); - if(page.headerValid()) output.write(page.toArray()); - byte[] expectedData = expectedDataStream.toByteArray(); - output.close(); - input.close(); - - assertTrue(Arrays.equals(filteredData, expectedData)); + if (page.headerValid()) { + output.write(page.toArray()); + } } @Test public void testChecksum() throws IOException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/valid_checksum.ogg")); - OggPage page = OggPage.readPage(input); - assertTrue(page.headerValid()); - input.close(); + testResourceFile("./ogg/valid_checksum.ogg", (input) -> { + OggPage page = OggPage.readPage(input); + assertTrue(page.headerValid()); + }); } @Test public void testInvalidChecksumInvalidates() throws IOException { - DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/invalid_checksum.ogg")); - OggPage page = OggPage.readPage(input); - assertFalse(page.headerValid()); - input.close(); + testResourceFile("./ogg/invalid_checksum.ogg", (input) -> { + OggPage page = OggPage.readPage(input); + assertFalse(page.headerValid()); + }); } } diff --git a/test/freenet/client/filter/PNGFilterTest.java b/test/freenet/client/filter/PNGFilterTest.java index 2ecaa0c87c6..2fa6777e460 100644 --- a/test/freenet/client/filter/PNGFilterTest.java +++ b/test/freenet/client/filter/PNGFilterTest.java @@ -1,16 +1,14 @@ package freenet.client.filter; -import static org.junit.Assert.*; +import freenet.support.api.Bucket; +import freenet.support.io.NullBucket; +import org.junit.Test; import java.io.IOException; -import java.io.InputStream; -import org.junit.Test; - -import freenet.support.api.Bucket; -import freenet.support.io.ArrayBucket; -import freenet.support.io.BucketTools; -import freenet.support.io.NullBucket; +import static freenet.client.filter.ResourceFileUtil.resourceToBucket; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class PNGFilterTest { protected static Object[][] testImages = { @@ -124,12 +122,4 @@ public void testSuiteTest() throws IOException { } } } - - protected Bucket resourceToBucket(String filename) throws IOException { - InputStream is = getClass().getResourceAsStream(filename); - if (is == null) throw new java.io.FileNotFoundException(); - ArrayBucket ab = new ArrayBucket(); - BucketTools.copyFrom(ab, is, Long.MAX_VALUE); - return ab; - } } diff --git a/test/freenet/client/filter/ResourceFileUtil.java b/test/freenet/client/filter/ResourceFileUtil.java new file mode 100644 index 00000000000..360fcdc1f1a --- /dev/null +++ b/test/freenet/client/filter/ResourceFileUtil.java @@ -0,0 +1,41 @@ +package freenet.client.filter; + +import freenet.support.io.ArrayBucket; +import freenet.support.io.BucketTools; + +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; + +class ResourceFileUtil { + + @FunctionalInterface + interface ResourceFileStreamConsumer { + void processDataInputStream(DataInputStream dataInputStream) throws IOException; + } + + static void testResourceFile(String fileName, ResourceFileStreamConsumer inputStreamConsumer) throws IOException { + try ( + InputStream resourceAsStream = ResourceFileUtil.class.getResourceAsStream(fileName); + ) { + if (resourceAsStream == null) { + throw new RuntimeException("File should exist: " + fileName); + } + try(DataInputStream input = new DataInputStream(resourceAsStream)) { + inputStreamConsumer.processDataInputStream(input); + } + } + } + + static ArrayBucket resourceToBucket(String filename) throws IOException { + ArrayBucket ab; + try (InputStream is = ResourceFileUtil.class.getResourceAsStream(filename)) { + if (is == null) { + throw new java.io.FileNotFoundException(filename); + } + ab = new ArrayBucket(); + BucketTools.copyFrom(ab, is, Long.MAX_VALUE); + } + return ab; + } +} diff --git a/test/freenet/client/filter/TagVerifierTest.java b/test/freenet/client/filter/TagVerifierTest.java index d6276f2954e..e431b8b4a66 100644 --- a/test/freenet/client/filter/TagVerifierTest.java +++ b/test/freenet/client/filter/TagVerifierTest.java @@ -21,9 +21,9 @@ public class TagVerifierTest { private static final String BASE_KEY = "USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/55/"; private static final String ALT_BASE_URI = BASE_URI_PROTOCOL+"://"+BASE_URI_CONTENT+'/'+BASE_KEY; - static String tagname; + String tagname; LinkedHashMap attributes; - ParsedTag HTMLTag; + ParsedTag htmlTag; TagVerifier verifier; HTMLFilter filter; HTMLFilter.HTMLParseContext pc; @@ -31,7 +31,7 @@ public class TagVerifierTest { @Before public void setUp() throws Exception { filter = new HTMLFilter(); - attributes = new LinkedHashMap(); + attributes = new LinkedHashMap<>(); pc = filter.new HTMLParseContext(null, null, "utf-8", new GenericReadFilterCallback(new URI(ALT_BASE_URI), null, null, null), false); } @@ -42,11 +42,11 @@ public void tearDown() { pc = null; tagname = null; verifier = null; - HTMLTag = null; + htmlTag = null; } @Test - public void testHTMLTagWithInvalidNS() throws DataFilterException{ + public void testHTMLTagWithInvalidNS() throws DataFilterException { tagname = "html"; verifier = HTMLFilter.allowedTagsVerifiers.get(tagname); @@ -55,10 +55,10 @@ public void testHTMLTagWithInvalidNS() throws DataFilterException{ //Place a unparsed attribute into the tag attributes.put("version", "-//W3C//DTD HTML 4.01 Transitional//EN"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); final String HTML_INVALID_XMLNS = ""; - assertEquals("HTML tag containing an invalid xmlns", HTML_INVALID_XMLNS, verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("HTML tag containing an invalid xmlns", HTML_INVALID_XMLNS, verifier.sanitize(htmlTag, pc).toString()); } @Test @@ -72,11 +72,11 @@ public void testLinkTag() throws DataFilterException { attributes.put("media", "print, handheld"); attributes.put("href", "foo.css"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); final String LINK_STYLESHEET = ""; - assertEquals("Link tag importing CSS", LINK_STYLESHEET, verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("Link tag importing CSS", LINK_STYLESHEET, verifier.sanitize(htmlTag, pc).toString()); } @Test @@ -86,9 +86,9 @@ public void testMetaTagHTMLContentType() throws DataFilterException { attributes.put("http-equiv","Content-type"); attributes.put("content","text/html; charset=UTF-8"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); - assertEquals("Meta tag describing HTML content-type", HTMLTag.toString(), verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("Meta tag describing HTML content-type", htmlTag.toString(), verifier.sanitize(htmlTag, pc).toString()); } @Test @@ -98,26 +98,25 @@ public void testMetaTagXHTMLContentType() throws DataFilterException { attributes.put("http-equiv","Content-type"); attributes.put("content","application/xhtml+xml; charset=UTF-8"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); - assertEquals("Meta tag describing XHTML content-type", HTMLTag.toString(), verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("Meta tag describing XHTML content-type", htmlTag.toString(), verifier.sanitize(htmlTag, pc).toString()); } @Test - public void testMetaTagUnknownContentType() throws DataFilterException { + public void testMetaTagUnknownContentType() { tagname = "meta"; verifier = HTMLFilter.allowedTagsVerifiers.get(tagname); attributes.put("http-equiv","Content-type"); attributes.put("content","want/fishsticks; charset=UTF-8"); - HTMLTag = new ParsedTag(tagname, attributes); - - try { - verifier.sanitize(HTMLTag, pc); - assertTrue("Meta tag describing an unknown content-type: should throw an error", false); - } catch (DataFilterException e) { - // Ok. - } + htmlTag = new ParsedTag(tagname, attributes); + + assertThrows( + "Meta tag describing an unknown content-type: should throw an error", + DataFilterException.class, + () -> verifier.sanitize(htmlTag, pc) + ); } @Test @@ -129,11 +128,11 @@ public void testBodyTag() throws DataFilterException { //Let's pretend the following is malicious JavaScript attributes.put("onload", "evil_scripting_magic"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); final String BODY_TAG = ""; - assertEquals("Body tag", BODY_TAG, verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("Body tag", BODY_TAG, verifier.sanitize(htmlTag, pc).toString()); } @Test @@ -146,10 +145,10 @@ public void testFormTag() throws DataFilterException { attributes.put("accept-charset", "iso-8859-1"); attributes.put("action", "/library/"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); final String FORM_TAG = "

"; - assertEquals("Form tag", FORM_TAG, verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("Form tag", FORM_TAG, verifier.sanitize(htmlTag, pc).toString()); } @Test @@ -160,9 +159,9 @@ public void testInvalidFormMethod() throws DataFilterException { attributes.put("method", "INVALID_METHOD"); attributes.put("action", "/library/"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); - assertNull("Form tag with an invalid method", verifier.sanitize(HTMLTag, pc)); + assertNull("Form tag with an invalid method", verifier.sanitize(htmlTag, pc)); } @Test @@ -172,9 +171,9 @@ public void testValidInputTag() throws DataFilterException { attributes.put("type", "text"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); - assertEquals("Input tag with a valid type", HTMLTag.toString(), verifier.sanitize(HTMLTag, pc).toString()); + assertEquals("Input tag with a valid type", htmlTag.toString(), verifier.sanitize(htmlTag, pc).toString()); } @Test @@ -184,8 +183,8 @@ public void testInvalidInputTag() throws DataFilterException { attributes.put("type", "INVALID_TYPE"); - HTMLTag = new ParsedTag(tagname, attributes); + htmlTag = new ParsedTag(tagname, attributes); - assertNull("Input tag with an invalid type", verifier.sanitize(HTMLTag, pc)); + assertNull("Input tag with an invalid type", verifier.sanitize(htmlTag, pc)); } } diff --git a/test/freenet/client/filter/TheoraBitstreamFilterTest.java b/test/freenet/client/filter/TheoraBitstreamFilterTest.java index 888007154ed..fe58a619dd3 100644 --- a/test/freenet/client/filter/TheoraBitstreamFilterTest.java +++ b/test/freenet/client/filter/TheoraBitstreamFilterTest.java @@ -2,27 +2,28 @@ import org.junit.Test; -import java.io.DataInputStream; import java.io.EOFException; import java.io.IOException; -import static org.junit.Assert.*; +import static freenet.client.filter.ResourceFileUtil.testResourceFile; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; public class TheoraBitstreamFilterTest { @Test public void parseIdentificationHeaderTest() throws IOException { - try (DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/theora_header.ogg"))) { + testResourceFile("./ogg/theora_header.ogg", (input) -> { OggPage page = OggPage.readPage(input); TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); assertEquals(page.asPackets(), theoraBitstreamFilter.parse(page).asPackets()); - } + }); } @Test public void parseTest() throws IOException { - try (DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/Infinite_Hands-2008-Thusnelda-2009-09-18.ogv"))) { + testResourceFile("./ogg/Infinite_Hands-2008-Thusnelda-2009-09-18.ogv", (input) -> { OggPage page = OggPage.readPage(input); int pageSerial = page.getSerial(); TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); @@ -38,16 +39,15 @@ public void parseTest() throws IOException { break; } } - } + }); } - @Test(expected = UnknownContentTypeException.class) + @Test public void parseInvalidHeaderTest() throws IOException { - try (DataInputStream input = new DataInputStream(getClass().getResourceAsStream("./ogg/invalid_header.ogg"))) { + testResourceFile("./ogg/invalid_header.ogg", (input) -> { OggPage page = OggPage.readPage(input); - TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); - theoraBitstreamFilter.parse(page); - } + assertThrows(UnknownContentTypeException.class, () -> theoraBitstreamFilter.parse(page)); + }); } } From 9904a91105b291b8ae89e5b89599c4d3222982b3 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 29 Jan 2023 18:31:22 +0200 Subject: [PATCH 048/500] Minor improvements and code formatting according to #826 review * split try-with-resouces block in FailureCodeTrackerTest.getStoredLength * simplify ResourceFileUtil usage * improve code formatting Signed-off-by: Veniamin Fernandes --- .../client/FailureCodeTrackerTest.java | 8 +- test/freenet/client/FetchContextTest.java | 2 +- test/freenet/client/filter/CSSParserTest.java | 8 +- test/freenet/client/filter/GIFFilterTest.java | 2 +- .../client/filter/OggBitStreamFilterTest.java | 79 +++++++++---------- test/freenet/client/filter/OggFilterTest.java | 51 ++++++------ test/freenet/client/filter/OggPageTest.java | 36 ++++----- .../client/filter/ResourceFileUtil.java | 29 +++---- .../filter/TheoraBitstreamFilterTest.java | 25 +++--- 9 files changed, 110 insertions(+), 130 deletions(-) diff --git a/test/freenet/client/FailureCodeTrackerTest.java b/test/freenet/client/FailureCodeTrackerTest.java index cd8690c3144..eb1ac2eefa9 100644 --- a/test/freenet/client/FailureCodeTrackerTest.java +++ b/test/freenet/client/FailureCodeTrackerTest.java @@ -32,13 +32,11 @@ public void testSize(boolean insert) throws IOException { } private int getStoredLength(FailureCodeTracker f) throws IOException { - try ( - CountedOutputStream os = new CountedOutputStream(new NullOutputStream()); - DataOutputStream dos = new DataOutputStream(os) - ) { + CountedOutputStream os = new CountedOutputStream(new NullOutputStream()); + try (DataOutputStream dos = new DataOutputStream(os)) { f.writeFixedLengthTo(dos); - return (int) os.written(); } + return (int) os.written(); } } diff --git a/test/freenet/client/FetchContextTest.java b/test/freenet/client/FetchContextTest.java index 2c4ac174f67..1828489cab9 100644 --- a/test/freenet/client/FetchContextTest.java +++ b/test/freenet/client/FetchContextTest.java @@ -23,7 +23,7 @@ public void testPersistence() throws IOException, StorageFormatException { new ArrayBucketFactory(), new SimpleEventProducer() ); - final ArrayBucket bucket = new ArrayBucket(); + ArrayBucket bucket = new ArrayBucket(); try { try (DataOutputStream dos = new DataOutputStream(bucket.getOutputStream())) { context.writeTo(dos); diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index b199c8b5c1e..46e480b24fa 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -11,8 +11,12 @@ import java.io.StringWriter; import java.net.URI; import java.net.URISyntaxException; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.hamcrest.MatcherAssert; import org.junit.Before; @@ -927,7 +931,7 @@ private void testCssSelectorFiltering(Map cssSelectorMap) throws } private void testBadSelectorFiltering(Set badSelectorSet) throws IOException, URISyntaxException { - for(String key : badSelectorSet) { + for (String key : badSelectorSet) { assertEquals( "Bad selector filtering should produce empty string: '" + key + "'", "", diff --git a/test/freenet/client/filter/GIFFilterTest.java b/test/freenet/client/filter/GIFFilterTest.java index 57b6ad1a792..5aff6b485e3 100644 --- a/test/freenet/client/filter/GIFFilterTest.java +++ b/test/freenet/client/filter/GIFFilterTest.java @@ -117,11 +117,11 @@ public void testFilterPairs() throws IOException { @Test public void testReject() throws IOException { - ContentDataFilter filter = new GIFFilter(); for (String reject : REJECT) { try (InputStream inStream = resourceToBucket(reject).getInputStream(); NullOutputStream outStream = new NullOutputStream()) { + ContentDataFilter filter = new GIFFilter(); assertThrows( "Filter did not fail on reject sample " + reject, DataFilterException.class, diff --git a/test/freenet/client/filter/OggBitStreamFilterTest.java b/test/freenet/client/filter/OggBitStreamFilterTest.java index da355ca5dfe..43ad28320c6 100644 --- a/test/freenet/client/filter/OggBitStreamFilterTest.java +++ b/test/freenet/client/filter/OggBitStreamFilterTest.java @@ -1,52 +1,49 @@ package freenet.client.filter; -import static freenet.client.filter.ResourceFileUtil.testResourceFile; +import static freenet.client.filter.ResourceFileUtil.resourceToDataInputStream; +import static freenet.client.filter.ResourceFileUtil.resourceToOggPage; import static org.junit.Assert.*; +import java.io.DataInputStream; import java.io.IOException; import org.junit.Test; public class OggBitStreamFilterTest { - @Test - public void testGetVorbisBitstreamFilter() throws IOException { - testResourceFile("./ogg/vorbis_header.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - assertEquals(VorbisBitstreamFilter.class, getFilterClass(page)); - }); - } - - @Test - public void testGetTheoraBitStreamFilter() throws IOException { - testResourceFile("./ogg/theora_header.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - assertEquals(TheoraBitstreamFilter.class, getFilterClass(page)); - }); - } - @Test - public void testGetFilterForInvalidFormat() throws IOException { - testResourceFile("./ogg/invalid_header.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - assertNull(getFilterClass(page)); - }); - } - - @Test - public void testPagesOutOfOrderCausesException() throws IOException { - testResourceFile("./ogg/pages_out_of_order.ogg", (input) -> { - OggPage filterPage = OggPage.readPage(input); - OggBitstreamFilter filter = new OggBitstreamFilter(filterPage); - OggPage page = OggPage.readPage(input); - assertThrows(DataFilterException.class, ()-> filter.parse(page)); - }); - } - - private Class getFilterClass(OggPage page) { - OggBitstreamFilter filter = OggBitstreamFilter.getBitstreamFilter(page); - if(filter != null) { - return filter.getClass(); - } - return null; - } + @Test + public void testGetVorbisBitstreamFilter() throws IOException { + OggPage page = resourceToOggPage("./ogg/vorbis_header.ogg"); + assertEquals(VorbisBitstreamFilter.class, getFilterClass(page)); + } + + @Test + public void testGetTheoraBitStreamFilter() throws IOException { + OggPage page = resourceToOggPage("./ogg/theora_header.ogg"); + assertEquals(TheoraBitstreamFilter.class, getFilterClass(page)); + } + + @Test + public void testGetFilterForInvalidFormat() throws IOException { + OggPage page = resourceToOggPage("./ogg/invalid_header.ogg"); + assertNull(getFilterClass(page)); + } + + @Test + public void testPagesOutOfOrderCausesException() throws IOException { + try (DataInputStream input = resourceToDataInputStream("./ogg/pages_out_of_order.ogg")) { + OggPage filterPage = OggPage.readPage(input); + OggBitstreamFilter filter = new OggBitstreamFilter(filterPage); + OggPage page = OggPage.readPage(input); + assertThrows(DataFilterException.class, () -> filter.parse(page)); + } + } + + private Class getFilterClass(OggPage page) { + OggBitstreamFilter filter = OggBitstreamFilter.getBitstreamFilter(page); + if (filter != null) { + return filter.getClass(); + } + return null; + } } diff --git a/test/freenet/client/filter/OggFilterTest.java b/test/freenet/client/filter/OggFilterTest.java index 317660f0a40..e4eda7227d5 100644 --- a/test/freenet/client/filter/OggFilterTest.java +++ b/test/freenet/client/filter/OggFilterTest.java @@ -1,9 +1,10 @@ package freenet.client.filter; -import static freenet.client.filter.ResourceFileUtil.testResourceFile; +import static freenet.client.filter.ResourceFileUtil.resourceToDataInputStream; import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.net.URL; @@ -22,47 +23,41 @@ public void setUp() { @Test public void testEmptyOutputRaisesException() throws IOException { - testResourceFile("./ogg/invalid_header.ogg", (input) -> { + try (DataInputStream input = resourceToDataInputStream("./ogg/invalid_header.ogg")) { assertThrows( DataFilterException.class, () -> filter.readFilter(input, new ByteArrayOutputStream(), null, null, null, null) ); - }); + } } @Test public void testValidSubPageStripped() throws IOException { - testResourceFile("./ogg/contains_subpages.ogg", (input) -> { - try (ByteArrayOutputStream output = new ByteArrayOutputStream()) { - assertThrows( - DataFilterException.class, - () -> filter.readFilter(input, output, null, null, null, null) - ); - assertArrayEquals(new byte[]{}, output.toByteArray()); - } - }); + try ( + DataInputStream input = resourceToDataInputStream("./ogg/contains_subpages.ogg"); + ByteArrayOutputStream output = new ByteArrayOutputStream() + ) { + assertThrows( + DataFilterException.class, + () -> filter.readFilter(input, output, null, null, null, null) + ); + assertArrayEquals(new byte[]{}, output.toByteArray()); + } } /** the purpose of this test is to create the testoutputFile so you can check it with a video player. */ @Test public void testFilterFfmpegEncodedVideoSegment() throws IOException { - try ( - ByteArrayOutputStream unchangedData = new ByteArrayOutputStream(); - ByteArrayOutputStream output = new ByteArrayOutputStream() - ) { - testResourceFile( - "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--filtered.ogv", - (inputFileUnchanged) -> IOUtils.copy(inputFileUnchanged, unchangedData) - ); - testResourceFile( - "./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--orig.ogv", - (input) -> { - filter.readFilter(input, output, null, null, null, null); - writeToTestOutputFile(output); - } - ); - assertArrayEquals(unchangedData.toByteArray(), output.toByteArray()); + ByteArrayOutputStream expectedData = new ByteArrayOutputStream(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + try (DataInputStream input = resourceToDataInputStream("./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--filtered.ogv")) { + IOUtils.copy(input, expectedData); + } + try (DataInputStream input = resourceToDataInputStream("./ogg/36C3_-_opening--cc-by--c3voc--fem-ags-opensuse--ccc--orig.ogv")) { + filter.readFilter(input, output, null, null, null, null); + writeToTestOutputFile(output); } + assertArrayEquals(expectedData.toByteArray(), output.toByteArray()); } private void writeToTestOutputFile(ByteArrayOutputStream output) throws IOException { diff --git a/test/freenet/client/filter/OggPageTest.java b/test/freenet/client/filter/OggPageTest.java index 72844204f14..1c48aa2901d 100644 --- a/test/freenet/client/filter/OggPageTest.java +++ b/test/freenet/client/filter/OggPageTest.java @@ -1,6 +1,7 @@ package freenet.client.filter; -import static freenet.client.filter.ResourceFileUtil.testResourceFile; +import static freenet.client.filter.ResourceFileUtil.resourceToDataInputStream; +import static freenet.client.filter.ResourceFileUtil.resourceToOggPage; import static org.junit.Assert.*; import java.io.ByteArrayOutputStream; @@ -12,20 +13,15 @@ public class OggPageTest { @Test public void testStripNonsenseInterruption() throws IOException { - try ( - ByteArrayOutputStream actualDataStream = new ByteArrayOutputStream(); - ByteArrayOutputStream expectedDataStream = new ByteArrayOutputStream() - ) { - testResourceFile( - "./ogg/nonsensical_interruption_filtered.ogg", - (input) -> readPages(expectedDataStream, input) - ); - testResourceFile( - "./ogg/nonsensical_interruption.ogg", - (input) -> readPages(actualDataStream, input) - ); - assertArrayEquals(expectedDataStream.toByteArray(), actualDataStream.toByteArray()); + ByteArrayOutputStream actualDataStream = new ByteArrayOutputStream(); + ByteArrayOutputStream expectedDataStream = new ByteArrayOutputStream(); + try (DataInputStream input = resourceToDataInputStream("./ogg/nonsensical_interruption_filtered.ogg")) { + readPages(expectedDataStream, input); } + try (DataInputStream input = resourceToDataInputStream("./ogg/nonsensical_interruption.ogg")) { + readPages(actualDataStream, input); + } + assertArrayEquals(expectedDataStream.toByteArray(), actualDataStream.toByteArray()); } private static void readPages(ByteArrayOutputStream output, DataInputStream input) throws IOException { @@ -41,17 +37,13 @@ private static void readPages(ByteArrayOutputStream output, DataInputStream inpu @Test public void testChecksum() throws IOException { - testResourceFile("./ogg/valid_checksum.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - assertTrue(page.headerValid()); - }); + OggPage page = resourceToOggPage("./ogg/valid_checksum.ogg"); + assertTrue(page.headerValid()); } @Test public void testInvalidChecksumInvalidates() throws IOException { - testResourceFile("./ogg/invalid_checksum.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - assertFalse(page.headerValid()); - }); + OggPage page = resourceToOggPage("./ogg/invalid_checksum.ogg"); + assertFalse(page.headerValid()); } } diff --git a/test/freenet/client/filter/ResourceFileUtil.java b/test/freenet/client/filter/ResourceFileUtil.java index 360fcdc1f1a..651028863da 100644 --- a/test/freenet/client/filter/ResourceFileUtil.java +++ b/test/freenet/client/filter/ResourceFileUtil.java @@ -4,34 +4,31 @@ import freenet.support.io.BucketTools; import java.io.DataInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; class ResourceFileUtil { - @FunctionalInterface - interface ResourceFileStreamConsumer { - void processDataInputStream(DataInputStream dataInputStream) throws IOException; + static DataInputStream resourceToDataInputStream(String fileName) throws IOException { + InputStream resourceAsStream = ResourceFileUtil.class.getResourceAsStream(fileName); + if (resourceAsStream == null) { + throw new FileNotFoundException(fileName); + } + return new DataInputStream(resourceAsStream); } - static void testResourceFile(String fileName, ResourceFileStreamConsumer inputStreamConsumer) throws IOException { - try ( - InputStream resourceAsStream = ResourceFileUtil.class.getResourceAsStream(fileName); - ) { - if (resourceAsStream == null) { - throw new RuntimeException("File should exist: " + fileName); - } - try(DataInputStream input = new DataInputStream(resourceAsStream)) { - inputStreamConsumer.processDataInputStream(input); - } + static OggPage resourceToOggPage(String fileName) throws IOException { + try (DataInputStream input = resourceToDataInputStream(fileName)) { + return OggPage.readPage(input); } } - static ArrayBucket resourceToBucket(String filename) throws IOException { + static ArrayBucket resourceToBucket(String fileName) throws IOException { ArrayBucket ab; - try (InputStream is = ResourceFileUtil.class.getResourceAsStream(filename)) { + try (InputStream is = ResourceFileUtil.class.getResourceAsStream(fileName)) { if (is == null) { - throw new java.io.FileNotFoundException(filename); + throw new FileNotFoundException(fileName); } ab = new ArrayBucket(); BucketTools.copyFrom(ab, is, Long.MAX_VALUE); diff --git a/test/freenet/client/filter/TheoraBitstreamFilterTest.java b/test/freenet/client/filter/TheoraBitstreamFilterTest.java index fe58a619dd3..24c396ead7e 100644 --- a/test/freenet/client/filter/TheoraBitstreamFilterTest.java +++ b/test/freenet/client/filter/TheoraBitstreamFilterTest.java @@ -2,10 +2,12 @@ import org.junit.Test; +import java.io.DataInputStream; import java.io.EOFException; import java.io.IOException; -import static freenet.client.filter.ResourceFileUtil.testResourceFile; +import static freenet.client.filter.ResourceFileUtil.resourceToDataInputStream; +import static freenet.client.filter.ResourceFileUtil.resourceToOggPage; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; @@ -13,17 +15,14 @@ public class TheoraBitstreamFilterTest { @Test public void parseIdentificationHeaderTest() throws IOException { - testResourceFile("./ogg/theora_header.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - - TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); - assertEquals(page.asPackets(), theoraBitstreamFilter.parse(page).asPackets()); - }); + OggPage page = resourceToOggPage("./ogg/theora_header.ogg"); + TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); + assertEquals(page.asPackets(), theoraBitstreamFilter.parse(page).asPackets()); } @Test public void parseTest() throws IOException { - testResourceFile("./ogg/Infinite_Hands-2008-Thusnelda-2009-09-18.ogv", (input) -> { + try (DataInputStream input = resourceToDataInputStream("./ogg/Infinite_Hands-2008-Thusnelda-2009-09-18.ogv")) { OggPage page = OggPage.readPage(input); int pageSerial = page.getSerial(); TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); @@ -39,15 +38,13 @@ public void parseTest() throws IOException { break; } } - }); + } } @Test public void parseInvalidHeaderTest() throws IOException { - testResourceFile("./ogg/invalid_header.ogg", (input) -> { - OggPage page = OggPage.readPage(input); - TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); - assertThrows(UnknownContentTypeException.class, () -> theoraBitstreamFilter.parse(page)); - }); + OggPage page = resourceToOggPage("./ogg/invalid_header.ogg"); + TheoraBitstreamFilter theoraBitstreamFilter = new TheoraBitstreamFilter(page); + assertThrows(UnknownContentTypeException.class, () -> theoraBitstreamFilter.parse(page)); } } From 8991303493f2c0d9933f645337f0a7a5a979e70a Mon Sep 17 00:00:00 2001 From: Christophe Date: Wed, 8 Feb 2023 15:48:11 +0100 Subject: [PATCH 049/500] Upgrade to Gradle 7.6 This upgrade enables using the Gradle Linux Packaging Plugin (ospackage) in order to easily generate RPM and DEB packages for the Freenet REference Daemon on Linux OS. --- build.gradle | 101 ++-- gradle/verification-keyring.keys | 601 +++++++++++++++++++++++ gradle/verification-metadata.xml | 111 +++++ gradle/wrapper/gradle-wrapper.properties | 4 +- 4 files changed, 758 insertions(+), 59 deletions(-) create mode 100644 gradle/verification-keyring.keys create mode 100644 gradle/verification-metadata.xml diff --git a/build.gradle b/build.gradle index 634dcd89801..8b9ad593510 100644 --- a/build.gradle +++ b/build.gradle @@ -1,10 +1,11 @@ +import java.security.MessageDigest + buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' - classpath files('gradle/gradle-witness.jar') } } @@ -13,13 +14,17 @@ configurations { compile } -apply plugin: 'witness' apply plugin: 'java' apply plugin: 'maven-publish' repositories { flatDir { dirs uri("${projectDir}/lib") } - maven { url 'https://mvn.freenetproject.org' } + maven { + url 'https://mvn.freenetproject.org' + metadataSources { + artifact() + } + } jcenter() } @@ -28,7 +33,7 @@ sourceSets { test.compileClasspath += configurations.provided } -def version_buildir = "$projectDir/build/tmp/compileVersion/" +def version_buildir = file("$projectDir/build/tmp/compileVersion/") def version_src = 'freenet/node/Version.java' sourceSets { @@ -50,7 +55,7 @@ task buildInfo { def cmd = "git describe --always --abbrev=4 --dirty" def proc = cmd.execute() gitrev = proc.text.trim() - } catch (java.io.IOException e) { + } catch (IOException ignored) { gitrev = "@unknown@" } } @@ -69,7 +74,7 @@ tasks.withType(Javadoc) { task compileVersion (type: JavaCompile) { copy { from sourceSets.main.java.srcDirs - into "${version_buildir}" + into version_buildir include "${version_src}" filter { String line -> line.replaceAll("@custom@","${gitrev}") @@ -77,14 +82,14 @@ task compileVersion (type: JavaCompile) { } sourceCompatibility = 1.8 targetCompatibility = 1.8 - source = "${version_buildir}" + source = version_buildir include "${version_src}" - classpath = files(sourceSets.main.compileClasspath, sourceSets.main.output.classesDir) - destinationDir = file("${buildDir}/java/version/") + classpath = files(sourceSets.main.compileClasspath, sourceSets.main.output.classesDirs) + destinationDirectory.set(layout.buildDirectory.dir("java/version/").get()) } compileVersion.dependsOn buildInfo compileVersion.dependsOn compileJava -processResources.dependsOn compileVersion +//processResources.dependsOn compileVersion task jar (type: Jar, overwrite: true) { from (compileVersion) { @@ -130,7 +135,7 @@ gradle.addBuildListener(new BuildAdapter() { void buildFinished(BuildResult result) { if(jars) { def hash = { - File file -> def sha256 = java.security.MessageDigest.getInstance('SHA-256') + File file -> def sha256 = MessageDigest.getInstance('SHA-256') file.eachByte(1024 * 4) { buffer, len -> sha256.update(buffer, 0, len) } println "SHA-256 of ${file.name}: ${sha256.digest().encodeHex().toString()}" } @@ -141,12 +146,12 @@ gradle.addBuildListener(new BuildAdapter() { }) task copyResourcesToClasses2 { - inputs.dir sourceSets.main.java.srcDirs - outputs.dir sourceSets.main.output.classesDir + inputs.files sourceSets.main.allSource + outputs.dir layout.buildDirectory.dir("classes/java/main/") doLast { copy { - from sourceSets.main.java.srcDirs - into sourceSets.main.output.classesDir + from sourceSets.main.allSource + into layout.buildDirectory.dir("classes/java/main/") include 'freenet/l10n/*properties' include 'freenet/l10n/iso-*.tab' include 'freenet/clients/http/staticfiles/**' @@ -155,7 +160,7 @@ task copyResourcesToClasses2 { } copy { from "${projectDir}/" - into sourceSets.main.output.classesDir + into layout.buildDirectory.dir("classes/java/main/") include 'dependencies.properties' } } @@ -163,12 +168,12 @@ task copyResourcesToClasses2 { processResources.dependsOn copyResourcesToClasses2 task copyTestResourcesToClasses2 { - inputs.dir sourceSets.test.java.srcDirs - outputs.dir sourceSets.test.output.classesDir + inputs.files sourceSets.test.allSource + outputs.dir layout.buildDirectory.dir("classes/java/test/") doLast { copy { - from sourceSets.test.java.srcDirs - into sourceSets.test.output.classesDir + from sourceSets.test.allSource + into layout.buildDirectory.dir("classes/java/test/") include 'freenet/client/filter/*/**' include 'freenet/crypt/ciphers/rijndael-gladman-test-data/**' include 'freenet/l10n/*properties' @@ -189,7 +194,7 @@ test { // no inner class include 'freenet/**/*Test.class' exclude 'freenet/**/*$*Test.class' - workingDir = sourceSets.test.output.classesDir + workingDir = layout.buildDirectory.dir("classes/java/test/") scanForTestClasses = false systemProperties += [ "test.l10npath_test": "freenet/l10n/", @@ -226,47 +231,27 @@ publishing { task copyRuntimeLibs(type: Copy) { into "${buildDir}/output/" - from configurations.runtime + from configurations.runtimeClasspath from jar } copyRuntimeLibs.dependsOn jar // In this section you declare the dependencies for your production and test code dependencies { - compile "org.bouncycastle:bcprov-jdk15on:1.59" - compile "net.java.dev.jna:jna:4.5.2" - compile "net.java.dev.jna:jna-platform:4.5.2" - compile "org.freenetproject:freenet-ext:29" - compile "io.pebbletemplates:pebble:3.1.5" + implementation "org.bouncycastle:bcprov-jdk15on:1.59" + implementation "net.java.dev.jna:jna:4.5.2" + implementation "net.java.dev.jna:jna-platform:4.5.2" + implementation "org.freenetproject:freenet-ext:29" + implementation "io.pebbletemplates:pebble:3.1.5" // dependencies of pebble - compile "org.unbescape:unbescape:1.1.6.RELEASE" - compile "org.slf4j:slf4j-api:1.7.25" - - 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 { - // testCompile includes all of compile deps... so let's include only these - includedConfigurations = [configurations.testCompile] - verify = [ - 'org.bouncycastle:bcprov-jdk15on:1c31e44e331d25e46d293b3e8ee2d07028a67db011e74cb2443285aed1d59c85', - 'net.java.dev.jna:jna-platform:f1d00c167d8921c6e23c626ef9f1c3ae0be473c95c68ffa012bc7ae55a87e2d6', - 'net.java.dev.jna:jna:0c8eb7acf67261656d79005191debaba3b6bf5dd60a43735a245429381dbecff', - 'org.freenetproject:freenet-ext:32f2b3d6beedf54137ea2f9a3ebef67666d769f0966b08cd17fd7db59ba4d79f', - 'junit:junit:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a', - 'org.mockito:mockito-core:f97483ba0944b9fa133aa29638764ddbeadb51ec3dbc02074c58fa2caecd07fa', - 'org.hamcrest:hamcrest-library:711d64522f9ec410983bd310934296da134be4254a125080a0416ec178dfad1c', - 'org.hamcrest:hamcrest-core:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9', - 'org.objenesis:objenesis:c5694b55d92527479382f254199b3c6b1d8780f652ad61e9ca59919887f491a8', - 'io.pebbletemplates:pebble:d253a6dde59e138698aaaaee546461d2f1f6c8bd2aa38ecdd347df17cf90d6f0', - // dependencies of pebble - 'org.unbescape:unbescape:597cf87d5b1a4f385b9d1cec974b7b483abb3ee85fc5b3f8b62af8e4bec95c2c', - 'org.slf4j:slf4j-api:18c4a0095d5c1da6b817592e767bb23d29dd2f560ad74df75ff3961dbde25b79' - ] + implementation "org.unbescape:unbescape:1.1.6.RELEASE" + implementation "org.slf4j:slf4j-api:1.7.25" + + testImplementation 'junit:junit:4.12' + testImplementation "org.mockito:mockito-core:1.9.5" + testImplementation "org.hamcrest:hamcrest-library:1.3" + testImplementation "org.hamcrest:hamcrest-core:1.3" + testImplementation "org.objenesis:objenesis:1.0" } task tar(type: Tar) { @@ -295,6 +280,8 @@ task tar(type: Tar) { } } -javadoc << { - failOnError false +javadoc { + doLast { + failOnError false + } } diff --git a/gradle/verification-keyring.keys b/gradle/verification-keyring.keys new file mode 100644 index 00000000000..823e0a4427b --- /dev/null +++ b/gradle/verification-keyring.keys @@ -0,0 +1,601 @@ +pub B341DDB020FCB6AB +sub 315693699F8D102F +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQGiBEowbDsRBAD2jx/Q2jNuCkgiS3fzIj6EzDP+2kipIKH2LEnpnTiBlds2PFYM +xYibVab/grgQODxTdDnAKifbJA/4h1/T7ba+OV+xIUoSI5MbgaF3USidiDHPX0pY +qvG+k3hKECLysQ2zoZpcC8c2ePiZQSVC2i5BRqgs0xZPz3kiT5U9WPozTwCgtasB +TgHhkOGhZ0SOUuQ4dL54R9cEAIaDjdPcI7LxyOMvvGTuW/SaS9JyP21Kch+Vf6I4 +vKWWqXEaF0So8S088zHnBrcBKhu9D1sKIHS64EoYCrznfMUtoENPe4sf5QuJmZ9D ++fBuFcudQIpkx8L73q+E3fmCK0uX+anqipJtS8mgpMeabKda4KkjDsZkiaNl7OBI +0H09BACofK1HTNHNke2N0wXN1GyG7IAqprKl4lBbu5aRXvfKQ2tDj8s5webNQ+Se +Om/Yg0Bi+CiONLgUjiwYe1wNls8zkk3LwYFeKIJ1AjAY3auBRWOI0/IFFzwTkV8J +YPHa3Dl/kmYp8NMMwA5bgrblggM0Qhnp+k//xpb0FYbmwHMwUrkCDQRKMGw7EAgA +5MMlt89bomqE0TSq63JnPaSeEKsAx6A1KaXaSg0LEI7fMebSQcAdVdAFBo4HaR+j +NNGv5JGTvAObLrqxnn5mU/+qhdTw4WCf17R4ETEKc3iFN3xrpxz2Vew8ZWpw3PcE +gCe27ZN02J6BgtEqhT9v9f0EkAgRHIkcaFCnxme1yPOFN+O0/n1A+59Ar8rmwcHG +opSoZlGDEdEdqElx/shQjqq6Lx3bWYXS+fGzSAip+EAX/dh8S9mZuS6VCWjLx0St +a1tuouq9PdOz5/4W/z4dF36XbZd1UZHkw7DSAUXYXfwfHPmrBOrLx8L+3nLjNnF4 +SSBd14AfOhnBcTQtvLuVMwADBQf8DC9ZhtJqHB/aXsQSrJtmoHbUHuOB3Hd8486U +bZR+BPnnXQndt3Lm2zaSY3plWM2njxL42kuPVrhddLu4fWmWGhn/djFhUehZ7hsr +Qw735eMPhWZQpFnXQBRX98ElZ4VVspszSBhybwlH39iCQBOv/IuR/tykWIxjPY7R +H41EWcSOjJ1LJM2yrk/R+FidUyetedcwUApuDZHnH330Tl/1e+MYpmMzgdUGpU9v +xZJHD9uzEbIxyTd2ky2y3R+n/6EkRt3AU9eI0IY1BqUh0wAuGv/Mq2aSDXXNYJ/p +znXSQBjmy2tvJlqXn+wI1/ujRMHTTFUBySuMyZkC0PwUAAnWMYhJBBgRAgAJBQJK +MGw7AhsMAAoJELNB3bAg/Larfc0AnAmQbEg9XnLr/t0iUS7+V7FcL5KpAJ9k3LS5 +JI97g3GZQ2CHkQwJ3+WcPw== +=OasT +-----END PGP PUBLIC KEY BLOCK----- + +pub 7C7D8456294423BA +sub 9842FE565AA0601E +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQGiBEvsZw4RBADH20nX+H1xvMBYmXRj1Aae4dRr6Y6qI7QRWHO6Z7/dxr9bk/NN +Yjq5KsVOQxZzloVdtqx75rznT7fZq98g7Nq9IeEtB6k4tnh6XQLhljJMk0a3mzdt +q3VzdxeVbwCaPJ0zixv8XPTAH6MpRJUvP9XjzxwaYHrjwcQ1LslW4TrIzwCgi5rf +jChLCyKcaL05gqUjl4lmefED/iqOwYZw5pJ8+X+OHUViiOB43wsJt1brAhPj4KgB +ODStcE6WlHFKi7YzcYNLzYMebSGYn6bj65b3qNf6rybWD1hGUFK4122Q7+HCH9Ic +J+rr8HwjGFo/yxI0/mkyaF0BthXYPy4WtdsdTM2kgx8Zr3Q2rSt1jBPuV3q8d27z +FZMiA/9cWPkRx0RfAJmBPKmKkbBkEtBbNau3G7MY1OEAkEkRnzmnyyjr5IP84A7K +RdjTCvkbiQrOQH00Ki4sHIg+9Xv1gDg1XLkFDzRARKA1TxjL0OeS4RWF3iia7Swk +MOnTdhR50pjb18W8kB4mEMZY7duP4nwDfQwHMwbFZGHrjImaurkCDQRL7GcQEAgA +thrbFDDbIGq97dbX1ZEwNGpjILdeumxZzaCc5PgldHGA86TL2V9iPpONJtv7/Csr +1c/rvH0IA/BFu+0Kde9UP+z9JycmfJpIsd2Qtxfhn9R4+Td0VtN9NNkpt1+JcThb +zyQq4UU82uBKwSG/wzubOI4Fn+7ypIuNgDkqK0STIL3ucKF/RV77PsOBeLHkCGKI +VhUUfY1D51BWZKKB1efaVK7PLdnsi64lAhbaexA43dwUUtVwQOvDzJVtkycV2IMw +XwyHonlK+4vbcwIH2BAU46LIZy+VFaI+lNNmR9+xeWH49oJYnMWIXif4RzvO1ag2 +KKwlG2sacuVTtpWVqKayBwADBQf7BGl4POKtluAbX3a/KGnX1YyibPT2e4pdOxqb +KTwuRc7ILIK/LVcejVuLd+eOF1QmjToI7Y3qjlzvtaxSemfkxbIQpdus0SyHEEAG +H/qjNuTs8ZwEl9tPPrKaJHbJ9kQrlDPwkufA0NDAXTE76UhcHPY0DeykAKEw2rav +EqI7Y0nXR2WSmRLFChmQ+aNTm/9UGI/IoRdS/dgo1eaLD/7RLFeL5tGDe+2nj+B6 +j+52nZEmaRCWWU7O9jYL1cQu5WTurtneCLtIqehLsjuVz9ihBysYuUcTOV/6W0AI +clQoMEiFR9Kyv0owDk6LtX2DgibJuAvvLlnajsiGm5nyVh3G1IhJBBgRAgAJBQJL +7GcQAhsMAAoJEHx9hFYpRCO6iXUAnRcLw17lBhe/WcKFRkzETSxaJcjIAJ4/P1NN +On/eScLdx27sje7q3sBENw== +=TzHJ +-----END PGP PUBLIC KEY BLOCK----- + +pub 3B17BFC1FCC1B644 +sub AB1D1A77026CB606 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBFro+cgBCADCxtYd7ZFChfyOnmp/rCtWS0DGY48wCmJTcgOyBFuTy8UJ+PdK +e8aBsbpx6I5OM2WqvsGkqs/vboAbZxJ+G0br0qriXrz2SUQEJ7EMJJsUgkVSb/iO +DEiqTr+XASuqVoCKsUnB+7eCWycsfODVYZbEjo52PZIJwiNS2yXBtYjf6t6i1rx0 +KrMF9dy9ZRWKe48UGK4KkZ5l9/yiM5CscJM3Wt5fBdFKpp8JmJQHMUivwURjT7dP +o7ZDBLmvgs1/U55AJw9Uo7FwmNSoxr77OtGFaN6rmQS2w1jEt0ieujmuvj+z91sw +FKQ8vxVBSLDtzDNP4NMA4Ie4G4sLDAzi0+1xABEBAAG5AQ0EWuj5yAEIALC3ywW3 +q+flFxeSpSuhLPNrJ1xzp5Ox8sZ/56f7PBEHYR4XAqyF5RLTaslHjxVkdq7JfQsi +saoW48ToFGU4wt21A9Wgh+k6LpnO2CLPvZZmLmXYvikoU74JReCaLjxWLqgD5aQG +6LakGNGgB4qHngFhccJozJn7irGUb2rJ58TkwAfbvghIKOvp2RI6dInKFEuIeWBz +98v5xZp0HRbMnq0bd4RqNGXdJ3yJ2VyC4nVCw+IaZafVgI8MWSaQCiOgwVgS73kL +wgX3xTFfsKMie8Kwo6zCYFyFekKdImG7w9yVavQmgSid2K+Xkb3qxpfjTZSM7qsK +23nL/IoKChLu7eUAEQEAAYkBHwQYAQgACQUCWuj5yAIbDAAKCRA7F7/B/MG2RF3+ +B/46dH70jqBWl/8UtnV4/Tb3hNXb2vU3w7BTawg7qHmUPj0R6BBtRPQqvPxH7K62 +8ARhgBdEaVKMDA6ijSet7zJm2mU9DlBz+Yunz5a1jlDN/vXAzOQyA7jEd9iyI4Dn +lWp+0Gy8EXEysV1mrXRQd0EwRp8kyozLpjAk+P3Xtu6OEHEWOJHZ67OzVLx/bOfU +DIn5Sv8Dxi3cmaAj5ZjnCfM7a35nseGhFcezd+HjQy2v7W1X+zCJaDejdGe32pPU +5Bx0+rqt7BzGjCtQ9N952neH8mAeLLhcpVQQqHx/YjIqJ1qfMPX6vXsur7fxJ1t0 +oY3gZlwqvKcRwJwExFAQotNX +=Ql65 +-----END PGP PUBLIC KEY BLOCK----- + +pub A6ADFC93EF34893E +sub 9C4C23E6FFE405BD +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBE+xZxIBCACzKctn4ez8xOC0pGThhAwjYWGkzcwK4HNaC1usHThBFz3/t8JN +OqUXRixLyi5wELN6GHlsGVUQS3IfB4JtuhScsieSB8PTree68/knMq6JI08mJqZr +9nFrAB4eDW0UMbSL9kPmclUm/yN+qcCZBrsVn0q6CWb/Kcd8EEXEu6sGILzOGqGe +d433t5O+tGXWL2TjAz+Scsk2Hf4zcuDeQcxELAMnVaVgKuGuEZvibrjsdIvJDGI+ +0BzWIu8ZP8ldBl4SVtzGpEVzLvDUo3mOqBeTkj3rP7xLtFDN/3AFtowbLfL7L2Pg +SMcTnKK+jfFHRfbHP1Ih3rQ4ilLzhCnY/QIZABEBAAG5AQ0ET7FnEgEIAM3i3e1s +jwrx2PN8XYMPQWG+/YTtw1BYDl2+iYE+LaZvtq1hpbgeCLgEVwXrCJ4spLP1rFXo +gWqKrkJ0LRjlpdKhKBvyH1ex4grh3cWN/bIDJcJ7JA4I/Bhqhlh8hYycS9pGFeS+ +MR3aFIsii+vadrwYYvuVYGeWvdZhB7mJKYevj5Ms0OpYTfZd95Pzo4o//lNpDnrG +7Xd3tgTNU/fkpw6rFB/2Ib1Qlk+Kz1z6JNsp+tOPGGCBrzwfwglcikTuqS+xyRgC +9cHh5eCol11uSoWPKcQR2Ar8Eo56nxv/UApdu15iJ7R8cA5guKeeS4jt0CGCPs2P +huggDxI73Xvl4zsAEQEAAYkBHwQYAQIACQUCT7FnEgIbDAAKCRCmrfyT7zSJPuyl +B/9iwtIQeexMWBmQNdDe0md8HLulDfcujPtklrvYHtXMJQFaGA0Vafq0oT9MhBfb +1YCP79uF0qgswSxINYCOJx4nTPIP9BOdTwqfGo7ul27REgNq4lIUW0GkMgZAUA2f +t/vc0u/I0PqnhKCi4Pq79hLIx7eiX2ySfXfYfLXRVzbMWKMoi7lWXseQqbM0RvCA +54J1qAi6Ew+JyoYGQ7OvXdL5Eh5Tkm2cpIADyqCkp/aFDe5lqZiU1zS2fU6mpOf/ +o0co+GoYkieIxxibDCmt3BioLgmyzpGUsMNwh4pAIQUGkcxd4spC0KIWdDEvq/QJ +EEIhZlI/ojefaZkRseFrtl3X +=pJaU +-----END PGP PUBLIC KEY BLOCK----- + +pub 2189CA6247F3DEE5 +sub DC032628E927D006 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBFEsDjYBCADKUrv1zJObnlCQ/2AyexoofOuSSzj+L8AIRm2tm2qdPgYNYZHJ +II661t4G5mg6QSGRlO1+NaD1S4GlcEpYvC860Uv26M9FbUAjlMJlWqLoNME9N1Oe +eSLKs+C6RroY4qDuuA0UaLE1SQ9i5cm5bxPIfbm6aCcIzecTbfD18bxIq3fZrO2S +yHek0H2upHAipKd2g2Ed4CikWZV2f8MoMZr7CLs4XgrmpEF01Ab5RBX01kX2MYaa +Vk1BAc3FgLwA/azW3X1pdiyD4iAesHN6SlAaD7x2tZs8CrnRCaWLu31t+x+Sc4Uc +zShjTGdB+euZykFpJW3t/D9BLicjRDTGjBfZABEBAAG5AQ0EUSwONgEIANijDStd +yc4CSVYSXmX+ZQnWTF3gjYMkszD41yT129Xw1RTw//ayxYeBYruIgZb24eAULVhp +hEEW9XgkXvPT1gvAlU27GJ5DYswuh+EIJGGjZMngvORS4Dvr+lkWXU347dgBIIHw +vVl+rw2hUrnhn6Y/nBGWHRFWIXAMwQC2w61iwa2E1aLUJ1u3OvrC8U7Llmb76YOe +qLGbOFiQN9vcr5orrqP/dAdTr4MoyS6dG7Lh8McfWwEDzq0Ygy5d0EJDudusApwc +SQ9set/SO6b3F7IiQHAz2+sXlGJB1Kscx6tpbt5NRegKQp3qyZG71pp31QRePgbf +O99L+AAv19DsQ40AEQEAAYkCRAQYAQIADwUCUSwONgIbLgUJB4YfgAEpCRAhicpi +R/Pe5cBdIAQZAQIABgUCUSwONgAKCRDcAyYo6SfQBtuJB/sH31Gs3MKbEJksDtR3 +VKXGp+kll7BYSoVYv+llFcx7CxkAJNUQ/LH8l9Zbd/j8MA7e1V/ts/QkuLcLqtbe +IdPWcHqXNSjFgOCIC46zGfV8dOmtjlblhfG8YvUZNnlEtJAFBtxOV+kKnMV7YWnS +xm/slrbEFyaaQpicdtP+hw5ubWIAIzK+N3PbjXgKlIywSljU8iXsch2oCms8dAMY +TQeqhnbq5VRjpIyGVrYzqubRLojeXWdCJ60rDvFHnqCyEJgKtxiWX4lQBGfdsnqK +pmJNVv0X4CDHxyPUwChTtFLgNiJvJ2OoYJi5oEg0IZ0rt/9JNNwNnUYlB3qYCXU8 +3771PnwH/iql4tb/K9HUZMcZdjJ9cwljVbwL0Lk4SPeVuPkhTsRmSsrm9FHjOJkX +RitmKnkQWbhBChV3oxVwklJTstYoGXHsUrHnmYV21C8y0HVGEuu2bGyWD7YaOH5c +ayTK1jWK3Jm3BqFE1ORHQjPLMYd+ysGZsCFGcAGEL/3XBu0Tx1poq24uckus5XVk +zq9Kt/d/C8lZR+TSi8In64cpKSl8ZuowN7h7gvldhC3A1jLu2vwyA2IBEaew3EbZ +P0Trh3QbPrrKYy8ljK3LXa6TrtCpkO2JdQDC2Ih/3IS1ed2w6MML/Ss5trXwUuAN +a2WwWwzksx7K6171af7wQ5jdvQaFDVM= +=KJKl +-----END PGP PUBLIC KEY BLOCK----- + +pub 3D52C2966A51F8F4 +sub 888C89049BDEB64C +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQGiBEqVGHgRBACyrZHA3gvzM5WeoD6WwQSIPdTPuWw5EUonHytf4m7pgX8Xkj2G +enqbzW70POgJDUTUpvHDSCaAWiPY+ld1h0j+ghXgKD7IQjqFQTvnkdBT/qbOL7P1 +Umv5OLGSKeyx/BhxNiD0uF/huyP9b1HWC9dbIdVebhDcyBDkBAFtJMOxjwCgjnxw +sUI5vJ5FMPDjUdRPTVQxwlkD/1PGN4Ycdn8ncmZ1OG0T+vmL+C+yGMIdbWIizffC +Li05HMziwK33NHk5ABkeyIijm4Mq7JUlSSwt6gQXJTGlidHEcmKqSTg4AQhybPL5 +w40KcjNyAeQhIFgHAfMzy+Ikxzlt8fNunMTf6utWrPq2IU4uE4lJT4kSL1ic89vx +a4CLA/4g4MJVuzTegJXS5vhMnEI2Nhmc2MIAsEhPcIwJjhUN4rJJMcVxQO+Cmrfl +0rcosxA6wtjFDdPcuXYiAoJBJQrVYp6+w4GyHW45/WR6iGas/Rm0ZRQqnf9WnlpX +o5d7uEwzLfck4iVw+z298y6qk52coFKaKPH0bGVxguifMNdbwbkCDQRKlRh4EAgA +oSWTikKPMX99ZIqYgjAKlM82x6H5xxkisLGwI13m/nvRgOBy8gYzfJCdxrEupnvN +k4PK7twUka18oAoaKfKFBdIKQ0bSyUNV/RzkJDhkBCCU0T8DbN7Xe4rP35l1PvSK +OwtGmIxovip+Spm/j38KKnSTWyZ0JIBTOYEoB8wzyna/fcibwIy/M/wj+lrurXE/ +6QnAxqJjAsL2MtuTurC5IMfRPQqUL0yMk+l+wUpuBaWhg70NhbsTisdJy9TP+Nsu +7tCJu3GumEuYKd3E46xIFedyA1etFHr9n7GkjQkrthlqaza2bUFOv2xOpTJOvZYr +15zOCpHslcIQiWT5zWCQcwADBgf/WBNDvc3jNmAyTP3nLRbA2JP+tVBVwdQkHktY +4EjaLC7HjUA5TblQFTycXtZyKJ+LUwXM2W47h4HMXhSRq7E/wzMUHGhUMBf21MwY +//8mirKgRiU1rkArBKtr+bHTpsJ1UEoCaGzXxvTGxWZSLLrV1nBvbBXXOOhFKvCy +mFcudN12i1MfBrubGNT905obseKThEc1umWzeRRWOlFEZkCONLR9PgSwCok7TT3O +lkaGKRQB4cu54e/faOaLvFh2BgqSIoMgGHfVLJBTbssV6GL6T4YoU2Bq0wtLZ2k9 +tMgJHvPziWrk0rI4oesVWDmbEoRgAsYlTkdev0u98g3c5zAHLYhJBBgRAgAJBQJK +lRh4AhsMAAoJED1SwpZqUfj05WEAnRNjXTAHWA3uXnDtK4XDHeCkqzUIAJwO+CnW +RTDq7K7Q63sS3rHl9X9ZgA== +=lGHK +-----END PGP PUBLIC KEY BLOCK----- + +pub 2189CA6247F3DEE5 +sub DC032628E927D006 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBFEsDjYBCADKUrv1zJObnlCQ/2AyexoofOuSSzj+L8AIRm2tm2qdPgYNYZHJ +II661t4G5mg6QSGRlO1+NaD1S4GlcEpYvC860Uv26M9FbUAjlMJlWqLoNME9N1Oe +eSLKs+C6RroY4qDuuA0UaLE1SQ9i5cm5bxPIfbm6aCcIzecTbfD18bxIq3fZrO2S +yHek0H2upHAipKd2g2Ed4CikWZV2f8MoMZr7CLs4XgrmpEF01Ab5RBX01kX2MYaa +Vk1BAc3FgLwA/azW3X1pdiyD4iAesHN6SlAaD7x2tZs8CrnRCaWLu31t+x+Sc4Uc +zShjTGdB+euZykFpJW3t/D9BLicjRDTGjBfZABEBAAG5AQ0EUSwONgEIANijDStd +yc4CSVYSXmX+ZQnWTF3gjYMkszD41yT129Xw1RTw//ayxYeBYruIgZb24eAULVhp +hEEW9XgkXvPT1gvAlU27GJ5DYswuh+EIJGGjZMngvORS4Dvr+lkWXU347dgBIIHw +vVl+rw2hUrnhn6Y/nBGWHRFWIXAMwQC2w61iwa2E1aLUJ1u3OvrC8U7Llmb76YOe +qLGbOFiQN9vcr5orrqP/dAdTr4MoyS6dG7Lh8McfWwEDzq0Ygy5d0EJDudusApwc +SQ9set/SO6b3F7IiQHAz2+sXlGJB1Kscx6tpbt5NRegKQp3qyZG71pp31QRePgbf +O99L+AAv19DsQ40AEQEAAYkCRAQYAQIADwUCUSwONgIbLgUJB4YfgAEpCRAhicpi +R/Pe5cBdIAQZAQIABgUCUSwONgAKCRDcAyYo6SfQBtuJB/sH31Gs3MKbEJksDtR3 +VKXGp+kll7BYSoVYv+llFcx7CxkAJNUQ/LH8l9Zbd/j8MA7e1V/ts/QkuLcLqtbe +IdPWcHqXNSjFgOCIC46zGfV8dOmtjlblhfG8YvUZNnlEtJAFBtxOV+kKnMV7YWnS +xm/slrbEFyaaQpicdtP+hw5ubWIAIzK+N3PbjXgKlIywSljU8iXsch2oCms8dAMY +TQeqhnbq5VRjpIyGVrYzqubRLojeXWdCJ60rDvFHnqCyEJgKtxiWX4lQBGfdsnqK +pmJNVv0X4CDHxyPUwChTtFLgNiJvJ2OoYJi5oEg0IZ0rt/9JNNwNnUYlB3qYCXU8 +3771PnwH/iql4tb/K9HUZMcZdjJ9cwljVbwL0Lk4SPeVuPkhTsRmSsrm9FHjOJkX +RitmKnkQWbhBChV3oxVwklJTstYoGXHsUrHnmYV21C8y0HVGEuu2bGyWD7YaOH5c +ayTK1jWK3Jm3BqFE1ORHQjPLMYd+ysGZsCFGcAGEL/3XBu0Tx1poq24uckus5XVk +zq9Kt/d/C8lZR+TSi8In64cpKSl8ZuowN7h7gvldhC3A1jLu2vwyA2IBEaew3EbZ +P0Trh3QbPrrKYy8ljK3LXa6TrtCpkO2JdQDC2Ih/3IS1ed2w6MML/Ss5trXwUuAN +a2WwWwzksx7K6171af7wQ5jdvQaFDVM= +=KJKl +-----END PGP PUBLIC KEY BLOCK----- + +pub 86E02C5A42196CA8 +uid Christian Grobmeier (Apache Codesigning) + +sub B4038E8B427473DA +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQGiBEoAFh0RBACoIMutlZW5Isr0+btD/zsuxnCw5Ee2J+DANmA6Gvf4wiXPYw8X +evehIDiitZFCB/imcxF+1Qr+30c/+2V/j8TrDAqrj4UvQ8ryyejfR8aPT31C4lYF ++ktWT2PZA3ZOL03q8MtsLZiXdgRE5RwpUAGg2iAKlq4kx0RtDKJM3DHkQwCg9a7s +erb8gudgyDo7vjmATzu9d5cD/imS3/8CPWHnIfQMQNFkniShm0XoVCuZfQASf4I7 +ksRX+RfERc/RQ/vWoKW95DGupuBKm0KZYWjHgkd4NQcTvjtgVBpSksGuTg2dtY2R +96azS8Va0igUaUthZFCCD6TCHnOAsBCt47Fdv2ymlQiUZYXR1CPTkew/fXkBJJNw +mtH2A/4mT16lRfma4n5uBpjNMRD4juW4hI7/7/QS7xol4Zb74i9rcYldWY3U6AGt +lGUHeZ1ue9JZ+2SicJ25v+XAehbVsr+9NiiBqfOwGXij/d1UQTNsrsfvwYOC0foU +zw0xQFW5lYqJ7romLcly42jSC/lDkACDrL6MfeT5LWPId/cMKrQ/Q2hyaXN0aWFu +IEdyb2JtZWllciAoQXBhY2hlIENvZGVzaWduaW5nKSA8Z3JvYm1laWVyQGFwYWNo +ZS5vcmc+iGAEExECACAFAkoAFh0CGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK +CRCG4CxaQhlsqK6wAKDLkpYfzS9kKqpEI9WAPYVW5prNLgCgmrZz7r8/bxUBloxL +yK+fUQzwGoiIawQQEQIAKwUCSgAajgWDAeKFAB4aaHR0cDovL3d3dy5jYWNlcnQu +b3JnL2Nwcy5waHAACgkQ0rsNAWXQ/VgcRQCfbryBlBcu3GZR08g3YvAtOEWFvKkA +mwdDHEZYUvfc1KlBF8ckDIMgqyTMiEYEExECAAYFAkoBT6sACgkQwdUjR0YP7qr5 +agCdEMlgsJpuMPGBo+IB6Mk4QPGGwEYAnA2sjlbR2YfH0i0+ARizG7UkqmFZiQIz +BBABCAAdFiEERb6+7JUKvQXPDvXDUKBNDDtlF/IFAltB18oACgkQUKBNDDtlF/KM +DA/+P8S3sp68kc8QUu6d5Jg6NGCr178Belj9k8/tAdqw0F4594rmKsCkmEOV5GJ6 +CEOM7N6r7gAzqy1gRYuxwuz5sI77oFk/+ZNxZGxhITcbQ9pKJDhmniRaBPMP9qH4 +w3HD/MIcDRO4eh7s+XxLeFNbUokSOc5j/oTOMhvn5sykkeqGaSeSa2t8W/GVAAum +UVzHqj6Kt8km0Q7nglQ5lA9XCBDEdGjg5g3jlqUCJD4nXsAKC1C7iHQoNG1dF2yc +LDLsEqRlDaPT4mz1aQ78gR+8GbxNCVeuOw2IxtzjDcf5PMx1Qsok+jB0FGAT+yX+ +Uc2R33Z/9CPlGO7h67V+sF6Msz3/23osSSxm/zly1jm8ZNz4loq9sDmTSgT9/HKr +7RzAAXkB2oHQNuXOfJ5A2GrvlUWNs2PGzN8a3YbkwFAvi9axexEyMKA2dXtAJgtD +jYO8Ymwruz9cSCCN0QX+NNKEBvCYezIOCPHP5Q+WCAsqSmpCZ056JjoYpuvMORwK +RCHdU7Vwe9K/O1iF1SZNbvUH1u1DOQXHhT9KSEIBKsIuvWDilL5xVlSWQ582Nfij +3Rc+s233pMnaAj3FEL56V9bgCqJM4Wg+cqGzgkseQ3b+tj8ScW+QFd7AYsODR4uP +o3e6myld2YO2NnRGMllek3CsThFA07+1BAAa9qQ+ZawX3f+5Ag0ESgAWHRAIAM+c +1iXVNnm6wZSFh3cv2Z+CQ/6BBMpCl2hHoHbnpaT8PeACCIemF26g7KRl08ZqtHul +01heWaknIX3PiKb3Lca1iirOODeTzUi6IoLdcmjmlMGyTKyox+Svz9K9hPDdaSOd +xzE7Lv9kdNH3kqThATu/sAO4ozj28bqqpusiMrmNDxdv2+5CMuvaXZ2U5wudAHr6 +HKE/MZmme3Y5gwKYsVnINdq0mPdGuH9GajP2NXI3ZxUqTYej/4m2PNt/COMloEFS +UCxk9AGeT6toCfgh42pJIKs6iSriHkgWL0FB2uTqxXU89DTTPGhEJQwDVgOYWY1K +uKqSm+t2wveRURRly38AAwUIAM1IKiPziF0qRdc7j0bhnanTBf2Y19pBsBRnHdjv +imHgFcBmyOCKSluaXQx5meta3sfg/k0EDNE9DYKHFPxCFh81FrI3XTaM12c2RPdf +el8WsX9INCr2W+qGN9hjPW89jfu2l2Zb8ik64RHxvgQHDlXsdZ4giVwOkdhm84W/ +fK4mvUzIfA3V/nQUCglz1k3F57VwqABmRHVkTrqJOmOJOp02YpkbxLpzW/oUsAHi +iAVCZDlYHuDaJBMMuPiTXqy4EUH1/d5KC0KGDrp2c659hCBQI5NF5Pn4V9hT/HUT +lg75dFhH8cE/1Iia870TwT/4dEZ+p/YjMdMXmYN8awDSuTSISQQYEQIACQUCSgAW +HQIbDAAKCRCG4CxaQhlsqOuWAKCEPnKsC6CKZYc5gO3IqznfBypWBQCgvVtfSUhY +XjiXXCbb93QV4sRTRDGISQQYEQIACQUCSgAWHQIbDAAKCRCG4CxaQhlsqOuWAKDU +HnzofOxJfDu+AfBE1o3EGD9UDACgnA/tAUf1l/ZcjTQYRSKctjE8pnQ= +=B9qr +-----END PGP PUBLIC KEY BLOCK----- + +pub 7C25280EAE63EBE5 +uid Oleg Kalnichevski +uid Oleg Kalnichevski + +sub 926DFB2EDB329089 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQGiBEPonucRBACtbhYckAoyz1tuSXYX4XiqGa5390gIMcxe2hJ+Ncx9o3zX09Im +f8PW27BnMrz7EIydgB2wphhjfK4vkNNtm5ZDWH/zJStsk1Fe7lNuuxs8XorX1+8D +bhhFEuc2B85vNf2o9Y4V5GFwbD+tFNy4u24n7zg6/VgE2WDvYJ8JRqCEkwCggyLj +ba0lsZ2XtSINh/W8ok+9f0sD/A8WhqBfDTEBuG9gnuCYXM0j7XBBPdPS+FXmmfea +zyP+URKRprLCdt0ThZAMllIxZJrkbv7aeXVpM6KSZ/XvvaFQ/gha4o4iJFvpoKt1 +Er2j4Tz/STKztHGsMt6pqfrMNPWovu4tLuLZQmojtbIk+IwmcYxMy99owH8oV1WC +U4HeA/9MlUxzmlmrQF7VLqFTGEEqQaEJqz95wNPj/t1DmI97hshPzXLD4zwKwa9m +qZJPStRHM0a6xW2dztF12aXhrmYg1gIGNnsHtq+t8ZhfINZUurSWn0m65WT5notA +15s6hwyDACHWWOgFQ9jmWuGDh0ZpiaBe7BxeTV+MsswY81sOn7QkT2xlZyBLYWxu +aWNoZXZza2kgPG9sZWdrQGFwYWNoZS5vcmc+iF4EExECAB4FAkPoqRMCGyMGCwkI +BwMCAxUCAwMWAgECHgECF4AACgkQfCUoDq5j6+XjRQCeIEh3JU8sLG4ExznDs7kl ++SR4RKMAn3+zjPmxYiThri5RovWg5EhXz0HpiD8DBQBBaaspFjgKAdFPluURAqRQ +AKCLSRzils2MYm/KwSs16oOB2/IZLgCcCLo0Ep0NqgjYLeJu4hZuGmxuVbmIPwMF +AEFpqzEWOAoB0U+W5RECJv4An0h5UxW8QmQjD0h4SdgSuzfBmeD2AJ9JeV2/9dts +U4fitD4Ic+Xb4AdoJYg/AwUAQWmrNxY4CgHRT5blEQIM2ACgvNsIQOBx/743d+ue +YtUDZJeVWsAAoLTHA5+hglNnweh+4hjCe3xS2g4LiD8DBQBBaas9FjgKAdFPluUR +AqudAKChoE8qfrg7c58DuDpEEgP7u0LgjQCgrfsmvS+wct4LiISClfwVXVosipeI +PwMFAEReP5sWOAoB0U+W5RECQZsAn3aRCyBcjZi94o2KO6pF3KV3FQUMAJsELuK5 +lnWW4kixwKG73CPfMQQIBIg/AwUARF4/nxY4CgHRT5blEQJPgwCfVPNjNeUuDE5Z +I14Otld7fBwQpXsAnAipI4vlTT1xTocZaAPq368dC1OhiD8DBQBEXj+rFjgKAdFP +luURApV+AKCdqxU0lRM9guSO5KeGTYT9P63hhACgqNP+m2ZYeUMlho/WlzVKFGb7 +wfGIPwMFAEReP64WOAoB0U+W5RECfFIAn18+cqoEppOcuwUDV84NRXobL09ZAJ4v +NiAI9wP+3GVtCkRP/NHn0hF/I7QgT2xlZyBLYWxuaWNoZXZza2kgPG9sZWdAdXJh +bC5ydT6IWwQTEQIAGwUCQ+ie5wYLCQgHAwIDFQIDAxYCAQIeAQIXgAAKCRB8JSgO +rmPr5VDrAJ9GdkLrR/ndy4hX6lZn/Mpkz8htZQCeJIn74fhSsEPFM8w3ezOUX7Kz +3mS5Ag0EQ+ifBxAIALIr1cwH89+EBPkuFk1wrpJ5mIkhBJ8k8JPWsG+dr62JYaEN +rdhIUQpXP7UekG4TTIWjMT7dTmHrrTr2TeKtteiBNksGcyAw03IWAKT/26wXSA3+ +C/1xlhSKn7Qkp/r529CwM2DVbjV7TcEZ4tqv32d4NcJ4lTGydjKyTbdlYS6z/Sv4 +qRc+yQiYrbTJ4Jpgxe5hCoZ66gUTi7mxbFHzZs9akQuj4hMMsggnRvuJvHyIksqp +2twjJGa/1GlX8bhmR1jPB2BpokI2n6ni6qPGkm1nq8w2LRdvr+IQALfXg8HYGMvK +DcVxL8O0PhuZYsfuklDGFejSizVGwWH35vcI1bsAAwUH/A2wO0ac4mVi7+wx40d9 +QAOZ5xhHrndHQkTvK8H0DZ2kL7iavLIkZlN7jwC9jcA4DGmtHE9cbe6eP/P0VNDf +aLVap85CzFE7qqv8LUK0LdDlrBCUcsXplhcIi/WaVOHk4OPXHzkF44Nqt328fQ9V +6+gbvz5+1A1PK/Rmw0rRie0d2dJJIbQhK1pxjV27qpVXfLhLMnjNh2KTO+gZh//L +zION5TicsoeiHdtGU59x4Fs0SOUGgydSWAYTLlQoW0z1AnDKMfqoIh+CrUSAI7fp +t8NAMY7KqNxBT8HlhqUX6jMolHBEreF/2fVdjX+NTR/p0O+L90b6T+xFin/RXxLR +aa+IRgQYEQIABgUCQ+ifBwAKCRB8JSgOrmPr5Te9AJ9XRqxecT5oej+N1PfmcCTL +ZNfGiQCfdH3+RPBbKSQofz2bGx7/niTd9qg= +=CP3a +-----END PGP PUBLIC KEY BLOCK----- + +pub ECA081A9790D4FC4 +uid Ralph Schaer + +sub CEC8F362662576CF +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBEwwaQIBCAC/SIIRRSgKRDy1LGdgMiwnXSFCw6GmVHmcKw/EIZSgRwpr5c5G +jIsdubpDLgICSCQcqiSYArx46nyBazksvvKji95oSBAdnuNMFD0XC5MdHBn5OE6I +poa1CBnz/g2XTskrK85Ct+LelP6migrebK2pAKC5LuHn6nyFpb8C/ceQ3ou77yYj +5i4/TP9QDFqnWL4tkdAhnoACmBil5sH8Kt0pR9fPtb+wDOnjtHDpb5FH5pPIN5zV +EdP0k9MA6pp0wtWXavdMspJoxJctiqJ+AL8ejNqI7PbvXcUQ2A4k/oUYJUm2JU6g +UGzs17pWDUE+xekjmTJEEKwhIVR8I8+dTzohABEBAAG0JFJhbHBoIFNjaGFlciA8 +cmFscGhzY2hhZXJAZ21haWwuY29tPokBOAQTAQIAIgUCTDBpAgIbAwYLCQgHAwIG +FQgCCQoLBBYCAwECHgECF4AACgkQ7KCBqXkNT8RRHQgAlacmTmvQ2sti+9Sbwmzq +lLwb0Lp9T4UXb9rmPt3dwpNOQmT1FAtjiGBjJ4/lm0wra4f7pQUOyhLr9ZmbD7QV +m6z3/SjyBajDAGPQbmtASjhl6QU0EFetJhhIpiznuvCdX+DDltV3uMWHMdIp/XOJ +IO6nu8guV07k85Ud0OmjXyBfqV54HbqQL5a9rEqYuBWDMGlQGjjbWbrMe0SZZUVt +e2g9z6Ki4oisSvBS7ZQ3x4Uzz45fcfWWqIKstzyjfMJ5obITkkHXqEO/CQ+uR06f +0NoB2CYGe59Ee4cRJ8R32pQJ1bfw4ehQsnOrcB3bj1taLspkPn/RG7+qYYVck1kU +z7kBDQRMMGkCAQgAyLpmVFisy7DFYkTnvnDjAzkmjvtBKyjYytG/Le81L60wBbVe +PhVAq1MaNikGtdm5ofjvQ9j7K/z8Mpn8KYExsNkNcrREZcuBswlOJZZvqsSDy8RY +EUQ7rR7SgQEqSpBCqGVe96q08hoam0D2ohviokocoFr6JiGXYaXTnYsJKwZCgY3I +r1FxVaXvkqqFwLGvPlGL28L6un5GTbplRJThOujaWtiOpjWt63GnJ35ukpOOKxtO +H0MoYZwx8A/IN8J9nH7fR0c6y8pgloOcrDFRBacGSUJtxdy+qK/R225xF8eudO/G +CXrVyxM1oMGL/MtnXfU1euZl0VENjLyDE+G+DwARAQABiQEfBBgBAgAJBQJMMGkC +AhsMAAoJEOyggal5DU/EKtQIAKQW/u8UPr7fBs6ir/xSURK649reQdCREqEoZccX +nwRUJAJwz75g2jNJeag/4VjgAVmoKELu8PnHBy5TeTeoDKhVfop8iwIZazdWG4ri +lTWIdVdqq4viw7jktaVSyPo17wUJc1+YgKMprSk9fNptU9gD00P0RDcdrEmBzDe6 +mrZXlmNr9ecOU3hJRrAi6DDMdMsBCQTqownQqIKLX13akKk63TaSzO1/y/UcmLbj +VbGAJ2YeyoirsXbAm5565Esrd+ZzFtUlYySFsma7MtE3Ry/U259VP9kcx6hET6Xq +Q2QTcPh8Hht67/q6SyQGbHuvZZ17kvVHvYBP21xQPgPV5Kc= +=ane8 +-----END PGP PUBLIC KEY BLOCK----- + +pub BE096E29EDB8D141 +uid Eric Lafortune (Key for signing ProGuard artefacts) + +sub E05A9780475FAB55 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBFFGZXQBCADeZK9xuCrDwJ7v37y8RITlchzBfJEWv7cSbrSIBlFNAsUUoshW +Y8U6xYKe0GdiLVta2F8bzs0Si4LcDeglQNi9Fxvh3/jfs0MEJUfSeZ4z1Mn5WY35 +utbdlHe6i+7qvhpHveREwWoWuvFGKeSCV8SioolG1mzxrDVLkQefPZ+Kr+xd2cYZ +SIkbjdhCvJHcUkD9gs8Wz9q9eDyc7dGJmfBYaQ7Xa6lbd852qj8LjQ7Gd41yHU6T +U3oo0kKfAPFkW7rX4zeJEBgpncK0i4ertd5to/y2hauqPU3VMExqNS0/L2GqKNmb +Q2Me02pBSBCrLLCUJkm8jZorPNxlQxHpFLHDABEBAAG0T0VyaWMgTGFmb3J0dW5l +IChLZXkgZm9yIHNpZ25pbmcgUHJvR3VhcmQgYXJ0ZWZhY3RzKSA8ZXJpY0BncmFw +aGljcy5jb3JuZWxsLmVkdT6JATgEEwECACIFAlFGZXQCGwMGCwkIBwMCBhUIAgkK +CwQWAgMBAh4BAheAAAoJEL4JbintuNFBUQ0H/1ahtWOeS+EEZqUxxgLE3aiuw6XR +mcFY/9kRlnBsKpWGGyV0DRkLThXSV5fWwiP0+moef04Miv81txVXR3U5f4MY3U5J +SDgeB1GK+BvcYz1CXxGcErgaMIDXu/K03OyQNp1lD2kjmDDz8SHdVqpv/aFfxWpL +uMaogbStXfbDiMjeMg2zRcAzXqu7JlMt3z33uiTUZk9jubAPOBnP5/Yhuc2wcnfu +cLUUL9xNE6gpl0Noy8qJ2TaVoHLfDEdSgVbLDNpippNQCIEXn8VtlBCG9FBtTUR7 +z8fGU8f+ijNYHMa6jNsDlSo45/RV+alQSSZhx3hPCIgO2klEkawBs0ikEjS5AQ0E +UUZldAEIAL0CmXXJLZWMbKXEROAYFnUqQ4eNLUcLY1NfL9xrF2KP6apMXLJdftwz +JtcenfD5vra8w5JJBn6cvY4Dr4zmueDSsN3Cpgr7c0trDNspAQMyUGmg4Cw7lAMr +uIX2om1TTa5ALsQ1PfupnLFLFKbYd2MmfwEVHgEBAzqmr89RoG/NnlV4uxvWumb/ +OrLzzizGLHdLFjnq3Szl6wQPJwmxCtWHvzW/Y+HYclm+wp0sufvrXJ/G1RrHKxwh +xaDVyLKsb5wkUC6SZmE477SP6ZCokoAGHqEK+5JnM9MYXreQ7N6NggRUseCokFaq +ckze5wVBXmPuVAg76ScPFQd4JzLkGzUAEQEAAYkBHwQYAQIACQUCUUZldAIbDAAK +CRC+CW4p7bjRQSkUCACPWdIvMXPtSQFnFR8oUIGxvcp9MYdealHNYkf3qgJTuWbH +TeD8WpE53immju4hitOq/qDevKOWhcfSaLqCtdRyYQFFDWQt4SsiGdWfCvKiBMSM +nrDQI9f+XCv7J3ute5alyMgv9Uo1XLyyiwhz9kJ9mzg+ENvy152PucI4TN63qMRQ +MQbkAenrTzIer+5Q9ZY4TILC8pVVAIPQjTHuhdh8VMclTdkHab2PCFC57/3djJyY +44PLhN3hLI4CElAGLUwBZLRa6OFOvwW5naivwgk0zeeTqq/jTOWPYiy2dyyX1pRX +8bJh5et4mXyM7HLHRp+FblgWxpFWNvMCEpxujLsG +=B/UT +-----END PGP PUBLIC KEY BLOCK----- + +pub 15C71C0A4E0B8EDD +sub 891E4C2D471515FE +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQINBFcyNOoBEACj0zTN3GkRNAY3jihHZdGvi70i4R8mUfcQUwWGRsGGlzSwyJfe +20qNOHqwHaxVCAIp4e5paNf9cEKepOv5IqMkmaRdiC2W+BHDxcJgBot/IrC81ube +y5M9gIc0yCynC4Cnmg2DmRWuafVvqogz0vDKUG3ADvPgRyaItzh0xO/PsWPZvIHD +SlCX9Ny/RT1vZ741tBUm1flGUzxs0zAPt0I+ievjwOeKw8OeUb59sc98U3XpVOVQ +KDD6RIzhnvronznoPkcKPGMrVgBbgyP1/6rwn1u/69CTlED+lyWervseGtDQCO4h +nVZGTfLLo3cB1ertknmmMqyahfaQcohykvAmVzxxkzaWE1vSkOX1U2bFaUNiYuZN +U8zJtdENX2isKQp4xSxJ1/+/hjyfrGwLAebtvnwNcsM3oDwHoevusMoLmMNGkGe0 +yLjz38gwLCIuVrSFeHtHJKdPPsnWVsA65o3iCQyEO5lp38cjDE1hkHzXGO34LiPX +AlDHU2YzoWvAHPqSppppjPJmz1tgHqx146tukezuzoRXuEUTmDAjbpLEHxvKQuBr +DcSfWqe4zfKKqH/CfhxlPGilUcVyLmhaHjs1ti1Bnj4YmQuWo9BR3rPdLi1gQFlp +wZfzytmmK6Zy4Ek89la7cgt6AF3eXjNmpVtGZlAb7lr3xne9DTp98IW3iwARAQAB +uQINBFcyNOoBEADH4HSIjsu94/e0zGBJbyrFFCE8ISGTI7HANfUQeL0Cpl7EbpQN +jIGFbEtvdPheeaz5hJ5sg3dt/og3fQ9oBAXkkx65XmRnsLwYud5uI4bS240UV+HX +DBBAVTE/luQfIp6CWImSY3dpfSRZWarXkU3vDtZgj3drSrY8DbLBPU6B9e7QqToy +3qmZQ9/VN7QEXR+AyNDR2ajEbCzhkWyvXD+7VJg+lzhDnzepIxmDmpbiwmsT9J1i ++BoG8FrN++ZRVXaOEslARP0+rvpIK6RZG9wdBtb09RJODBnufyprYP0//GmcZyOZ +CbyLBfJqOI7vUYu78xyBcbwQgbulwMop3sN/IgxCTGFY4R4waHmgfMdagBNobCv5 +bjODfegAeKmI/Tmg4sppfH31+YahntYZ+MZCxgbCWRpODut6JlZ/KW015I/BAjrx +cj/WooDMxGgq87SAYF6+Kl/Zm4eNp8emduIfLQguZymAryzWQixWwZFfkis/DVYA +OhZWYvlXao1RPAMMHFhht+578atKpJYzMca6WzGX5TuLSip2tXRR5Y8k7vWMVEQa +TlQyHQAl3jw62Sc4WI7u7vA3edbW++1wH8kQvoHTIjdUHpGEkGiNDuVi2dlr0LH1 +yEoVyoZYu+sSeRhBKezHtPsOd02iVBevJIXpnVA9z/FlTEOBfcz4oFKyiQARAQAB +iQIfBBgBCAAJBQJXMjTqAhsMAAoJEBXHHApOC47d7fIQAJn0SxAcJ5iSKenIHCzi +epDP9Z63hjquhAgmDoVxc1sp4Y4MMUrXqunSuN5i2RXNYH2OdPCCvyOjt/vjjI0p +PrAxi+D6nHE6+vFAaMC0zeKFdKyHybafg9yzd0e60v4/vXOkstBq81+Xm8awD20J +w49rBAFu+psgxDaSo8jKeZ536ni9erTTZ1FT+eRG8oILlhRbXX6PKSJfYbvxM68L +WJePyH8fjeL4DfZfeAqbD5Myt/KwU5iFzExnfIlG0Fe12JdO/GYgyqk9l2HobugR +d54SBW+gsyNCG5g22aBk3SedaWfLtrMGbf/2w0UXdaRT4QZAkQvhG5x/6AWnYFU8 +eNxe6f44saFl6l/mb02Qp6FgNTAtUFS8373+w+kcObzbQPJrZRKjCs8eSn92HlDd +hSL5A2wn1+dUJSQuDnvSeb3RY56KFlSoIgTwGq+vPWOAu7c6RjNijnJdPoqP4PQD +ZEpunKUQk2SsIDl5dA1Xm3lo7Hbev26hyjjy4S59FDW1JjM86z6O9cu6ojA5r+Q/ +Cv2lYMYl+66A0r/T0qsLGd5sPhFeC0K9dgMNlhtrjYozvfa9NsajVOr7xxIJVh/3 ++YE+HmDRLRk6sqeTzU7mJCOxismwYBD7S42cpL71iTZ/z+inZnLMULYV9152wiEa +tiwy+wOBjaK9g3Kk8jsN3I8t +=8Tiq +-----END PGP PUBLIC KEY BLOCK----- + +pub 80C08B1C29100955 +uid Jake Wharton + +sub CF771F914C2A4A73 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQGiBE2fCWARBAC3v9wYo5kmynmVP+43ccamidflSLQjjpsXpSDLPFokGxeuw0OC +QJy46m8b5ACoCqRlfwnRRcEHxiSlaBATJA6hi7NRO41R39C62JXsIxNJR16JNQ5k +oG/NOAraw0E1RQIFslznQexfxPg4yFIVrsFp1wkpCRrCklatPMNap2DuNwCg7PWJ +1vV93YIsaH0O2fnXz3E+6zsD/3cTzUWuySEDiCLNO3JYJm97v4NDQ93encP1Ooxh +n+PSIP4GvjrAObh3FfWUucv8UGqcw5bAL7dA1z8SgKeyFk/afs2XofXdvC+PhZqC +DwU0NiE0D/tDWqX0qIG4ezTU2uk+5dE/WVl3R10nOBgquQdWIdYKGfV4FNTiEduD +Uw7fA/0XcwFom7eyR9eBonQmgIadljztm4gkv11lY33V1ZfJNndPKNzwevDwX+om +/VEHvpEfPx5toD4H523BPx55ZtfowuMtFHZI718alpCo3h6xaDhGwXvsg3s9k03k +rfxzCjf9qcJX1gb2JVZ2+2jCwUDQZeEwV2vivjGNiN9rShWW+7QkSmFrZSBXaGFy +dG9uIDxqYWtld2hhcnRvbkBnbWFpbC5jb20+iGAEExECACAFAk2fCWACGwMGCwkI +BwMCBBUCCAMEFgIDAQIeAQIXgAAKCRCAwIscKRAJVQoeAKDLeCOKKnt5aqlHD/7+ +QPOgX4iYPACgvGRCubBztEBkU2xXbr9J2cQY5em5Ag0ETZ8JYBAIALeU4dgFKEn8 +b3E1LUT25svvUUX2kuVLQ5TzokC6zjWQrPehOlsYx+ey8RSN/6A5rBLtn1z75ror +F3+vN5kLPAz8x2Th6Cxd6lvn3DQHfvDL0YHlp0AZzhHx5ogyJxdaqwzNy0JWxava +FGN6b8bbrR1Nf08kq/d5dNe+NGVdBXcuqUo6jt1W+tkbntklS5e+B9/Q/4L8dYkl +8xXRIMAuKw6h8j4LFXse6xndWeWtTIkfZImz0f7cLQV5X7QSv90i1KfzT9hLiUjp +wqPydtTNuB6+gda64jFNhVcvgW+h7MH6FT/zSss2Jh2eDR4HFrv7EJSS8dKCvPox +y8El8pQMG/8AAwUIAIXq+ryw44voH/IdbvTQtK4t5/lp/Oj9b7QrMR3u/iQxM4K3 +dq7rUbA8hjdMM3gfMu13B4pzGtpcf25b4NIIQkhES9+CUDQDYHF+gwkrwEascbdf +YZiLAHtcMjW1Og+IhTY8wDuJT4I1pqumSzWV8UxVJctqNUTY2eU7158oD5+prdCc +eQLbzxoKFtu056kZ2+46v6bAl8g/w8WoVORUuHruuvKohMVPHwNQws7KHCFy9YCr +4yIQfqC8g8oITqlgUZcZaXx6K+NndwA6LAoXJL0edaZOZBuFq5H7Fkrw07+OIQFq +LTGcFpR12AzDh9lmtyJQ8nVfb6IjAOSwBPlEZWSISQQYEQIACQUCTZ8JYAIbDAAK +CRCAwIscKRAJVd58AJ0YA8xv0U5Odm8u21BvyxjGS3tBZACggF6P6KjhUPpIAYTS +6v3TtzhkJdo= +=Zirr +-----END PGP PUBLIC KEY BLOCK----- + +pub 5F69AD087600B22C +sub 0440006D577EAE4B +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBE7JURcBCADO+9Dc4/JnB+wX+fq+Fr2zUGSPOT6/qjE5kXL4FEbJKsqDSAKG +VnbtRrsIUdmNIFQmz71bBDFhRBbrSrkz927k8eUPhYtxE2NmmWSuKgrjF4qviPQv +m/7SqGx378m/qw4EvpgGUB8EYif98LYdWp5vsU/zx0Ps9auqvetAzJaL9489oE0F +q8FVhve6BMfUUV7zOTCmJnf438YO68upjU0PVBdfFE6Qx4cgCeWbQGy2cooW5azN +iIenhuYU1qikmxMHq2xZzN4uSTWLGDpimPyz+Y1aTSYJ/bgn9gPStbI9sojWo9SS +5gvNK3XqJzMwxwFow86UcIE0vPD2T6ZlBAXRABEBAAG5AQ0ETslRFwEIANrjVe+1 +SPgEY9Xfe2+XGN/3q9DHHPP0PXLTGPuWKUmAzkBddNEAXTkPKtyCbH4WXhf4jBZR +yFIpLkoGrW/yIeJZNfoq5xET7ldjDaAMNxb59/78JfyctGbEAgUlzueFONk3Dl0s +DS5GDiWqJg4orqOtUcY+46oo6Z8ncKBbxIvOL+qv1KLWtzIoxjG81PUMk1/CfTij +HgklKtLlbpOHs3m47/28AP2sf6kESKxBwzjgdSyeSci2nCuPoeSfLTJBJlsREL+z +DaJES4G2nj6r/rXX9YHnuH9n0hNxFyhcY0ztsIyz1wqx0kiOYHnLIpUJ+2TcR/YN +mFCYqZ/co98sDMUAEQEAAYkBHwQYAQIACQUCTslRFwIbDAAKCRBfaa0IdgCyLK1s +B/97PLjfP4A523G01/uzf2X0AVyWfh/RhopJmESRNcaDnhLfTDqmchg02XxjP6jS +ngxn2q+6XEUJTCvwODbbOROndTl/HwZFAbWGp8sozS5U98g4zulWldEgrIAMzY1G +anOJcUvWrTepneZupViwHR4Ia17lei7IijkvveobXIaAr075u5nDyO8NeOsiUUsg +gufj8mxt7pbeWOkAEpMCN2VgdLtDylKKoJcFp4KZbvtBYm9q8ULy99orOGK2Gmfl +8KEervwYL9Gb2YsqZNe1JNe6w2/yX3i6g5+6Fuh5YIvSji20USIO78GVaNiMXKO2 +hsWaeXOM0n2j759uNb/Nd2XA +=2J9s +-----END PGP PUBLIC KEY BLOCK----- + +pub 2C7B12F2A511E325 +uid Ceki Gulcu + +sub 10DA72CD7FBFA159 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBE+ZO+EBCAC3fZOOuYKthr0GcUge0PH2bh18sbM9XUmPKQz/W15l1NA/2ARS +2gUXM0R+SunMlun9KsqjnojJ2ObVPvbm1Hg/66JSRgR3JWfIpSlJxLicpfu8rCfN +bOjh4v9ZipD+px8w3o/RNrnZH/KRsoJg9yER6pf+pUZqTJfdg5lXezc1WF+/1qVo +ypldMGfrkfLsPrUZTT689ubbig978e7eYmJEqldtaIwaAzHQnB70wIJyg/rEwFUM +ldsvs6t6czSuJ4zPMvmh8TMpTg9e6+DMktPl1CWRONl8RPpgYMIC96gb4OnfDDjk +Ex6clSCwgbDwdeAyOjjR6pVq+pCNTo1Pcj5jABEBAAG0GENla2kgR3VsY3UgPGNl +a2lAcW9zLmNoPokBOAQTAQIAIgUCT5k74QIbAwYLCQgHAwIGFQgCCQoLBBYCAwEC +HgECF4AACgkQLHsS8qUR4yVwIwgAlj6R9Lxk/GnclmSvgtTyk1r5GxJ75iSCzs7q +DlNuM6EfFbuZvLWORGgP8KtdQdh/bdICtRbh2eoW0vEKJKkl0ZI0/RnVMYKYpIHi +KVUSjPq0svwDk5tUa7taNSdHfi9o1G1doBHyPu1u1xDVzMSWsbEvx6aVr2HkBDRy +A+VcmnX6tokZjyRX4C9ldX3tR+ffn7v2Iy0bIesM92nMPnH/fPXWlnbQKTxQeMj2 +qYSl3H/NGp57G7KNSl1na5U8ueMcUtYb+eHphMsmaEb9xw8dM96CzIPZh1xMHNoQ +NNJibURysbUpFlGUTOv6K0A392QkX3GwuCQGOeLWHOoQHD6Jt7kBDQRPmTvhAQgA +trGiCYnW3tqvDzaStXsguVw67pou65dO7LTcrX+NTvejJZ9SrC89JsfiKBwtvyS3 +X/qiB+S7RP21PH7SYOy+orwDw1nacNNeiTdPnxQCDQVNeWpSpmbLlA+0b6K3aPf/ +EaCKndXmnQyXVOoSXZJ9bqAe0um0NRbO7M+L1KArVkWW56ms+DvHAeZaGnSDDHQp +JI5haUqgSWWP/VoPEU1x0qiBZwY3lokSwRMISC4E/uiUvvm7rvfbBzfOiVrjNPLl +sVPiQRgOTfQO7dUZAmt2yqWJt1Clliby4fgBVcOYUx0QCMiz8MZGtSB17+hSrC2C +b1T6n0ypxuYyh4sV2LtqMQARAQABiQEfBBgBAgAJBQJPmTvhAhsMAAoJECx7EvKl +EeMlX0UIAKS+4ZAKrGG9jbWfzTTDbu9zzkXgV13suMD+XcGz10DkdluTUBXj8wWl +p289fXNm4E49ipsNK+dcZ+gOATjUvb1Llh6D6bHz1QM7olxBCeU2feTmYYKBH8GY +Y9JZzfAXNMQhcNiiPj+ntZqePy/EFA4uZHM7We7vl2c7CBcDAq1NNeEczo0KvG7A +Wt6QoaMVmbvA14EKadNzrmEy9apkag1BKvwzXInYCvIHMa9ZqicOSUcI5QCYu5Tu +fvIE7Eq3Khh2Ex1FiOaEA+57LMrt6NsSKXrB8JNYbI5pqE1rxJXZnYtx3ZpPAAEf +LjPdi1AOkWhvhsoPmiGFC6ebYQ5eVbI= +=9O4j +-----END PGP PUBLIC KEY BLOCK----- + +pub 7457CA33C3CE9E15 +sub ABE9F3126BB741C1 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBFIXyRQBCADe285y3Pu7KzoKyP6wqeNXtvvuwMatAmPm5x/i+S8MlryqzsYa +x6twUmXV1yKjjtGrO+9fHvTOWBfSSP+fP9KTaTQYSasoJq2Mw4cQDy1i0zrxNZUw +N4/BiyjQA25sdfaOolhO0sFlZuTZpYy5wG72KkA1ygNq0L+8aBKhEF6zDU61YzCC +AxjcgTftgTeeoqkJtYa06lNz3jmJDN+zUQignfRa3ymoGtFHTzoXR9maE8RWDty4 +y+DY+8ibdGgSgKPZ0byTCDyNojgU1YTlADa/1/NY1ShYg617O1xicLNo0JEJlf2U +Tu4Ymql36+xSkYSISU97Q6Utgq27XMuZvDUDABEBAAG5AQ0EUhfJFAEIAN9NHRd2 +bYP/3CDi+n1ilSChld0NR3DUBgS/AdqQ7IoAUfj7skyI/WyaMdV4uy6vRh5YgNg2 +g01nd0LLZR8Gf2Ck+D6F88CdZaTxlkcxHV/dXMZ8yBO+0D6yFRZEL7Imsv8Ig4QX +OVwfuiXEPk/Ef5Dy9SdAVhcoErTGGR6BOGVVvexGtBwefsjMaOG0khkRbWIQ32Wx +fUFuAv5XBQ0ckLrlKvYWUYhOlXg27GtFKH2EBBF0Z5ZWu7gaBFwSV0oLp9EWcD+C ++WEwUSfBdqfRJtyXvgf4kZdwdQ5caM8P2/Sdncl2l/LU1At2Smc+plr6zhIhDlLh +lrzKGa16oARSBdUAEQEAAYkCPgQYAQoACQUCUhfJFAIbLgEpCRB0V8ozw86eFcBd +IAQZAQoABgUCUhfJFAAKCRCr6fMSa7dBwURMCADHrqwRNHkbG1QsXJr9oUK6KVkL +sPhcngIhxRLlqe89omg9G7eGNauzs2PKsB3txotCFc7ROVNv/TAuSDYzkPos8G46 +p3bGesjfJb24zc6GMT4RGIJoh1oNG1IciafIIHjp2ZJHRmEDwmvZG24OHJ+mlHLj +aedtqlWu+zwwhH2VZrI/U3gW/x4imbk9UyyzciEIxrAc+fc19xl5PkUVcSDVC0cA +qGpeZz8+SxFaf3Rr0aGnSbeuHRjNupmoxkQOAey1ztmdWiCPf5RFfmFD+fENh+/x +qYiGorYpcIN7UAsMkvD5UHc5ZG2tTD41jM99w9Lm/xHJ9ks8gNwZESwIzr6ABKIH +/1ulsflI216qPz5o7uUxlTm8NfTyATfCUuZEDMYGOjDQPqQa8hFebqjWWYBUq2Sl +aKD2xMeEuEXV+M5k88Cx6T2nvaZWMsrD7uGj+tTsFaKBGxP5p2OSEWOTETKKv6Cx +7vcMTQmrqSFo47bFKlNSs+aVM48UnQeFtTDyOhwa5jvtqtst4eQHwHWQ99BK0TEy +mNx0vF0nPjWA76CRrfopOwXKdxJgoKq4MrxE92ot5I82AZBPeiWVJ+6wECeK/GoB +IXZ5jEUqrQmmzIboWA5G5PMJ8egzLJNRJjTWHjCWrUTnwNcqaD4/qZxIlW4Lt0uv +Glx6pKOJQ05u+9X/BzoVWrw= +=ajY9 +-----END PGP PUBLIC KEY BLOCK----- + +pub 164BD2247B936711 +uid Marc Philipp (JUnit Development, 2014) + +sub EFE8086F9E93774E +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBFPU8TIBCADGNvExYTJpVuNGCF9NuWw+IkitjAD7WzF7QkvFCSw9VftzgTUZ +3PYrThRiaDdmHQAke4Sp+nYyAJ7iUcQqg/5/ONiMdzXEv5Kwy5WJN8+o2aXSunIT +PALIw29DemZdVerw8Xc9jcdNYGxbPgtfSjr/DBCBs5Guq+RuuwsBvyTGLiHpc6hb +91D/wX6Y0NQB4UlY9f3k6AgqiR5OGq602hXYvL10pH6eT3gSmCvxp1WvNJDBmaRi +ZdgW76Y+bGQkmygWdAb3Q2DUEQHVH30YTBx5VFoiCfx1Jud4mD90Tv1hhPn0fS50 +oLGqI6f+VB14iJ4XLaSfyk/UMl343iF9PAg9ABEBAAG0PE1hcmMgUGhpbGlwcCAo +SlVuaXQgRGV2ZWxvcG1lbnQsIDIwMTQpIDxtYWlsQG1hcmNwaGlsaXBwLmRlPokB +OQQTAQIAIwUCU9TxMgIbLwcLCQgHAwIBBhUIAgkKCwQWAgMBAh4BAheAAAoJEBZL +0iR7k2cRglYH/iq1jxu/Wsv4HTLS+aGZYrgxJUv7bWGaFP12VG1xmhVDCPIxNV1/ +MKR9nI9BXyqTlI7ccipwJyZE6VmbbK+wCuALGJNaE04Iw6adGu0bHvk9H/xjY7HA +8lWkXd/fnYe8bnCaGWr8NpbTxFNVo8u0QXzn1U5sindJSzyE1+Wi5Y45BE9gYh3o +uLEJeguj0PodKsjxfRnRnijEqN78pKj8gkxLY44pt/arG9iGRQ8wD+KiXBgAEpnc +4pZVe7hXA/PIHBsWufBDr3HFbfhI3j+AxhnLWbDick2GsOTsSTX37C/VIAaGzUnD +NZLW8NcRAhL4RhvQY5F9TDrD+guwg3HoPFyJAjMEEAEIAB0WIQRFvr7slQq9Bc8O +9cNQoE0MO2UX8gUCWz80BgAKCRBQoE0MO2UX8q5eD/9Egux1zMbRm6ZWune4Ov2c +ag4X6Qx7eA0so20w299jpNyr4zZVJAcAyeYjE3BCAPaIwZzGeW9f6LuYcZrv7qIT +Ij9cxquD5oPzgd38UhqFF8N9p467Wh6PAU3wwMrTJXIFpKZ6r843mthdmDKPXG23 +OEyCEK47Ga/PltW+K0sHauUTei3iLxePrlsjGBc7enKjBHgkj87RgMJ5bzSMJ3ai +7/V28AjUIu+Y6z9BaNpKDRJ8Rp3HIIvVt+uhloP1aYD53OKnohCXeIMuUC0WnqWl +yN4RhguCUuGf0ygzcSwKZBldh1friOdkZdS+9Vxm3Y0l97BPB70QdgFJPa8CZSR3 +DXpdb2j5N0bryI5txP2bO6C8Yq5/Xx7JddnxatOm1dsATxv5EcZN/U5d+wdd0dCz +36RrqQ+beYs6WST26jFMgNyifU8xoY/9PqemHMURkP1n/zgsnYMqRAn5XtytGtv4 +rUOugncGVH8rP+YpUhVl6vTeHSI5irsgjjhV5EOPiY5fXoxfY3SpqKunWajgAzTx +FCEQ6B4v/HyvySTX2YR7x3mJ9xHfBm0EP++mSnMMQrxR/cgIBpeOXyboYQZZ3T4G +V5cZjHKabs0uQSy8uVm5NBXKAUT199M0aoeDeT0O/+ook60NBQzpvvJCObLc0eRv +n7q8wS/j7XFSgIdCN7NB7rkBDQRT1PEyAQgA0A5RG31MshHFziVkue970s1KNN7e +Dzww5KgIj8SzI5Hi20yZzs2o2ALBhfK42VqT6NIa6ktuJQJoWr6KhhY+kMaZlkt+ +I0U+Llmby4l2jlG6lFPNZYIavLOFvU8eWvU934fgLutK4HimBNo8HTqn+jsfoNTf +8cpvcASQnjQVOElf5xTYQ6RWz331ZDpfJpuPyPWK9/GMHQrurhK4QYSla9sYdYIZ +M27OmNxdi9haPLSkaAmeYF9png0CoPqanI3HfIN9W9Uu7kPczW3Zr1DgXq4pto7r +lK69M01GewKMVuTS2MJqzWzaP9BCMj0jI+icpSRV0696A/1eZCR7Vab9NwARAQAB +iQI+BBgBAgAJBQJT1PEyAhsuASkJEBZL0iR7k2cRwF0gBBkBAgAGBQJT1PEyAAoJ +EO/oCG+ek3dOenoH/1vTfHTzf4Z1odIE7lC98k0zF7jtvPHndsUysKp3zMOtruEb +8CE0cuw9Z0rYzIBzVTzNm305So7G1xv3HVOd6rVcMtpsZpo2dAyFEbBTyOqbDKfW +rGx4T9e61m7syNCCjadGlTAEr7XLkJwLgjhHGwTN9/VEWz207JfL6u1XdfaGGSxP +gZRqDw7c+kKax1fU10wV9wv5bs6t/fnPqJppZSR607BiHNUAt8Cpn7kEC3Rm8mS2 +ufqg5LX+quLlgl4K7L+EYecq5Ox/UG4lRCNGa6e1TM/LyoM8GpMC0OOK079GceNj +R+r1Jx5fxD8Qi04rKo8U4LZd8Kig//NPGjBx2ytpcQf+J0linycedx3OyhGifM1j +7SfrWpeQT/TJZG08qVw7mr7eLzYgtPfz7YzsxCAcGo+IvxSaxVF8c3BMe0liwwcS +DL3SF5XWYt+3X04e9YTODKimD4bqhZto/DsJHR2Md8m8Q8Za+V1bS8clogD1f6Wb +o3adzy2w+braL+KDyjm2NQsBSuLNBqcK/ztXGqxK3bhWH2wT541djd98y/jB52X+ +eVoeCEEPZi21wW6UDCgHqfC1Xxhsq70BbH5RCwIMx2iyVVoKEyxNhaOgApSfq9mk +o0NAlpAuT9HbTm6GPVgoEzTAHBhD37R+PsUfSEPep+pmyBlX2nrKxxoRNsl5KWNi +Qw== +=iceo +-----END PGP PUBLIC KEY BLOCK----- diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml new file mode 100644 index 00000000000..890a4606be2 --- /dev/null +++ b/gradle/verification-metadata.xml @@ -0,0 +1,111 @@ + + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4230076d14a..f78e0289036 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip -distributionSha256Sum=8626cbf206b4e201ade7b87779090690447054bc93f052954c78480fa6ed186e +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionSha256Sum=7ba68c54029790ab444b39d7e293d3236b2632631fb5f2e012bb28b4ff669e4b zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 77f49b8f6a10f5681ca2fc6dc348dff1a0bae7cf Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 30 Jan 2023 18:01:42 +0100 Subject: [PATCH 050/500] re-add delay; check noderef to match RequestHandler.finishOpennetInner --- src/freenet/node/RequestSender.java | 43 +++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index 418140aca72..ca402300388 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1721,14 +1721,13 @@ private boolean finishOpennet(final PeerNode next) { if(ref == null) { ackOpennet(next); - return false; + return false; } - if(!node.canWriteDatastoreRequest(origHTL)) { - // Do not path fold at all at high HTL. - ackOpennet(next); - return false; - } + if (!node.canWriteDatastoreRequest(origHTL)) { + // Do not path fold at all at high HTL. + return false; + } if(node.addNewOpennetNode(ref, ConnectionType.PATH_FOLDING) == null) { if(logMINOR) Logger.minor(this, "Don't want noderef on "+this); @@ -1737,8 +1736,25 @@ private boolean finishOpennet(final PeerNode next) { opennetNoderef = noderef; } // RequestHandler will send a noderef back up, eventually, and will unlockHandler() after that point. - assert(source != null); - if(origTag.shouldStop()) { + // If this is a local request, we must still wait for the noderef + // to prevent giving an indication that we are the source. + if (source == null) { + long delay = randomDelayFinishOpennetLocal(); + if (logMINOR) { + Logger.minor( + this, + "Delaying opennet completion for " + TimeUtil.formatTime(delay, 2, true)); + } + node.ticker.queueTimedJob(new Runnable() { + + @Override + public void run() { + ackOpennet(next); + } + + }, delay); + + } else if (origTag.shouldStop()) { // Can't pass it on. origTag.finishedWaitingForOpennet(next); } @@ -1777,6 +1793,17 @@ private boolean finishOpennet(final PeerNode next) { synchronized(this) { opennetTimedOut = true; opennetFinished = true; + try { + next.sendAsync( + DMT.createFNPOpennetCompletedTimeout(uid), + finishOpennetOnAck(next), + this); + } catch (NotConnectedException notConnectedException) { + if (logMINOR) { + Logger.minor(this, "Not connected sending ConnectReply on " + this + " to " + next); + } + origTag.finishedWaitingForOpennet(next); + } notifyAll(); } // We need to wait. From 6127bab50a7536a7321bcb087e7603cdfa548662 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 21 Feb 2023 16:59:04 +0100 Subject: [PATCH 051/500] =?UTF-8?q?Do=20not=20send=20a=20duplicate=20Ack?= =?UTF-8?q?=20on=20path=20folding=20=E2=80=94=20thanks=20to=20Yonghuan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/freenet/node/RequestHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/node/RequestHandler.java b/src/freenet/node/RequestHandler.java index 53a063cf41a..1d62d48486d 100644 --- a/src/freenet/node/RequestHandler.java +++ b/src/freenet/node/RequestHandler.java @@ -760,8 +760,8 @@ private void finishOpennetInner(OpennetManager om) { try { noderef = rs.waitForOpennetNoderef(); } catch (WaitedTooLongForOpennetNoderefException e) { + // Send the timeout info upstream (towards higher HTL) sendTerminal(DMT.createFNPOpennetCompletedTimeout(uid)); - rs.ackOpennet(rs.successFrom()); return; } if(noderef == null) { From 99738fa84749214befecc2f64611142473d9f588 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 2 Mar 2023 21:32:54 +0100 Subject: [PATCH 052/500] correctly close resources on rejecting path folding at too high HTL --- src/freenet/node/RequestSender.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index ca402300388..9f8353deb7a 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -1726,6 +1726,7 @@ private boolean finishOpennet(final PeerNode next) { if (!node.canWriteDatastoreRequest(origHTL)) { // Do not path fold at all at high HTL. + ackOpennet(next); return false; } From 8d26ac16139c0af9df16021bec75607da2804eae Mon Sep 17 00:00:00 2001 From: "Arne Babenhauserheide (freenet releases)" Date: Tue, 28 Feb 2023 23:27:58 +0000 Subject: [PATCH 053/500] Update default bookmark editions --- src/freenet/clients/http/staticfiles/defaultbookmarks.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index 5f09a7a46f6..3306434b3e2 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -122,7 +122,7 @@ BookmarkCategory3.Content.Bookmark0.Name=ArneBab BookmarkCategory3.Content.Bookmark0.Description=L10N:Flog.ArneBab BookmarkCategory3.Content.Bookmark0.ShortDescription=L10N:Flog.ArneBab BookmarkCategory3.Content.Bookmark0.hasAnActivelink=true -BookmarkCategory3.Content.Bookmark0.URI=USK@sUm3oJISSEU4pl2Is9qa1eRoCLyz6r2LPkEqlXc3~oc,yBEbf-IJrcB8Pe~gAd53DEEHgbugUkFSHtzzLqnYlbs,AQACAAE/random_babcom/472/ +BookmarkCategory3.Content.Bookmark0.URI=USK@sUm3oJISSEU4pl2Is9qa1eRoCLyz6r2LPkEqlXc3~oc,yBEbf-IJrcB8Pe~gAd53DEEHgbugUkFSHtzzLqnYlbs,AQACAAE/random_babcom/479/ BookmarkCategory3.Content.Bookmark1.Name=Bombe BookmarkCategory3.Content.Bookmark1.Description=L10N:Flog.Bombe BookmarkCategory3.Content.Bookmark1.ShortDescription=L10N:Flog.Bombe From e3bb502b1542bf479e62f3e1387864545be86cf5 Mon Sep 17 00:00:00 2001 From: "Arne Babenhauserheide (freenet releases)" Date: Tue, 28 Feb 2023 23:28:22 +0000 Subject: [PATCH 054/500] Build 1497 See tag for changelog. --- src/freenet/node/Version.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/node/Version.java b/src/freenet/node/Version.java index 0bd22348706..7e3118787fe 100644 --- a/src/freenet/node/Version.java +++ b/src/freenet/node/Version.java @@ -50,7 +50,7 @@ public class Version { public static final String protocolVersion = "1.0"; /** The build number of the current revision */ - private static final int buildNumber = 1496; + private static final int buildNumber = 1497; /** Oldest build of fred we will talk to *before* _cal */ private static final int oldLastGoodBuild = 1474; From ea2dc860ce04b31e03851d33e796c838719ab317 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 19 Apr 2023 23:07:04 +0200 Subject: [PATCH 055/500] fix: invalid max store size showed bytes with GiB suffix --- src/freenet/node/Node.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index 0b4fce5ffa5..ff707988a5f 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -11,6 +11,7 @@ import static freenet.node.stats.DataStoreType.CLIENT; import static freenet.node.stats.DataStoreType.SLASHDOT; import static freenet.node.stats.DataStoreType.STORE; +import static freenet.support.io.DatastoreUtil.oneGiB; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.MINUTES; import static java.util.concurrent.TimeUnit.SECONDS; @@ -1972,7 +1973,7 @@ public void set(Long storeSize) throws InvalidConfigValueException { } if(storeSize > (maxDatastoreSize = DatastoreUtil.maxDatastoreSize())) { throw new InvalidConfigValueException( - l10n("invalidMaxStoreSize", Long.toString(maxDatastoreSize))); + l10n("invalidMaxStoreSize", Long.toString(maxDatastoreSize / oneGiB))); } long newMaxStoreKeys = storeSize / sizePerKey; From be2978106e7b95667243a52ca136dd2158baab6a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 19 Apr 2023 23:07:47 +0200 Subject: [PATCH 056/500] polish: also show datastore size warning with GiB suffix --- src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java b/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java index a5249f10177..9e15580a9cf 100644 --- a/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java +++ b/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java @@ -1,5 +1,7 @@ package freenet.clients.http.wizardsteps; +import static freenet.support.io.DatastoreUtil.oneGiB; + import freenet.clients.http.FirstTimeWizardToadlet; import freenet.config.Config; import freenet.config.ConfigException; @@ -128,7 +130,7 @@ private static void _setDatastoreSize( long maxDatastoreSize = DatastoreUtil.maxDatastoreSize(); if (size > maxDatastoreSize) { throw new InvalidConfigValueException("Attempting to set DatastoreSize (" + size - + ") larger than maxDatastoreSize (" + maxDatastoreSize + ")"); + + ") larger than maxDatastoreSize (" + maxDatastoreSize / oneGiB + " GiB)"); } // client cache: 10% up to 200MB From fa77cbe4fe6dbb6a9f6231b5e35e37b3b58f8c07 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sat, 22 Apr 2023 00:19:42 +0300 Subject: [PATCH 057/500] Replace charset string parameters with constants from StandardCharsets Also remove unused private field with type Random from DatabaseKey class. Remove some unused methods from tests. Signed-off-by: Veniamin Fernandes --- src/freenet/client/Metadata.java | 38 ++++-------- src/freenet/client/async/USKFetcher.java | 7 +-- src/freenet/client/async/USKInserter.java | 9 +-- src/freenet/client/filter/JPEGFilter.java | 13 ++-- src/freenet/client/filter/M3UFilter.java | 7 ++- src/freenet/clients/fcp/AddPeer.java | 3 +- src/freenet/clients/fcp/BookmarkFeed.java | 13 ++-- src/freenet/clients/fcp/ClientPut.java | 8 +-- .../clients/fcp/FCPConnectionHandler.java | 3 +- src/freenet/clients/fcp/FCPMessage.java | 5 +- src/freenet/clients/fcp/FeedMessage.java | 22 +++---- .../clients/fcp/SendBookmarkMessage.java | 7 +-- src/freenet/clients/fcp/SendTextMessage.java | 6 +- src/freenet/clients/fcp/SendURIMessage.java | 6 +- src/freenet/clients/fcp/TextFeedMessage.java | 13 ++-- src/freenet/clients/fcp/URIFeedMessage.java | 13 ++-- src/freenet/clients/http/Cookie.java | 3 - src/freenet/clients/http/FProxyToadlet.java | 9 +-- src/freenet/clients/http/HTTPRequestImpl.java | 24 ++----- src/freenet/clients/http/QueueToadlet.java | 8 +-- src/freenet/clients/http/Toadlet.java | 18 ++---- .../clients/http/ToadletContextImpl.java | 14 ++--- .../clients/http/TranslationToadlet.java | 5 +- .../http/ajaxpush/PushDataToadlet.java | 3 +- .../ajaxpush/PushNotificationToadlet.java | 3 +- .../clients/http/geoip/IPConverter.java | 3 +- src/freenet/crypt/JceLoader.java | 3 +- src/freenet/crypt/KeyGenUtils.java | 8 +-- src/freenet/crypt/Util.java | 13 ---- src/freenet/crypt/Yarrow.java | 10 +-- src/freenet/io/AddressTracker.java | 5 +- src/freenet/keys/ClientKSK.java | 9 +-- src/freenet/keys/ClientSSK.java | 8 +-- src/freenet/l10n/ISO639_3.java | 3 +- src/freenet/node/Announcer.java | 3 +- src/freenet/node/DarknetPeerNode.java | 41 +++--------- src/freenet/node/DatabaseKey.java | 52 +++++++--------- src/freenet/node/FNPPacketMangler.java | 37 +++-------- src/freenet/node/LocationManager.java | 3 +- src/freenet/node/MasterKeys.java | 29 ++++----- src/freenet/node/Node.java | 20 +++--- src/freenet/node/NodeARKInserter.java | 13 ++-- src/freenet/node/NodeCrypto.java | 23 +++---- src/freenet/node/OpennetManager.java | 5 +- src/freenet/node/PeerManager.java | 18 +----- src/freenet/node/PeerNode.java | 62 ++++++------------- src/freenet/node/TextModeClientInterface.java | 25 +++----- .../node/simulator/BootstrapPullTest.java | 3 +- src/freenet/node/simulator/LongTermTest.java | 4 +- .../simulator/RealNodeBusyNetworkTest.java | 32 +++------- .../simulator/RealNodeRequestInsertTest.java | 7 ++- .../node/simulator/SeednodePingTest.java | 5 +- .../updater/MainJarDependenciesChecker.java | 25 +++----- src/freenet/node/updater/NodeUpdater.java | 3 +- .../PluginDownLoaderOfficialHTTPS.java | 3 +- src/freenet/support/Base64.java | 3 +- src/freenet/support/FileLoggerHook.java | 2 + src/freenet/support/Logger.java | 7 +-- src/freenet/support/SimpleFieldSet.java | 19 ++---- src/freenet/support/URIPreEncoder.java | 18 +++--- src/freenet/support/URLDecoder.java | 22 +++---- src/freenet/support/URLEncoder.java | 20 +++--- .../support/compress/Bzip2Compressor.java | 11 +--- src/freenet/support/io/FileUtil.java | 17 +++-- .../support/io/LineReadingInputStream.java | 13 ++-- src/freenet/tools/CleanupTranslations.java | 5 +- src/freenet/tools/MergeSFS.java | 3 +- .../client/filter/ContentFilterTest.java | 12 ++-- test/freenet/crypt/CryptUtilTest.java | 3 +- test/freenet/crypt/ECDHTest.java | 5 -- test/freenet/crypt/ECDSATest.java | 8 +-- .../EncryptedRandomAccessBufferTest.java | 11 +--- test/freenet/crypt/HMAC_legacy.java | 10 +-- test/freenet/crypt/HashTest.java | 5 +- test/freenet/crypt/MessageAuthCodeTest.java | 15 +---- test/freenet/crypt/ciphers/RijndaelTest.java | 3 +- test/freenet/keys/ClientCHKBlockTest.java | 20 +++--- test/freenet/node/MasterKeysTest.java | 8 +-- test/freenet/store/RAMSaltMigrationTest.java | 5 +- test/freenet/store/SlashdotStoreTest.java | 5 +- .../caching/CachingFreenetStoreTest.java | 23 +++---- .../SaltedHashFreenetStoreTest.java | 13 ++-- .../saltedhash/SaltedHashSlotFilterTest.java | 5 +- test/freenet/support/Base64Test.java | 11 ++-- .../support/URLEncoderDecoderTest.java | 26 +++----- .../compress/OldLZMACompressorTest.java | 3 +- .../io/LineReadingInputStreamTest.java | 13 ++-- .../support/math/MersenneTwisterTest.java | 22 ++++--- 88 files changed, 405 insertions(+), 696 deletions(-) diff --git a/src/freenet/client/Metadata.java b/src/freenet/client/Metadata.java index 2665bf7efdf..bc8c95300d7 100644 --- a/src/freenet/client/Metadata.java +++ b/src/freenet/client/Metadata.java @@ -10,8 +10,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.Serializable; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.HashMap; import java.util.LinkedList; @@ -441,7 +441,7 @@ public Metadata(DataInputStream dis, long length) throws IOException, MetadataPa byte[] toRead = new byte[len]; dis.readFully(toRead); // Use UTF-8 for everything, for simplicity - mimeType = new String(toRead, "UTF-8"); + mimeType = new String(toRead, StandardCharsets.UTF_8); if(logMINOR) Logger.minor(this, "Raw MIME"); if(!DefaultMIMETypes.isPlausibleMIMEType(mimeType)) throw new MetadataParseException("Does not look like a MIME type: \""+mimeType+"\""); @@ -688,7 +688,7 @@ else if(splitfileSingleCryptoAlgorithm == Key.ALGO_AES_CTR_256_SHA256) { short nameLength = dis.readShort(); byte[] buf = new byte[nameLength]; dis.readFully(buf); - String name = new String(buf, "UTF-8").intern(); + String name = new String(buf, StandardCharsets.UTF_8).intern(); if(logMINOR) Logger.minor(this, "Entry "+i+" name "+name); short len = dis.readShort(); if(len < 0) @@ -708,9 +708,9 @@ else if(splitfileSingleCryptoAlgorithm == Key.ALGO_AES_CTR_256_SHA256) { if(logMINOR) Logger.minor(this, "Reading archive internal redirect length "+len); byte[] buf = new byte[len]; dis.readFully(buf); - targetName = new String(buf, "UTF-8"); + targetName = new String(buf, StandardCharsets.UTF_8); while(true) { - if(targetName.isEmpty()) throw new MetadataParseException("Invalid target name is empty: \""+new String(buf, "UTF-8")+"\""); + if(targetName.isEmpty()) throw new MetadataParseException("Invalid target name is empty: \""+new String(buf, StandardCharsets.UTF_8)+"\""); if(targetName.charAt(0) == '/') { targetName = targetName.substring(1); continue; @@ -720,24 +720,10 @@ else if(splitfileSingleCryptoAlgorithm == Key.ALGO_AES_CTR_256_SHA256) { } } - private static final byte[] SPLITKEY; - static { - try { - SPLITKEY = "SPLITKEY".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } - - private static final byte[] CROSS_SEGMENT_SEED; - static { - try { - CROSS_SEGMENT_SEED = "CROSS_SEGMENT_SEED".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } - + private static final byte[] SPLITKEY = "SPLITKEY".getBytes(StandardCharsets.UTF_8); + + private static final byte[] CROSS_SEGMENT_SEED = "CROSS_SEGMENT_SEED".getBytes(StandardCharsets.UTF_8); + public static byte[] getCryptoKey(HashResult[] hashes) { if(hashes == null || hashes.length == 0 || !HashResult.contains(hashes, HashType.SHA256)) throw new IllegalArgumentException("No hashes in getCryptoKey - need hashes to generate splitfile key!"); @@ -1527,7 +1513,7 @@ public void writeTo(DataOutputStream dos) throws IOException, MetadataUnresolved if(hasCompressedMIMEParams) dos.writeShort(compressedMIMEParams); } else { - byte[] data = mimeType.getBytes("UTF-8"); + byte[] data = mimeType.getBytes(StandardCharsets.UTF_8); if(data.length > 255) throw new Error("MIME type too long: "+data.length+" bytes: "+mimeType); dos.writeByte((byte)data.length); dos.write(data); @@ -1580,7 +1566,7 @@ public void writeTo(DataOutputStream dos) throws IOException, MetadataUnresolved LinkedList unresolvedMetadata = null; for(Map.Entry entry: manifestEntries.entrySet()) { String name = entry.getKey(); - byte[] nameData = name.getBytes("UTF-8"); + byte[] nameData = name.getBytes(StandardCharsets.UTF_8); if(nameData.length > Short.MAX_VALUE) throw new IllegalArgumentException("Manifest name too long"); dos.writeShort(nameData.length); dos.write(nameData); @@ -1622,7 +1608,7 @@ public void writeTo(DataOutputStream dos) throws IOException, MetadataUnresolved } if((documentType == DocumentType.ARCHIVE_INTERNAL_REDIRECT) || (documentType == DocumentType.ARCHIVE_METADATA_REDIRECT) || (documentType == DocumentType.SYMBOLIC_SHORTLINK)) { - byte[] data = targetName.getBytes("UTF-8"); + byte[] data = targetName.getBytes(StandardCharsets.UTF_8); if(data.length > Short.MAX_VALUE) throw new IllegalArgumentException("Archive internal redirect name too long"); dos.writeShort(data.length); dos.write(data); diff --git a/src/freenet/client/async/USKFetcher.java b/src/freenet/client/async/USKFetcher.java index 3c9b48b2066..c90e1a4804c 100644 --- a/src/freenet/client/async/USKFetcher.java +++ b/src/freenet/client/async/USKFetcher.java @@ -11,9 +11,9 @@ import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; -import java.io.UnsupportedEncodingException; import java.lang.ref.WeakReference; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -272,10 +272,7 @@ private void innerSuccess(Bucket bucket, } String line; try { - line = new String(data, "UTF-8"); - } catch (UnsupportedEncodingException e) { - Logger.error(this, "Impossible: "+e, e); - return; + line = new String(data, StandardCharsets.UTF_8); } catch (Throwable t) { // Something very bad happened, most likely bogus encoding. // Ignore it. diff --git a/src/freenet/client/async/USKInserter.java b/src/freenet/client/async/USKInserter.java index e479b014b1e..af22aed62ac 100644 --- a/src/freenet/client/async/USKInserter.java +++ b/src/freenet/client/async/USKInserter.java @@ -5,8 +5,8 @@ import java.io.IOException; import java.io.Serializable; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import freenet.client.InsertContext; @@ -152,12 +152,7 @@ private void insertSucceeded(ClientContext context, long edition) { if(logMINOR) Logger.minor(this, "Inserted to edition "+edition+" - inserting USK date hints..."); USKDateHint hint = USKDateHint.now(); MultiPutCompletionCallback m = new MultiPutCompletionCallback(cb, parent, tokenObject, persistent, true); - byte[] hintData; - try { - hintData = hint.getData(edition).getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); // Impossible - } + byte[] hintData = hint.getData(edition).getBytes(StandardCharsets.UTF_8); FreenetURI[] hintURIs = hint.getInsertURIs(privUSK); boolean added = false; for(FreenetURI uri : hintURIs) { diff --git a/src/freenet/client/filter/JPEGFilter.java b/src/freenet/client/filter/JPEGFilter.java index c4041a6266d..313c161e60e 100644 --- a/src/freenet/client/filter/JPEGFilter.java +++ b/src/freenet/client/filter/JPEGFilter.java @@ -9,9 +9,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.HashMap; import java.util.Map; import freenet.l10n.NodeL10n; @@ -321,13 +320,9 @@ private static String l10n(String key) { } private void writeNullTerminatedString(ByteArrayOutputStream baos, String type) throws IOException { - try { - byte[] data = type.getBytes("ISO-8859-1"); // ascii, near enough - baos.write(data); - baos.write(0); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support ISO-8859-1: " + e, e); - } + byte[] data = type.getBytes(StandardCharsets.ISO_8859_1); // ascii, near enough + baos.write(data); + baos.write(0); } private String readNullTerminatedAsciiString(DataInputStream dis) throws IOException { diff --git a/src/freenet/client/filter/M3UFilter.java b/src/freenet/client/filter/M3UFilter.java index d94516c9e14..31b5f26b7a7 100644 --- a/src/freenet/client/filter/M3UFilter.java +++ b/src/freenet/client/filter/M3UFilter.java @@ -8,6 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Map; @@ -106,7 +107,7 @@ public void readFilter( if (fileIndex <= MAX_URI_LENGTH) { boolean lineIsEmpty = fileIndex == 0; if (!lineIsEmpty) { - String uriold = new String(fileUri, 0, fileIndex, "UTF-8"); + String uriold = new String(fileUri, 0, fileIndex, StandardCharsets.UTF_8); // System.out.println(uriold); // clean up the URL: allow sub-m3us and mp3/ogg/flac (what we can filter) String filtered; @@ -156,9 +157,9 @@ public void readFilter( filtered = badUriReplacement; } try { - dos.write(filtered.getBytes("UTF-8")); + dos.write(filtered.getBytes(StandardCharsets.UTF_8)); } catch (Exception e) { - dos.write(badUriReplacement.getBytes("UTF-8")); + dos.write(badUriReplacement.getBytes(StandardCharsets.UTF_8)); } } // write the newline if we're not at EOF diff --git a/src/freenet/clients/fcp/AddPeer.java b/src/freenet/clients/fcp/AddPeer.java index 10e9c5e07ab..c6f8d00c406 100644 --- a/src/freenet/clients/fcp/AddPeer.java +++ b/src/freenet/clients/fcp/AddPeer.java @@ -13,6 +13,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import freenet.client.FetchException; @@ -151,7 +152,7 @@ public void run(FCPConnectionHandler handler, Node node) throws MessageInvalidEx throw new MessageInvalidException(ProtocolErrorMessage.NOT_A_FILE_ERROR, "The given ref file path <"+fileString+"> is not a file", identifier, false); } try { - in = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8")); + in = new BufferedReader(new InputStreamReader(new FileInputStream(f), StandardCharsets.UTF_8)); ref = new StringBuilder(1024); String line; while((line = in.readLine()) != null) { diff --git a/src/freenet/clients/fcp/BookmarkFeed.java b/src/freenet/clients/fcp/BookmarkFeed.java index 7459eb3f91b..2b5d29af1a3 100644 --- a/src/freenet/clients/fcp/BookmarkFeed.java +++ b/src/freenet/clients/fcp/BookmarkFeed.java @@ -1,6 +1,6 @@ package freenet.clients.fcp; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import freenet.keys.FreenetURI; import freenet.support.SimpleFieldSet; @@ -23,13 +23,10 @@ public BookmarkFeed(String header, String shortText, String text, short priority this.URI = URI; this.hasAnActivelink = hasAnActivelink; final Bucket descriptionBucket; - try { - if(description != null) - descriptionBucket = new ArrayBucket(description.getBytes("UTF-8")); - else - descriptionBucket = new NullBucket(); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); + if (description != null) { + descriptionBucket = new ArrayBucket(description.getBytes(StandardCharsets.UTF_8)); + } else { + descriptionBucket = new NullBucket(); } buckets.put("Description", descriptionBucket); diff --git a/src/freenet/clients/fcp/ClientPut.java b/src/freenet/clients/fcp/ClientPut.java index 0d96f9b3ce5..ce91afc44fc 100644 --- a/src/freenet/clients/fcp/ClientPut.java +++ b/src/freenet/clients/fcp/ClientPut.java @@ -7,7 +7,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.Arrays; import java.util.Date; @@ -231,11 +231,7 @@ public ClientPut(FCPConnectionHandler handler, ClientPutMessage message, FCPServ if(salt != null) { MessageDigest md = SHA256.getMessageDigest(); byte[] foundHash; - try { - md.update(salt.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + md.update(salt.getBytes(StandardCharsets.UTF_8)); InputStream is = null; try { is = data.getInputStream(); diff --git a/src/freenet/clients/fcp/FCPConnectionHandler.java b/src/freenet/clients/fcp/FCPConnectionHandler.java index c5cd3c92919..48e227491af 100644 --- a/src/freenet/clients/fcp/FCPConnectionHandler.java +++ b/src/freenet/clients/fcp/FCPConnectionHandler.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.Socket; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; import java.util.Random; @@ -802,7 +803,7 @@ protected DDACheckJob enqueueDDACheck(String path, boolean read, boolean write) try { fos = new FileOutputStream(result.readFilename); bos = new BufferedOutputStream(fos); - bos.write(result.readContent.getBytes("UTF-8")); + bos.write(result.readContent.getBytes(StandardCharsets.UTF_8)); bos.flush(); } catch (IOException e) { Logger.error(this, "Got a IOE while creating the file (" + readFile.toString() + " ! " + e.getMessage()); diff --git a/src/freenet/clients/fcp/FCPMessage.java b/src/freenet/clients/fcp/FCPMessage.java index 4f1028fc954..fffbb31af07 100644 --- a/src/freenet/clients/fcp/FCPMessage.java +++ b/src/freenet/clients/fcp/FCPMessage.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import freenet.node.Node; import freenet.support.LogThresholdCallback; @@ -53,8 +54,8 @@ public void send(OutputStream os) throws IOException { } sfs.setEndMarker(getEndString()); String msg = sfs.toString(); - os.write((getName()+ '\n').getBytes("UTF-8")); - os.write(msg.getBytes("UTF-8")); + os.write((getName()+ '\n').getBytes(StandardCharsets.UTF_8)); + os.write(msg.getBytes(StandardCharsets.UTF_8)); if(logDEBUG) { Logger.debug(this, "Outgoing FCP message:\n"+getName()+'\n'+sfs.toString()); Logger.debug(this, "Being handled by "+this); diff --git a/src/freenet/clients/fcp/FeedMessage.java b/src/freenet/clients/fcp/FeedMessage.java index ef9af3a7d80..b19dc7841ef 100644 --- a/src/freenet/clients/fcp/FeedMessage.java +++ b/src/freenet/clients/fcp/FeedMessage.java @@ -1,6 +1,6 @@ package freenet.clients.fcp; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import freenet.node.Node; import freenet.support.SimpleFieldSet; @@ -18,18 +18,14 @@ public class FeedMessage extends MultipleDataCarryingMessage { private final long updatedTime; public FeedMessage(String header, String shortText, String text, short priorityClass, long updatedTime) { - this.header = header; - this.shortText = shortText; - this.priorityClass = priorityClass; - this.updatedTime = updatedTime; - - //The text may contain newlines - try { - Bucket textBucket = new ArrayBucket(text.getBytes("UTF-8")); - buckets.put("Text", textBucket); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + this.header = header; + this.shortText = shortText; + this.priorityClass = priorityClass; + this.updatedTime = updatedTime; + + //The text may contain newlines + Bucket textBucket = new ArrayBucket(text.getBytes(StandardCharsets.UTF_8)); + buckets.put("Text", textBucket); } @Override diff --git a/src/freenet/clients/fcp/SendBookmarkMessage.java b/src/freenet/clients/fcp/SendBookmarkMessage.java index 655fd15be3b..f2371479a41 100644 --- a/src/freenet/clients/fcp/SendBookmarkMessage.java +++ b/src/freenet/clients/fcp/SendBookmarkMessage.java @@ -1,8 +1,8 @@ package freenet.clients.fcp; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import freenet.keys.FreenetURI; import freenet.node.DarknetPeerNode; @@ -53,13 +53,10 @@ protected int handleFeed(DarknetPeerNode pn) throws MessageInvalidException { try { if(dataLength() > 0) { byte[] description = BucketTools.toByteArray(bucket); - return pn.sendBookmarkFeed(uri, name, new String(description, "UTF-8"), hasAnAnActiveLink); + return pn.sendBookmarkFeed(uri, name, new String(description, StandardCharsets.UTF_8), hasAnAnActiveLink); } else return pn.sendBookmarkFeed(uri, name, null, hasAnAnActiveLink); - - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } catch (IOException e) { throw new MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, "", null, false); } diff --git a/src/freenet/clients/fcp/SendTextMessage.java b/src/freenet/clients/fcp/SendTextMessage.java index 4a6c9de47f9..4e1ad8bdd44 100644 --- a/src/freenet/clients/fcp/SendTextMessage.java +++ b/src/freenet/clients/fcp/SendTextMessage.java @@ -1,7 +1,7 @@ package freenet.clients.fcp; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import freenet.node.DarknetPeerNode; import freenet.support.SimpleFieldSet; @@ -28,13 +28,11 @@ protected int handleFeed(DarknetPeerNode pn) throws MessageInvalidException { try { if(dataLength() > 0) { byte[] text = BucketTools.toByteArray(bucket); - return pn.sendTextFeed(new String(text, "UTF-8")); + return pn.sendTextFeed(new String(text, StandardCharsets.UTF_8)); } else { throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Invalid data length", null, false); } - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } catch (IOException e) { throw new MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, "", null, false); } diff --git a/src/freenet/clients/fcp/SendURIMessage.java b/src/freenet/clients/fcp/SendURIMessage.java index b8e425a81c0..ec68d61e433 100644 --- a/src/freenet/clients/fcp/SendURIMessage.java +++ b/src/freenet/clients/fcp/SendURIMessage.java @@ -1,8 +1,8 @@ package freenet.clients.fcp; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import freenet.keys.FreenetURI; import freenet.node.DarknetPeerNode; @@ -41,12 +41,10 @@ protected int handleFeed(DarknetPeerNode pn) throws MessageInvalidException { try { if(dataLength() > 0) { byte[] description = BucketTools.toByteArray(bucket); - return pn.sendDownloadFeed(uri, new String(description, "UTF-8")); + return pn.sendDownloadFeed(uri, new String(description, StandardCharsets.UTF_8)); } else return pn.sendDownloadFeed(uri, null); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } catch (IOException e) { throw new MessageInvalidException(ProtocolErrorMessage.INVALID_MESSAGE, "", null, false); } diff --git a/src/freenet/clients/fcp/TextFeedMessage.java b/src/freenet/clients/fcp/TextFeedMessage.java index a2a9908c814..ff842571af8 100644 --- a/src/freenet/clients/fcp/TextFeedMessage.java +++ b/src/freenet/clients/fcp/TextFeedMessage.java @@ -1,6 +1,6 @@ package freenet.clients.fcp; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import freenet.support.api.Bucket; import freenet.support.io.ArrayBucket; @@ -15,13 +15,10 @@ public TextFeedMessage(String header, String shortText, String text, short prior String messageText) { super(header, shortText, text, priorityClass, updatedTime, sourceNodeName, composed, sent, received); final Bucket messageTextBucket; - try { - if(messageText != null) - messageTextBucket = new ArrayBucket(messageText.getBytes("UTF-8")); - else - messageTextBucket = new NullBucket(); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); + if (messageText != null) { + messageTextBucket = new ArrayBucket(messageText.getBytes(StandardCharsets.UTF_8)); + } else { + messageTextBucket = new NullBucket(); } buckets.put("MessageText", messageTextBucket); } diff --git a/src/freenet/clients/fcp/URIFeedMessage.java b/src/freenet/clients/fcp/URIFeedMessage.java index f18a7864d6e..a88b62d19d2 100644 --- a/src/freenet/clients/fcp/URIFeedMessage.java +++ b/src/freenet/clients/fcp/URIFeedMessage.java @@ -1,6 +1,6 @@ package freenet.clients.fcp; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import freenet.keys.FreenetURI; import freenet.support.SimpleFieldSet; @@ -19,13 +19,10 @@ public URIFeedMessage(String header, String shortText, String text, short priori super(header, shortText, text, priorityClass, updatedTime, sourceNodeName, composed, sent, received); this.URI = URI; final Bucket descriptionBucket; - try { - if(description != null) - descriptionBucket = new ArrayBucket(description.getBytes("UTF-8")); - else - descriptionBucket = new NullBucket(); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); + if (description != null) { + descriptionBucket = new ArrayBucket(description.getBytes(StandardCharsets.UTF_8)); + } else { + descriptionBucket = new NullBucket(); } buckets.put("Description", descriptionBucket); } diff --git a/src/freenet/clients/http/Cookie.java b/src/freenet/clients/http/Cookie.java index 02c25d22c85..b7f6f734e39 100644 --- a/src/freenet/clients/http/Cookie.java +++ b/src/freenet/clients/http/Cookie.java @@ -5,7 +5,6 @@ import java.net.URI; import java.net.URISyntaxException; -import java.nio.charset.Charset; import java.util.Arrays; import java.util.Date; import java.util.HashSet; @@ -37,8 +36,6 @@ public class Cookie { public static final HashSet httpSeparatorCharacters = new HashSet(Arrays.asList(new Character[] { '(', ')', '<', '>', '@', ',', ';', ':', '\\', '\"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t' })); - private static final Charset usasciiCharset = Charset.forName("US-ASCII"); - protected int version; diff --git a/src/freenet/clients/http/FProxyToadlet.java b/src/freenet/clients/http/FProxyToadlet.java index 2f5a86d79df..f699b4eef78 100644 --- a/src/freenet/clients/http/FProxyToadlet.java +++ b/src/freenet/clients/http/FProxyToadlet.java @@ -12,6 +12,7 @@ import java.net.SocketException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -220,7 +221,7 @@ private void handleDownload(ToadletContext context, Bucket data, BucketFactory b NodeL10n.getBase().addL10nSubstitution(option, "FProxyToadlet.backToFProxy", new String[] { "link" }, new HTMLNode[] { HTMLNode.link("/") }); - byte[] pageBytes = pageNode.generate().getBytes("UTF-8"); + byte[] pageBytes = pageNode.generate().getBytes(StandardCharsets.UTF_8); context.sendReplyHeaders(200, "OK", new MultiValueTable(), "text/html; charset=utf-8", pageBytes.length); context.writeData(pageBytes); return; @@ -523,7 +524,7 @@ private void innerHandleMethodGET(URI uri, HTTPRequest httprequest, ToadletConte } else if(ks.startsWith("/feed/") || ks.equals("/feed")) { String schemeHostAndPort = getSchemeHostAndPort(ctx); String atom = ctx.getAlertManager().getAtom(schemeHostAndPort); - byte[] buf = atom.getBytes("UTF-8"); + byte[] buf = atom.getBytes(StandardCharsets.UTF_8); ctx.sendReplyHeadersFProxy(200, "OK", null, "application/atom+xml", buf.length); ctx.writeData(buf, 0, buf.length); return; @@ -1096,8 +1097,8 @@ private static String getForceValue(FreenetURI key, long time) { try{ bos.write(random); - bos.write(key.toString().getBytes("UTF-8")); - bos.write(Long.toString(time / FORCE_GRAIN_INTERVAL).getBytes("UTF-8")); + bos.write(key.toString().getBytes(StandardCharsets.UTF_8)); + bos.write(Long.toString(time / FORCE_GRAIN_INTERVAL).getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { throw new Error(e); } diff --git a/src/freenet/clients/http/HTTPRequestImpl.java b/src/freenet/clients/http/HTTPRequestImpl.java index 0d8b2faf6c2..2effb497926 100644 --- a/src/freenet/clients/http/HTTPRequestImpl.java +++ b/src/freenet/clients/http/HTTPRequestImpl.java @@ -11,6 +11,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -205,12 +206,7 @@ private void parseRequestParameters(String queryString, boolean doUrlDecoding, b for (Entry> parameterValues : parameters.entrySet()) { List values = parameterValues.getValue(); String value = values.get(values.size() - 1); - byte[] buf; - try { - buf = value.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } // FIXME some other encoding? + byte[] buf = value.getBytes(StandardCharsets.UTF_8); RandomAccessBucket b = new SimpleReadOnlyArrayBucket(buf); parts.put(parameterValues.getKey(), b); if(logMINOR) @@ -492,7 +488,7 @@ private void parseMultiPartData() throws IOException { if(data.size() > 1024 * 1024) throw new IOException("Too big"); byte[] buf = BucketTools.toByteArray(data); - String s = new String(buf, "us-ascii"); + String s = new String(buf, StandardCharsets.US_ASCII); parseRequestParameters(s, true, true); } if(!ctypeparts[0].trim().equalsIgnoreCase("multipart/form-data") || (ctypeparts.length < 2)) @@ -587,7 +583,7 @@ else if(hdrname.equalsIgnoreCase("Content-Type")) { bucketos = filedata.getOutputStream(); // buffer characters that match the boundary so far // FIXME use whatever charset was used - byte[] bbound = boundary.getBytes("UTF-8"); // ISO-8859-1? boundary should be in US-ASCII + byte[] bbound = boundary.getBytes(StandardCharsets.UTF_8); // ISO-8859-1? boundary should be in US-ASCII int offset = 0; while((is.available() > 0) && (offset < bbound.length)) { byte b = (byte) is.read(); @@ -658,11 +654,7 @@ public boolean isPartSet(String name) { @Override @Deprecated public String getPartAsString(String name, int maxlength) { - try { - return new String(getPartAsBytes(name, maxlength), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + return new String(getPartAsBytes(name, maxlength), StandardCharsets.UTF_8); } @Override @@ -687,11 +679,7 @@ public String getPartAsStringFailsafe(String name, int maxLength) { } private String getPartAsLimitedString(Bucket part, int maxLength) { - try { - return new String(getPartAsLimitedBytes(part, maxLength), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + return new String(getPartAsLimitedBytes(part, maxLength), StandardCharsets.UTF_8); } /* (non-Javadoc) diff --git a/src/freenet/clients/http/QueueToadlet.java b/src/freenet/clients/http/QueueToadlet.java index f94dd5d76f9..86f1ff34a26 100644 --- a/src/freenet/clients/http/QueueToadlet.java +++ b/src/freenet/clients/http/QueueToadlet.java @@ -14,10 +14,10 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Arrays; @@ -2413,7 +2413,7 @@ private boolean readCompletedIdentifiers(File file) { try { fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); - InputStreamReader isr = new InputStreamReader(bis, "UTF-8"); + InputStreamReader isr = new InputStreamReader(bis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); synchronized(completedRequestIdentifiers) { completedRequestIdentifiers.clear(); @@ -2429,8 +2429,6 @@ private boolean readCompletedIdentifiers(File file) { } catch (FileNotFoundException e) { // Normal return false; - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } catch (IOException e) { Logger.error(this, "Could not read completed identifiers list from "+file); return false; @@ -2450,7 +2448,7 @@ private void saveCompletedIdentifiers() { temp = File.createTempFile("completed.list", ".tmp", core.node.getUserDir()); temp.deleteOnExit(); fos = new FileOutputStream(temp); - OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); bw = new BufferedWriter(osw); String[] identifiers; synchronized(completedRequestIdentifiers) { diff --git a/src/freenet/clients/http/Toadlet.java b/src/freenet/clients/http/Toadlet.java index 9f4c1171f50..def85639747 100644 --- a/src/freenet/clients/http/Toadlet.java +++ b/src/freenet/clients/http/Toadlet.java @@ -6,9 +6,9 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.net.URI; +import java.nio.charset.StandardCharsets; import freenet.client.FetchContext; import freenet.client.FetchException; @@ -314,7 +314,7 @@ protected void writeReply(ToadletContext context, int code, String mimeType, Str } protected void writeReply(ToadletContext context, int code, String mimeType, String desc, MultiValueTable headers, String reply, boolean forceDisableJavascript) throws ToadletContextClosedException, IOException { - byte[] buffer = reply.getBytes("UTF-8"); + byte[] buffer = reply.getBytes(StandardCharsets.UTF_8); writeReply(context, code, mimeType, desc, headers, buffer, 0, buffer.length, forceDisableJavascript); } @@ -357,12 +357,7 @@ static void writePermanentRedirect(ToadletContext ctx, String msg, String locati ""+msg+"

" + l10n("permRedirectWithReason", "reason", msg)+ "

"+l10n("clickHere")+""; - byte[] buf; - try { - buf = redirDoc.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + byte[] buf = redirDoc.getBytes(StandardCharsets.UTF_8); ctx.sendReplyHeaders(301, "Moved Permanently", mvt, "text/html; charset=UTF-8", buf.length); ctx.writeData(buf, 0, buf.length); } @@ -389,12 +384,7 @@ protected void writeTemporaryRedirect(ToadletContext ctx, String msg, String loc l10n("tempRedirectWithReason", "reason", msg)+ "" + l10n("clickHere") + ""; - byte[] buf; - try { - buf = redirDoc.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + byte[] buf = redirDoc.getBytes(StandardCharsets.UTF_8); ctx.sendReplyHeaders(302, "Found", mvt, "text/html; charset=UTF-8", buf.length); ctx.writeData(buf, 0, buf.length); } diff --git a/src/freenet/clients/http/ToadletContextImpl.java b/src/freenet/clients/http/ToadletContextImpl.java index f3518a72fe0..4c93756b699 100644 --- a/src/freenet/clients/http/ToadletContextImpl.java +++ b/src/freenet/clients/http/ToadletContextImpl.java @@ -12,13 +12,13 @@ import java.net.Socket; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Enumeration; -import java.util.List; import java.util.Locale; import java.util.StringJoiner; import java.util.TimeZone; @@ -160,7 +160,7 @@ private static void sendError(OutputStream os, int code, String httpReason, Stri */ private static void sendHTMLError(OutputStream os, int code, String httpReason, String htmlMessage, boolean disconnect, MultiValueTable mvt) throws IOException { if(mvt == null) mvt = new MultiValueTable(); - byte[] messageBytes = htmlMessage.getBytes("UTF-8"); + byte[] messageBytes = htmlMessage.getBytes(StandardCharsets.UTF_8); sendReplyHeaders(os, code, httpReason, mvt, "text/html; charset=UTF-8", messageBytes.length, null, disconnect, false, false); os.write(messageBytes); } @@ -278,8 +278,8 @@ public boolean checkFullAccess(Toadlet toadlet) throws ToadletContextClosedExcep @Override public boolean hasFormPassword(HTTPRequest request) throws IOException { String pass = request.getPartAsStringFailsafe("formPassword", 32); - byte[] inputBytes = pass.getBytes("UTF-8"); - byte[] compareBytes = getFormPassword().getBytes("UTF-8"); + byte[] inputBytes = pass.getBytes(StandardCharsets.UTF_8); + byte[] compareBytes = getFormPassword().getBytes(StandardCharsets.UTF_8); if(!MessageDigest.isEqual(inputBytes, compareBytes)) { if (logMINOR) Logger.minor(this, "Bad formPassword: " + pass); @@ -442,7 +442,7 @@ static void sendReplyHeaders(OutputStream sockOutputStream, int replyCode, Strin } } buf.append("\r\n"); - sockOutputStream.write(buf.toString().getBytes("US-ASCII")); + sockOutputStream.write(buf.toString().getBytes(StandardCharsets.US_ASCII)); } private static String generateCSP(boolean allowScripts, boolean allowFrames) { @@ -717,8 +717,8 @@ public static void handle(Socket sock, ToadletContainer container, PageMaker pag PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.flush(); - msg = msg + sw.toString() + ""; - byte[] messageBytes = msg.getBytes("UTF-8"); + msg = msg + sw + ""; + byte[] messageBytes = msg.getBytes(StandardCharsets.UTF_8); sendReplyHeaders(sock.getOutputStream(), 500, "Internal failure", null, "text/html; charset=UTF-8", messageBytes.length, null, true, false, false); sock.getOutputStream().write(messageBytes); } catch (IOException e1) { diff --git a/src/freenet/clients/http/TranslationToadlet.java b/src/freenet/clients/http/TranslationToadlet.java index bf321bd99f1..478197f30cd 100644 --- a/src/freenet/clients/http/TranslationToadlet.java +++ b/src/freenet/clients/http/TranslationToadlet.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import freenet.client.HighLevelSimpleClient; @@ -53,7 +54,7 @@ public void handleMethodGET(URI uri, HTTPRequest request, ToadletContext ctx) th super.sendErrorPage(ctx, 503 /* Service Unavailable */, "Service Unavailable", l10n("noCustomTranslations")); return; } - byte[] data = sfs.toOrderedString().getBytes("UTF-8"); + byte[] data = sfs.toOrderedString().getBytes(StandardCharsets.UTF_8); MultiValueTable head = new MultiValueTable(); head.put("Content-Disposition", "attachment; filename=\"" + this.base.getL10nOverrideFileName(this.base.getSelectedLanguage()) + '"'); ctx.sendReplyHeaders(200, "Found", head, "text/plain; charset=utf-8", data.length); @@ -249,7 +250,7 @@ public void handleMethodPOST(URI uri, HTTPRequest request, ToadletContext ctx) t if(request.getPartAsStringFailsafe("translation_update", 32).length() > 0){ String key = request.getPartAsStringFailsafe("key", 256); - this.base.setOverride(key, new String(BucketTools.toByteArray(request.getPart("trans")), "UTF-8").trim()); + this.base.setOverride(key, new String(BucketTools.toByteArray(request.getPart("trans")), StandardCharsets.UTF_8).trim()); if("on".equalsIgnoreCase(request.getPartAsStringFailsafe("gotoNext", 7))) { KeyIterator it = base.getDefaultLanguageTranslation().keyIterator(""); diff --git a/src/freenet/clients/http/ajaxpush/PushDataToadlet.java b/src/freenet/clients/http/ajaxpush/PushDataToadlet.java index cdd8f1cdbfd..6076fc4c973 100644 --- a/src/freenet/clients/http/ajaxpush/PushDataToadlet.java +++ b/src/freenet/clients/http/ajaxpush/PushDataToadlet.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.net.URI; +import java.nio.charset.StandardCharsets; import freenet.client.HighLevelSimpleClient; import freenet.clients.http.RedirectException; @@ -39,7 +40,7 @@ public void handleMethodGET(URI uri, HTTPRequest req, ToadletContext ctx) throws if (logMINOR) { Logger.minor(this, "Data got element:" + node.generateChildren()); } - writeHTMLReply(ctx, 200, "OK", UpdaterConstants.SUCCESS + ":" + Base64.encodeStandard(node.getUpdaterType().getBytes("UTF-8")) + ":" + Base64.encodeStandard(node.generateChildren().getBytes("UTF-8"))); + writeHTMLReply(ctx, 200, "OK", UpdaterConstants.SUCCESS + ":" + Base64.encodeStandard(node.getUpdaterType().getBytes(StandardCharsets.UTF_8)) + ":" + Base64.encodeStandard(node.generateChildren().getBytes(StandardCharsets.UTF_8))); } @Override diff --git a/src/freenet/clients/http/ajaxpush/PushNotificationToadlet.java b/src/freenet/clients/http/ajaxpush/PushNotificationToadlet.java index 2e7f6f53576..0169fd5b5f8 100644 --- a/src/freenet/clients/http/ajaxpush/PushNotificationToadlet.java +++ b/src/freenet/clients/http/ajaxpush/PushNotificationToadlet.java @@ -2,6 +2,7 @@ import java.io.IOException; import java.net.URI; +import java.nio.charset.StandardCharsets; import freenet.client.HighLevelSimpleClient; import freenet.clients.http.RedirectException; @@ -34,7 +35,7 @@ public void handleMethodGET(URI uri, HTTPRequest req, ToadletContext ctx) throws if (event != null) { String elementRequestId = event.getRequestId(); String elementId = event.getElementId(); - writeHTMLReply(ctx, 200, "OK", UpdaterConstants.SUCCESS + ":" + Base64.encodeStandard(elementRequestId.getBytes("UTF-8")) + UpdaterConstants.SEPARATOR + elementId); + writeHTMLReply(ctx, 200, "OK", UpdaterConstants.SUCCESS + ":" + Base64.encodeStandard(elementRequestId.getBytes(StandardCharsets.UTF_8)) + UpdaterConstants.SEPARATOR + elementId); if (logMINOR) { Logger.minor(this, "Notification got:" + event); } diff --git a/src/freenet/clients/http/geoip/IPConverter.java b/src/freenet/clients/http/geoip/IPConverter.java index f0d4861027c..91ee8293b9a 100644 --- a/src/freenet/clients/http/geoip/IPConverter.java +++ b/src/freenet/clients/http/geoip/IPConverter.java @@ -6,6 +6,7 @@ import java.io.RandomAccessFile; import java.lang.ref.SoftReference; import java.lang.ref.WeakReference; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; @@ -244,7 +245,7 @@ private Cache readRanges() { String code = line.substring(offset, offset + 2); // Ip String ipcode = line.substring(offset + 2, offset + 7); - long ip = decodeBase85(ipcode.getBytes("ISO-8859-1")); + long ip = decodeBase85(ipcode.getBytes(StandardCharsets.ISO_8859_1)); try { Country country = Country.valueOf(code); codes[i] = (short) country.ordinal(); diff --git a/src/freenet/crypt/JceLoader.java b/src/freenet/crypt/JceLoader.java index f0ef8488019..44c068d979f 100644 --- a/src/freenet/crypt/JceLoader.java +++ b/src/freenet/crypt/JceLoader.java @@ -6,6 +6,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.lang.reflect.Constructor; +import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.Provider; import java.security.Security; @@ -126,7 +127,7 @@ private Provider load(boolean atfirst) throws Throwable { try { // More robust than PrintWriter(file), which can hang on out of disk space. os = new FileOutputStream(nssFile); - OutputStreamWriter osw = new OutputStreamWriter(os, "ISO-8859-1"); + OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.ISO_8859_1); BufferedWriter bw = new BufferedWriter(osw); bw.write("name=NSScrypto\n"); bw.write("nssDbMode=noDb\n"); diff --git a/src/freenet/crypt/KeyGenUtils.java b/src/freenet/crypt/KeyGenUtils.java index b574dcb79bd..f81490de03e 100755 --- a/src/freenet/crypt/KeyGenUtils.java +++ b/src/freenet/crypt/KeyGenUtils.java @@ -3,8 +3,8 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.crypt; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.KeyFactory; @@ -315,11 +315,7 @@ private static ByteBuffer deriveBytes(SecretKey kdfKey, Class c, String kdfSt throw new NullPointerException(); } MessageAuthCode kdf = new MessageAuthCode(MACType.HMACSHA512, kdfKey); - try { - return kdf.genMac((c.getName()+kdfString).getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new Error(e); // Impossible - } + return kdf.genMac((c.getName()+kdfString).getBytes(StandardCharsets.UTF_8)); } diff --git a/src/freenet/crypt/Util.java b/src/freenet/crypt/Util.java index c239aaeb795..34976631695 100644 --- a/src/freenet/crypt/Util.java +++ b/src/freenet/crypt/Util.java @@ -108,19 +108,6 @@ public static byte[] hashBytes( return d.digest(); } - /** - * Hashes a string in a consistent manner - */ - public static byte[] hashString(MessageDigest d, String s) { - try { - byte[] sbytes = s.getBytes("UTF-8"); - d.update(sbytes, 0, sbytes.length); - return d.digest(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } public static byte[] xor(byte[] b1, byte[] b2) { int maxl = Math.max(b1.length, b2.length); diff --git a/src/freenet/crypt/Yarrow.java b/src/freenet/crypt/Yarrow.java index efdb0acfca8..2f305ee2edd 100644 --- a/src/freenet/crypt/Yarrow.java +++ b/src/freenet/crypt/Yarrow.java @@ -14,8 +14,8 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -790,13 +790,7 @@ else if(args[0].equalsIgnoreCase("sample")) } private void consumeString(String str) { - byte[] b; - try { - b = str.getBytes("UTF-8"); - } catch(UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } - consumeBytes(b); + consumeBytes(str.getBytes(StandardCharsets.UTF_8)); } private void consumeBytes(byte[] bytes) { diff --git a/src/freenet/io/AddressTracker.java b/src/freenet/io/AddressTracker.java index 1f195ea6c9b..b596a011e10 100644 --- a/src/freenet/io/AddressTracker.java +++ b/src/freenet/io/AddressTracker.java @@ -30,6 +30,7 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.InetAddress; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Iterator; @@ -78,7 +79,7 @@ public static AddressTracker create(long lastBootID, ProgramDirectory runDir, in try { fis = new FileInputStream(data); BufferedInputStream bis = new BufferedInputStream(fis); - InputStreamReader ir = new InputStreamReader(bis, "UTF-8"); + InputStreamReader ir = new InputStreamReader(bis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(ir); SimpleFieldSet fs = new SimpleFieldSet(br, false, true); return new AddressTracker(fs, lastBootID); @@ -299,7 +300,7 @@ public void storeData(long bootID, ProgramDirectory runDir, int port) { try { fos = new FileOutputStream(dataBak); BufferedOutputStream bos = new BufferedOutputStream(fos); - OutputStreamWriter osw = new OutputStreamWriter(bos, "UTF-8"); + OutputStreamWriter osw = new OutputStreamWriter(bos, StandardCharsets.UTF_8); BufferedWriter bw = new BufferedWriter(osw); SimpleFieldSet fs = getFieldset(bootID); fs.writeTo(bw); diff --git a/src/freenet/keys/ClientKSK.java b/src/freenet/keys/ClientKSK.java index 0326b29a713..deeef38bfcc 100644 --- a/src/freenet/keys/ClientKSK.java +++ b/src/freenet/keys/ClientKSK.java @@ -5,8 +5,8 @@ /** A KSK. We know the private key from the keyword, so this can be both * requested and inserted. */ -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import freenet.support.math.MersenneTwister; @@ -45,12 +45,7 @@ public static InsertableClientSSK create(FreenetURI uri) { public static ClientKSK create(String keyword) { MessageDigest md256 = SHA256.getMessageDigest(); try { - byte[] keywordHash; - try { - keywordHash = md256.digest(keyword.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + byte[] keywordHash = md256.digest(keyword.getBytes(StandardCharsets.UTF_8)); MersenneTwister mt = new MersenneTwister(keywordHash); DSAPrivateKey privKey = new DSAPrivateKey(Global.DSAgroupBigA, mt); DSAPublicKey pubKey = new DSAPublicKey(Global.DSAgroupBigA, privKey); diff --git a/src/freenet/keys/ClientSSK.java b/src/freenet/keys/ClientSSK.java index f060f618cb0..c3ab0d74898 100644 --- a/src/freenet/keys/ClientSSK.java +++ b/src/freenet/keys/ClientSSK.java @@ -3,8 +3,8 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.keys; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.Arrays; @@ -83,11 +83,7 @@ public ClientSSK(String docName, byte[] pubKeyHash, byte[] extras, DSAPublicKey throw new IllegalArgumentException(); } this.cryptoKey = cryptoKey; - try { - md.update(docName.getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + md.update(docName.getBytes(StandardCharsets.UTF_8)); byte[] buf = md.digest(); try { Rijndael aes = new Rijndael(256, 256); diff --git a/src/freenet/l10n/ISO639_3.java b/src/freenet/l10n/ISO639_3.java index 6d707b4eec5..0b0b8586328 100644 --- a/src/freenet/l10n/ISO639_3.java +++ b/src/freenet/l10n/ISO639_3.java @@ -6,6 +6,7 @@ import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.Hashtable; import java.util.Map; @@ -180,7 +181,7 @@ private static Hashtable loadFromTabFile() { if (in == null) throw new RuntimeException("Could not open the language codes resource"); - isr = new InputStreamReader(in, "UTF-8"); + isr = new InputStreamReader(in, StandardCharsets.UTF_8); br = new BufferedReader(isr); { diff --git a/src/freenet/node/Announcer.java b/src/freenet/node/Announcer.java index 74fca944368..abdc9863ba7 100644 --- a/src/freenet/node/Announcer.java +++ b/src/freenet/node/Announcer.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.InetAddress; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -267,7 +268,7 @@ public static List readSeednodes(File file) { try { fis = new FileInputStream(file); BufferedInputStream bis = new BufferedInputStream(fis); - InputStreamReader isr = new InputStreamReader(bis, "UTF-8"); + InputStreamReader isr = new InputStreamReader(bis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); while(true) { try { diff --git a/src/freenet/node/DarknetPeerNode.java b/src/freenet/node/DarknetPeerNode.java index 4c3a95a2153..fa599e46ad5 100644 --- a/src/freenet/node/DarknetPeerNode.java +++ b/src/freenet/node/DarknetPeerNode.java @@ -14,8 +14,8 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -517,12 +517,7 @@ public boolean readExtraPeerDataFile(File extraPeerDataFile, int fileNumber) { Logger.normal(this, "Extra peer data file not found: "+extraPeerDataFile.getPath()); return false; } - InputStreamReader isr; - try { - isr = new InputStreamReader(fis, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); SimpleFieldSet fs = null; try { @@ -595,7 +590,7 @@ private boolean parseExtraPeerData(SimpleFieldSet fs, File extraPeerDataFile, in } else if(extraPeerDataType == Node.EXTRA_PEER_DATA_TYPE_QUEUED_TO_SEND_N2NM) { int type = fs.getInt("n2nType"); if(isConnected()) { - Message n2nm; + if(fs.get("extraPeerDataType") != null) { fs.removeValue("extraPeerDataType"); } @@ -608,12 +603,7 @@ private boolean parseExtraPeerData(SimpleFieldSet fs, File extraPeerDataFile, in } fs.putOverwrite("sentTime", Long.toString(System.currentTimeMillis())); - try { - n2nm = DMT.createNodeToNodeMessage(type, fs.toString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - Logger.error(this, "UnsupportedEncodingException processing extraPeerDataType ("+extraPeerDataTypeString+") in file "+extraPeerDataFile.getPath(), e); - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + Message n2nm = DMT.createNodeToNodeMessage(type, fs.toString().getBytes(StandardCharsets.UTF_8)); // the callback ensures that n2ns are only unqueued after being acknowledged UnqueueMessageOnAckCallback cb = new UnqueueMessageOnAckCallback(this, fileNumber); try { @@ -682,12 +672,7 @@ public int writeNewExtraPeerDataFile(SimpleFieldSet fs, int extraPeerDataType) { + f + " - " + e2, e2); return -1; } - OutputStreamWriter w; - try { - w = new OutputStreamWriter(fos, "UTF-8"); - } catch (UnsupportedEncodingException e2) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e2, e2); - } + OutputStreamWriter w = new OutputStreamWriter(fos, StandardCharsets.UTF_8); BufferedWriter bw = new BufferedWriter(w); try { fs.writeTo(bw); @@ -780,12 +765,7 @@ public boolean rewriteExtraPeerDataFile(SimpleFieldSet fs, int extraPeerDataType + f + " - " + e2, e2); return false; } - OutputStreamWriter w; - try { - w = new OutputStreamWriter(fos, "UTF-8"); - } catch (UnsupportedEncodingException e2) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e2, e2); - } + OutputStreamWriter w = new OutputStreamWriter(fos, StandardCharsets.UTF_8); BufferedWriter bw = new BufferedWriter(w); try { fs.writeTo(bw); @@ -1982,14 +1962,7 @@ public void run() { InflaterInputStream dis = new InflaterInputStream(bais); SimpleFieldSet fs; try { - fs = new SimpleFieldSet(new BufferedReader(new InputStreamReader(dis, "UTF-8")), false, false); - } catch (UnsupportedEncodingException e) { - synchronized(DarknetPeerNode.this) { - receivingFullNoderef = false; - } - Logger.error(this, "Impossible: "+e, e); - e.printStackTrace(); - return; + fs = new SimpleFieldSet(new BufferedReader(new InputStreamReader(dis, StandardCharsets.UTF_8)), false, false); } catch (IOException e) { synchronized(DarknetPeerNode.this) { receivingFullNoderef = false; diff --git a/src/freenet/node/DatabaseKey.java b/src/freenet/node/DatabaseKey.java index 756f77358ef..141019a4bfd 100644 --- a/src/freenet/node/DatabaseKey.java +++ b/src/freenet/node/DatabaseKey.java @@ -2,7 +2,7 @@ import org.bouncycastle.util.Arrays; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Random; import freenet.crypt.AEADCryptBucket; @@ -11,13 +11,19 @@ import freenet.support.api.Bucket; public class DatabaseKey { + + private static final byte[] PLUGIN = "PLUGIN".getBytes(StandardCharsets.UTF_8); + private static final byte[] CLIENT_LAYER = "CLIENT".getBytes(StandardCharsets.UTF_8); private final byte[] databaseKey; - private final Random random; - - DatabaseKey(byte[] key, Random random) { + + @Deprecated + DatabaseKey(byte[] key, Random unused) { + this(key); + } + + DatabaseKey(byte[] key) { this.databaseKey = Arrays.copyOf(key, key.length); - this.random = random; } public Bucket createEncryptedBucketForClientLayer(Bucket underlying) { @@ -27,7 +33,7 @@ public Bucket createEncryptedBucketForClientLayer(Bucket underlying) { public static DatabaseKey createRandom(RandomSource random) { byte[] databaseKey = new byte[32]; random.nextBytes(databaseKey); - return new DatabaseKey(databaseKey, random); + return new DatabaseKey(databaseKey); } /** Key Derivation Function for plugin stores: Use the database key as an HMAC key to an HMAC @@ -36,19 +42,15 @@ public static DatabaseKey createRandom(RandomSource random) { * @return An encryption key, as byte[]. */ public byte[] getPluginStoreKey(String storeIdentifier) { - try { - byte[] id = storeIdentifier.getBytes("UTF-8"); - byte[] full = new byte[databaseKey.length+PLUGIN.length+id.length]; - int x = 0; - System.arraycopy(databaseKey, 0, full, 0, databaseKey.length); - x += databaseKey.length; - System.arraycopy(PLUGIN, 0, full, x, PLUGIN.length); - x += PLUGIN.length; - System.arraycopy(id, 0, full, x, id.length); - return HMAC.macWithSHA256(databaseKey, full); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } + byte[] id = storeIdentifier.getBytes(StandardCharsets.UTF_8); + byte[] full = new byte[databaseKey.length+PLUGIN.length+id.length]; + int x = 0; + System.arraycopy(databaseKey, 0, full, 0, databaseKey.length); + x += databaseKey.length; + System.arraycopy(PLUGIN, 0, full, x, PLUGIN.length); + x += PLUGIN.length; + System.arraycopy(id, 0, full, x, id.length); + return HMAC.macWithSHA256(databaseKey, full); } /** Key Derivation Function for client.dat: Use the database key as an HMAC key to an HMAC @@ -63,18 +65,6 @@ public byte[] getKeyForClientLayer() { System.arraycopy(CLIENT_LAYER, 0, full, x, CLIENT_LAYER.length); return HMAC.macWithSHA256(databaseKey, full); } - - private static final byte[] PLUGIN; - private static final byte[] CLIENT_LAYER; - - static { - try { - PLUGIN = "PLUGIN".getBytes("UTF-8"); - CLIENT_LAYER = "CLIENT".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } @Override public int hashCode() { diff --git a/src/freenet/node/FNPPacketMangler.java b/src/freenet/node/FNPPacketMangler.java index 9575926a110..09d24a53591 100644 --- a/src/freenet/node/FNPPacketMangler.java +++ b/src/freenet/node/FNPPacketMangler.java @@ -4,8 +4,8 @@ package freenet.node; import java.io.File; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.interfaces.ECPublicKey; import java.util.Arrays; @@ -77,19 +77,8 @@ public class FNPPacketMangler implements OutgoingPacketMangler { */ private final HashMap authenticatorCache; /** The following is used in the HMAC calculation of JFK message3 and message4 */ - private static final byte[] JFK_PREFIX_INITIATOR, JFK_PREFIX_RESPONDER; - static { - byte[] I,R; - try { - I = "I".getBytes("UTF-8"); - R = "R".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } - - JFK_PREFIX_INITIATOR = I; - JFK_PREFIX_RESPONDER = R; - } + private static final byte[] JFK_PREFIX_INITIATOR = "I".getBytes(StandardCharsets.UTF_8); + private static final byte[] JFK_PREFIX_RESPONDER = "R".getBytes(StandardCharsets.UTF_8); /* How often shall we generate a new exponential and add it to the FIFO? */ public final static int DH_GENERATION_INTERVAL = 30000; // 30sec @@ -1769,11 +1758,7 @@ private int getInitialMessageID(byte[] identity) { MessageDigest md = SHA256.getMessageDigest(); md.update(identity); // Similar to JFK keygen, should be safe enough. - try { - md.update("INITIAL0".getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } + md.update("INITIAL0".getBytes(StandardCharsets.UTF_8)); byte[] hashed = md.digest(); SHA256.returnMessageDigest(md); return Fields.bytesToInt(hashed, 0); @@ -1784,11 +1769,7 @@ private int getInitialMessageID(byte[] identity, byte[] otherIdentity) { md.update(identity); md.update(otherIdentity); // Similar to JFK keygen, should be safe enough. - try { - md.update("INITIAL1".getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } + md.update("INITIAL1".getBytes(StandardCharsets.UTF_8)); byte[] hashed = md.digest(); SHA256.returnMessageDigest(md); return Fields.bytesToInt(hashed, 0); @@ -2192,12 +2173,8 @@ private byte[] getTransientKey() { private byte[] computeJFKSharedKey(byte[] exponential, byte[] nI, byte[] nR, String what) { assert("0".equals(what) || "1".equals(what) || "2".equals(what) || "3".equals(what) || "4".equals(what) || "5".equals(what) || "6".equals(what) || "7".equals(what)); - byte[] number = null; - try { - number = what.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + + byte[] number = what.getBytes(StandardCharsets.UTF_8); byte[] toHash = new byte[nI.length + nR.length + number.length]; int offset = 0; diff --git a/src/freenet/node/LocationManager.java b/src/freenet/node/LocationManager.java index c6d439a5465..49e68bffc58 100644 --- a/src/freenet/node/LocationManager.java +++ b/src/freenet/node/LocationManager.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.security.MessageDigest; import java.text.DateFormat; @@ -924,7 +925,7 @@ public void run() { FileOutputStream os = null; try { os = new FileOutputStream(locationLog, true); - BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, "ISO-8859-1")); + BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.ISO_8859_1)); DateFormat df = DateFormat.getDateTimeInstance(); df.setTimeZone(TimeZone.getTimeZone("GMT")); bw.write(""+df.format(new Date())+" : "+getLocation()+(randomReset ? " (random reset"+(fromDupLocation?" from duplicated location" : "")+")" : "")+'\n'); diff --git a/src/freenet/node/MasterKeys.java b/src/freenet/node/MasterKeys.java index bd084ecbb99..22ef1129fe6 100644 --- a/src/freenet/node/MasterKeys.java +++ b/src/freenet/node/MasterKeys.java @@ -10,7 +10,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.Arrays; import java.util.Random; @@ -103,7 +103,7 @@ public static MasterKeys read(File masterKeysFile, Random hardRandom, String pas byte[] dataAndHash = new byte[length - salt.length - iv.length - 4 - 8]; dis.readFully(dataAndHash); // System.err.println("Data and hash: "+HexUtil.bytesToHex(dataAndHash)); - byte[] pwd = password.getBytes("UTF-8"); + byte[] pwd = password.getBytes(StandardCharsets.UTF_8); MessageDigest md = SHA256.getMessageDigest(); md.update(pwd); md.update(salt); @@ -172,10 +172,6 @@ public static MasterKeys read(File masterKeysFile, Random hardRandom, String pas return ret; } catch (FileNotFoundException e) { // Ok, create a new one. - } catch (UnsupportedEncodingException e) { - // Impossible - System.err.println("JVM doesn't support UTF-8, this should be impossible!"); - throw new Error(e); } catch (EOFException e) { throw new MasterKeysFileSizeException(false); } finally { @@ -197,7 +193,7 @@ private static MasterKeys readOldFormat(DataInputStream dis, int length, Random byte[] dataAndHash = new byte[length - salt.length - iv.length]; dis.readFully(dataAndHash); // System.err.println("Data and hash: "+HexUtil.bytesToHex(dataAndHash)); - byte[] pwd = password.getBytes("UTF-8"); + byte[] pwd = password.getBytes(StandardCharsets.UTF_8); MessageDigest md = SHA256.getMessageDigest(); md.update(pwd); md.update(salt); @@ -273,14 +269,8 @@ private void write(File masterKeysFile, String newPassword, Random hardRandom) t byte[] salt = new byte[32]; hardRandom.nextBytes(salt); - byte[] pwd; - try { - pwd = newPassword.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - // Impossible - throw new Error(e); - } - MessageDigest md = SHA256.getMessageDigest(); + byte[] pwd = newPassword.getBytes(StandardCharsets.UTF_8); + MessageDigest md = SHA256.getMessageDigest(); md.update(pwd); md.update(salt); byte[] outerKey = md.digest(); @@ -346,8 +336,13 @@ public static void killMasterKeys(File masterKeysFile) throws IOException { FileUtil.secureDelete(masterKeysFile); } - public DatabaseKey createDatabaseKey(Random random) { - return new DatabaseKey(databaseKey, random); + @Deprecated + public DatabaseKey createDatabaseKey(Random unused) { + return new DatabaseKey(databaseKey); + } + + public DatabaseKey createDatabaseKey() { + return new DatabaseKey(databaseKey); } /** Used for creating keys for persistent encrypted tempfiles */ diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index 0b4fce5ffa5..ca85f83a2b8 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -23,9 +23,9 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.RandomAccessFile; -import java.io.UnsupportedEncodingException; import java.net.InetAddress; import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; @@ -800,7 +800,7 @@ public void startProbe(final byte htl, final long uid, final Type type, final Li private void readNodeFile(String filename) throws IOException { // REDFLAG: Any way to share this code with NodePeer? FileInputStream fis = new FileInputStream(filename); - InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); + InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); SimpleFieldSet fs = new SimpleFieldSet(br, false, true); br.close(); @@ -1196,7 +1196,7 @@ public void set(Boolean val) throws InvalidConfigValueException, } clientCacheKey = keys.clientCacheMasterKey; persistentSecret = keys.getPersistentMasterSecret(); - databaseKey = keys.createDatabaseKey(secureRandom); + databaseKey = keys.createDatabaseKey(); if(securityLevels.getPhysicalThreatLevel() == PHYSICAL_THREAT_LEVEL.HIGH) { System.err.println("Physical threat level is set to HIGH but no password, resetting to NORMAL - probably timing glitch"); securityLevels.resetPhysicalThreatLevel(PHYSICAL_THREAT_LEVEL.NORMAL); @@ -1228,7 +1228,7 @@ public void set(Boolean val) throws InvalidConfigValueException, } else { byte[] buf = new byte[BOOT_FILE_LENGTH]; raf.readFully(buf); - String s = new String(buf, "ISO-8859-1"); + String s = new String(buf, StandardCharsets.ISO_8859_1); try { oldBootID = Fields.bytesToLong(HexUtil.hexToBytes(s)); } catch (NumberFormatException e) { @@ -1237,7 +1237,7 @@ public void set(Boolean val) throws InvalidConfigValueException, raf.seek(0); } String s = HexUtil.bytesToHex(Fields.longToBytes(bootID)); - byte[] buf = s.getBytes("ISO-8859-1"); + byte[] buf = s.getBytes(StandardCharsets.ISO_8859_1); if(buf.length != BOOT_FILE_LENGTH) System.err.println("Not 16 bytes for boot ID "+bootID+" - WTF??"); raf.write(buf); @@ -4112,7 +4112,7 @@ public void handleMessage(byte[] data, boolean fromDarknet, PeerNode src, int ty Logger.normal(this, "Received differential node reference node to node message from "+src.getPeer()); SimpleFieldSet fs = null; try { - fs = new SimpleFieldSet(new String(data, "UTF-8"), false, true, false); + fs = new SimpleFieldSet(new String(data, StandardCharsets.UTF_8), false, true, false); } catch (IOException e) { Logger.error(this, "IOException while parsing node to node message data", e); return; @@ -4142,9 +4142,7 @@ public void handleMessage(byte[] data, boolean fromDarknet, PeerNode src, int ty Logger.normal(this, "Received N2NTM from '"+darkSource.getPeer()+"'"); SimpleFieldSet fs = null; try { - fs = new SimpleFieldSet(new String(data, "UTF-8"), false, true, false); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); + fs = new SimpleFieldSet(new String(data, StandardCharsets.UTF_8), false, true, false); } catch (IOException e) { Logger.error(this, "IOException while parsing node to node message data", e); return; @@ -4634,7 +4632,7 @@ public void setMasterPassword(String password, boolean inFirstTimeWizard) throws if(keys == null) { // Decrypting. keys = MasterKeys.read(masterKeysFile, secureRandom, password); - databaseKey = keys.createDatabaseKey(secureRandom); + databaseKey = keys.createDatabaseKey(); } else { // Setting password when changing to HIGH from another mode. keys.changePassword(masterKeysFile, password, secureRandom); @@ -4658,7 +4656,7 @@ private void setPasswordInner(MasterKeys keys, boolean inFirstTimeWizard) throws if(wantClientCache) activatePasswordedClientCache(keys); if(wantDatabase) - lateSetupDatabase(keys.createDatabaseKey(secureRandom)); + lateSetupDatabase(keys.createDatabaseKey()); } diff --git a/src/freenet/node/NodeARKInserter.java b/src/freenet/node/NodeARKInserter.java index 360e3213458..2bc9898b319 100644 --- a/src/freenet/node/NodeARKInserter.java +++ b/src/freenet/node/NodeARKInserter.java @@ -3,8 +3,8 @@ */ package freenet.node; -import java.io.UnsupportedEncodingException; import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import freenet.client.InsertContext; import freenet.client.InsertException; @@ -152,14 +152,9 @@ private void startInserter() { //fs.remove("version"); - keep version because of its significance in reconnection String s = fs.toString(); - - byte[] buf; - try { - buf = s.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } - + + byte[] buf = s.getBytes(StandardCharsets.UTF_8); + RandomAccessBucket b = new SimpleReadOnlyArrayBucket(buf); long number = crypto.myARKNumber; diff --git a/src/freenet/node/NodeCrypto.java b/src/freenet/node/NodeCrypto.java index 005527a0015..4251294a15d 100644 --- a/src/freenet/node/NodeCrypto.java +++ b/src/freenet/node/NodeCrypto.java @@ -5,8 +5,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.security.interfaces.ECPublicKey; import java.util.ArrayList; import java.util.zip.DeflaterOutputStream; @@ -363,20 +363,13 @@ SimpleFieldSet exportPublicCryptoFieldSet(boolean forSetup, boolean forAnonIniti private String ecdsaSignRef(String mySignedReference) throws NodeInitException { if(logMINOR) Logger.minor(this, "Signing reference:\n"+mySignedReference); - try{ - byte[] ref = mySignedReference.getBytes("UTF-8"); - // We don't need a padded signature here - byte[] sig = ecdsaP256.sign(ref); - if(logMINOR && !ECDSA.verify(Curves.P256, getECDSAP256Pubkey(), sig, ref)) - throw new NodeInitException(NodeInitException.EXIT_EXCEPTION_TO_DEBUG, mySignedReference); - return Base64.encode(sig); - } catch(UnsupportedEncodingException e){ - //duh ? - Logger.error(this, "Error while signing the node identity!" + e, e); - System.err.println("Error while signing the node identity!"+e); - e.printStackTrace(); - throw new NodeInitException(NodeInitException.EXIT_CRAPPY_JVM, "Impossible: JVM doesn't support UTF-8"); - } + byte[] ref = mySignedReference.getBytes(StandardCharsets.UTF_8); + + // We don't need a padded signature here + byte[] sig = ecdsaP256.sign(ref); + if(logMINOR && !ECDSA.verify(Curves.P256, getECDSAP256Pubkey(), sig, ref)) + throw new NodeInitException(NodeInitException.EXIT_EXCEPTION_TO_DEBUG, mySignedReference); + return Base64.encode(sig); } private byte[] myCompressedRef(boolean setup, boolean heavySetup, boolean forARK) { diff --git a/src/freenet/node/OpennetManager.java b/src/freenet/node/OpennetManager.java index 8a18124159b..c1cc4f438fe 100644 --- a/src/freenet/node/OpennetManager.java +++ b/src/freenet/node/OpennetManager.java @@ -16,6 +16,7 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.InetAddress; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; @@ -309,7 +310,7 @@ private void writeFile(File orig, File backup) { BufferedWriter bw = null; try { fos = new FileOutputStream(backup); - osr = new OutputStreamWriter(fos, "UTF-8"); + osr = new OutputStreamWriter(fos, StandardCharsets.UTF_8); bw = new BufferedWriter(osr); fs.writeTo(bw); @@ -325,7 +326,7 @@ private void writeFile(File orig, File backup) { private void readFile(File filename) throws IOException { // REDFLAG: Any way to share this code with Node and NodePeer? FileInputStream fis = new FileInputStream(filename); - InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); + InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); SimpleFieldSet fs = new SimpleFieldSet(br, false, true); br.close(); diff --git a/src/freenet/node/PeerManager.java b/src/freenet/node/PeerManager.java index a23a6773498..519970abb09 100644 --- a/src/freenet/node/PeerManager.java +++ b/src/freenet/node/PeerManager.java @@ -12,7 +12,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -234,12 +234,7 @@ private boolean readPeers(File peersFile, NodeCrypto crypto, OpennetManager open Logger.normal(this, "Peers file not found: " + peersFile); return false; } - InputStreamReader ris; - try { - ris = new InputStreamReader(fis, "UTF-8"); - } catch(UnsupportedEncodingException e4) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e4, e4); - } + InputStreamReader ris = new InputStreamReader(fis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(ris); File brokenPeersFile = new File(peersFile.getPath() + ".broken"); DroppedOldPeersUserAlert droppedOldPeers = new DroppedOldPeersUserAlert(brokenPeersFile); @@ -1519,14 +1514,7 @@ private void writePeersInner(String filename, String sb, int maxBackups, boolean f.delete(); return; } - OutputStreamWriter w = null; - try { - w = new OutputStreamWriter(fos, "UTF-8"); - } catch(UnsupportedEncodingException e2) { - Closer.close(w); - f.delete(); - throw new Error("Impossible: JVM doesn't support UTF-8: " + e2, e2); - } + OutputStreamWriter w = new OutputStreamWriter(fos, StandardCharsets.UTF_8); try { w.write(sb); w.flush(); diff --git a/src/freenet/node/PeerNode.java b/src/freenet/node/PeerNode.java index b6b828c58e9..2abc0ed64e1 100644 --- a/src/freenet/node/PeerNode.java +++ b/src/freenet/node/PeerNode.java @@ -4,12 +4,12 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; import java.io.Writer; import java.lang.ref.WeakReference; import java.net.InetAddress; import java.net.MalformedURLException; import java.net.UnknownHostException; +import java.nio.charset.StandardCharsets; import java.security.interfaces.ECPublicKey; import java.util.ArrayList; import java.util.Arrays; @@ -310,14 +310,7 @@ public abstract class PeerNode implements USKRetrieverCallback, BasePeerNode, Pe static final long CHECK_FOR_SWAPPED_TRACKERS_INTERVAL = FNPPacketMangler.SESSION_KEY_REKEYING_INTERVAL / 30; - static final byte[] TEST_AS_BYTES; - static { - try { - TEST_AS_BYTES = "test".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } - } + static final byte[] TEST_AS_BYTES = "test".getBytes(StandardCharsets.UTF_8); /** Holds a String-Long pair that shows which message types (as name) have been send to this peer. */ private final Hashtable localNodeSentMessageTypes = new Hashtable(); @@ -2404,12 +2397,7 @@ static SimpleFieldSet compressedNoderefToFieldSet(byte[] data, int offset, int l // Now decode it ByteArrayInputStream bais = new ByteArrayInputStream(data, offset, length); - InputStreamReader isr; - try { - isr = new InputStreamReader(bais, "UTF-8"); - } catch(UnsupportedEncodingException e1) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e1, e1); - } + InputStreamReader isr = new InputStreamReader(bais, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); try { SimpleFieldSet fs = new SimpleFieldSet(br, false, true); @@ -3623,13 +3611,7 @@ public void onFound(USK origUSK, long edition, FetchResult result) { return; } - String ref; - try { - ref = new String(data, "UTF-8"); - } catch(UnsupportedEncodingException e) { - result.asBucket().free(); - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + String ref = new String(data, StandardCharsets.UTF_8); SimpleFieldSet fs; try { @@ -4032,24 +4014,21 @@ public void sendNodeToNodeMessage(SimpleFieldSet fs, int n2nType, boolean includ if(includeSentTime) { fs.put("sentTime", now); } + Message n2nm = DMT.createNodeToNodeMessage( + n2nType, + fs.toString().getBytes(StandardCharsets.UTF_8) + ); + UnqueueMessageOnAckCallback cb = null; + if (isDarknet() && queueOnNotConnected) { + int fileNumber = queueN2NM(fs); + cb = new UnqueueMessageOnAckCallback((DarknetPeerNode)this, fileNumber); + } try { - Message n2nm; - n2nm = DMT.createNodeToNodeMessage( - n2nType, fs.toString().getBytes("UTF-8")); - UnqueueMessageOnAckCallback cb = null; - if (isDarknet() && queueOnNotConnected) { - int fileNumber = queueN2NM(fs); - cb = new UnqueueMessageOnAckCallback((DarknetPeerNode)this, fileNumber); - } - try { - sendAsync(n2nm, cb, node.nodeStats.nodeToNodeCounter); - } catch (NotConnectedException e) { - if(includeSentTime) { - fs.removeValue("sentTime"); - } + sendAsync(n2nm, cb, node.nodeStats.nodeToNodeCounter); + } catch (NotConnectedException e) { + if(includeSentTime) { + fs.removeValue("sentTime"); } - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } } @@ -5796,9 +5775,8 @@ private boolean verifyReferenceSignature(SimpleFieldSet fs) throws ReferenceSign // THEN // verify the signatures fs.removeValue("sig"); - byte[] toVerifyDSA = fs.toOrderedString().getBytes("UTF-8"); fs.removeValue("sigP256"); - byte[] toVerifyECDSA = fs.toOrderedString().getBytes("UTF-8"); + byte[] toVerifyECDSA = fs.toOrderedString().getBytes(StandardCharsets.UTF_8); boolean isECDSAsigPresent = (signatureP256 != null && peerECDSAPubKey != null); @@ -5834,10 +5812,8 @@ private boolean verifyReferenceSignature(SimpleFieldSet fs) throws ReferenceSign } catch(IllegalBase64Exception e) { Logger.error(this, "Invalid reference: " + e, e); throw new ReferenceSignatureVerificationException("The node reference you added is invalid: It does not have a valid ECDSA signature."); - } catch(UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); } - return !failed; + return !failed; } protected final byte[] getPubKeyHash() { diff --git a/src/freenet/node/TextModeClientInterface.java b/src/freenet/node/TextModeClientInterface.java index 004cb523f43..f280f562ecf 100644 --- a/src/freenet/node/TextModeClientInterface.java +++ b/src/freenet/node/TextModeClientInterface.java @@ -16,13 +16,14 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.io.Writer; import java.net.MalformedURLException; import java.net.SocketException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.NumberFormat; import java.util.HashMap; @@ -78,7 +79,7 @@ public class TextModeClientInterface implements Runnable { final File downloadsDir; final InputStream in; final Writer w; - private static final String ENCODING = "UTF-8"; + private static final Charset ENCODING = StandardCharsets.UTF_8; private static volatile boolean logMINOR; static { @@ -98,12 +99,8 @@ public TextModeClientInterface(TextModeClientInterfaceServer server, InputStream client = core.makeClient(RequestStarter.INTERACTIVE_PRIORITY_CLASS, true, false); this.downloadsDir = server.downloadsDir; this.in = in; - try { - w = new OutputStreamWriter(out, ENCODING); - client.addEventHook(new EventDumper(new BufferedWriter(new OutputStreamWriter(out, ENCODING)), false)); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } + this.w = new OutputStreamWriter(out, ENCODING); + client.addEventHook(new EventDumper(new BufferedWriter(new OutputStreamWriter(out, ENCODING)), false)); } public TextModeClientInterface(Node n, NodeClientCore core, HighLevelSimpleClient c, File downloadDir, InputStream in, OutputStream out) { @@ -113,13 +110,9 @@ public TextModeClientInterface(Node n, NodeClientCore core, HighLevelSimpleClien this.client = c; this.downloadsDir = downloadDir; this.in = in; - try { - w = new OutputStreamWriter(out, ENCODING); - client.addEventHook(new EventDumper(new BufferedWriter(new OutputStreamWriter(out, ENCODING)), false)); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } + this.w = new OutputStreamWriter(out, ENCODING); + client.addEventHook(new EventDumper(new BufferedWriter(new OutputStreamWriter(out, ENCODING)), false)); + } @Override public void run() { @@ -440,7 +433,7 @@ public void run() { outsb.append("Here is the result:\r\n"); final String content = readLines(reader, false); - final Bucket input = new ArrayBucket(content.getBytes("UTF-8")); + final Bucket input = new ArrayBucket(content.getBytes(StandardCharsets.UTF_8)); final Bucket output = new ArrayBucket(); InputStream inputStream = null; OutputStream outputStream = null; diff --git a/src/freenet/node/simulator/BootstrapPullTest.java b/src/freenet/node/simulator/BootstrapPullTest.java index 4db9ed53dc0..c2fac285aa5 100644 --- a/src/freenet/node/simulator/BootstrapPullTest.java +++ b/src/freenet/node/simulator/BootstrapPullTest.java @@ -9,6 +9,7 @@ import java.io.OutputStreamWriter; import java.net.InetAddress; import java.net.Socket; +import java.nio.charset.StandardCharsets; import freenet.support.math.MersenneTwister; @@ -141,7 +142,7 @@ private static FreenetURI insertData(File dataFile) throws IOException { InputStream sockIS = sock.getInputStream(); System.out.println("Connected to node."); LineReadingInputStream lis = new LineReadingInputStream(sockIS); - OutputStreamWriter osw = new OutputStreamWriter(sockOS, "UTF-8"); + OutputStreamWriter osw = new OutputStreamWriter(sockOS, StandardCharsets.UTF_8); osw.write("ClientHello\nExpectedVersion=0.7\nName=BootstrapPullTest-"+System.currentTimeMillis()+"\nEnd\n"); osw.flush(); String name = lis.readLine(65536, 128, true); diff --git a/src/freenet/node/simulator/LongTermTest.java b/src/freenet/node/simulator/LongTermTest.java index 10409b87bb3..5aedc05b13e 100644 --- a/src/freenet/node/simulator/LongTermTest.java +++ b/src/freenet/node/simulator/LongTermTest.java @@ -4,6 +4,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -26,7 +28,7 @@ public class LongTermTest { protected static final int EXIT_FAILED_TARGET = 258; protected static final int EXIT_THREW_SOMETHING = 261; - protected static final String ENCODING = "UTF-8"; + protected static final Charset ENCODING = StandardCharsets.UTF_8; protected static void writeToStatusLog(File file, List csvLine) { try { diff --git a/src/freenet/node/simulator/RealNodeBusyNetworkTest.java b/src/freenet/node/simulator/RealNodeBusyNetworkTest.java index e435e1f22e4..5c70573021c 100644 --- a/src/freenet/node/simulator/RealNodeBusyNetworkTest.java +++ b/src/freenet/node/simulator/RealNodeBusyNetworkTest.java @@ -3,37 +3,24 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.node.simulator; -import static java.util.concurrent.TimeUnit.DAYS; - -import java.io.File; -import java.io.UnsupportedEncodingException; - import freenet.client.HighLevelSimpleClient; import freenet.crypt.DummyRandomSource; -import freenet.io.comm.PeerParseException; -import freenet.io.comm.ReferenceSignatureVerificationException; import freenet.keys.CHKBlock; -import freenet.keys.CHKDecodeException; -import freenet.keys.CHKEncodeException; -import freenet.keys.CHKVerifyException; import freenet.keys.ClientCHK; import freenet.keys.ClientCHKBlock; -import freenet.node.FSParseException; import freenet.node.Node; -import freenet.node.NodeInitException; import freenet.node.NodeStarter; import freenet.node.RequestStarter; -import freenet.support.Executor; -import freenet.support.Fields; -import freenet.support.HexUtil; -import freenet.support.Logger; +import freenet.support.*; import freenet.support.Logger.LogLevel; -import freenet.support.LoggerHook.InvalidThresholdException; -import freenet.support.PooledExecutor; import freenet.support.compress.Compressor.COMPRESSOR_TYPE; -import freenet.support.compress.InvalidCompressionCodecException; import freenet.support.io.FileUtil; +import java.io.File; +import java.nio.charset.StandardCharsets; + +import static java.util.concurrent.TimeUnit.DAYS; + /** * Test a busy, bandwidth limited network. Hopefully this should reveal any serious problems with * load limiting and block transfer. @@ -56,14 +43,13 @@ public class RealNodeBusyNetworkTest extends RealNodeRoutingTest { static final boolean FORK_ON_CACHEABLE = false; static final boolean REAL_TIME_FLAG = false; - static final int TARGET_SUCCESSES = 20; //static final int NUMBER_OF_NODES = 50; //static final short MAX_HTL = 10; static final int DARKNET_PORT_BASE = 5008; static final int DARKNET_PORT_END = DARKNET_PORT_BASE + NUMBER_OF_NODES; - public static void main(String[] args) throws FSParseException, PeerParseException, CHKEncodeException, InvalidThresholdException, NodeInitException, ReferenceSignatureVerificationException, InterruptedException, UnsupportedEncodingException, CHKVerifyException, CHKDecodeException, InvalidCompressionCodecException { + public static void main(String[] args) throws Exception { String name = "realNodeRequestInsertTest"; File wd = new File(name); if(!FileUtil.removeAll(wd)) { @@ -122,7 +108,7 @@ public static void main(String[] args) throws FSParseException, PeerParseExcepti int node1 = random.nextInt(NUMBER_OF_NODES); Node randomNode = nodes[node1]; String dataString = baseString + i; - byte[] data = dataString.getBytes("UTF-8"); + byte[] data = dataString.getBytes(StandardCharsets.UTF_8); ClientCHKBlock b; b = ClientCHKBlock.encode(data, false, false, (short)-1, 0, COMPRESSOR_TYPE.DEFAULT_COMPRESSORDESCRIPTOR); CHKBlock block = b.getBlock(); @@ -131,7 +117,7 @@ public static void main(String[] args) throws FSParseException, PeerParseExcepti byte[] encHeaders = block.getHeaders(); ClientCHKBlock newBlock = new ClientCHKBlock(encData, encHeaders, chk, true); keys[i] = chk; - Logger.minor(RealNodeRequestInsertTest.class, "Decoded: "+new String(newBlock.memoryDecode(), "UTF-8")); + Logger.minor(RealNodeRequestInsertTest.class, "Decoded: "+new String(newBlock.memoryDecode(), StandardCharsets.UTF_8)); Logger.normal(RealNodeRequestInsertTest.class,"CHK: "+chk.getURI()); Logger.minor(RealNodeRequestInsertTest.class,"Headers: "+HexUtil.bytesToHex(block.getHeaders())); // Insert it. diff --git a/src/freenet/node/simulator/RealNodeRequestInsertTest.java b/src/freenet/node/simulator/RealNodeRequestInsertTest.java index 790c6e80508..fd54a3c21fd 100644 --- a/src/freenet/node/simulator/RealNodeRequestInsertTest.java +++ b/src/freenet/node/simulator/RealNodeRequestInsertTest.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.ArrayList; import java.util.List; @@ -180,7 +181,7 @@ int insertRequestTest() throws CHKEncodeException, InvalidCompressionCodecExcept ClientKey fetchKey; ClientKeyBlock block; - byte[] buf = dataString.getBytes("UTF-8"); + byte[] buf = dataString.getBytes(StandardCharsets.UTF_8); if(isSSK) { testKey = new FreenetURI("KSK", dataString); @@ -198,8 +199,8 @@ int insertRequestTest() throws CHKEncodeException, InvalidCompressionCodecExcept System.err.println("Created random test key "+testKey+" = "+fetchKey.getNodeKey(false)); System.err.println(); - byte[] data = dataString.getBytes("UTF-8"); - Logger.minor(RealNodeRequestInsertTest.class, "Decoded: "+new String(block.memoryDecode(), "UTF-8")); + byte[] data = dataString.getBytes(StandardCharsets.UTF_8); + Logger.minor(RealNodeRequestInsertTest.class, "Decoded: "+new String(block.memoryDecode(), StandardCharsets.UTF_8)); Logger.normal(RealNodeRequestInsertTest.class,"Insert Key: "+insertKey.getURI()); Logger.normal(RealNodeRequestInsertTest.class,"Fetch Key: "+fetchKey.getURI()); try { diff --git a/src/freenet/node/simulator/SeednodePingTest.java b/src/freenet/node/simulator/SeednodePingTest.java index fa9e1dbcb2e..d5f5c8eb2f8 100644 --- a/src/freenet/node/simulator/SeednodePingTest.java +++ b/src/freenet/node/simulator/SeednodePingTest.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; @@ -153,11 +154,11 @@ public static void main(String[] args) throws FSParseException, IOException, Ope System.out.println(status); File logFile = new File(STATUS_DIR, peer.getIdentityString()); FileOutputStream fos = new FileOutputStream(logFile, true); - OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); osw.write(status+"\n"); osw.close(); FileInputStream fis = new FileInputStream(logFile); - InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); + InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); String line; int successes = 0; diff --git a/src/freenet/node/updater/MainJarDependenciesChecker.java b/src/freenet/node/updater/MainJarDependenciesChecker.java index 77cd505200a..ee8c41c1e85 100644 --- a/src/freenet/node/updater/MainJarDependenciesChecker.java +++ b/src/freenet/node/updater/MainJarDependenciesChecker.java @@ -18,9 +18,9 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; -import java.io.UnsupportedEncodingException; import java.io.Writer; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.ArrayList; import java.util.Arrays; @@ -899,16 +899,8 @@ public void onFailure(FetchException e) { return true; } - static final byte[] SCRIPT_HEAD; - - static { - try { - SCRIPT_HEAD = "#!".getBytes("UTF-8"); - } catch(UnsupportedEncodingException e) { - throw new Error(e); - } - } - + static final byte[] SCRIPT_HEAD = "#!".getBytes(StandardCharsets.UTF_8); + private boolean isOnPathNotAScript(String toFind) { String path = System.getenv("PATH"); // Upper case should work on both linux and Windows if(path == null) return false; @@ -1512,7 +1504,7 @@ private File createRestartScript() throws IOException { OutputStream os = null; try { os = new BufferedOutputStream(fb.getOutputStream()); - OutputStreamWriter osw = new OutputStreamWriter(os, "ISO-8859-1"); // Right??? + OutputStreamWriter osw = new OutputStreamWriter(os, StandardCharsets.ISO_8859_1); // Right??? osw.write("#!/bin/sh\n"); // FIXME exec >/dev/null 2>&1 ???? Believed to be portable. //osw.write("trap true PIPE\n"); - should not be necessary osw.write("while kill -0 "+WrapperManager.getWrapperPID()+" > /dev/null 2>&1; do sleep 1; done\n"); @@ -1535,15 +1527,14 @@ private File createRestartScript() throws IOException { * just get rid of this - in which case maybe we want to improve on this. * @throws IOException */ private boolean createRunShNoNice(File input, File output) throws IOException { - final String charset = "UTF-8"; - InputStream is = null; + InputStream is = null; OutputStream os = null; boolean failed = false; try { is = new FileInputStream(input); - BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(is), charset)); + BufferedReader br = new BufferedReader(new InputStreamReader(new BufferedInputStream(is), StandardCharsets.UTF_8)); os = new FileOutputStream(output); - Writer w = new BufferedWriter(new OutputStreamWriter(new BufferedOutputStream(os), charset)); + Writer w = new BufferedWriter(new OutputStreamWriter(new BufferedOutputStream(os), StandardCharsets.UTF_8)); boolean writtenPrio = false; String line; while((line = br.readLine()) != null) { @@ -1563,8 +1554,6 @@ private boolean createRunShNoNice(File input, File output) throws IOException { return false; } return true; - } catch (UnsupportedEncodingException e) { - throw new Error(e); } catch (IOException e) { failed = true; return false; diff --git a/src/freenet/node/updater/NodeUpdater.java b/src/freenet/node/updater/NodeUpdater.java index 414a6eeb274..3ca575487d9 100644 --- a/src/freenet/node/updater/NodeUpdater.java +++ b/src/freenet/node/updater/NodeUpdater.java @@ -11,6 +11,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.util.Properties; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -341,7 +342,7 @@ protected void parseManifest(FetchResult result) { DataInputStream dis = new DataInputStream(zis); dis.readFully(buf); ByteArrayInputStream bais = new ByteArrayInputStream(buf); - InputStreamReader isr = new InputStreamReader(bais, "UTF-8"); + InputStreamReader isr = new InputStreamReader(bais, StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); String line; while((line = br.readLine()) != null) { diff --git a/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java b/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java index 6b9f7cc469e..d9d6a89038b 100644 --- a/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java +++ b/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java @@ -13,6 +13,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.security.cert.Certificate; import java.security.cert.CertificateFactory; @@ -61,7 +62,7 @@ String getSHA1sum() throws PluginNotFoundException { bos.write(buffer, 0, read); } - return new String(bos.toByteArray(), "ISO-8859-1").split(" ")[0]; + return new String(bos.toByteArray(), StandardCharsets.ISO_8859_1).split(" ")[0]; } catch (MalformedURLException e) { throw new PluginNotFoundException("impossible: "+e,e); diff --git a/src/freenet/support/Base64.java b/src/freenet/support/Base64.java index 06325e74a94..42d0f2de345 100644 --- a/src/freenet/support/Base64.java +++ b/src/freenet/support/Base64.java @@ -1,6 +1,7 @@ package freenet.support; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; /** @@ -20,7 +21,7 @@ */ public class Base64 { - static final Charset UTF8 = Charset.forName("UTF-8"); + static final Charset UTF8 = StandardCharsets.UTF_8; private static char[] base64Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789~-".toCharArray(); diff --git a/src/freenet/support/FileLoggerHook.java b/src/freenet/support/FileLoggerHook.java index 102b8dac7af..072c8a29bf3 100644 --- a/src/freenet/support/FileLoggerHook.java +++ b/src/freenet/support/FileLoggerHook.java @@ -14,6 +14,8 @@ import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.net.InetAddress; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; diff --git a/src/freenet/support/Logger.java b/src/freenet/support/Logger.java index ee03898e0af..00cbcda4a84 100644 --- a/src/freenet/support/Logger.java +++ b/src/freenet/support/Logger.java @@ -7,10 +7,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; import java.util.regex.PatternSyntaxException; import freenet.support.FileLoggerHook.IntervalParseException; @@ -69,14 +69,11 @@ public synchronized static String getFieldFromProcSelfStat(int fieldNumber, Obje if (procFile.exists()) { try { is = new FileInputStream(procFile); - br = new BufferedReader(new InputStreamReader(is, "ISO-8859-1" /* ASCII */)); + br = new BufferedReader(new InputStreamReader(is, StandardCharsets.ISO_8859_1 /* ASCII */)); } catch (FileNotFoundException e1) { logStatic(o, "'/proc/self/stat' not found", logToFileVerbosity); procSelfStatEnabled = false; br = null; - } catch (UnsupportedEncodingException e) { - // Impossible. - throw new Error(e); } if (null != br) { try { diff --git a/src/freenet/support/SimpleFieldSet.java b/src/freenet/support/SimpleFieldSet.java index 1a7babc8464..321840044f0 100644 --- a/src/freenet/support/SimpleFieldSet.java +++ b/src/freenet/support/SimpleFieldSet.java @@ -14,8 +14,8 @@ import java.io.OutputStreamWriter; import java.io.StringReader; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -946,13 +946,7 @@ public static SimpleFieldSet readFrom(InputStream is, boolean allowMultiple, boo try { bis = new BufferedInputStream(is); - try { - isr = new InputStreamReader(bis, "UTF-8"); - } catch (UnsupportedEncodingException e) { - Logger.error(SimpleFieldSet.class, "Impossible: "+e, e); - is.close(); - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + isr = new InputStreamReader(bis, StandardCharsets.UTF_8); br = new BufferedReader(isr); SimpleFieldSet fs = new SimpleFieldSet(br, allowMultiple, shortLived, allowBase64, alwaysBase64); br.close(); @@ -993,13 +987,8 @@ public void writeTo(OutputStream os, int bufferSize) throws IOException { BufferedWriter bw = null; bos = new BufferedOutputStream(os, bufferSize); - try { - osw = new OutputStreamWriter(bos, "UTF-8"); - } catch (UnsupportedEncodingException e) { - Logger.error(SimpleFieldSet.class, "Impossible: " + e, e); - throw e; - } - bw = new BufferedWriter(osw); + osw = new OutputStreamWriter(bos, StandardCharsets.UTF_8); + bw = new BufferedWriter(osw); writeTo(bw); bw.flush(); } diff --git a/src/freenet/support/URIPreEncoder.java b/src/freenet/support/URIPreEncoder.java index 73c760f706c..b132301792a 100644 --- a/src/freenet/support/URIPreEncoder.java +++ b/src/freenet/support/URIPreEncoder.java @@ -1,8 +1,8 @@ package freenet.support; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; /** * Replace any invalid characters in a string (to be converted to a URI) with encoded chars using UTF-8. @@ -29,16 +29,12 @@ public static String encode(String s) { output.append(c); } else { String tmp = String.valueOf(c); - try { - for(byte u: tmp.getBytes("UTF-8")) { - int x = u & 0xff; - output.append('%'); - if(x < 16) - output.append('0'); - output.append(Integer.toHexString(x)); - } - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); + for(byte u: tmp.getBytes(StandardCharsets.UTF_8)) { + int x = u & 0xff; + output.append('%'); + if(x < 16) + output.append('0'); + output.append(Integer.toHexString(x)); } } } diff --git a/src/freenet/support/URLDecoder.java b/src/freenet/support/URLDecoder.java index 9c5813a8cd5..b283647a73f 100644 --- a/src/freenet/support/URLDecoder.java +++ b/src/freenet/support/URLDecoder.java @@ -5,7 +5,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; /** * Decode encoded URLs (or parts of URLs). @see URLEncoder. @@ -65,29 +65,21 @@ public static String decode(String s, boolean tolerant) throws URLEncodedFormatE } catch (NumberFormatException nfe) { // Not encoded? if(tolerant && !hasDecodedSomething) { - try { - byte[] buf = ('%'+hexval).getBytes("UTF-8"); - decodedBytes.write(buf, 0, buf.length); - continue; - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + byte[] buf = ('%'+hexval).getBytes(StandardCharsets.UTF_8); + decodedBytes.write(buf, 0, buf.length); + continue; } throw new URLEncodedFormatException("Not a two character hex % escape: "+hexval+" in "+s); } } else { - try { - byte[] encoded = String.valueOf(c).getBytes("UTF-8"); - decodedBytes.write(encoded, 0, encoded.length); - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); - } + byte[] encoded = String.valueOf(c).getBytes(StandardCharsets.UTF_8); + decodedBytes.write(encoded, 0, encoded.length); } } try { decodedBytes.close(); - return new String(decodedBytes.toByteArray(), "utf-8"); + return new String(decodedBytes.toByteArray(), StandardCharsets.UTF_8); } catch (IOException ioe1) { /* if this throws something's wrong */ } diff --git a/src/freenet/support/URLEncoder.java b/src/freenet/support/URLEncoder.java index 3b62fe21aa0..00927af0752 100644 --- a/src/freenet/support/URLEncoder.java +++ b/src/freenet/support/URLEncoder.java @@ -3,7 +3,7 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.support; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; /** * Encodes strings for use in URIs. Note that this is NOT the same as java.net.URLEncoder, which @@ -43,17 +43,13 @@ public static String encode(String URL, String force, boolean ascii, String extr enc.append(c); } else { - try { - for (byte b: String.valueOf(c).getBytes("UTF-8")) { - int x = b & 0xFF; - if (x < 16) - enc.append("%0"); - else - enc.append('%'); - enc.append(Integer.toHexString(x)); - } - } catch (UnsupportedEncodingException e) { - throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e); + for (byte b: String.valueOf(c).getBytes(StandardCharsets.UTF_8)) { + int x = b & 0xFF; + if (x < 16) + enc.append("%0"); + else + enc.append('%'); + enc.append(Integer.toHexString(x)); } } } diff --git a/src/freenet/support/compress/Bzip2Compressor.java b/src/freenet/support/compress/Bzip2Compressor.java index 5bdb0758451..f61ffaabf57 100644 --- a/src/freenet/support/compress/Bzip2Compressor.java +++ b/src/freenet/support/compress/Bzip2Compressor.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream; import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream; @@ -28,14 +28,7 @@ */ public class Bzip2Compressor extends AbstractCompressor { - public static final byte[] BZ_HEADER; - static { - try { - BZ_HEADER = "BZ".getBytes("ISO-8859-1"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); // Impossible! - } - } + public static final byte[] BZ_HEADER = "BZ".getBytes(StandardCharsets.ISO_8859_1); @Override public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long maxWriteLength) diff --git a/src/freenet/support/io/FileUtil.java b/src/freenet/support/io/FileUtil.java index 352ed227cac..e3690427e41 100644 --- a/src/freenet/support/io/FileUtil.java +++ b/src/freenet/support/io/FileUtil.java @@ -15,10 +15,10 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.RandomAccessFile; -import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.nio.CharBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.SecureRandom; import java.util.Random; @@ -231,13 +231,10 @@ public static long estimateUsage(File file, long flen) { long blockUsage = roundup_2n(flen, 4096); // Assume 512 byte filename entries, with 100 bytes overhead, for filename overhead (NTFS) String filename = file.getName(); - int nameLength; - try { - nameLength = Math.max(filename.getBytes("UTF-16").length, filename.getBytes("UTF-8").length) + 100; - } catch (UnsupportedEncodingException e) { - // Impossible. - throw new RuntimeException("UTF-16 or UTF-8 charset not supported?!"); - } + int nameLength = 100 + Math.max( + filename.getBytes(StandardCharsets.UTF_16).length, + filename.getBytes(StandardCharsets.UTF_8).length + ); long filenameUsage = roundup_2n(nameLength, 512); // Assume 50 bytes per block tree overhead with 1kB blocks (reiser3 worst case) long extra = (roundup_2n(flen, 1024) / 1024) * 50; @@ -317,7 +314,7 @@ public static StringBuilder readUTF(File file, long offset) throws FileNotFoundE fis = new FileInputStream(file); skipFully(fis, offset); bis = new BufferedInputStream(fis); - isr = new InputStreamReader(bis, "UTF-8"); + isr = new InputStreamReader(bis, StandardCharsets.UTF_8); char[] buf = new char[4096]; int length = 0; @@ -356,7 +353,7 @@ public static StringBuilder readUTF(InputStream stream, long offset) throws IOEx skipFully(stream, offset); InputStreamReader reader = null; try { - reader = new InputStreamReader(stream, "UTF-8"); + reader = new InputStreamReader(stream, StandardCharsets.UTF_8); char[] buf = new char[4096]; int length = 0; while((length = reader.read(buf)) > 0) { diff --git a/src/freenet/support/io/LineReadingInputStream.java b/src/freenet/support/io/LineReadingInputStream.java index 391262443ba..7f002e6cb22 100644 --- a/src/freenet/support/io/LineReadingInputStream.java +++ b/src/freenet/support/io/LineReadingInputStream.java @@ -7,6 +7,7 @@ import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import freenet.support.HexUtil; @@ -46,7 +47,7 @@ public String readLine(int maxLength, int bufferSize, boolean utf) throws IOExce if(x < 0) { if(ctr == 0) return null; - return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1"); + return new String(buf, 0, ctr, utf ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1); } if(x == 0) { // Don't busy-loop. Probably a socket closed or something. @@ -60,14 +61,14 @@ public String readLine(int maxLength, int bufferSize, boolean utf) throws IOExce String toReturn = ""; if(ctr != 0) { boolean removeCR = (buf[ctr - 1] == '\r'); - toReturn = new String(buf, 0, (removeCR ? ctr - 1 : ctr), utf ? "UTF-8" : "ISO-8859-1"); + toReturn = new String(buf, 0, (removeCR ? ctr - 1 : ctr), utf ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1); } reset(); skip(ctr + 1); return toReturn; } if(ctr >= maxLength) - throw new TooLongException("We reached maxLength="+maxLength+ " parsing\n "+HexUtil.bytesToHex(buf, 0, ctr) + "\n" + new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1")); + throw new TooLongException("We reached maxLength="+maxLength+ " parsing\n "+HexUtil.bytesToHex(buf, 0, ctr) + "\n" + new String(buf, 0, ctr, utf ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1)); } if((buf.length < maxLength) && (buf.length - ctr < bufferSize)) { byte[] newBuf = new byte[Math.min(buf.length * 2, maxLength)]; @@ -87,7 +88,7 @@ protected String readLineWithoutMarking(int maxLength, int bufferSize, boolean u if(x == -1) { if(ctr == 0) return null; - return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1"); + return new String(buf, 0, ctr, utf ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1); } // REDFLAG this is definitely safe with the above charsets, it may not be safe with some wierd ones. if(x == '\n') { @@ -95,10 +96,10 @@ protected String readLineWithoutMarking(int maxLength, int bufferSize, boolean u return ""; if(buf[ctr - 1] == '\r') ctr--; - return new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1"); + return new String(buf, 0, ctr, utf ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1); } if(ctr >= maxLength) - throw new TooLongException("We reached maxLength="+maxLength+ " parsing\n "+HexUtil.bytesToHex(buf, 0, ctr) + "\n" + new String(buf, 0, ctr, utf ? "UTF-8" : "ISO-8859-1")); + throw new TooLongException("We reached maxLength="+maxLength+ " parsing\n "+HexUtil.bytesToHex(buf, 0, ctr) + "\n" + new String(buf, 0, ctr, utf ? StandardCharsets.UTF_8 : StandardCharsets.ISO_8859_1)); if(ctr >= buf.length) { buf = Arrays.copyOf(buf, Math.min(buf.length * 2, maxLength)); } diff --git a/src/freenet/tools/CleanupTranslations.java b/src/freenet/tools/CleanupTranslations.java index 0e0d070eff5..b480e402dad 100644 --- a/src/freenet/tools/CleanupTranslations.java +++ b/src/freenet/tools/CleanupTranslations.java @@ -9,6 +9,7 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import freenet.support.Logger; import freenet.support.LoggerHook; @@ -31,7 +32,7 @@ public static void main(String[] args) throws IOException, LoggerHook.InvalidThr if(!name.startsWith("freenet.l10n.")) continue; if(name.equals("freenet.1l0n.en.properties")) continue; FileInputStream fis = new FileInputStream(f); - InputStreamReader isr = new InputStreamReader(new BufferedInputStream(fis), "UTF-8"); + InputStreamReader isr = new InputStreamReader(new BufferedInputStream(fis), StandardCharsets.UTF_8); BufferedReader br = new BufferedReader(isr); StringWriter sw = new StringWriter(); boolean changed = false; @@ -71,7 +72,7 @@ public static void main(String[] args) throws IOException, LoggerHook.InvalidThr Closer.close(br); if(!changed) continue; FileOutputStream fos = new FileOutputStream(f); - OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); try { osw.write(sw.toString()); } finally { diff --git a/src/freenet/tools/MergeSFS.java b/src/freenet/tools/MergeSFS.java index 8cad246209e..6c2cb7e064c 100644 --- a/src/freenet/tools/MergeSFS.java +++ b/src/freenet/tools/MergeSFS.java @@ -7,6 +7,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.StandardCharsets; import freenet.support.SimpleFieldSet; @@ -37,7 +38,7 @@ public static void main(String[] args) throws IOException { } else { os = new FileOutputStream(f1); } - Writer w = new BufferedWriter(new OutputStreamWriter(os, "UTF-8")); + Writer w = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8)); fs1.writeToOrdered(w); w.flush(); } diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index e25e5eb50a7..a19a2182865 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -9,8 +9,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.UnsupportedEncodingException; import java.net.URI; +import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -288,13 +288,9 @@ public void testEvilCharset() throws IOException { s += " "; s = s+end; byte[] buf; - try { - buf = s.getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } + buf = s.getBytes(StandardCharsets.UTF_8); byte[] utf16bom = new byte[] { (byte)0xFE, (byte)0xFF }; - byte[] bufUTF16 = alt.getBytes("UTF-16"); + byte[] bufUTF16 = alt.getBytes(StandardCharsets.UTF_16); byte[] total = new byte[buf.length+utf16bom.length+bufUTF16.length]; System.arraycopy(utf16bom, 0, total, 0, utf16bom.length); System.arraycopy(buf, 0, total, utf16bom.length, buf.length); @@ -357,7 +353,7 @@ public static String HTMLFilter(String data, boolean alt) throws Exception { String returnValue; String typeName = "text/html"; URI baseURI = new URI(alt ? ALT_BASE_URI : BASE_URI); - byte[] dataToFilter = data.getBytes("UTF-8"); + byte[] dataToFilter = data.getBytes(StandardCharsets.UTF_8); ArrayBucket input = new ArrayBucket(dataToFilter); ArrayBucket output = new ArrayBucket(); InputStream inputStream = input.getInputStream(); diff --git a/test/freenet/crypt/CryptUtilTest.java b/test/freenet/crypt/CryptUtilTest.java index 8b414682a71..e827233893d 100644 --- a/test/freenet/crypt/CryptUtilTest.java +++ b/test/freenet/crypt/CryptUtilTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.*; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.security.SecureRandom; import java.security.NoSuchAlgorithmException; @@ -49,7 +50,7 @@ public void testSecureRandomBytes() } // SHA1PRNG have repeatable output when seeded try { - byte[] seed = "foobar barfoo feedbeef barfeed".getBytes("UTF-8"); + byte[] seed = "foobar barfoo feedbeef barfeed".getBytes(StandardCharsets.UTF_8); r1.setSeed(seed); r2.setSeed(seed); } catch(Throwable e) { diff --git a/test/freenet/crypt/ECDHTest.java b/test/freenet/crypt/ECDHTest.java index a1c970c644f..af0e95728f2 100644 --- a/test/freenet/crypt/ECDHTest.java +++ b/test/freenet/crypt/ECDHTest.java @@ -2,7 +2,6 @@ import static org.junit.Assert.*; -import java.io.UnsupportedEncodingException; import java.math.BigInteger; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; @@ -73,8 +72,4 @@ public static void main(String[] args) throws InvalidKeyException, IllegalStateE public static String toHex(byte[] arg) { return String.format("%040x", new BigInteger(1,arg)); } - - public static String toHex(String arg) throws UnsupportedEncodingException { - return toHex(arg.getBytes("utf-8")); - } } diff --git a/test/freenet/crypt/ECDSATest.java b/test/freenet/crypt/ECDSATest.java index 61b6d80784b..e2adf5fc5dc 100644 --- a/test/freenet/crypt/ECDSATest.java +++ b/test/freenet/crypt/ECDSATest.java @@ -2,8 +2,8 @@ import static org.junit.Assert.*; -import java.io.UnsupportedEncodingException; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.security.PublicKey; import org.junit.Before; @@ -83,7 +83,7 @@ public static void main(String[] args) throws Exception { Curves curve = ECDSA.Curves.P256; ECDSA ecdsa = new ECDSA(curve); String toSign = "test"; - byte[] signedBytes = toSign.getBytes("utf-8"); + byte[] signedBytes = toSign.getBytes(StandardCharsets.UTF_8); //byte[] sig = ecdsa.sign(signedBytes); byte[] sig = ecdsa.signToNetworkFormat(signedBytes); System.out.println("Curve in use : " + curve.toString()); @@ -111,9 +111,5 @@ public static void main(String[] args) throws Exception { public static String toHex(byte[] arg) { return String.format("%040x", new BigInteger(1,arg)); } - - public static String toHex(String arg) throws UnsupportedEncodingException { - return toHex(arg.getBytes("utf-8")); - } } diff --git a/test/freenet/crypt/EncryptedRandomAccessBufferTest.java b/test/freenet/crypt/EncryptedRandomAccessBufferTest.java index 0b1fdbb4ae1..8e6aca5c14e 100644 --- a/test/freenet/crypt/EncryptedRandomAccessBufferTest.java +++ b/test/freenet/crypt/EncryptedRandomAccessBufferTest.java @@ -13,8 +13,8 @@ import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.Security; import java.util.Random; @@ -37,14 +37,7 @@ public class EncryptedRandomAccessBufferTest { private final static EncryptedRandomAccessBufferType[] types = EncryptedRandomAccessBufferType.values(); - private final static byte[] message; - static { - try { - message = "message".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } + private final static byte[] message = "message".getBytes(StandardCharsets.UTF_8); private final static MasterSecret secret = new MasterSecret(); private final static long falseMagic = 0x2c158a6c8882ffd3L; diff --git a/test/freenet/crypt/HMAC_legacy.java b/test/freenet/crypt/HMAC_legacy.java index 8eb055c52a2..81280ee4bcf 100644 --- a/test/freenet/crypt/HMAC_legacy.java +++ b/test/freenet/crypt/HMAC_legacy.java @@ -3,7 +3,7 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.crypt; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -80,8 +80,8 @@ public byte[] mac(byte[] K, byte[] text, int macbytes) { } } - public static void main(String[] args) throws UnsupportedEncodingException { - HMAC_legacy s = null; + public static void main(String[] args) { + HMAC_legacy s; try { s = new HMAC_legacy(MessageDigest.getInstance("SHA1")); } catch(NoSuchAlgorithmException e) { @@ -90,7 +90,7 @@ public static void main(String[] args) throws UnsupportedEncodingException { byte[] key = new byte[20]; System.err.println("20x0b, 'Hi There':"); byte[] text; - text = "Hi There".getBytes("UTF-8"); + text = "Hi There".getBytes(StandardCharsets.UTF_8); for(int i = 0; i < key.length; i++) key[i] = (byte) 0x0b; @@ -120,7 +120,7 @@ public static void main(String[] args) throws UnsupportedEncodingException { System.err.println("20x0c, 'Test With Truncation':"); for(int i = 0; i < key.length; i++) key[i] = (byte) 0x0c; - text = "Test With Truncation".getBytes("UTF-8"); + text = "Test With Truncation".getBytes(StandardCharsets.UTF_8); mv = s.mac(key, text, 20); System.out.println(HexUtil.bytesToHex(mv, 0, mv.length)); mv = s.mac(key, text, 12); diff --git a/test/freenet/crypt/HashTest.java b/test/freenet/crypt/HashTest.java index 58123c648a2..2fae06d56a1 100644 --- a/test/freenet/crypt/HashTest.java +++ b/test/freenet/crypt/HashTest.java @@ -7,6 +7,7 @@ import java.nio.ByteBuffer; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import net.i2p.util.NativeBigInteger; @@ -17,8 +18,8 @@ import junit.framework.TestCase; public class HashTest { - static private byte[] helloWorld = "hello world".getBytes(Charset.forName("UTF-8")); - static private byte[] nullArray = null; + static private final byte[] helloWorld = "hello world".getBytes(StandardCharsets.UTF_8); + static private final byte[] nullArray = null; static private final HashType[] types = {HashType.MD5, HashType.ED2K, HashType.SHA1, HashType.TTH, HashType.SHA256, HashType.SHA384, HashType.SHA512}; static private final String[] trueHashes = { diff --git a/test/freenet/crypt/MessageAuthCodeTest.java b/test/freenet/crypt/MessageAuthCodeTest.java index 14cefab0f13..ddb68affe74 100755 --- a/test/freenet/crypt/MessageAuthCodeTest.java +++ b/test/freenet/crypt/MessageAuthCodeTest.java @@ -7,8 +7,8 @@ import org.bouncycastle.util.encoders.Hex; import org.junit.Test; -import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.Security; @@ -30,17 +30,8 @@ public class MessageAuthCodeTest{ Hex.decode("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"), Hex.decode("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"), Hex.decode("e285000e6080a701a410040f4814470b568d149b821f99d41319e6410094a760")}; - static private final byte[] hmacMessage; - static{ - byte[] temp = null; - try { - temp = "Hi There".getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - hmacMessage = temp; - } - static private byte[][] messages = { hmacMessage, hmacMessage, hmacMessage, + static private final byte[] hmacMessage = "Hi There".getBytes(StandardCharsets.UTF_8); + static private final byte[][] messages = { hmacMessage, hmacMessage, hmacMessage, Hex.decode("66f75c0e0c7a406586")}; static private final IvParameterSpec[] IVs = { null, null, null, new IvParameterSpec(Hex.decode("166450152e2394835606a9d1dd2cdc8b"))}; diff --git a/test/freenet/crypt/ciphers/RijndaelTest.java b/test/freenet/crypt/ciphers/RijndaelTest.java index 99e9af1889c..5a9f3965203 100644 --- a/test/freenet/crypt/ciphers/RijndaelTest.java +++ b/test/freenet/crypt/ciphers/RijndaelTest.java @@ -9,6 +9,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.util.Arrays; @@ -1941,7 +1942,7 @@ private void checkGladmanTestVectors(String type) throws UnsupportedCipherExcept InputStream is = null; try { is = getClass().getResourceAsStream("/freenet/crypt/ciphers/rijndael-gladman-test-data/ecbn"+type+testNumber+".txt"); - InputStreamReader isr = new InputStreamReader(is, "ISO-8859-1"); + InputStreamReader isr = new InputStreamReader(is, StandardCharsets.ISO_8859_1); BufferedReader br = new BufferedReader(isr); for(int i=0;i<7;i++) br.readLine(); // Skip header String line = br.readLine(); diff --git a/test/freenet/keys/ClientCHKBlockTest.java b/test/freenet/keys/ClientCHKBlockTest.java index e35881b50bc..e66957ee91f 100644 --- a/test/freenet/keys/ClientCHKBlockTest.java +++ b/test/freenet/keys/ClientCHKBlockTest.java @@ -2,13 +2,11 @@ import static org.junit.Assert.*; -import java.io.IOException; -import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import org.junit.Test; -import freenet.support.compress.InvalidCompressionCodecException; import freenet.support.io.ArrayBucket; import freenet.support.io.ArrayBucketFactory; import freenet.support.math.MersenneTwister; @@ -16,14 +14,14 @@ public class ClientCHKBlockTest { @Test - public void testEncodeDecodeEmptyBlock() throws CHKEncodeException, CHKVerifyException, CHKDecodeException, UnsupportedEncodingException, InvalidCompressionCodecException, IOException { + public void testEncodeDecodeEmptyBlock() throws Exception { byte[] buf = new byte[0]; checkBlock(buf, false); checkBlock(buf, true); } @Test - public void testEncodeDecodeFullBlock() throws CHKEncodeException, CHKVerifyException, CHKDecodeException, UnsupportedEncodingException, InvalidCompressionCodecException, IOException { + public void testEncodeDecodeFullBlock() throws Exception { byte[] fullBlock = new byte[CHKBlock.DATA_LENGTH]; MersenneTwister random = new MersenneTwister(42); for(int i=0;i<10;i++) { @@ -34,16 +32,16 @@ public void testEncodeDecodeFullBlock() throws CHKEncodeException, CHKVerifyExce } @Test - public void testEncodeDecodeShortInteger() throws CHKEncodeException, CHKVerifyException, CHKDecodeException, UnsupportedEncodingException, InvalidCompressionCodecException, IOException { + public void testEncodeDecodeShortInteger() throws Exception { for(int i=0;i<100;i++) { String s = Integer.toString(i); - checkBlock(s.getBytes("UTF-8"), false); - checkBlock(s.getBytes("UTF-8"), true); + checkBlock(s.getBytes(StandardCharsets.UTF_8), false); + checkBlock(s.getBytes(StandardCharsets.UTF_8), true); } } @Test - public void testEncodeDecodeRandomLength() throws CHKEncodeException, CHKVerifyException, CHKDecodeException, UnsupportedEncodingException, InvalidCompressionCodecException, IOException { + public void testEncodeDecodeRandomLength() throws Exception { MersenneTwister random = new MersenneTwister(42); for(int i=0;i<10;i++) { byte[] buf = new byte[random.nextInt(CHKBlock.DATA_LENGTH+1)]; @@ -54,7 +52,7 @@ public void testEncodeDecodeRandomLength() throws CHKEncodeException, CHKVerifyE } @Test - public void testEncodeDecodeNearlyFullBlock() throws CHKEncodeException, CHKVerifyException, CHKDecodeException, UnsupportedEncodingException, InvalidCompressionCodecException, IOException { + public void testEncodeDecodeNearlyFullBlock() throws Exception { MersenneTwister random = new MersenneTwister(68); for(int i=0;i<10;i++) { byte[] buf = new byte[CHKBlock.DATA_LENGTH - i]; @@ -70,7 +68,7 @@ public void testEncodeDecodeNearlyFullBlock() throws CHKEncodeException, CHKVeri } } - private void checkBlock(byte[] data, boolean newAlgo) throws CHKEncodeException, InvalidCompressionCodecException, CHKVerifyException, CHKDecodeException, IOException { + private void checkBlock(byte[] data, boolean newAlgo) throws Exception { byte cryptoAlgorithm = newAlgo ? Key.ALGO_AES_CTR_256_SHA256 : Key.ALGO_AES_PCFB_256_SHA256; byte[] copyOfData = new byte[data.length]; System.arraycopy(data, 0, copyOfData, 0, data.length); diff --git a/test/freenet/node/MasterKeysTest.java b/test/freenet/node/MasterKeysTest.java index 2e5f6d192a4..c35dcf3fe70 100644 --- a/test/freenet/node/MasterKeysTest.java +++ b/test/freenet/node/MasterKeysTest.java @@ -44,11 +44,11 @@ private void testRestart(String password) throws MasterKeysWrongPasswordExceptio DummyRandomSource random = new DummyRandomSource(77391); MasterKeys original = MasterKeys.read(keysFile, random, password); byte[] clientCacheMasterKey = original.clientCacheMasterKey; - DatabaseKey dkey = original.createDatabaseKey(random); + DatabaseKey dkey = original.createDatabaseKey(); MasterSecret tempfileMasterSecret = original.getPersistentMasterSecret(); MasterKeys restored = MasterKeys.read(keysFile, random, password); assertArrayEquals(clientCacheMasterKey, restored.clientCacheMasterKey); - assertEquals(dkey,restored.createDatabaseKey(random)); + assertEquals(dkey,restored.createDatabaseKey()); assertEquals(tempfileMasterSecret, restored.getPersistentMasterSecret()); } @@ -77,7 +77,7 @@ private void testChangePassword(String oldPassword, String newPassword) throws M DummyRandomSource random = new DummyRandomSource(77391); MasterKeys original = MasterKeys.read(keysFile, random, oldPassword); byte[] clientCacheMasterKey = original.clientCacheMasterKey; - DatabaseKey dkey = original.createDatabaseKey(random); + DatabaseKey dkey = original.createDatabaseKey(); MasterSecret tempfileMasterSecret = original.getPersistentMasterSecret(); // Change password. original.changePassword(keysFile, newPassword, random); @@ -92,7 +92,7 @@ private void testChangePassword(String oldPassword, String newPassword) throws M } MasterKeys restored = MasterKeys.read(keysFile, random, newPassword); assertArrayEquals(clientCacheMasterKey, restored.clientCacheMasterKey); - assertEquals(dkey,restored.createDatabaseKey(random)); + assertEquals(dkey,restored.createDatabaseKey()); assertEquals(tempfileMasterSecret, restored.getPersistentMasterSecret()); } diff --git a/test/freenet/store/RAMSaltMigrationTest.java b/test/freenet/store/RAMSaltMigrationTest.java index 546b1e9b1a8..e463c0e31f2 100644 --- a/test/freenet/store/RAMSaltMigrationTest.java +++ b/test/freenet/store/RAMSaltMigrationTest.java @@ -6,6 +6,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -628,11 +629,11 @@ private String decodeBlock(CHKBlock verify, ClientCHK key) ClientCHKBlock cb = new ClientCHKBlock(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientCHKBlock encodeBlock(String test, boolean newFormat) throws CHKEncodeException, IOException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); return ClientCHKBlock.encode(bucket, false, false, (short) -1, bucket.size(), Compressor.DEFAULT_COMPRESSORDESCRIPTOR, null, diff --git a/test/freenet/store/SlashdotStoreTest.java b/test/freenet/store/SlashdotStoreTest.java index cbf48c4524c..2daf9a27e14 100644 --- a/test/freenet/store/SlashdotStoreTest.java +++ b/test/freenet/store/SlashdotStoreTest.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Random; import org.junit.After; @@ -97,11 +98,11 @@ private String decodeBlock(CHKBlock verify, ClientCHK key) throws CHKVerifyExcep ClientCHKBlock cb = new ClientCHKBlock(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientCHKBlock encodeBlock(String test) throws CHKEncodeException, IOException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); return ClientCHKBlock.encode(bucket, false, false, (short)-1, bucket.size(), Compressor.DEFAULT_COMPRESSORDESCRIPTOR, null, (byte)0); diff --git a/test/freenet/store/caching/CachingFreenetStoreTest.java b/test/freenet/store/caching/CachingFreenetStoreTest.java index e96db85fe56..9ff75c5d1e7 100644 --- a/test/freenet/store/caching/CachingFreenetStoreTest.java +++ b/test/freenet/store/caching/CachingFreenetStoreTest.java @@ -8,6 +8,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -298,7 +299,7 @@ public void testCollisionsOverMaximumSize() // Write one key to the store. String test = "test"; - SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block = ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock = (SSKBlock) block.getBlock(); @@ -314,7 +315,7 @@ public void testCollisionsOverMaximumSize() // Write a colliding key. test = "test1"; - bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); block = ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); sskBlock = (SSKBlock) block.getBlock(); @@ -397,7 +398,7 @@ public void testSimpleManualWrite() // Write one key to the store. String test = "test"; - SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block = ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock = (SSKBlock) block.getBlock(); @@ -465,7 +466,7 @@ public void testManualWriteCollision() throws IOException, SSKEncodeException, I // Write one key to the cache. It will not be written through to disk. String test = "test"; - SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block = ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock = (SSKBlock) block.getBlock(); @@ -495,7 +496,7 @@ public Long call() throws Exception { // the block, and // thus must return 0. test = "test1"; - bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); block = ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock2 = (SSKBlock) block.getBlock(); @@ -696,11 +697,11 @@ private String decodeBlockCHK(CHKBlock verify, ClientCHK key) ClientCHKBlock cb = new ClientCHKBlock(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientCHKBlock encodeBlockCHK(String test) throws CHKEncodeException, IOException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); return ClientCHKBlock.encode(bucket, false, false, (short) -1, bucket.size(), Compressor.DEFAULT_COMPRESSORDESCRIPTOR, null, (byte) 0); @@ -889,7 +890,7 @@ private void checkOnCollisionsSSK(boolean useSlotFilter) throws IOException, SSK Key.ALGO_AES_PCFB_256_SHA256); String test = "test"; - SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block = ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock = (SSKBlock) block.getBlock(); @@ -904,7 +905,7 @@ private void checkOnCollisionsSSK(boolean useSlotFilter) throws IOException, SSK } String test1 = "test1"; - SimpleReadOnlyArrayBucket bucket1 = new SimpleReadOnlyArrayBucket(test1.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket1 = new SimpleReadOnlyArrayBucket(test1.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block1 = ik.encode(bucket1, false, false, (short) -1, bucket1.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock1 = (SSKBlock) block1.getBlock(); @@ -952,12 +953,12 @@ private String decodeBlockSSK(SSKBlock verify, ClientSSK key) ClientSSKBlock cb = ClientSSKBlock.construct(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientSSKBlock encodeBlockSSK(String test, RandomSource random) throws IOException, SSKEncodeException, InvalidCompressionCodecException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); InsertableClientSSK ik = InsertableClientSSK.createRandom(random, test); return ik.encode(bucket, false, false, (short) -1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); diff --git a/test/freenet/store/saltedhash/SaltedHashFreenetStoreTest.java b/test/freenet/store/saltedhash/SaltedHashFreenetStoreTest.java index 59f19da9358..c3c2cb9d7a3 100644 --- a/test/freenet/store/saltedhash/SaltedHashFreenetStoreTest.java +++ b/test/freenet/store/saltedhash/SaltedHashFreenetStoreTest.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Random; import org.junit.After; @@ -136,11 +137,11 @@ private String decodeBlockCHK(CHKBlock verify, ClientCHK key) throws CHKVerifyEx ClientCHKBlock cb = new ClientCHKBlock(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientCHKBlock encodeBlockCHK(String test) throws CHKEncodeException, IOException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); return ClientCHKBlock.encode(bucket, false, false, (short)-1, bucket.size(), Compressor.DEFAULT_COMPRESSORDESCRIPTOR, null, (byte)0); @@ -179,7 +180,7 @@ private void checkOnCollisionsSSK(boolean useSlotFilter) throws IOException, SSK InsertableClientSSK ik = new InsertableClientSSK(docName, pkHash, pubKey, privKey, ckey, Key.ALGO_AES_PCFB_256_SHA256); String test = "test"; - SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block = ik.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock = (SSKBlock) block.getBlock(); store.put(sskBlock, false, false); @@ -194,7 +195,7 @@ private void checkOnCollisionsSSK(boolean useSlotFilter) throws IOException, SSK } String test1 = "test1"; - SimpleReadOnlyArrayBucket bucket1 = new SimpleReadOnlyArrayBucket(test1.getBytes("UTF-8")); + SimpleReadOnlyArrayBucket bucket1 = new SimpleReadOnlyArrayBucket(test1.getBytes(StandardCharsets.UTF_8)); ClientSSKBlock block1 = ik.encode(bucket1, false, false, (short)-1, bucket1.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); SSKBlock sskBlock1 = (SSKBlock) block1.getBlock(); @@ -230,11 +231,11 @@ private String decodeBlockSSK(SSKBlock verify, ClientSSK key) throws SSKVerifyEx ClientSSKBlock cb = ClientSSKBlock.construct(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientSSKBlock encodeBlockSSK(String test, RandomSource random) throws IOException, SSKEncodeException, InvalidCompressionCodecException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); InsertableClientSSK ik = InsertableClientSSK.createRandom(random, test); return ik.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR); diff --git a/test/freenet/store/saltedhash/SaltedHashSlotFilterTest.java b/test/freenet/store/saltedhash/SaltedHashSlotFilterTest.java index 0497eec8f5b..cbc65774efe 100644 --- a/test/freenet/store/saltedhash/SaltedHashSlotFilterTest.java +++ b/test/freenet/store/saltedhash/SaltedHashSlotFilterTest.java @@ -5,6 +5,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Random; import org.junit.AfterClass; @@ -285,11 +286,11 @@ private String decodeBlockCHK(CHKBlock verify, ClientCHK key) ClientCHKBlock cb = new ClientCHKBlock(verify, key); Bucket output = cb.decode(new ArrayBucketFactory(), 32768, false); byte[] buf = BucketTools.toByteArray(output); - return new String(buf, "UTF-8"); + return new String(buf, StandardCharsets.UTF_8); } private ClientCHKBlock encodeBlockCHK(String test) throws CHKEncodeException, IOException { - byte[] data = test.getBytes("UTF-8"); + byte[] data = test.getBytes(StandardCharsets.UTF_8); SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(data); return ClientCHKBlock.encode(bucket, false, false, (short) -1, bucket.size(), Compressor.DEFAULT_COMPRESSORDESCRIPTOR, null, (byte) 0); diff --git a/test/freenet/support/Base64Test.java b/test/freenet/support/Base64Test.java index d153866e4bc..2fb4c023c43 100644 --- a/test/freenet/support/Base64Test.java +++ b/test/freenet/support/Base64Test.java @@ -18,6 +18,7 @@ import static org.junit.Assert.*; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Random; @@ -51,8 +52,8 @@ public class Base64Test { * to verify if it encode works correctly. */ @Test - public void testEncode() throws Exception { - byte[] aByteArrayToEncode = toEncode.getBytes("UTF-8"); + public void testEncode() { + byte[] aByteArrayToEncode = toEncode.getBytes(StandardCharsets.UTF_8); assertEquals(Base64.encode(aByteArrayToEncode), toDecode); } @@ -73,8 +74,8 @@ public void testDecode() throws Exception { * This is the same as encode() from generator/js/src/freenet/client/tools/Base64.java */ @Test - public void testEncodeStandard() throws Exception { - byte[] aByteArrayToEncode = testSample.getBytes("UTF-8"); + public void testEncodeStandard() { + byte[] aByteArrayToEncode = testSample.getBytes(StandardCharsets.UTF_8); assertEquals(Base64.encodeStandard(aByteArrayToEncode), testSampleStandardEncoding); } @@ -84,7 +85,7 @@ public void testEncodeStandard() throws Exception { */ @Test public void testDecodeStandard() throws Exception { - String decodedString = new String(Base64.decodeStandard(testSampleStandardEncoding), "UTF-8"); + String decodedString = new String(Base64.decodeStandard(testSampleStandardEncoding), StandardCharsets.UTF_8); assertEquals(decodedString, testSample); } diff --git a/test/freenet/support/URLEncoderDecoderTest.java b/test/freenet/support/URLEncoderDecoderTest.java index 243299ced40..4cd29bca405 100644 --- a/test/freenet/support/URLEncoderDecoderTest.java +++ b/test/freenet/support/URLEncoderDecoderTest.java @@ -17,9 +17,9 @@ import static org.junit.Assert.*; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; import org.junit.Test; @@ -125,21 +125,15 @@ private boolean areCorrectlyEncodedDecoded(String[] toEncode, boolean withLetter */ @Test public void testEncodeForced() { - String toEncode,expectedResult; - char eachChar; - for(int i=0; i Date: Mon, 1 May 2023 11:41:01 +0100 Subject: [PATCH 058/500] Changed pronoun --- src/freenet/l10n/freenet.l10n.en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index e4c8dbc7aa4..d6fd30c3601 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -412,7 +412,7 @@ DarknetConnectionsToadlet.peerTrust.LOW=LOW DarknetConnectionsToadlet.peerTrust.NORMAL=NORMAL DarknetConnectionsToadlet.peerTrust.HIGH=HIGH DarknetConnectionsToadlet.peerVisibilityTitle=Do you want your other friends to be able to see and connect to this friend? -DarknetConnectionsToadlet.peerVisibilityIntroduction=If you let your friends see this friend, and this friend see your friends, it will improve performance significantly. However you might not want your other friends to know about this one (but bear in mind that anyone who can see your internet connection might be able to link you). (S)he can also disable being seen by your friends. +DarknetConnectionsToadlet.peerVisibilityIntroduction=If you let your friends see this friend, and this friend see your friends, it will improve performance significantly. However you might not want your other friends to know about this one (but bear in mind that anyone who can see your internet connection might be able to link you). They can also disable being seen by your friends. DarknetConnectionsToadlet.peerVisibility.NO=NO DarknetConnectionsToadlet.peerVisibility.YES=YES DarknetConnectionsToadlet.peerVisibility.NAME_ONLY=NAME ONLY From 568562d6e011db3c5f722cd7f9521243cbb30297 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 23 May 2023 07:54:00 +0200 Subject: [PATCH 059/500] Sort peer-addresses to try by hostname -> ipv6 -> ipv4 --- src/freenet/io/comm/FreenetInetAddress.java | 6 ++++- src/freenet/io/comm/Peer.java | 30 ++++++++++++++++++++- src/freenet/node/PeerNode.java | 5 ++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/freenet/io/comm/FreenetInetAddress.java b/src/freenet/io/comm/FreenetInetAddress.java index 9cfe2773920..1e77a6907af 100644 --- a/src/freenet/io/comm/FreenetInetAddress.java +++ b/src/freenet/io/comm/FreenetInetAddress.java @@ -442,8 +442,12 @@ public FreenetInetAddress dropHostname() { } else return this; } + public boolean hasHostname() { + return hostname != null && hostname.length() > 0; + } + public boolean hasHostnameNoIP() { - return hostname != null && hostname.length() > 0 && _address == null; + return hasHostname() && _address == null; } public boolean isIPv6(boolean defaultValue) { diff --git a/src/freenet/io/comm/Peer.java b/src/freenet/io/comm/Peer.java index 16942bc10cc..31676ff64d5 100644 --- a/src/freenet/io/comm/Peer.java +++ b/src/freenet/io/comm/Peer.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Comparator; import freenet.io.WritableToDataOutputStream; import freenet.support.transport.ip.HostnameSyntaxException; @@ -41,6 +42,8 @@ public static class LocalAddressException extends Exception { private static final long serialVersionUID = -1; } + public static final PeerComparator PEER_COMPARATOR = new PeerComparator(); + public static final String VERSION = "$Id: Peer.java,v 1.4 2005/08/25 17:28:19 amphibian Exp $"; private final FreenetInetAddress addr; @@ -279,4 +282,29 @@ public boolean isIPv6(boolean defaultValue) { if(addr == null) return defaultValue; return addr.isIPv6(defaultValue); } -} \ No newline at end of file + + public static class PeerComparator implements Comparator { + @Override + public int compare(Peer p0, Peer p1) { + boolean hasHostnameP0 = p0.getFreenetAddress().hasHostname(); + boolean hasHostnameP1 = p1.getFreenetAddress().hasHostname(); + boolean isIpv6P0 = p0.isIPv6(false); // default for "no address yet" + boolean isIpv6P1 = p1.isIPv6(false); // default for "no address yet" + if (hasHostnameP0 && !hasHostnameP1) { + return -1; + } else if (!hasHostnameP0 && hasHostnameP1) { + return 1; + } else if (hasHostnameP0) { + return 0; + } + if (isIpv6P0 && !isIpv6P1) { + return -1; + } else if (!isIpv6P0 && isIpv6P1) { + return 1; + } else if (isIpv6P0) { + return 0; + } + return 0; + } + } +} diff --git a/src/freenet/node/PeerNode.java b/src/freenet/node/PeerNode.java index b6b828c58e9..4e473083329 100644 --- a/src/freenet/node/PeerNode.java +++ b/src/freenet/node/PeerNode.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.EnumMap; import java.util.GregorianCalendar; import java.util.HashSet; @@ -601,6 +602,9 @@ public PeerNode(SimpleFieldSet fs, Node node2, NodeCrypto crypto, boolean fromLo Logger.normal(this, "No IP addresses found for identity '" + identityAsBase64String + "', possibly at location '" + location + ": " + userToString()); detectedPeer = null; } else { + nominalPeer.sort(Peer.PEER_COMPARATOR); + // TODO this throws away all valid addresses but the first, without checking whether they can connect. Need to try a later one if connection fails. + // sort hostName first. detectedPeer = nominalPeer.get(0); } updateShortToString(); @@ -806,6 +810,7 @@ private String handshakeIPsToString() { synchronized(this) { localHandshakeIPs = handshakeIPs; } + Arrays.sort(localHandshakeIPs, Peer.PEER_COMPARATOR); if(localHandshakeIPs == null) return "null"; StringBuilder toOutputString = new StringBuilder(1024); From b491ba2473c2fdffaf7ed3f3ce14952af8a8324f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 23 May 2023 07:54:51 +0200 Subject: [PATCH 060/500] Use Collections.addAll instead of manual set adding --- src/freenet/node/PeerNode.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/freenet/node/PeerNode.java b/src/freenet/node/PeerNode.java index 4e473083329..7cd50e11fa4 100644 --- a/src/freenet/node/PeerNode.java +++ b/src/freenet/node/PeerNode.java @@ -858,9 +858,8 @@ private Peer[] updateHandshakeIPs(Peer[] localHandshakeIPs, boolean ignoreHostna } // De-dupe HashSet ret = new HashSet(); - for(Peer localHandshakeIP: localHandshakeIPs) - ret.add(localHandshakeIP); - return ret.toArray(new Peer[ret.size()]); + Collections.addAll(ret, localHandshakeIPs); + return ret.toArray(new Peer[0]); } /** From cceccbe7819fd93c79d37f7e59d59e216eb0c529 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 23 May 2023 07:59:12 +0200 Subject: [PATCH 061/500] Prefer IPv6 over IPv4 for handshake address --- src/freenet/io/comm/FreenetInetAddress.java | 16 +++++---- .../io/InetAddressIpv6FirstComparator.java | 34 +++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 src/freenet/support/io/InetAddressIpv6FirstComparator.java diff --git a/src/freenet/io/comm/FreenetInetAddress.java b/src/freenet/io/comm/FreenetInetAddress.java index 1e77a6907af..6f5b7fbf92e 100644 --- a/src/freenet/io/comm/FreenetInetAddress.java +++ b/src/freenet/io/comm/FreenetInetAddress.java @@ -9,11 +9,13 @@ import java.net.Inet6Address; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.Arrays; import freenet.io.AddressIdentifier; import freenet.support.LogThresholdCallback; import freenet.support.Logger; import freenet.support.Logger.LogLevel; +import freenet.support.io.InetAddressIpv6FirstComparator; import freenet.support.transport.ip.HostnameSyntaxException; import freenet.support.transport.ip.HostnameUtil; import freenet.support.transport.ip.IPUtil; @@ -337,19 +339,21 @@ public InetAddress getHandshakeAddress() { * DNS lookup with every packet we send. */ try { - InetAddress addr = InetAddress.getByName(hostname); - if(logMINOR) Logger.minor(this, "Look up got '"+addr+ '\''); - if( addr != null ) { - /* + InetAddress[] addresses = InetAddress.getAllByName(hostname); + if(logMINOR) Logger.minor(this, "Look up got '"+addresses+ '\''); + if( addresses.length != 0 ) { + /* sort by IPv6 first */ + Arrays.sort(addresses, InetAddressIpv6FirstComparator.COMPARATOR); + /* * cache the answer since getHandshakeAddress() * doesn't use the cached value, thus * getHandshakeIPs() should always get the * latest value from DNS (minus Java's caching) */ - this._address = InetAddress.getByAddress(addr.getAddress()); + this._address = InetAddress.getByAddress(addresses[0].getAddress()); if(logMINOR) Logger.minor(this, "Setting address to "+_address); } - return addr; + return addresses[0]; } catch (UnknownHostException e) { if(logMINOR) Logger.minor(this, "DNS said hostname '"+hostname+"' is an unknown host, returning null"); return null; diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java new file mode 100644 index 00000000000..3bfd9bc3c23 --- /dev/null +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -0,0 +1,34 @@ +package freenet.support.io; + +import java.net.InetAddress; +import java.util.Comparator; + +import freenet.support.Fields; + +/** Comparator for IP addresses that sorts IPv6 before IPv4 to enable + * selecting the first. + * @author toad */ +public class InetAddressIpv6FirstComparator implements Comparator { + + public final static InetAddressIpv6FirstComparator COMPARATOR = + new InetAddressIpv6FirstComparator(); + + @Override + public int compare(InetAddress arg0, InetAddress arg1) { + if(arg0 == arg1) return 0; + byte[] bytes0 = arg0.getAddress(); + byte[] bytes1 = arg1.getAddress(); + if(bytes0.length > bytes1.length) + return -1; // IPv6 < IPv4. => prefer IPv6 over IPv4 + if(bytes1.length > bytes0.length) + return 1; // IPv4 < IPv6. + int a = arg0.hashCode(); + int b = arg1.hashCode(); + // By hash code first. Works really fast for IPv4. + if(a > b) return 1; + else if(b > a) return -1; + return Fields.compareBytes(bytes0, bytes1); + // Hostnames in InetAddress are merely cached, equals() only operates on the byte[]. + } + +} From 045a1bfc2f448b953972757f10db5e354e2d7669 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 23 May 2023 07:59:52 +0200 Subject: [PATCH 062/500] avoid possible Null Pointer Exception --- src/freenet/io/comm/FreenetInetAddress.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/freenet/io/comm/FreenetInetAddress.java b/src/freenet/io/comm/FreenetInetAddress.java index 6f5b7fbf92e..3bd2b9c1bcc 100644 --- a/src/freenet/io/comm/FreenetInetAddress.java +++ b/src/freenet/io/comm/FreenetInetAddress.java @@ -281,7 +281,10 @@ public boolean strictEquals(FreenetInetAddress addr) { } // No hostname, go by address. - if(!getHostName(_address).equalsIgnoreCase(getHostName(addr._address))) { + String reverseHostNameISee = getHostName(_address); + String reverseHostNameTheySee = getHostName(addr._address); + if(reverseHostNameISee == null + || !reverseHostNameISee.equalsIgnoreCase(reverseHostNameTheySee)) { //Logger.minor(this, "Addresses do not match: mine="+getHostName(_address)+" his="+getHostName(addr._address)); return false; } From dcd4f9e33d81b76c693e917c3081ccecc703fae6 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 23 May 2023 08:00:05 +0200 Subject: [PATCH 063/500] Prefer IPv6 over IPv4 in the InetAddressComparator --- src/freenet/support/io/InetAddressComparator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freenet/support/io/InetAddressComparator.java b/src/freenet/support/io/InetAddressComparator.java index 74f2c647326..9f745f280bd 100644 --- a/src/freenet/support/io/InetAddressComparator.java +++ b/src/freenet/support/io/InetAddressComparator.java @@ -27,9 +27,9 @@ public int compare(InetAddress arg0, InetAddress arg1) { byte[] bytes1 = arg1.getAddress(); // Fields.compareBytes doesn't go first by length, so check it here. if(bytes0.length > bytes1.length) - return 1; // IPv6 > IPv4. + return -1; // IPv6 < IPv4. => prefer IPv6 over IPv4 if(bytes1.length > bytes0.length) - return -1; // IPv4 > IPv6. + return 1; // IPv4 < IPv6. return Fields.compareBytes(bytes0, bytes1); // Hostnames in InetAddress are merely cached, equals() only operates on the byte[]. } From bdd7e21c4154182faa836c855f388c505b227df7 Mon Sep 17 00:00:00 2001 From: Hiina Date: Fri, 26 May 2023 00:18:36 +0200 Subject: [PATCH 064/500] Change logging for "too many excluded sub-arrays" from normal to minor. --- src/freenet/support/SectoredRandomGrabArray.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/support/SectoredRandomGrabArray.java b/src/freenet/support/SectoredRandomGrabArray.java index d2c7c7bc124..b622a1feec1 100644 --- a/src/freenet/support/SectoredRandomGrabArray.java +++ b/src/freenet/support/SectoredRandomGrabArray.java @@ -173,7 +173,8 @@ private RandomGrabArrayItem removeRandomLimited( Logger.error(this, "Slot "+x+" is null for client "+grabClients[x]); excluded++; if(excluded > MAX_EXCLUDED) { - Logger.normal(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); + if(logMINOR) + Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); return null; } continue; From 597e90b80fb92738e872baae8a87f4a3e3809e1f Mon Sep 17 00:00:00 2001 From: Hiina Date: Fri, 26 May 2023 00:18:36 +0200 Subject: [PATCH 065/500] Change logging for "too many excluded sub-arrays" from normal to minor. --- src/freenet/support/SectoredRandomGrabArray.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/support/SectoredRandomGrabArray.java b/src/freenet/support/SectoredRandomGrabArray.java index d2c7c7bc124..b622a1feec1 100644 --- a/src/freenet/support/SectoredRandomGrabArray.java +++ b/src/freenet/support/SectoredRandomGrabArray.java @@ -173,7 +173,8 @@ private RandomGrabArrayItem removeRandomLimited( Logger.error(this, "Slot "+x+" is null for client "+grabClients[x]); excluded++; if(excluded > MAX_EXCLUDED) { - Logger.normal(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); + if(logMINOR) + Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); return null; } continue; From 9f79f790f0c30f2d488f58a8db1db2b359516b24 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 00:42:12 +0200 Subject: [PATCH 066/500] prefer reachable addresses --- .../io/InetAddressIpv6FirstComparator.java | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index 3bfd9bc3c23..6ee526d66e0 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -1,29 +1,71 @@ package freenet.support.io; +import java.io.IOException; import java.net.InetAddress; import java.util.Comparator; import freenet.support.Fields; +import freenet.support.LRUCache; /** Comparator for IP addresses that sorts IPv6 before IPv4 to enable * selecting the first. * @author toad */ public class InetAddressIpv6FirstComparator implements Comparator { - public final static InetAddressIpv6FirstComparator COMPARATOR = + // need a cache for reachability to avoid doing NlogN issReachable checks in worst case. + public LRUCache reachabilityCache = new LRUCache<>(1000, 10000); + + public static final InetAddressIpv6FirstComparator COMPARATOR = new InetAddressIpv6FirstComparator(); @Override public int compare(InetAddress arg0, InetAddress arg1) { if(arg0 == arg1) return 0; + // prefer everything over loopback + if (!arg0.isLoopbackAddress() && arg1.isLoopbackAddress()) { + return -1; + } else if (arg0.isLoopbackAddress() && !arg1.isLoopbackAddress()) { + return 1; + } + // prefer LAN routable addresses over link-local addresses + if (!arg0.isLinkLocalAddress() && arg1.isLinkLocalAddress()) { + return -1; + } else if (arg0.isLinkLocalAddress() && !arg1.isLinkLocalAddress()) { + return 1; + } byte[] bytes0 = arg0.getAddress(); byte[] bytes1 = arg1.getAddress(); + // prefer IPv6 over IPv4 if(bytes0.length > bytes1.length) - return -1; // IPv6 < IPv4. => prefer IPv6 over IPv4 + return -1; if(bytes1.length > bytes0.length) - return 1; // IPv4 < IPv6. + return 1; + // prefer reachable over unreachable. TODO: This actually pings all advertised ip addresses. Is that OK? int a = arg0.hashCode(); int b = arg1.hashCode(); + Boolean reachable0 = reachabilityCache.get(a); + Boolean reachable1 = reachabilityCache.get(b); + if (reachable0 == null) { + try { + reachable0 = arg0.isReachable(300); + } catch (IOException e) { + reachable0 = false; + } + reachabilityCache.put(a, reachable0); + } + if (reachable1 == null) { + try { + reachable1 = arg1.isReachable(300); + } catch (IOException e) { + reachable1 = false; + } + reachabilityCache.put(b, reachable1); + } + if (reachable0 && !reachable1) { + return -1; + } else if (!reachable0 && reachable1) { + return 1; + } // By hash code first. Works really fast for IPv4. if(a > b) return 1; else if(b > a) return -1; From 2c928cbd260b17a50a42a209607a08e36f95af74 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 00:42:57 +0200 Subject: [PATCH 067/500] compare equal peer-instances by their addresses prefer hostname, then ipv6, then reachable. --- src/freenet/io/comm/Peer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/freenet/io/comm/Peer.java b/src/freenet/io/comm/Peer.java index 31676ff64d5..cc09da4ee42 100644 --- a/src/freenet/io/comm/Peer.java +++ b/src/freenet/io/comm/Peer.java @@ -27,6 +27,7 @@ import java.util.Comparator; import freenet.io.WritableToDataOutputStream; +import freenet.support.io.InetAddressIpv6FirstComparator; import freenet.support.transport.ip.HostnameSyntaxException; import freenet.support.transport.ip.IPUtil; @@ -301,10 +302,9 @@ public int compare(Peer p0, Peer p1) { return -1; } else if (!isIpv6P0 && isIpv6P1) { return 1; - } else if (isIpv6P0) { - return 0; } - return 0; + return InetAddressIpv6FirstComparator.COMPARATOR + .compare(p0.getAddress(), p1.getAddress()); } } } From fd3f52753cbc59368f0f5178fa83269f7a936b22 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 00:44:10 +0200 Subject: [PATCH 068/500] only sort if at least 2 addresses (performance) --- src/freenet/io/comm/FreenetInetAddress.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/io/comm/FreenetInetAddress.java b/src/freenet/io/comm/FreenetInetAddress.java index 3bd2b9c1bcc..011499ace4d 100644 --- a/src/freenet/io/comm/FreenetInetAddress.java +++ b/src/freenet/io/comm/FreenetInetAddress.java @@ -344,7 +344,7 @@ public InetAddress getHandshakeAddress() { try { InetAddress[] addresses = InetAddress.getAllByName(hostname); if(logMINOR) Logger.minor(this, "Look up got '"+addresses+ '\''); - if( addresses.length != 0 ) { + if( addresses.length > 1 ) { /* sort by IPv6 first */ Arrays.sort(addresses, InetAddressIpv6FirstComparator.COMPARATOR); /* From 328dd26509ef90c6b3f1bf84f7e28a4037d1a6b0 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 00:47:48 +0200 Subject: [PATCH 069/500] add two more logMINOR paths --- src/freenet/support/SectoredRandomGrabArray.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/freenet/support/SectoredRandomGrabArray.java b/src/freenet/support/SectoredRandomGrabArray.java index b622a1feec1..662b17b224a 100644 --- a/src/freenet/support/SectoredRandomGrabArray.java +++ b/src/freenet/support/SectoredRandomGrabArray.java @@ -183,7 +183,8 @@ private RandomGrabArrayItem removeRandomLimited( if(excludeTime > 0) { excluded++; if(excluded > MAX_EXCLUDED) { - Logger.normal(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); + if (logMINOR) + Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); return null; } continue; @@ -209,7 +210,8 @@ private RandomGrabArrayItem removeRandomLimited( } else { excluded++; if(excluded > MAX_EXCLUDED) { - Logger.normal(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); + if (logMINOR) + Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); return null; } } From a110ccc7e56057c5cd8587df0cdecd81c84b42e5 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 00:46:20 +0200 Subject: [PATCH 070/500] when using a USK with -1 as version, also find version 0. --- .../client/async/SingleFileFetcher.java | 5 +- src/freenet/client/async/USKFetcher.java | 82 ++++++++++--------- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/src/freenet/client/async/SingleFileFetcher.java b/src/freenet/client/async/SingleFileFetcher.java index 3bea647a5de..feef22929ea 100644 --- a/src/freenet/client/async/SingleFileFetcher.java +++ b/src/freenet/client/async/SingleFileFetcher.java @@ -1274,11 +1274,12 @@ public int hashCode() { @Override public void onFoundEdition(long l, USK newUSK, ClientContext context, boolean metadata, short codec, byte[] data, boolean newKnownGood, boolean newSlotToo) { - if(l < usk.suggestedEdition && datastoreOnly) + if(l < usk.suggestedEdition && datastoreOnly) { l = usk.suggestedEdition; + } ClientSSK key = usk.getSSK(l); try { - if(l == usk.suggestedEdition) { + if(l == usk.suggestedEdition || (l == 0 && usk.suggestedEdition == 1)) { SingleFileFetcher sf = new SingleFileFetcher(parent, cb, null, key, metaStrings, key.getURI().addMetaStrings(metaStrings), 0, ctx, false, realTimeFlag, actx, null, null, maxRetries, recursionLevel+1, dontTellClientGet, token, false, true, false, (short)0, context, false); if(tag != null) { diff --git a/src/freenet/client/async/USKFetcher.java b/src/freenet/client/async/USKFetcher.java index 3c9b48b2066..0a21c7fec81 100644 --- a/src/freenet/client/async/USKFetcher.java +++ b/src/freenet/client/async/USKFetcher.java @@ -1733,8 +1733,14 @@ public synchronized ToFetch getEditionsToFetch(long lookedUp, Random random, Lis for(Iterator> it = fromSubscribers.entrySet().iterator();it.hasNext();) { Entry entry = it.next(); long l = entry.getKey() - 1; - if(l <= lookedUp) + if(l <= lookedUp) { it.remove(); + } + if (l == 0) { + // add check for edition 0: this happens if -1 is suggested. + // Needed because we cannot set -0 for exhaustive search (-0 == 0 in Java). + entry.getValue().getEditionIfNotAlreadyRunning(toFetch, alreadyRunning, l, false); + } entry.getValue().getNextEditions(toFetch, toPoll, l-1, alreadyRunning, random); } @@ -1841,60 +1847,60 @@ public KeyList(long slot) { public synchronized void getNextEditions(List toFetch, List toPoll, long lookedUp, List alreadyRunning, Random random) { if(logMINOR) Logger.minor(this, "Getting next editions from "+lookedUp); if(lookedUp < 0) lookedUp = 0; + boolean poll = backgroundPoll; for(int i=1;i<=origMinFailures;i++) { long ed = i + lookedUp; - Lookup l = new Lookup(); - l.val = ed; - boolean poll = backgroundPoll; - if(((!poll) && toFetch.contains(l)) || (poll && toPoll.contains(l))) { - if(logDEBUG) Logger.debug(this, "Ignoring "+l); - continue; - } - if(alreadyRunning.remove(l)) { - if(logDEBUG) Logger.debug(this, "Ignoring (2): "+l); - continue; - } - ClientSSK key; - // FIXME reuse ehDocnames somehow - // The problem is we need a ClientSSK for the high level stuff. - key = origUSK.getSSK(ed); - l.key = key; - l.ignoreStore = true; - if(poll) { - if(!toPoll.contains(l)) { - toPoll.add(l); - } else { - if(logDEBUG) Logger.debug(this, "Ignoring poll (3): "+l); - } + if (poll) { + getEditionIfNotAlreadyRunning(toPoll, alreadyRunning, ed, true); } else { - if(!toFetch.contains(l)) { - toFetch.add(l); - } else { - if(logDEBUG) Logger.debug(this, "Ignoring fetch (3): "+l); - } + getEditionIfNotAlreadyRunning(toFetch, alreadyRunning, ed, true); } } } + /** @return whether the edition was added. */ + public boolean getEditionIfNotAlreadyRunning( + List lookupList, + List alreadyRunning, + long ed, + boolean ignoreStore) { + Lookup l = new Lookup(); + l.val = ed; + if(lookupList.contains(l)) { + if(logDEBUG) Logger.debug(this, "Ignoring "+l); + return false; + } + if(alreadyRunning.remove(l)) { + if(logDEBUG) Logger.debug(this, "Ignoring (2): "+l); + return false; + } + ClientSSK key; + // FIXME reuse ehDocnames somehow + // The problem is we need a ClientSSK for the high level stuff. + key = origUSK.getSSK(ed); + l.key = key; + l.ignoreStore = ignoreStore; + if(lookupList.contains(l)) { + if (logDEBUG) Logger.debug(this, "Ignoring (3): " + l); + return false; + } + return lookupList.add(l); + } + public synchronized void getRandomEditions(List toFetch, long lookedUp, List alreadyRunning, Random random, int allowed) { // Then add a couple of random editions for catch-up. long baseEdition = lookedUp + origMinFailures; for(int i=0;i= WATCH_KEYS); - toFetch.add(l); if(logMINOR) Logger.minor(this, "Trying random future edition "+fetch+" for "+origUSK+" current edition "+lookedUp); - break; + if (getEditionIfNotAlreadyRunning(toFetch, alreadyRunning, fetch, !(fetch - lookedUp >= WATCH_KEYS))) { + break; + } } } } From 9f249b90b4171f3cb334a302ccfd158d6d760244 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 20:54:39 +0200 Subject: [PATCH 071/500] cache reachability for 100s, not only for 10s --- src/freenet/support/io/InetAddressIpv6FirstComparator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index 6ee526d66e0..a1992d9535d 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -13,7 +13,7 @@ public class InetAddressIpv6FirstComparator implements Comparator { // need a cache for reachability to avoid doing NlogN issReachable checks in worst case. - public LRUCache reachabilityCache = new LRUCache<>(1000, 10000); + public LRUCache reachabilityCache = new LRUCache<>(1000, 100000); public static final InetAddressIpv6FirstComparator COMPARATOR = new InetAddressIpv6FirstComparator(); From 7ff9e18d0a310638f693f6b4db4dbd24e734f858 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 20:54:53 +0200 Subject: [PATCH 072/500] prefer reachable LAN addresses over reachable globally reachable addresses --- .../io/InetAddressIpv6FirstComparator.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index a1992d9535d..4bcbf9ef1eb 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -21,26 +21,19 @@ public class InetAddressIpv6FirstComparator implements Comparator { @Override public int compare(InetAddress arg0, InetAddress arg1) { if(arg0 == arg1) return 0; - // prefer everything over loopback + // prefer everything over loopback / localhost if (!arg0.isLoopbackAddress() && arg1.isLoopbackAddress()) { return -1; } else if (arg0.isLoopbackAddress() && !arg1.isLoopbackAddress()) { return 1; } - // prefer LAN routable addresses over link-local addresses + // prefer LAN routable addresses over link-local addresses because most of these will not work if (!arg0.isLinkLocalAddress() && arg1.isLinkLocalAddress()) { return -1; } else if (arg0.isLinkLocalAddress() && !arg1.isLinkLocalAddress()) { return 1; } - byte[] bytes0 = arg0.getAddress(); - byte[] bytes1 = arg1.getAddress(); - // prefer IPv6 over IPv4 - if(bytes0.length > bytes1.length) - return -1; - if(bytes1.length > bytes0.length) - return 1; - // prefer reachable over unreachable. TODO: This actually pings all advertised ip addresses. Is that OK? + // prefer reachable over unreachable addresses. This is usually a ping. TODO: This actually pings all advertised ip addresses. Is that OK? Do we need a maximum number of accepted addresses to prevent abuse as DDoS? int a = arg0.hashCode(); int b = arg1.hashCode(); Boolean reachable0 = reachabilityCache.get(a); @@ -66,7 +59,22 @@ public int compare(InetAddress arg0, InetAddress arg1) { } else if (!reachable0 && reachable1) { return 1; } - // By hash code first. Works really fast for IPv4. + // among routable addresses prefer LAN addresses over global addresses, because they should stay within VPNs + if (!arg0.isSiteLocalAddress() && arg1.isSiteLocalAddress()) { + return -1; + } else if (arg0.isSiteLocalAddress() && !arg1.isSiteLocalAddress()) { + return 1; + } + byte[] bytes0 = arg0.getAddress(); + byte[] bytes1 = arg1.getAddress(); + // prefer IPv6 over IPv4 + if(bytes0.length > bytes1.length) { + return -1; + } else if(bytes1.length > bytes0.length) { + return 1; + } + + // Sort by hash code as fallback. This is fast. if(a > b) return 1; else if(b > a) return -1; return Fields.compareBytes(bytes0, bytes1); From 5ef01b0a55a1c91b51230cadf29a8dc07eb1bc1e Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 21:11:55 +0200 Subject: [PATCH 073/500] increase cache time to 5 minutes --- src/freenet/support/io/InetAddressIpv6FirstComparator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index 4bcbf9ef1eb..38a9a18eb8e 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -13,7 +13,7 @@ public class InetAddressIpv6FirstComparator implements Comparator { // need a cache for reachability to avoid doing NlogN issReachable checks in worst case. - public LRUCache reachabilityCache = new LRUCache<>(1000, 100000); + public LRUCache reachabilityCache = new LRUCache<>(1000, 300000); public static final InetAddressIpv6FirstComparator COMPARATOR = new InetAddressIpv6FirstComparator(); From ef096184eb0521ae6c14588700ca05985d40d580 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 21:12:12 +0200 Subject: [PATCH 074/500] use the default max ping time for reachability --- src/freenet/support/io/InetAddressIpv6FirstComparator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index 38a9a18eb8e..aa8a9d19982 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -1,5 +1,7 @@ package freenet.support.io; +import static freenet.node.NodeStats.DEFAULT_MAX_PING_TIME; + import java.io.IOException; import java.net.InetAddress; import java.util.Comparator; @@ -40,7 +42,7 @@ public int compare(InetAddress arg0, InetAddress arg1) { Boolean reachable1 = reachabilityCache.get(b); if (reachable0 == null) { try { - reachable0 = arg0.isReachable(300); + reachable0 = arg0.isReachable((int) DEFAULT_MAX_PING_TIME); } catch (IOException e) { reachable0 = false; } @@ -48,7 +50,7 @@ public int compare(InetAddress arg0, InetAddress arg1) { } if (reachable1 == null) { try { - reachable1 = arg1.isReachable(300); + reachable1 = arg1.isReachable((int) DEFAULT_MAX_PING_TIME); } catch (IOException e) { reachable1 = false; } From 5037d12eed2a6875a986d30f8f8689f3acb3f780 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 21:12:47 +0200 Subject: [PATCH 075/500] prefer everything over broadcast addresses --- src/freenet/support/io/InetAddressIpv6FirstComparator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index aa8a9d19982..66c314524d9 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -23,6 +23,12 @@ public class InetAddressIpv6FirstComparator implements Comparator { @Override public int compare(InetAddress arg0, InetAddress arg1) { if(arg0 == arg1) return 0; + // prefer everything over broadcast + if (!arg0.isAnyLocalAddress() && arg1.isAnyLocalAddress()) { + return -1; + } else if (arg0.isAnyLocalAddress() && !arg1.isAnyLocalAddress()) { + return 1; + } // prefer everything over loopback / localhost if (!arg0.isLoopbackAddress() && arg1.isLoopbackAddress()) { return -1; From b8bc00018b17705a328265dbcbb377939eea1e4f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 May 2023 21:15:27 +0200 Subject: [PATCH 076/500] whitespace --- src/freenet/io/comm/FreenetInetAddress.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/freenet/io/comm/FreenetInetAddress.java b/src/freenet/io/comm/FreenetInetAddress.java index 011499ace4d..8e696776020 100644 --- a/src/freenet/io/comm/FreenetInetAddress.java +++ b/src/freenet/io/comm/FreenetInetAddress.java @@ -331,7 +331,7 @@ public InetAddress getHandshakeAddress() { return _address; } else { if(logMINOR) Logger.minor(this, "Looking up '"+hostname+"' in DNS", new Exception("debug")); - /* + /* * Peers are constructed from an address once a * handshake has been completed, so this lookup * will only be performed during a handshake @@ -346,8 +346,8 @@ public InetAddress getHandshakeAddress() { if(logMINOR) Logger.minor(this, "Look up got '"+addresses+ '\''); if( addresses.length > 1 ) { /* sort by IPv6 first */ - Arrays.sort(addresses, InetAddressIpv6FirstComparator.COMPARATOR); - /* + Arrays.sort(addresses, InetAddressIpv6FirstComparator.COMPARATOR); + /* * cache the answer since getHandshakeAddress() * doesn't use the cached value, thus * getHandshakeIPs() should always get the From 1562207029e8021354ae97e360c4d60d6f5d7f3a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 27 May 2023 10:07:24 +0200 Subject: [PATCH 077/500] fix whitespace --- src/freenet/support/SectoredRandomGrabArray.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/freenet/support/SectoredRandomGrabArray.java b/src/freenet/support/SectoredRandomGrabArray.java index 662b17b224a..88150250aa2 100644 --- a/src/freenet/support/SectoredRandomGrabArray.java +++ b/src/freenet/support/SectoredRandomGrabArray.java @@ -184,14 +184,14 @@ private RandomGrabArrayItem removeRandomLimited( excluded++; if(excluded > MAX_EXCLUDED) { if (logMINOR) - Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); + Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); return null; } continue; } if(logMINOR) Logger.minor(this, "Picked "+x+" of "+grabArrays.length+" : "+rga+" on "+this); - + RandomGrabArrayItem item = null; RemoveRandomReturn val = rga.removeRandom(excluding, context, now); if(val != null && val.item != null) item = val.item; @@ -210,8 +210,8 @@ private RandomGrabArrayItem removeRandomLimited( } else { excluded++; if(excluded > MAX_EXCLUDED) { - if (logMINOR) - Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); + if (logMINOR) + Logger.minor(this, "Too many sub-arrays are entirely excluded on "+this+" length = "+grabArrays.length, new Exception("error")); return null; } } From fbb0a2821c2216b594012f7494025e04625e08aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 23 Jun 2023 15:46:34 +0200 Subject: [PATCH 078/500] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Update=20Hamcrest?= =?UTF-8?q?=20dependency=20to=202.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I want to use the anEmptyMap matcher so I guess 2.2 it is! --- build.gradle | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 634dcd89801..3b81c493383 100644 --- a/build.gradle +++ b/build.gradle @@ -244,8 +244,7 @@ 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.hamcrest:hamcrest:2.2" testCompile "org.objenesis:objenesis:1.0" } @@ -259,8 +258,7 @@ dependencyVerification { 'org.freenetproject:freenet-ext:32f2b3d6beedf54137ea2f9a3ebef67666d769f0966b08cd17fd7db59ba4d79f', 'junit:junit:59721f0805e223d84b90677887d9ff567dc534d7c502ca903c0c2b17f05c116a', 'org.mockito:mockito-core:f97483ba0944b9fa133aa29638764ddbeadb51ec3dbc02074c58fa2caecd07fa', - 'org.hamcrest:hamcrest-library:711d64522f9ec410983bd310934296da134be4254a125080a0416ec178dfad1c', - 'org.hamcrest:hamcrest-core:66fdef91e9739348df7a096aa384a5685f4e875584cce89386a7a47251c4d8e9', + 'org.hamcrest:hamcrest:5e62846a89f05cd78cd9c1a553f340d002458380c320455dd1f8fc5497a8a1c1', 'org.objenesis:objenesis:c5694b55d92527479382f254199b3c6b1d8780f652ad61e9ca59919887f491a8', 'io.pebbletemplates:pebble:d253a6dde59e138698aaaaee546461d2f1f6c8bd2aa38ecdd347df17cf90d6f0', // dependencies of pebble From e882e319ffd6da27cc0219d37a4a035ac635f43c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 23 Jun 2023 15:48:00 +0200 Subject: [PATCH 079/500] =?UTF-8?q?=F0=9F=90=9B=20Fix=20NPE=20when=20subse?= =?UTF-8?q?ts=20are=20not=20initialized?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes https://freenet.mantishub.io/view.php?id=7197. --- src/freenet/support/SimpleFieldSet.java | 4 +++- test/freenet/support/SimpleFieldSetTest.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/freenet/support/SimpleFieldSet.java b/src/freenet/support/SimpleFieldSet.java index 1a7babc8464..78bad63f718 100644 --- a/src/freenet/support/SimpleFieldSet.java +++ b/src/freenet/support/SimpleFieldSet.java @@ -31,6 +31,8 @@ import freenet.support.io.LineReader; import freenet.support.io.Readers; +import static java.util.Collections.emptyMap; + /** * @author amphibian * @@ -802,7 +804,7 @@ public Set directKeys() { * @return */ public Map directSubsets() { - return Collections.unmodifiableMap(subsets); + return subsets == null ? emptyMap() : Collections.unmodifiableMap(subsets); } /** Tolerant put(); does nothing if fs is empty */ diff --git a/test/freenet/support/SimpleFieldSetTest.java b/test/freenet/support/SimpleFieldSetTest.java index 4cde4f6c0ed..4373f36b49d 100644 --- a/test/freenet/support/SimpleFieldSetTest.java +++ b/test/freenet/support/SimpleFieldSetTest.java @@ -16,6 +16,8 @@ package freenet.support; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anEmptyMap; import static org.junit.Assert.*; import java.io.BufferedReader; @@ -840,4 +842,12 @@ public void testSplit() { assertTrue(Arrays.equals(SimpleFieldSet.split(";;blah;1;2;;"), new String[] { "", "", "blah", "1", "2", "", "" })); assertTrue(Arrays.equals(SimpleFieldSet.split(";;;"), new String[] { "", "", "" })); } + + // This fixes https://freenet.mantishub.io/view.php?id=7197. + @Test + public void directSubsetsReturnsEmptyMapWhenSubsetsIsNotInitialized() { + SimpleFieldSet simpleFieldSet = new SimpleFieldSet(true); + assertThat(simpleFieldSet.directSubsets(), anEmptyMap()); + } + } From b18668d41bc75a3da67cb5fe3d423f0ec2c85320 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 25 Jul 2023 10:04:17 +0200 Subject: [PATCH 080/500] start test for USK -1 to 0, WIP --- .../node/NodeAndClientLayerBlobTest.java | 2 +- test/freenet/node/NodeAndClientLayerTest.java | 23 +++++++++++++++---- .../node/NodeAndClientLayerTestBase.java | 9 +++++++- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/test/freenet/node/NodeAndClientLayerBlobTest.java b/test/freenet/node/NodeAndClientLayerBlobTest.java index 9e3d06b647e..b53241cc07d 100644 --- a/test/freenet/node/NodeAndClientLayerBlobTest.java +++ b/test/freenet/node/NodeAndClientLayerBlobTest.java @@ -61,7 +61,7 @@ public void testFetchPullBlobSingleNode() throws InvalidThresholdException, Node // First do an ordinary insert. InsertContext ictx = client.getInsertContext(true); ictx.localRequestOnly = true; - InsertBlock block = generateBlock(random); + InsertBlock block = generateBlock(random, false); FreenetURI uri = client.insert(block, "", (short)0, ictx); assertEquals(uri.getKeyType(), "SSK"); diff --git a/test/freenet/node/NodeAndClientLayerTest.java b/test/freenet/node/NodeAndClientLayerTest.java index 1a2922e0622..4b21b2bbea1 100644 --- a/test/freenet/node/NodeAndClientLayerTest.java +++ b/test/freenet/node/NodeAndClientLayerTest.java @@ -37,9 +37,25 @@ public class NodeAndClientLayerTest extends NodeAndClientLayerTestBase { private static final File dir = new File("test-fetch-pull-single-node"); @Test - public void testFetchPullSingleNode() throws InvalidThresholdException, NodeInitException, InsertException, FetchException, IOException { + public void testFetchPullSingleNodeSsk() throws InvalidThresholdException, NodeInitException, InsertException, FetchException, IOException { if(!TestProperty.EXTENSIVE) return; DummyRandomSource random = new DummyRandomSource(25312); + InsertBlock block = generateBlock(random, false); + FetchResult result = insertAndRetrieveBlock(random, block); + assertTrue(BucketTools.equalBuckets(result.asBucket(), block.getData())); + } + + @Test + public void testFetchPullSingleNodeUskEditionZero() throws InvalidThresholdException, NodeInitException, InsertException, FetchException, IOException { + if(!TestProperty.EXTENSIVE) return; + DummyRandomSource random = new DummyRandomSource(25312); + InsertBlock block = generateBlock(random, true); + FetchResult result = insertAndRetrieveBlock(random, block); + assertTrue(BucketTools.equalBuckets(result.asBucket(), block.getData())); + } + + private static FetchResult insertAndRetrieveBlock(DummyRandomSource random, InsertBlock block) + throws InvalidThresholdException, NodeInitException, InsertException, FetchException { final Executor executor = new PooledExecutor(); FileUtil.removeAll(dir); dir.mkdir(); @@ -57,7 +73,6 @@ public void testFetchPullSingleNode() throws InvalidThresholdException, NodeInit node.clientCore.makeClient((short)0, false, false); InsertContext ictx = client.getInsertContext(true); ictx.localRequestOnly = true; - InsertBlock block = generateBlock(random); FreenetURI uri = client.insert(block, "", (short)0, ictx); assertEquals(uri.getKeyType(), "SSK"); @@ -66,9 +81,9 @@ public void testFetchPullSingleNode() throws InvalidThresholdException, NodeInit FetchWaiter fw = new FetchWaiter(rc); client.fetch(uri, FILE_SIZE*2, fw, ctx, (short)0); FetchResult result = fw.waitForCompletion(); - assertTrue(BucketTools.equalBuckets(result.asBucket(), block.getData())); + return result; } - + @After public void cleanUp() { FileUtil.removeAll(dir); diff --git a/test/freenet/node/NodeAndClientLayerTestBase.java b/test/freenet/node/NodeAndClientLayerTestBase.java index 4550882cb8a..14554758b2b 100644 --- a/test/freenet/node/NodeAndClientLayerTestBase.java +++ b/test/freenet/node/NodeAndClientLayerTestBase.java @@ -7,6 +7,8 @@ import freenet.crypt.DummyRandomSource; import freenet.keys.FreenetURI; import freenet.keys.InsertableClientSSK; +import freenet.keys.InsertableUSK; +import freenet.keys.USK; import freenet.support.SimpleReadOnlyArrayBucket; import freenet.support.api.RandomAccessBucket; @@ -29,11 +31,16 @@ public boolean realTimeFlag() { }; - protected InsertBlock generateBlock(DummyRandomSource random) throws MalformedURLException { + protected InsertBlock generateBlock(DummyRandomSource random, boolean createUsk) throws MalformedURLException { byte[] data = new byte[FILE_SIZE]; random.nextBytes(data); RandomAccessBucket bucket = new SimpleReadOnlyArrayBucket(data); FreenetURI uri = InsertableClientSSK.createRandom(random, "test").getInsertURI(); + if (createUsk) { + uri = uri.setDocName("foo-0"); + uri = uri.uskForSSK(); + uri = uri.setSuggestedEdition(-1); + } return new InsertBlock(bucket, new ClientMetadata(null), uri); } From 8d247b476d61df42a1a23b753687d2222fcce623 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 25 Jul 2023 10:10:57 +0200 Subject: [PATCH 081/500] gradle: undo change to disable preserving file timestamps --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index fec243ba911..52b65401981 100644 --- a/build.gradle +++ b/build.gradle @@ -283,7 +283,7 @@ task tar(type: Tar) { into(baseName) - preserveFileTimestamps = false + preserveFileTimestamps = true reproducibleFileOrder = true // Set destination directory. From d91251f58bb1aca792374a9f8ae796bfe9c9953d Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 25 Jul 2023 10:12:20 +0200 Subject: [PATCH 082/500] Also build debian package on next --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 268fa172aa8..f6e93efbcff 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,7 +1,7 @@ name: Build debian package on: push: - branches: [ 'master', 'debian-pkg' ] + branches: [ 'master', 'next', 'debian-pkg' ] tags: - build** - testing-** From 696dfba2f0be0bf306a756fb62970d0719456112 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 25 Jul 2023 10:16:16 +0200 Subject: [PATCH 083/500] update news --- NEWS.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 5365f1c7289..0015b944b2f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,10 @@ next: -- +- merge debian package build for 1494 (not yet updated for 1497). + +1497: + +- fixed severe path folding vulnerability. 1496: From 841dc089edb65b868add67344ab696dc0b2c9dab Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 25 Jul 2023 10:17:32 +0200 Subject: [PATCH 084/500] whitespace --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 0015b944b2f..1a86e50f1d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,7 @@ next: - fixed severe path folding vulnerability. + 1496: - fix keepalive regression — thanks to PlantEater for tracking it down and fixing it! From fcc32a21cfb962a03b731edd3a14d6d0b2e0860c Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 25 Jul 2023 10:20:48 +0200 Subject: [PATCH 085/500] build debian package from master --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index f6e93efbcff..da31367e06a 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-pkg -us -uc --git-ignore-new + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=master -us -uc --git-ignore-new - name: Get package info run: | From d8a2f79e62ac86bd95f967471c46fd4c4cca28c7 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:47:26 +0200 Subject: [PATCH 086/500] build debian package from debian-pkg for quick experimentation --- .github/workflows/package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index da31367e06a..44ecf8f25bb 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -11,7 +11,7 @@ jobs: matrix: os: [ ubuntu-latest ] distribution: [temurin] - java: [8, 11] + java: [8] runs-on: ubuntu-latest steps: @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=master -us -uc --git-ignore-new + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=depian-pkg -us -uc --git-ignore-new - name: Get package info run: | From f84441847c7fd75fa68080a1c763d0bf524a4514 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:47:50 +0200 Subject: [PATCH 087/500] disable -Zgzip --- debian/rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index 981de548a74..8b6deb513b7 100755 --- a/debian/rules +++ b/debian/rules @@ -38,8 +38,8 @@ override_dh_auto_build: build_seed_file sed -e 's/@version@/$(FREENET_VERSION)/' -e 's/@build@/$(FREENET_BUILD)/' $(CURDIR)/debian/freenet.service.params | \ $(WRAPPER_INIT) -q > "$(CURDIR)/debian/freenet.init" -override_dh_builddeb: - dh_builddeb -- -Zgzip +# override_dh_builddeb: +# dh_builddeb -- -Zgzip override_dh_auto_install: dh_auto_install From 6994b34f728bfec4ec0376e8e99a3dc5494c2ed8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:48:02 +0200 Subject: [PATCH 088/500] mark debian version as 1497 --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 8b6deb513b7..23ecd71c2c0 100755 --- a/debian/rules +++ b/debian/rules @@ -4,7 +4,7 @@ # Uncomment this to turn on verbose mode. export DH_VERBOSE=0 FREENET_VERSION := 0.7.5 -FREENET_BUILD := 1494 +FREENET_BUILD := 1497 WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh BUILD_DIR := /tmp/fred-build From 761317ab18ed989c4a44674650bff4a8b980f2f2 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:48:18 +0200 Subject: [PATCH 089/500] include new deps in debian package --- debian/rules | 3 +++ debian/wrapper.conf | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/debian/rules b/debian/rules index 23ecd71c2c0..2a085e7a4bb 100755 --- a/debian/rules +++ b/debian/rules @@ -54,3 +54,6 @@ override_jh_installlibs: jh_installlibs $(BUILD_DIR)/output/jna-4.5.2.jar jh_installlibs $(BUILD_DIR)/output/jna-platform-4.5.2.jar jh_installlibs $(BUILD_DIR)/output/bcprov-jdk15on-1.59.jar + jh_installlibs $(BUILD_DIR)/output/pebble-3.1.5.jar + jh_installlibs $(BUILD_DIR)/output/unbescape-1.1.6.RELEASE.jar + jh_installlibs $(BUILD_DIR)/output/slf4j-api-1.7.25.jar diff --git a/debian/wrapper.conf b/debian/wrapper.conf index 5cbf4dfe993..056e5522b74 100644 --- a/debian/wrapper.conf +++ b/debian/wrapper.conf @@ -8,6 +8,10 @@ wrapper.java.classpath.2=/usr/share/java/freenet-ext-29.jar wrapper.java.classpath.3=/usr/share/java/jna-4.5.2.jar wrapper.java.classpath.4=/usr/share/java/jna-platform-4.5.2.jar wrapper.java.classpath.5=/usr/share/java/bcprov-jdk15on-1.59.jar +wrapper.java.classpath.6=/usr/share/java/pebble-3.1.5.jar +wrapper.java.classpath.7=/usr/share/java/unbescape-1.1.6.RELEASE.jar +wrapper.java.classpath.8=/usr/share/java/slf4j-api-1.7.25.jar + wrapper.java.library.path.1=/usr/lib/jni wrapper.java.mainclass=freenet.node.NodeStarter wrapper.java.additional.1=-Dnetworkaddress.cache.ttl=0 From 9f9febbaf4fa9be563f66e34e31bf7f57c902581 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:48:27 +0200 Subject: [PATCH 090/500] add new required wrapper arguments for Java 11 in debian package --- debian/wrapper.conf | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/wrapper.conf b/debian/wrapper.conf index 056e5522b74..c3332b34ab9 100644 --- a/debian/wrapper.conf +++ b/debian/wrapper.conf @@ -16,6 +16,13 @@ wrapper.java.library.path.1=/usr/lib/jni wrapper.java.mainclass=freenet.node.NodeStarter wrapper.java.additional.1=-Dnetworkaddress.cache.ttl=0 wrapper.java.additional.2=-Dnetworkaddress.cache.negative.ttl=0 +wrapper.java.additional.3=-Djava.net.preferIPv4Stack=false +wrapper.java.additional.4=-Djava.io.tmpdir=./tmp/ +wrapper.java.additional.5=--illegal-access=permit +wrapper.java.additional.6=--add-opens=java.base/java.lang=ALL-UNNAMED +wrapper.java.additional.7=--add-opens=java.base/java.util=ALL-UNNAMED +wrapper.java.additional.8=--add-opens=java.base/java.io=ALL-UNNAMED +wrapper.java.additional.9=-Xss512k #wrapper.java.additional.3=-enableassertions:freenet # You might want to set the following line if you have changed java.maxmemory #wrapper.java.additional.4=-XX:MaxPermSize= From ff732d878f921a2c50b7d924709408d58f0b5434 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:49:58 +0200 Subject: [PATCH 091/500] switch debian java to 17 (from debian stable) --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 44ecf8f25bb..2578f65562d 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -11,7 +11,7 @@ jobs: matrix: os: [ ubuntu-latest ] distribution: [temurin] - java: [8] + java: [17] runs-on: ubuntu-latest steps: From dc979565d6487b9c97e82ac5ab1b75e1500f3544 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 01:51:05 +0200 Subject: [PATCH 092/500] build debian package from debian-package --- .github/workflows/package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2578f65562d..e306d57521a 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,7 +1,7 @@ name: Build debian package on: push: - branches: [ 'master', 'next', 'debian-pkg' ] + branches: [ 'master', 'next', 'debian-package' ] tags: - build** - testing-** @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=depian-pkg -us -uc --git-ignore-new + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=depian-package -us -uc --git-ignore-new - name: Get package info run: | From 025723d92a62ccba1400e2f82fa2d59d4e520ae2 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 02:05:42 +0200 Subject: [PATCH 093/500] typo --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index e306d57521a..0c9c94f1626 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=depian-package -us -uc --git-ignore-new + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new - name: Get package info run: | From eb8c4cda6865caa30c9e918666cb829008e02f0b Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 02:20:30 +0200 Subject: [PATCH 094/500] make debian/rules work on guix --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 2a085e7a4bb..bd47d16205e 100755 --- a/debian/rules +++ b/debian/rules @@ -1,4 +1,4 @@ -#!/usr/bin/make -f +#!/usr/bin/env -S make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. From 5081ee9399a8de32073adbdf08b639fedff96966 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 02:21:02 +0200 Subject: [PATCH 095/500] Add debian/changelog entry for 1497 --- debian/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/changelog b/debian/changelog index a7d7dbd19ee..2fb1d08a93a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,7 @@ +freenet (0.7.5+1497-16) unstable; urgency=medium + + * Build 1497 + freenet (0.7.5+1494-7) unstable; urgency=medium * Remove outdated files From 1715d0782aa37069011370108acb65d060f1970f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 02:45:48 +0200 Subject: [PATCH 096/500] manually update changelog again --- debian/changelog | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2fb1d08a93a..4c79e3cb6b8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,12 @@ -freenet (0.7.5+1497-16) unstable; urgency=medium +freenet (0.7.5+1497-17) unstable; urgency=medium * Build 1497 + -- Arne Tue, 07 Sep 2023 23:42:30 +0100 + freenet (0.7.5+1494-7) unstable; urgency=medium - * Remove outdated files + * Remove outdated files -- DC Sat, 17 Sep 2022 15:46:23 +0100 From 600e54c35f61658d8ee2d0ad736431550b2ee288 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 02:47:21 +0200 Subject: [PATCH 097/500] show debian diff --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 0c9c94f1626..86e52b83080 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || cat /tmp/freenet_0.7.5+*diff* - name: Get package info run: | From 9ec186aa7127fe26783e4b3ba2909c811e1a24d6 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 02:48:48 +0200 Subject: [PATCH 098/500] debian 1497 --- debian/files | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/files b/debian/files index cc40908ba31..e6babe95aeb 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,2 @@ -freenet_0.7.5+1494-7_amd64.buildinfo net optional -freenet_0.7.5+1494-7_amd64.deb net optional +freenet_0.7.5+1497-17_amd64.buildinfo net optional +freenet_0.7.5+1497-17_amd64.deb net optional From 93e8562948c832718f24139a56d382bbc87407e8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 05:46:59 +0200 Subject: [PATCH 099/500] sudo --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 86e52b83080..fc910833b4e 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || cat /tmp/freenet_0.7.5+*diff* + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || sudo cat /tmp/freenet_0.7.5+*diff* - name: Get package info run: | From ceb56059fc8ccf464c0b451dca3ee2e75b44e3f6 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 05:56:54 +0200 Subject: [PATCH 100/500] stay false --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index fc910833b4e..da74f000381 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || sudo cat /tmp/freenet_0.7.5+*diff* + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (sudo cat /tmp/freenet_0.7.5+*diff* && false) - name: Get package info run: | From 7b737ec5e6bbe3ac8fb531a3de1fbe8cbf3daf0d Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 26 Jul 2023 06:41:59 +0200 Subject: [PATCH 101/500] Summary: first patch --- debian/changelog | 2 +- debian/files | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4c79e3cb6b8..ffe614429d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -freenet (0.7.5+1497-17) unstable; urgency=medium +freenet (0.7.5+1497-1) unstable; urgency=medium * Build 1497 diff --git a/debian/files b/debian/files index e6babe95aeb..95be461c9e4 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,2 @@ -freenet_0.7.5+1497-17_amd64.buildinfo net optional -freenet_0.7.5+1497-17_amd64.deb net optional +freenet_0.7.5+1497-1_amd64.buildinfo net optional +freenet_0.7.5+1497-1_amd64.deb net optional From 620396c74d90c63a935961ca87bb12e31527237d Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 29 Jul 2023 00:44:05 +0200 Subject: [PATCH 102/500] Debian init: name 1497 --- debian/freenet.init | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/freenet.init b/debian/freenet.init index 5432eaac92d..0d96abfd0c3 100644 --- a/debian/freenet.init +++ b/debian/freenet.init @@ -34,13 +34,13 @@ # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Freenet 0.7.5 build 1494 (experimental release) +# Short-Description: Freenet 0.7.5 build 1497 (experimental release) # Description: Freenet reference daemon ### END INIT INFO # Application APP_NAME="freenet" -APP_LONG_NAME="Freenet 0.7.5 build 1494 (experimental release)" +APP_LONG_NAME="Freenet 0.7.5 build 1497 (experimental release)" # If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer # be passed to the wrapper. See documentation for details. @@ -156,7 +156,7 @@ MACOSX_KEEP_RUNNING="false" # The following two lines are used by the chkconfig command. Change as is # appropriate for your application. They should remain commented. # chkconfig: 2345 20 80 -# description: Freenet 0.7.5 build 1494 (experimental release) +# description: Freenet 0.7.5 build 1497 (experimental release) # Set run level to use when installing the application to start and stop on # system startup and shutdown. It is important that the application always From 7bd08746fa320ea6c3036eb7297d6a2a36dbea7f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 29 Jul 2023 01:45:26 +0200 Subject: [PATCH 103/500] extract static PebbleUtils from WebTemlateToadlet for easier reuse --- .../clients/http/WebTemplateToadlet.java | 52 ++----------------- .../clients/http/utils/L10nExtension.java | 39 ++++++++++++++ .../clients/http/utils/PebbleUtils.java | 42 +++++++++++++++ 3 files changed, 84 insertions(+), 49 deletions(-) create mode 100644 src/freenet/clients/http/utils/L10nExtension.java create mode 100644 src/freenet/clients/http/utils/PebbleUtils.java diff --git a/src/freenet/clients/http/WebTemplateToadlet.java b/src/freenet/clients/http/WebTemplateToadlet.java index 33f6cdcc528..6272ae1fbdc 100644 --- a/src/freenet/clients/http/WebTemplateToadlet.java +++ b/src/freenet/clients/http/WebTemplateToadlet.java @@ -1,13 +1,11 @@ package freenet.clients.http; -import com.mitchellbosecke.pebble.PebbleEngine; import com.mitchellbosecke.pebble.extension.AbstractExtension; import com.mitchellbosecke.pebble.extension.Function; -import com.mitchellbosecke.pebble.loader.ClasspathLoader; -import com.mitchellbosecke.pebble.loader.Loader; import com.mitchellbosecke.pebble.template.EvaluationContext; import com.mitchellbosecke.pebble.template.PebbleTemplate; import freenet.client.HighLevelSimpleClient; +import freenet.clients.http.utils.PebbleUtils; import freenet.l10n.NodeL10n; import freenet.support.HTMLNode; @@ -18,19 +16,6 @@ abstract class WebTemplateToadlet extends Toadlet { - private static final String TEMPLATE_ROOT_PATH = "freenet/clients/http/templates/"; - private static final String TEMPLATE_NAME_SUFFIX = ".html"; - - private static final PebbleEngine templateEngine; - - static { - Loader loader = new ClasspathLoader(WebTemplateToadlet.class.getClassLoader()); - loader.setPrefix(TEMPLATE_ROOT_PATH); - loader.setSuffix(TEMPLATE_NAME_SUFFIX); - - templateEngine = new PebbleEngine.Builder().loader(loader).extension(new L10nExtension()).build(); - } - WebTemplateToadlet(HighLevelSimpleClient client) { super(client); } @@ -44,43 +29,12 @@ abstract class WebTemplateToadlet extends Toadlet { * @throws IOException If the template cannot be read. */ void addChild(HTMLNode parent, String templateName, Map model) throws IOException { - addChild(parent, templateName, model, ""); + PebbleUtils.addChild(parent, templateName, model, ""); } void addChild(HTMLNode parent, String templateName, Map model, String l10nPrefix) throws IOException { - model.put("l10nPrefix", l10nPrefix); - PebbleTemplate template = templateEngine.getTemplate(templateName); - - Writer writer = new StringWriter(); - template.evaluate(writer, model); - - parent.addChild("%", writer.toString()); + PebbleUtils.addChild(parent, templateName, model, l10nPrefix); } -} -class L10nExtension extends AbstractExtension { - - @Override - public Map getFunctions() { - Map functions = new HashMap<>(); - functions.put("l10n", new L10nFunction()); - return functions; - } } -class L10nFunction implements Function { - - @Override - public Object execute(Map args, PebbleTemplate self, EvaluationContext context, int lineNumber) { - Object key = args.get("0"); - if (key == null) { - return "null"; - } - return NodeL10n.getBase().getString(context.getVariable("l10nPrefix") + key.toString()); - } - - @Override - public List getArgumentNames() { - return null; - } -} diff --git a/src/freenet/clients/http/utils/L10nExtension.java b/src/freenet/clients/http/utils/L10nExtension.java new file mode 100644 index 00000000000..79efc6129c7 --- /dev/null +++ b/src/freenet/clients/http/utils/L10nExtension.java @@ -0,0 +1,39 @@ +package freenet.clients.http.utils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.mitchellbosecke.pebble.extension.AbstractExtension; +import com.mitchellbosecke.pebble.extension.Function; +import com.mitchellbosecke.pebble.template.EvaluationContext; +import com.mitchellbosecke.pebble.template.PebbleTemplate; + +import freenet.l10n.NodeL10n; + +class L10nExtension extends AbstractExtension { + + @Override + public Map getFunctions() { + Map functions = new HashMap<>(); + functions.put("l10n", new L10nFunction()); + return functions; + } + + static class L10nFunction implements Function { + + @Override + public Object execute(Map args, PebbleTemplate self, EvaluationContext context, int lineNumber) { + Object key = args.get("0"); + if (key == null) { + return "null"; + } + return NodeL10n.getBase().getString(context.getVariable("l10nPrefix") + key.toString()); + } + + @Override + public List getArgumentNames() { + return null; + } + } +} diff --git a/src/freenet/clients/http/utils/PebbleUtils.java b/src/freenet/clients/http/utils/PebbleUtils.java new file mode 100644 index 00000000000..591b5595534 --- /dev/null +++ b/src/freenet/clients/http/utils/PebbleUtils.java @@ -0,0 +1,42 @@ +package freenet.clients.http.utils; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Map; + +import com.mitchellbosecke.pebble.PebbleEngine; +import com.mitchellbosecke.pebble.loader.ClasspathLoader; +import com.mitchellbosecke.pebble.loader.Loader; +import com.mitchellbosecke.pebble.template.PebbleTemplate; + +import freenet.support.HTMLNode; + +public class PebbleUtils { + private static final String TEMPLATE_ROOT_PATH = "freenet/clients/http/templates/"; + private static final String TEMPLATE_NAME_SUFFIX = ".html"; + private static final PebbleEngine templateEngine; + + static { + Loader loader = new ClasspathLoader(PebbleUtils.class.getClassLoader()); + loader.setPrefix(PebbleUtils.TEMPLATE_ROOT_PATH); + loader.setSuffix(PebbleUtils.TEMPLATE_NAME_SUFFIX); + + templateEngine = new PebbleEngine.Builder().loader(loader).extension(new L10nExtension()).build(); + } + + public static void addChild( + HTMLNode parent, + String templateName, + Map model, + String l10nPrefix) throws + IOException { + model.put("l10nPrefix", l10nPrefix); + PebbleTemplate template = templateEngine.getTemplate(templateName); + + Writer writer = new StringWriter(); + template.evaluate(writer, model); + + parent.addChild("%", writer.toString()); + } +} From 092b703bc9ef47abbc71a305926b2d45d8b6f153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 29 Jul 2023 12:53:03 +0200 Subject: [PATCH 104/500] =?UTF-8?q?=E2=9C=85=20Add=20test=20for=20L10nExte?= =?UTF-8?q?nsion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clients/http/utils/L10nExtensionTest.java | 63 +++++++++++++++++++ test/freenet/l10n/freenet.l10n.en.properties | 1 + 2 files changed, 64 insertions(+) create mode 100644 test/freenet/clients/http/utils/L10nExtensionTest.java diff --git a/test/freenet/clients/http/utils/L10nExtensionTest.java b/test/freenet/clients/http/utils/L10nExtensionTest.java new file mode 100644 index 00000000000..f33edff961d --- /dev/null +++ b/test/freenet/clients/http/utils/L10nExtensionTest.java @@ -0,0 +1,63 @@ +package freenet.clients.http.utils; + +import java.util.Locale; +import java.util.Map; + +import com.mitchellbosecke.pebble.extension.Function; +import com.mitchellbosecke.pebble.template.EvaluationContext; +import org.junit.Test; + +import static java.util.Collections.emptyMap; +import static java.util.Collections.singletonMap; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; + +public class L10nExtensionTest { + + @Test + public void l10nExtensionExposesAnL10nFunction() { + assertThat(l10nExtension.getFunctions().keySet(), contains("l10n")); + } + + @Test + public void l10nFunctionDoesNotHaveArguments() { + assertThat(l10nFunction.getArgumentNames(), nullValue()); + } + + @Test + public void l10nFunctionReturnStringNullIfNotArgumentsAreGiven() { + assertThat(l10nFunction.execute(emptyMap(), null, null, 0), equalTo("null")); + } + + @Test + public void l10nFunctionRetrievesGivenArgumentWithPrefixFromContextToNodeL10n() { + Map arguments = singletonMap("0", "l10nFunctionTest"); + EvaluationContext context = createEvaluationContext(); + assertThat(l10nFunction.execute(arguments, null, context, 0), equalTo("Localized Value")); + } + + private static EvaluationContext createEvaluationContext() { + return new EvaluationContext() { + @Override + public boolean isStrictVariables() { + return false; + } + + @Override + public Locale getLocale() { + return null; + } + + @Override + public Object getVariable(String key) { + return key.equals("l10nPrefix") ? "test." : null; + } + }; + } + + private final L10nExtension l10nExtension = new L10nExtension(); + private final Function l10nFunction = l10nExtension.getFunctions().get("l10n"); + +} diff --git a/test/freenet/l10n/freenet.l10n.en.properties b/test/freenet/l10n/freenet.l10n.en.properties index 48f56c20a48..73d13e2f29c 100644 --- a/test/freenet/l10n/freenet.l10n.en.properties +++ b/test/freenet/l10n/freenet.l10n.en.properties @@ -10,4 +10,5 @@ test.emptySelfNestedSubstitution=${tag}content ${tag}nested${/tag} test.missingBraceSubstitution=${ok}Text${/ok} and ${broken substitution test.unmatchedCloseSubstitution=${ok}Text${/ok} and ${/close} test.badSubstitutionFallback=Fallback ${tag} +test.l10nFunctionTest=Localized Value End From 4ab8b1817b831825c0f296e3dddcdc6ce1034a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 29 Jul 2023 19:01:16 +0200 Subject: [PATCH 105/500] =?UTF-8?q?=E2=9C=85=20Add=20test=20for=20PebbleUt?= =?UTF-8?q?ils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../templates/pebble-utils-test-l10n.html | 1 + .../templates/pebble-utils-test-simple.html | 1 + .../clients/http/utils/PebbleUtilsTest.java | 30 +++++++++++++++++++ test/freenet/l10n/freenet.l10n.en.properties | 1 + 5 files changed, 34 insertions(+) create mode 100644 test/freenet/clients/http/templates/pebble-utils-test-l10n.html create mode 100644 test/freenet/clients/http/templates/pebble-utils-test-simple.html create mode 100644 test/freenet/clients/http/utils/PebbleUtilsTest.java diff --git a/build.gradle b/build.gradle index 52b65401981..a60524342cb 100644 --- a/build.gradle +++ b/build.gradle @@ -172,6 +172,7 @@ task copyTestResourcesToClasses2 { include 'freenet/client/filter/*/**' include 'freenet/crypt/ciphers/rijndael-gladman-test-data/**' include 'freenet/l10n/*properties' + include 'freenet/clients/http/templates/**' } } } diff --git a/test/freenet/clients/http/templates/pebble-utils-test-l10n.html b/test/freenet/clients/http/templates/pebble-utils-test-l10n.html new file mode 100644 index 00000000000..80a30752d4e --- /dev/null +++ b/test/freenet/clients/http/templates/pebble-utils-test-l10n.html @@ -0,0 +1 @@ +{{ l10n('testKey') }} diff --git a/test/freenet/clients/http/templates/pebble-utils-test-simple.html b/test/freenet/clients/http/templates/pebble-utils-test-simple.html new file mode 100644 index 00000000000..3ee671165b1 --- /dev/null +++ b/test/freenet/clients/http/templates/pebble-utils-test-simple.html @@ -0,0 +1 @@ +Test! diff --git a/test/freenet/clients/http/utils/PebbleUtilsTest.java b/test/freenet/clients/http/utils/PebbleUtilsTest.java new file mode 100644 index 00000000000..96efae12c15 --- /dev/null +++ b/test/freenet/clients/http/utils/PebbleUtilsTest.java @@ -0,0 +1,30 @@ +package freenet.clients.http.utils; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import freenet.support.HTMLNode; +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +public class PebbleUtilsTest { + + @Test + public void addChildAddsCorrectlyEvaluatedSimpleTemplateToHtmlNode() throws IOException { + PebbleUtils.addChild(emptyParentNode, "pebble-utils-test-simple", model, null); + assertThat(emptyParentNode.generate(), equalTo("Test!\n")); + } + + @Test + public void addChildAddsCorrectlyEvaluatedTemplateWithL10nFunctionToHtmlNode() throws IOException { + PebbleUtils.addChild(emptyParentNode, "pebble-utils-test-l10n", model, "pebble-utils-tests."); + assertThat(emptyParentNode.generate(), equalTo("Test Value")); + } + + private final HTMLNode emptyParentNode = new HTMLNode("#"); + private final Map model = new HashMap<>(); + +} diff --git a/test/freenet/l10n/freenet.l10n.en.properties b/test/freenet/l10n/freenet.l10n.en.properties index 73d13e2f29c..dd99f9d38fc 100644 --- a/test/freenet/l10n/freenet.l10n.en.properties +++ b/test/freenet/l10n/freenet.l10n.en.properties @@ -11,4 +11,5 @@ test.missingBraceSubstitution=${ok}Text${/ok} and ${broken substitution test.unmatchedCloseSubstitution=${ok}Text${/ok} and ${/close} test.badSubstitutionFallback=Fallback ${tag} test.l10nFunctionTest=Localized Value +pebble-utils-tests.testKey=Test Value End From e1f09e1cc227e560b86631fc9f018d2829ed648a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 20:13:09 +0200 Subject: [PATCH 106/500] Show the noderef in basic-mode: it is now robust enough Previously the noderef was hidden in basic mode to get people to send it as file, because line terminators made problems (\n vs \r\n vs \r) and inserted linebreaks broke the noderef. It has been made much more resilient since then, so the added click is now a bigger problem than potential breakage due to corruption. --- src/freenet/clients/http/DarknetAddRefToadlet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/clients/http/DarknetAddRefToadlet.java b/src/freenet/clients/http/DarknetAddRefToadlet.java index 9c4b865becd..f8e4d1105eb 100644 --- a/src/freenet/clients/http/DarknetAddRefToadlet.java +++ b/src/freenet/clients/http/DarknetAddRefToadlet.java @@ -86,7 +86,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c ConnectionsToadlet.drawAddPeerBox(contentNode, ctx, false, friendsToadlet.path()); - friendsToadlet.drawNoderefBox(contentNode, getNoderef(), pageMaker.advancedMode(request, this.container)); + friendsToadlet.drawNoderefBox(contentNode, getNoderef(), true); this.writeHTMLReply(ctx, 200, "OK", pageNode.generate()); } From 9449e36374df203270d0fb613f6222a01da3d0a5 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 20:16:10 +0200 Subject: [PATCH 107/500] Add generate media site to the default bookmarks --- src/freenet/clients/http/staticfiles/defaultbookmarks.dat | 7 ++++++- src/freenet/l10n/freenet.l10n.en.properties | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index 3306434b3e2..dcc2f745457 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -21,7 +21,7 @@ BookmarkCategory0.Content.Bookmark2.hasAnActivelink=true BookmarkCategory0.Content.Bookmark2.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsVfWQ-HQo,cJrPvdNz4AnrHJQXNteDV7k3YnAVY-MClt84gwH2qEo,AQACAAE/freenet-first-steps/23/ BookmarkCategory1.Name=L10N:categorySoftware BookmarkCategory1.Content.BookmarkCategory=0 -BookmarkCategory1.Content.Bookmark=7 +BookmarkCategory1.Content.Bookmark=8 BookmarkCategory1.Content.Bookmark0.Name=Freenet Message System BookmarkCategory1.Content.Bookmark0.Description=L10N:FMS BookmarkCategory1.Content.Bookmark0.ShortDescription=L10N:FMS @@ -57,6 +57,11 @@ BookmarkCategory1.Content.Bookmark6.Name=Sharesite BookmarkCategory1.Content.Bookmark6.Description=L10N:Sharesite BookmarkCategory1.Content.Bookmark6.ShortDescription=L10N:Sharesite BookmarkCategory1.Content.Bookmark6.hasAnActivelink=true +BookmarkCategory1.Content.Bookmark7.URI=USK@rQnuHCVpf7BHcsZHBt911K3-iaELN1u1Vg0fzxDRq7k,I1vFYWONhGfECHr9XD-1lKxxstr64rF4dTykcMq9swY,AQACAAE/gms/28/ +BookmarkCategory1.Content.Bookmark7.Name=Generate Media Site +BookmarkCategory1.Content.Bookmark7.Description=L10N:GenerateMediaSite +BookmarkCategory1.Content.Bookmark7.ShortDescription=L10N:GenerateMediaSite +BookmarkCategory1.Content.Bookmark7.hasAnActivelink=true BookmarkCategory2.Name=L10N:categoryDocumentation BookmarkCategory2.Content.BookmarkCategory=0 BookmarkCategory2.Content.Bookmark=11 diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index e4c8dbc7aa4..474d0e00faa 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -121,6 +121,7 @@ Bookmarks.Defaults.Description.freenetdocwiki=A Wiki about Freenet (needs some t Bookmarks.Defaults.Description.FSNG=An illustrated guide to setting up social networking tools Bookmarks.Defaults.Description.jSite=Tool for uploading freesites (Freenet websites) Bookmarks.Defaults.Description.Sharesite=Plugin to publish simple Freesites with minimal effort. +Bookmarks.Defaults.Description.GenerateMediaSite=Tool to create video- or audio-on-demand sites that start playing right-away Bookmarks.Defaults.Description.Flog.Toad=Toad's flog Bookmarks.Defaults.Description.Flog.Bombe=Bombe's flog Bookmarks.Defaults.Description.Flog.Xor=Flog of the main Freetalk & Web Of Trust developer @@ -148,6 +149,7 @@ Bookmarks.Defaults.ShortDescription.freenetdocwiki=Freenet documentation wiki Bookmarks.Defaults.ShortDescription.FSNG=Step by step guide to how to set up anonymous email, forums, chat, social tools etc on Freenet. Strongly recommended! Bookmarks.Defaults.ShortDescription.jSite=Essential tool for uploading websites to Freenet Bookmarks.Defaults.ShortDescription.Sharesite=Plugin that manages a list of sites for which you only need to set title and content, save and click insert. The rest is done by the plugin. +Bookmarks.Defaults.ShortDescription.GenerateMediaSite=Tool to create video- or audio-freesites. Bookmarks.Defaults.ShortDescription.Flog.Toad=Former chief Freenet developer's personal blog Bookmarks.Defaults.ShortDescription.Flog.Bombe=Sone developer's personal blog Bookmarks.Defaults.ShortDescription.Flog.Xor=Freetalk and Web of Trust developer's blog From 94faffea02094a24219edd9e86a401a20e04e928 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 20:19:28 +0200 Subject: [PATCH 108/500] Re-order default software bookmarks by ease of use from fproxy --- .../http/staticfiles/defaultbookmarks.dat | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index dcc2f745457..f8944fe1429 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -22,40 +22,40 @@ BookmarkCategory0.Content.Bookmark2.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsV BookmarkCategory1.Name=L10N:categorySoftware BookmarkCategory1.Content.BookmarkCategory=0 BookmarkCategory1.Content.Bookmark=8 -BookmarkCategory1.Content.Bookmark0.Name=Freenet Message System -BookmarkCategory1.Content.Bookmark0.Description=L10N:FMS -BookmarkCategory1.Content.Bookmark0.ShortDescription=L10N:FMS +BookmarkCategory1.Content.Bookmark0.URI=USK@dCnkUL22fAmKbKg-Cftx9j2m4IwyWB0QbGoiq1RSLP8,4d1TDqwRr4tYlsubLrQK~c4h0~FtmE-OXCDmFiI8BB4,AQACAAE/Sharesite/36/ +BookmarkCategory1.Content.Bookmark0.Name=Sharesite +BookmarkCategory1.Content.Bookmark0.Description=L10N:Sharesite +BookmarkCategory1.Content.Bookmark0.ShortDescription=L10N:Sharesite BookmarkCategory1.Content.Bookmark0.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark0.URI=USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/153/ -BookmarkCategory1.Content.Bookmark1.Name=Freemail -BookmarkCategory1.Content.Bookmark1.Description=L10N:Freemail -BookmarkCategory1.Content.Bookmark1.ShortDescription=L10N:Freemail +BookmarkCategory1.Content.Bookmark1.Name=Sone +BookmarkCategory1.Content.Bookmark1.Description=L10N:Sone +BookmarkCategory1.Content.Bookmark1.ShortDescription=L10N:Sone +BookmarkCategory1.Content.Bookmark1.URI=USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/82/ BookmarkCategory1.Content.Bookmark1.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark1.URI=USK@cZu5Jx1eTvsN-p0c22uD3y3DvjKwv6bPRIHlCM5~4zQ,IOBbCUJWoNsYYPYcmscE70tFM-QjfWFW~myTPbeGIHg,AQACAAE/index/2/ -BookmarkCategory1.Content.Bookmark2.Name=Sone -BookmarkCategory1.Content.Bookmark2.Description=L10N:Sone -BookmarkCategory1.Content.Bookmark2.ShortDescription=L10N:Sone -BookmarkCategory1.Content.Bookmark2.URI=USK@nwa8lHa271k2QvJ8aa0Ov7IHAV-DFOCFgmDt3X6BpCI,DuQSUZiI~agF8c-6tjsFFGuZ8eICrzWCILB60nT8KKo,AQACAAE/sone/82/ +BookmarkCategory1.Content.Bookmark2.Name=Freemail +BookmarkCategory1.Content.Bookmark2.Description=L10N:Freemail +BookmarkCategory1.Content.Bookmark2.ShortDescription=L10N:Freemail BookmarkCategory1.Content.Bookmark2.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark3.URI=USK@1waTsw46L9-JEQ8yX1khjkfHcn--g0MlMsTlYHax9zQ,oYyxr5jyFnaTsVGDQWk9e3ddOWGKnqEASxAk08MHT2Y,AQACAAE/jSite/17/ -BookmarkCategory1.Content.Bookmark3.Name=jSite -BookmarkCategory1.Content.Bookmark3.Description=L10N:jSite -BookmarkCategory1.Content.Bookmark3.ShortDescription=L10N:jSite +BookmarkCategory1.Content.Bookmark2.URI=USK@cZu5Jx1eTvsN-p0c22uD3y3DvjKwv6bPRIHlCM5~4zQ,IOBbCUJWoNsYYPYcmscE70tFM-QjfWFW~myTPbeGIHg,AQACAAE/index/2/ +BookmarkCategory1.Content.Bookmark3.URI=USK@MYLAnId-ZEyXhDGGbYOa1gOtkZZrFNTXjFl1dibLj9E,Xpu27DoAKKc8b0718E-ZteFrGqCYROe7XBBJI57pB4M,AQACAAE/Shoeshop/3/ +BookmarkCategory1.Content.Bookmark3.Name=Shoeshop +BookmarkCategory1.Content.Bookmark3.Description=L10N:Shoeshop +BookmarkCategory1.Content.Bookmark3.ShortDescription=L10N:Shoeshop BookmarkCategory1.Content.Bookmark3.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark4.URI=USK@MYLAnId-ZEyXhDGGbYOa1gOtkZZrFNTXjFl1dibLj9E,Xpu27DoAKKc8b0718E-ZteFrGqCYROe7XBBJI57pB4M,AQACAAE/Shoeshop/3/ -BookmarkCategory1.Content.Bookmark4.Name=Shoeshop -BookmarkCategory1.Content.Bookmark4.Description=L10N:Shoeshop -BookmarkCategory1.Content.Bookmark4.ShortDescription=L10N:Shoeshop +BookmarkCategory1.Content.Bookmark4.URI=USK@1waTsw46L9-JEQ8yX1khjkfHcn--g0MlMsTlYHax9zQ,oYyxr5jyFnaTsVGDQWk9e3ddOWGKnqEASxAk08MHT2Y,AQACAAE/jSite/17/ +BookmarkCategory1.Content.Bookmark4.Name=jSite +BookmarkCategory1.Content.Bookmark4.Description=L10N:jSite +BookmarkCategory1.Content.Bookmark4.ShortDescription=L10N:jSite BookmarkCategory1.Content.Bookmark4.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark5.URI=USK@pGQPA-9PcFiE3A2tCuCjacK165UaX07AQYw98iDQrNA,8gwQ67ytBNR03hNj7JU~ceeew22HVq6G50dcEeMcgks,AQACAAE/flip/17/ -BookmarkCategory1.Content.Bookmark5.Name=FLIP -BookmarkCategory1.Content.Bookmark5.Description=L10N:FLIP -BookmarkCategory1.Content.Bookmark5.ShortDescription=L10N:FLIP +BookmarkCategory1.Content.Bookmark5.Name=Freenet Message System +BookmarkCategory1.Content.Bookmark5.Description=L10N:FMS +BookmarkCategory1.Content.Bookmark5.ShortDescription=L10N:FMS BookmarkCategory1.Content.Bookmark5.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark6.URI=USK@dCnkUL22fAmKbKg-Cftx9j2m4IwyWB0QbGoiq1RSLP8,4d1TDqwRr4tYlsubLrQK~c4h0~FtmE-OXCDmFiI8BB4,AQACAAE/Sharesite/36/ -BookmarkCategory1.Content.Bookmark6.Name=Sharesite -BookmarkCategory1.Content.Bookmark6.Description=L10N:Sharesite -BookmarkCategory1.Content.Bookmark6.ShortDescription=L10N:Sharesite +BookmarkCategory1.Content.Bookmark5.URI=USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/153/ +BookmarkCategory1.Content.Bookmark6.URI=USK@pGQPA-9PcFiE3A2tCuCjacK165UaX07AQYw98iDQrNA,8gwQ67ytBNR03hNj7JU~ceeew22HVq6G50dcEeMcgks,AQACAAE/flip/17/ +BookmarkCategory1.Content.Bookmark6.Name=FLIP +BookmarkCategory1.Content.Bookmark6.Description=L10N:FLIP +BookmarkCategory1.Content.Bookmark6.ShortDescription=L10N:FLIP BookmarkCategory1.Content.Bookmark6.hasAnActivelink=true BookmarkCategory1.Content.Bookmark7.URI=USK@rQnuHCVpf7BHcsZHBt911K3-iaELN1u1Vg0fzxDRq7k,I1vFYWONhGfECHr9XD-1lKxxstr64rF4dTykcMq9swY,AQACAAE/gms/28/ BookmarkCategory1.Content.Bookmark7.Name=Generate Media Site From 53b9bd9d63af7f02995355fd520f0ceea57754b1 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 20:23:06 +0200 Subject: [PATCH 109/500] =?UTF-8?q?Reorder=20starting=20bookmarks:=20FFS?= =?UTF-8?q?=20=E2=86=92=20clean=20spider=20=E2=86=92=20Index=20of=20Indexe?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/staticfiles/defaultbookmarks.dat | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index f8944fe1429..5aa4ea688cf 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -4,21 +4,21 @@ Bookmark=0 BookmarkCategory0.Name=L10N:categoryStarting BookmarkCategory0.Content.BookmarkCategory=0 BookmarkCategory0.Content.Bookmark=3 -BookmarkCategory0.Content.Bookmark0.Name=Clean Spider -BookmarkCategory0.Content.Bookmark0.Description=L10N:CleanSpider -BookmarkCategory0.Content.Bookmark0.ShortDescription=L10N:CleanSpider +BookmarkCategory0.Content.Bookmark0.Name=Freenet First Steps +BookmarkCategory0.Content.Bookmark0.ShortDescription=L10N:FFS +BookmarkCategory0.Content.Bookmark0.Description=L10N:FFS BookmarkCategory0.Content.Bookmark0.hasAnActivelink=true -BookmarkCategory0.Content.Bookmark0.URI=USK@5ijbfKSJ4kPZTRDzq363CHteEUiSZjrO-E36vbHvnIU,ZEZqPXeuYiyokY2r0wkhJr5cy7KBH9omkuWDqSC6PLs,AQACAAE/clean-spider/129/ -BookmarkCategory0.Content.Bookmark1.Name=Index of Indexes -BookmarkCategory0.Content.Bookmark1.ShortDescription=L10N:JFnikiIndex -BookmarkCategory0.Content.Bookmark1.Description=L10N:JFnikiIndex +BookmarkCategory0.Content.Bookmark0.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsVfWQ-HQo,cJrPvdNz4AnrHJQXNteDV7k3YnAVY-MClt84gwH2qEo,AQACAAE/freenet-first-steps/23/ +BookmarkCategory0.Content.Bookmark1.Name=Clean Spider +BookmarkCategory0.Content.Bookmark1.Description=L10N:CleanSpider +BookmarkCategory0.Content.Bookmark1.ShortDescription=L10N:CleanSpider BookmarkCategory0.Content.Bookmark1.hasAnActivelink=true -BookmarkCategory0.Content.Bookmark1.URI=USK@t-YmshUm43nS16QFieoZMfBdfieb9Opy0a2aMWsoH8o,7NqDX88r1R4SC~elmpW4SuKbnAOka~MKUuBufUWa2xQ,AQACAAE/jFniki.Index/8/Index_of_Indexes.html -BookmarkCategory0.Content.Bookmark2.Name=Freenet First Steps -BookmarkCategory0.Content.Bookmark2.ShortDescription=L10N:FFS -BookmarkCategory0.Content.Bookmark2.Description=L10N:FFS +BookmarkCategory0.Content.Bookmark1.URI=USK@5ijbfKSJ4kPZTRDzq363CHteEUiSZjrO-E36vbHvnIU,ZEZqPXeuYiyokY2r0wkhJr5cy7KBH9omkuWDqSC6PLs,AQACAAE/clean-spider/129/ +BookmarkCategory0.Content.Bookmark2.Name=Index of Indexes +BookmarkCategory0.Content.Bookmark2.ShortDescription=L10N:JFnikiIndex +BookmarkCategory0.Content.Bookmark2.Description=L10N:JFnikiIndex BookmarkCategory0.Content.Bookmark2.hasAnActivelink=true -BookmarkCategory0.Content.Bookmark2.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsVfWQ-HQo,cJrPvdNz4AnrHJQXNteDV7k3YnAVY-MClt84gwH2qEo,AQACAAE/freenet-first-steps/23/ +BookmarkCategory0.Content.Bookmark2.URI=USK@t-YmshUm43nS16QFieoZMfBdfieb9Opy0a2aMWsoH8o,7NqDX88r1R4SC~elmpW4SuKbnAOka~MKUuBufUWa2xQ,AQACAAE/jFniki.Index/8/Index_of_Indexes.html BookmarkCategory1.Name=L10N:categorySoftware BookmarkCategory1.Content.BookmarkCategory=0 BookmarkCategory1.Content.Bookmark=8 From 29c4a46ff60159a42e5db4f08e576015dc0d95bd Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 20:32:48 +0200 Subject: [PATCH 110/500] bookmarks: Add Opennet SeedNodes stats --- src/freenet/clients/http/staticfiles/defaultbookmarks.dat | 5 +++++ src/freenet/l10n/freenet.l10n.en.properties | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index 5aa4ea688cf..f8727655333 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -120,6 +120,11 @@ BookmarkCategory2.Content.Bookmark10.Name=Infocalypse and pyFreenet BookmarkCategory2.Content.Bookmark10.Description=L10N:InfocalypsePyFreenet BookmarkCategory2.Content.Bookmark10.ShortDescription=L10N:InfocalypsePyFreenet BookmarkCategory2.Content.Bookmark10.hasAnActivelink=true +BookmarkCategory2.Content.Bookmark11.URI=USK@SYsHNvVtTUa5h12MnZ9Bvqhyk9yTma2~IKk2uFk1HMo,7k4bmQkXE-oxbjeUPKy1QZkPWfLDkNB8XR-2EpEs-eY,AQACAAE/opennet-seednodes-stats/3/ +BookmarkCategory2.Content.Bookmark11.Name=Opennet SeedNodes Uptime Statistics +BookmarkCategory2.Content.Bookmark11.Description=L10N:SeedNodesUptimeStats +BookmarkCategory2.Content.Bookmark11.ShortDescription=L10N:SeedNodesUptimeStats +BookmarkCategory2.Content.Bookmark11.hasAnActivelink=true BookmarkCategory3.Name=L10N:categoryBlogs BookmarkCategory3.Content.BookmarkCategory=0 BookmarkCategory3.Content.Bookmark=5 diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 474d0e00faa..b7fb3c50097 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -122,6 +122,7 @@ Bookmarks.Defaults.Description.FSNG=An illustrated guide to setting up social ne Bookmarks.Defaults.Description.jSite=Tool for uploading freesites (Freenet websites) Bookmarks.Defaults.Description.Sharesite=Plugin to publish simple Freesites with minimal effort. Bookmarks.Defaults.Description.GenerateMediaSite=Tool to create video- or audio-on-demand sites that start playing right-away +Bookmarks.Defaults.Description.SeedNodesUptimeStats=Statistics about the Seednodes needed for the initial connection into Opennet. Bookmarks.Defaults.Description.Flog.Toad=Toad's flog Bookmarks.Defaults.Description.Flog.Bombe=Bombe's flog Bookmarks.Defaults.Description.Flog.Xor=Flog of the main Freetalk & Web Of Trust developer @@ -150,6 +151,7 @@ Bookmarks.Defaults.ShortDescription.FSNG=Step by step guide to how to set up ano Bookmarks.Defaults.ShortDescription.jSite=Essential tool for uploading websites to Freenet Bookmarks.Defaults.ShortDescription.Sharesite=Plugin that manages a list of sites for which you only need to set title and content, save and click insert. The rest is done by the plugin. Bookmarks.Defaults.ShortDescription.GenerateMediaSite=Tool to create video- or audio-freesites. +Bookmarks.Defaults.ShortDescription.SeedNodesUptimeStats=Uptime statistics for the Opennet Seednodes Bookmarks.Defaults.ShortDescription.Flog.Toad=Former chief Freenet developer's personal blog Bookmarks.Defaults.ShortDescription.Flog.Bombe=Sone developer's personal blog Bookmarks.Defaults.ShortDescription.Flog.Xor=Freetalk and Web of Trust developer's blog From 37f251d2b085d11aa0963b73b8488b5f9747378a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 21:21:16 +0200 Subject: [PATCH 111/500] Update debian/freenet.init from the output of running on debian --- debian/freenet.init | 122 +++++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 46 deletions(-) diff --git a/debian/freenet.init b/debian/freenet.init index 0d96abfd0c3..83baebd24e9 100644 --- a/debian/freenet.init +++ b/debian/freenet.init @@ -1,7 +1,7 @@ #! /bin/sh # -# Copyright (c) 1999, 2016 Tanuki Software, Ltd. +# Copyright (c) 1999, 2022 Tanuki Software, Ltd. # http://www.tanukisoftware.com # All rights reserved. # @@ -12,38 +12,49 @@ # # Java Service Wrapper sh script. Suitable for starting and stopping # wrapped Java applications on UNIX platforms. +# Optimized for use with version 3.5.51 of the Wrapper. # #----------------------------------------------------------------------------- # These settings can be modified to fit the needs of your application -# Optimized for use with version 3.5.30 of the Wrapper. # IMPORTANT - Please always stop and uninstall an application before making # any changes to this file. Failure to do so could remove the # script's ability to control the application. +# NOTE - After loading the variables below, the script will attempt to locate a +# file with the same basename as this script and having a '.shconf' extension. +# If such file exists, it will be executed giving the user a chance to +# override the default settings. Having the customized configuration in a +# separate '.shconf' file makes it easier to upgrade the Wrapper, as the +# present script file can then be replaced with minimal changes (although at +# least the 'INIT INFO' below needs to be updated). + # Initialization block for the install_initd and remove_initd scripts used by -# SUSE linux, CentOS and RHEL distributions. +# SUSE linux, CentOS and RHEL distributions. Also used by update-rc.d. # Note: From CentOS 6, make sure the BEGIN INIT INFO section is before any line # of code otherwise the service won't be displayed in the Service # Configuration GUI. ### BEGIN INIT INFO # Provides: freenet -# Required-Start: $local_fs $network $syslog -# Should-Start: -# Required-Stop: +# Required-Start: $remote_fs $syslog +# Should-Start: $network $time +# Should-Stop: $network $time +# Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Freenet 0.7.5 build 1497 (experimental release) # Description: Freenet reference daemon ### END INIT INFO -# Application +# Application name and long name: If these variables are not set (or left to +# the default tokens), APP_NAME will default to the name of the script, then +# APP_LONG_NAME will default to the value of APP_NAME. APP_NAME="freenet" APP_LONG_NAME="Freenet 0.7.5 build 1497 (experimental release)" # If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer -# be passed to the wrapper. See documentation for details. +# be passed to the wrapper. See documentation for details. #APP_NAME_PASS_TO_WRAPPER=false # Wrapper @@ -64,14 +75,25 @@ PIDDIR="/var/run/freenet" PIDFILE_CHECK_PID=true # FIXED_COMMAND tells the script to use a hard coded action rather than -# expecting the first parameter of the command line to be the command. -# By default the command will will be expected to be the first parameter. +# expecting the first parameter of the command line to be the command. +# By default the command will be expected to be the first parameter. #FIXED_COMMAND=console -# PASS_THROUGH tells the script to pass all arguments through to the JVM -# as is. If FIXED_COMMAND is specified then all arguments will be passed. -# If not set then all arguments starting with the second will be passed. -#PASS_THROUGH=true +# PASS_THROUGH controls how the script arguments should be passed to the +# Wrapper. Possible values are: +# - commented or 'false': the arguments will be ignored (not passed). +# - 'app_args' or 'true': the arguments will be passed through the Wrapper as +# arguments for the Java Application. +# - 'both': both Wrapper properties and Application arguments can be passed to +# the Wrapper. The Wrapper properties come in first position. The +# user can optionally add a '--' separator followed by application +# arguments. +# NOTE - If FIXED_COMMAND is set to true the above applies to all arguments, +# otherwise it applies to arguments starting with the second. +# NOTE - Passing arguments is only valid with the following commands: +# - 'console' +# - 'start', 'restart', 'condrestart' (if not installed as a daemon) +#PASS_THROUGH=app_args # If uncommented, causes the Wrapper to be shutdown using an anchor file. # When launched with the 'start' command, it will also ignore all INT and @@ -84,7 +106,6 @@ PIDFILE_CHECK_PID=true # startup scripts. Setting WAIT_AFTER_STARTUP to a positive number will # cause the start command to delay for the indicated period of time # (in seconds). -# WAIT_AFTER_STARTUP=0 # If set, wait for the wrapper to report that the daemon has started @@ -101,56 +122,65 @@ WAIT_FOR_STARTED_TIMEOUT=120 # properties for more information. #PAUSABLE=true -# If specified, the Wrapper will be run as the specified user. +# Set the mode used to 'pause' or 'resume' the Wrapper. Possible values are +# 'signals' which uses SIGUSR1 and SIGUSR2, and 'file' which uses the command +# file to communicate these actions. The default value is 'signals'. +# Be aware that depending on the mode, the properties wrapper.signal.mode.usr1, +# wrapper.signal.mode.usr2, or wrapper.commandfile of the configuration file may +# be overriden. +#PAUSABLE_MODE=signals + +# If set, the Wrapper will be run as the specified user. # IMPORTANT - Make sure that the user has the required privileges to write # the PID file and wrapper.log files. Failure to be able to write the log # file will cause the Wrapper to exit without any way to write out an error # message. -# NOTE - This will set the user which is used to run the Wrapper as well as +# NOTES - This will set the user which is used to run the Wrapper as well as # the JVM and is not useful in situations where a privileged resource or # port needs to be allocated prior to the user being changed. +# - Setting this variable will cause stdin to be closed. While this +# should not be a problem when running as Daemon, it would disable ability +# for console applications to receive inputs. RUN_AS_USER="freenet" -# Set the full path to the 'su' command (substitute user). -# NOTE - In case 'su' is not in the PATH, you can set the absolute path here, -# for example: -# SU_BIN=/bin/su -# NOTE - For Red Hat, the script will use '/sbin/runuser' if it is present and -# ignore the value of SU_BIN. -SU_BIN=su - -# Set option for 'su'. -# In case the user set in RUN_AS_USER has no bash set, the 'su' command will fail. -# The workaround for GNU/Linux system is to specify which bash to use with -# the '-s' option. +# When RUN_AS_USER is set, the 'runuser' command will be used to substitute the +# user. If not present on the machine, 'su' will be used as a fallback. +# The parameter below lets you specify option(s) for the 'runuser' (or 'su') +# command. +# NOTES - The '-u' option is not allowed. Please set the user with RUN_AS_USER. +# - On GNU/Linux systems, if the user specified by RUN_AS_USER doesn't +# have a default shell please specify one with the '-s' option. #SU_OPTS="-s /bin/bash" -# Set the full path to the 'id' command. -# For example: -# ID_BIN=/usr/bin/id -ID_BIN=id - # By default we show a detailed usage block. Uncomment to show brief usage. #BRIEF_USAGE=true -# OS service management tool: flag for using Upstart when installing (rather than init.d rc.d). -USE_UPSTART= - -# OS service management tool: flag for using systemd when installing. -USE_SYSTEMD= - -# Flag for AIX to start/stop the Wrapper without using the System Resource -# Controller (SRC).This is useful when you want to start the Wrapper as a -# daemon without installation or when APP_NAME is longer than 14 chars. -SKIP_SRC= +# Set which service management tool to use. +# Possible values are: +# for linux...: auto, systemd, upstart, initd +# for aix.....: auto, src, initd +# When set to 'auto', this script file will try to detect in the order of the +# list for each platform which service management tool to use to install the Wrapper. +SERVICE_MANAGEMENT_TOOL=auto + +# Specify how the Wrapper daemon and its child processes should be killed +# when using systemd. +# The default is 'control-group' which tells systemd to kill all child +# processes (including detached ones) in the control group of the daemon +# when it stops. +# Alternatively, 'process' can be specified to prevent systemd from +# killing the child processes leaving this responsibility to the Wrapper. +# In this case child processes marked as 'detached' will not be killed on shutdown. +# NOTE - the daemon must be reinstalled for any changes on this property to take effect. +SYSTEMD_KILLMODE=control-group # When installing on Mac OSX platforms, the following domain will be used to # prefix the plist file name. PLIST_DOMAIN=org.tanukisoftware.wrapper # When installing on Mac OSX platforms, this parameter controls whether the daemon -# is to be kept continuously running or to let demand and conditions control the -# invocation. +# is to be kept continuously running or to let demand and conditions control the +# invocation. MACOSX_KEEP_RUNNING="false" # The following two lines are used by the chkconfig command. Change as is From d5538eb6f23cd0e6805714749a444dddf5af7f0e Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 21:37:28 +0200 Subject: [PATCH 112/500] Version without -1 (try to get github runner working) --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index ffe614429d6..c0d123ea7a9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -freenet (0.7.5+1497-1) unstable; urgency=medium +freenet (0.7.5+1497) unstable; urgency=medium * Build 1497 From a8eda00611293f1db8498fcfc38f3393483290f8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 21:45:58 +0200 Subject: [PATCH 113/500] revert the version change --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c0d123ea7a9..ffe614429d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -freenet (0.7.5+1497) unstable; urgency=medium +freenet (0.7.5+1497-1) unstable; urgency=medium * Build 1497 From a5f0ed59741514dbb53eea58acd182d138211895 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 21:55:30 +0200 Subject: [PATCH 114/500] fix day of week in changelog --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index ffe614429d6..287221a42a2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ freenet (0.7.5+1497-1) unstable; urgency=medium * Build 1497 - -- Arne Tue, 07 Sep 2023 23:42:30 +0100 + -- Arne Thu, 07 Sep 2023 23:42:30 +0100 freenet (0.7.5+1494-7) unstable; urgency=medium From 6413e357fc3dc7947d4ae72f01050075429dcb5f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:05:23 +0200 Subject: [PATCH 115/500] hack: Do a local commit to get the package to work --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index da74f000381..cf6ff2ba4f5 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (sudo cat /tmp/freenet_0.7.5+*diff* && false) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (dpkg-source --commit && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From 2fcc3b69d64cc1fc6f488bf0d1b592efb2fd021a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:10:50 +0200 Subject: [PATCH 116/500] hack-1: Do a local commit to get the package to work --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index cf6ff2ba4f5..6d804754481 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (dpkg-source --commit && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From 27b308d8e58877b70a52b971e9bd4601433e9a64 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:20:35 +0200 Subject: [PATCH 117/500] noninteractive debian --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 6d804754481..30b6f367325 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (DEBIAN_FRONTEND=noninteractive dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From b097273a1ea855bac9d4c963af1b560fe5575c23 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:27:00 +0200 Subject: [PATCH 118/500] more hackery --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 30b6f367325..154699573f1 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (DEBIAN_FRONTEND=noninteractive dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From 184f7a8cab0d9a6261b3c08c42320a296892e659 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:34:28 +0200 Subject: [PATCH 119/500] hackmore: format the patch --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 154699573f1..cc293bbf0b5 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && git format-patch HEAD && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new && cat 0001*patch) - name: Get package info run: | From d98f89bcc2f0d58676aea6bf9dfdc1fccc50ac58 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:42:23 +0200 Subject: [PATCH 120/500] output format-patch directly --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index cc293bbf0b5..0cada48d5f3 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && git format-patch HEAD && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new && cat 0001*patch) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && git format-patch --stdout HEAD && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From 9fca1d206d5d2cd97cd273ca89e2e7efce50691a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:48:04 +0200 Subject: [PATCH 121/500] actually output the latest commit (HEAD^) --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 0cada48d5f3..2e21541627c 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && git format-patch --stdout HEAD && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && git format-patch --stdout HEAD^ && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From 845f4d4778e57d1aadacb1e8175467a985ab7158 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:51:01 +0200 Subject: [PATCH 122/500] output hack --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2e21541627c..aff8e9ebae9 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && git format-patch --stdout HEAD^ && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && cat fred/debian/patches/hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From bf86ad26ccc738e0ebe6786c285c1dfc299494b8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 22:56:27 +0200 Subject: [PATCH 123/500] =?UTF-8?q?don=E2=80=99t=20try=20to=20get=20the=20?= =?UTF-8?q?patch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index aff8e9ebae9..154699573f1 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && cat fred/debian/patches/hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) - name: Get package info run: | From 1ee38bc6e2d00254051d7d2d6aa92155b48dd716 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 3 Sep 2023 07:57:26 +0200 Subject: [PATCH 124/500] =?UTF-8?q?Switch=20swiss=20flag=20to=20civil=20an?= =?UTF-8?q?d=20state=20ensign=20=E2=80=94=20thanks=20to=20Percept0r@NY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this change the swiss flag matches the other flags in proportions, so it’s size matches the sizes of other flags in the "Connections to Strangers" view. thanks to Percept0r@NYZkOs7eQNLmiqWzm7YY8hFt-c7mUe3V~q6idbEsZjE for fixing the issue! --- .../clients/http/staticfiles/icon/flags/ch.png | Bin 367 -> 161 bytes 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/freenet/clients/http/staticfiles/icon/flags/ch.png diff --git a/src/freenet/clients/http/staticfiles/icon/flags/ch.png b/src/freenet/clients/http/staticfiles/icon/flags/ch.png old mode 100755 new mode 100644 index 242ec01aaf5ad351cb978a4eb650ad801a438b09..97e9af6da3a25b580531e683685c32f48a79a385 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~o!3-oFZT@ltDa8Pv5ZB+oe}Dh}{olWTzyJLH z`{(bEA3uKm`t|3}pPxT}{{8#+Jp)60Rbf3)v9+g*V@SoVqz6vSJQgf7EGz?AEi7+N zWSwCVc|-Dsg#go>Hwt#zP7QM?7U|?FE@Zm|i>fBlzF zc~M_qKf%h=bAcoS;}NE7f8|yFe%B9?;;8%o@BeG_!|(4qhyo=(h-XBmKHXpc{~y!A z`THH3fsDVeudko)ARzm9UL&JI!+~uEM*rBES1=kd6zV%LH0J*N$gIQAc0y}k9qTFv z4h1oVG?rB#zNY^8{QUp5wE>>R#S4NZQd1i@F)*?OF@6y}@zmk^!Gr7L9asuAf!ae1 z{{CbBBH Date: Sun, 3 Sep 2023 16:09:32 +0200 Subject: [PATCH 125/500] Remove no longer used showNoderef parameter --- .../clients/http/ConnectionsToadlet.java | 20 ++++++++----------- .../clients/http/DarknetAddRefToadlet.java | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/freenet/clients/http/ConnectionsToadlet.java b/src/freenet/clients/http/ConnectionsToadlet.java index eb5d752eff5..3c5cb072bb4 100644 --- a/src/freenet/clients/http/ConnectionsToadlet.java +++ b/src/freenet/clients/http/ConnectionsToadlet.java @@ -588,7 +588,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c // our reference if(shouldDrawNoderefBox(advancedMode)) { drawAddPeerBox(contentNode, ctx); - drawNoderefBox(contentNode, getNoderef(), true); + drawNoderefBox(contentNode, getNoderef()); } this.writeHTMLReply(ctx, 200, "OK", pageNode.generate()); @@ -863,13 +863,10 @@ protected void handleAltPost(URI uri, HTTPRequest request, ToadletContext ctx, b final HTMLNode REFTEXT_LINK; /** - * * @param contentNode Node to add noderef box to. * @param fs Noderef to render as text if requested. - * @param showNoderef If true, render the text of the noderef so that it may be copy-pasted. If false, only - * show a link to download it. */ - void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs, boolean showNoderef) { + void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs) { HTMLNode referenceInfobox = contentNode.addChild("div", "class", "infobox infobox-normal"); HTMLNode headerReferenceInfobox = referenceInfobox.addChild("div", "class", "infobox-header"); // FIXME better way to deal with this sort of thing??? @@ -888,13 +885,12 @@ void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs, boolean showNoderef myName.addChild("span", "]"); } - if (showNoderef) { - HTMLNode warningSentence = referenceInfoboxContent.addChild("p"); - NodeL10n.getBase().addL10nSubstitution(warningSentence, "DarknetConnectionsToadlet.referenceCopyWarning", - new String[] { "bold" }, - new HTMLNode[] { HTMLNode.STRONG }); - referenceInfoboxContent.addChild("pre", "id", "reference", fs.toOrderedStringWithBase64() + '\n'); - } + HTMLNode warningSentence = referenceInfoboxContent.addChild("p"); + NodeL10n.getBase().addL10nSubstitution(warningSentence, "DarknetConnectionsToadlet.referenceCopyWarning", + new String[] { "bold" }, + new HTMLNode[] { HTMLNode.STRONG }); + referenceInfoboxContent.addChild("pre", "id", "reference", fs.toOrderedStringWithBase64() + '\n'); + } protected abstract String getPageTitle(String titleCountString); diff --git a/src/freenet/clients/http/DarknetAddRefToadlet.java b/src/freenet/clients/http/DarknetAddRefToadlet.java index f8e4d1105eb..5b6c7e6bbe9 100644 --- a/src/freenet/clients/http/DarknetAddRefToadlet.java +++ b/src/freenet/clients/http/DarknetAddRefToadlet.java @@ -86,7 +86,7 @@ public void handleMethodGET(URI uri, final HTTPRequest request, ToadletContext c ConnectionsToadlet.drawAddPeerBox(contentNode, ctx, false, friendsToadlet.path()); - friendsToadlet.drawNoderefBox(contentNode, getNoderef(), true); + friendsToadlet.drawNoderefBox(contentNode, getNoderef()); this.writeHTMLReply(ctx, 200, "OK", pageNode.generate()); } From 0bdd0d0484a34568e1b8c8d499dc568cc51fdf07 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 24 Aug 2023 19:56:04 +0200 Subject: [PATCH 126/500] Show the unencoded IP addresses before the noderef MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This shows what the noderef will expose and can be an important warning to advanced users who have VPN addresses and real node addresses that they don’t want to show. (in this case they’ll have to change the bindTo to the one address to use in the config) --- src/freenet/clients/http/ConnectionsToadlet.java | 6 ++++++ src/freenet/l10n/freenet.l10n.en.properties | 1 + 2 files changed, 7 insertions(+) diff --git a/src/freenet/clients/http/ConnectionsToadlet.java b/src/freenet/clients/http/ConnectionsToadlet.java index eb5d752eff5..bc28d120e54 100644 --- a/src/freenet/clients/http/ConnectionsToadlet.java +++ b/src/freenet/clients/http/ConnectionsToadlet.java @@ -895,6 +895,12 @@ void drawNoderefBox(HTMLNode contentNode, SimpleFieldSet fs, boolean showNoderef new HTMLNode[] { HTMLNode.STRONG }); referenceInfoboxContent.addChild("pre", "id", "reference", fs.toOrderedStringWithBase64() + '\n'); } + + if(!isOpennet()) { + HTMLNode myIps = referenceInfoboxContent.addChild("p"); + myIps.addChild("span", NodeL10n.getBase().getString("DarknetConnectionsToadlet.myIps", "ips", fs.get("physical.udp"))); + } + } protected abstract String getPageTitle(String titleCountString); diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index e4c8dbc7aa4..9719356032f 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -346,6 +346,7 @@ DarknetConnectionsToadlet.foafReachableThroughTitle=Reachable Through DarknetConnectionsToadlet.connError=Connection failed (buggy node?) DarknetConnectionsToadlet.routingDisabled=Not routing traffic (we are currently connected to the node but we or it refuse to route traffic) DarknetConnectionsToadlet.routingDisabledShort=Not routing traffic +DarknetConnectionsToadlet.myIps=The physical.udp field of the noderef contains the IP addresses ${ips}. To change this, set bindTo=THE_ADDRESSES (comma separated) in the file freenet.ini (the node must be stopped before editing). DarknetConnectionsToadlet.noLoadStats=Don't know how many requests we can send so can't send any DarknetConnectionsToadlet.noLoadStatsShort=No load stats DarknetConnectionsToadlet.myName=Nickname for this node: ${name} From c610408ad2e1695aa2962b7faabd32c72e8d8999 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 23 May 2023 08:01:51 +0200 Subject: [PATCH 127/500] Provide default Key Type for File Insert In order: - if seclevel maximum: always SSK - last selection (CHK or SSK), if available - otherwise SSK --- src/freenet/clients/http/FileInsertWizardToadlet.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/freenet/clients/http/FileInsertWizardToadlet.java b/src/freenet/clients/http/FileInsertWizardToadlet.java index 37beaeb2971..3d05f3ed8a7 100644 --- a/src/freenet/clients/http/FileInsertWizardToadlet.java +++ b/src/freenet/clients/http/FileInsertWizardToadlet.java @@ -87,11 +87,13 @@ private HTMLNode createInsertBox (PageMaker pageMaker, ToadletContext ctx, boole insertContent.addChild("p", l10n("insertIntro")); NETWORK_THREAT_LEVEL seclevel = core.node.securityLevels.getNetworkThreatLevel(); HTMLNode insertForm = ctx.addFormChild(insertContent, QueueToadlet.PATH_UPLOADS, "queueInsertForm"); + boolean preselectSsk = (!rememberedLastTime && seclevel != NETWORK_THREAT_LEVEL.LOW) + || (rememberedLastTime && !wasCanonicalLastTime) + || seclevel == NETWORK_THREAT_LEVEL.MAXIMUM; HTMLNode input = insertForm.addChild("input", new String[] { "type", "name", "value", "id" }, new String[] { "radio", "keytype", "CHK", "keytypeChk" }); - if ((!rememberedLastTime && seclevel == NETWORK_THREAT_LEVEL.LOW) || - (rememberedLastTime && wasCanonicalLastTime && seclevel != NETWORK_THREAT_LEVEL.MAXIMUM)) { + if (!preselectSsk) { input.addAttribute("checked", "checked"); } insertForm.addChild("label", @@ -105,7 +107,7 @@ private HTMLNode createInsertBox (PageMaker pageMaker, ToadletContext ctx, boole input = insertForm.addChild("input", new String[] { "type", "name", "value", "id" }, new String[] { "radio", "keytype", "SSK", "keytypeSsk" }); - if (seclevel == NETWORK_THREAT_LEVEL.MAXIMUM || (rememberedLastTime && !wasCanonicalLastTime)) { + if (preselectSsk) { input.addAttribute("checked", "checked"); } insertForm.addChild("label", From b58bff147c78697a41d4ae6b0fe8408a2e4ab8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 4 Sep 2023 21:02:08 +0200 Subject: [PATCH 128/500] =?UTF-8?q?=E2=9C=A8=20Allow=20registering=20of=20?= =?UTF-8?q?ignored=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The whole reason for this is that Fred logs messages at ERROR if a config file contains an option it does not know about. As the plan is to remove a number of options, not having these values show up in log files is a definite plus. --- src/freenet/config/SubConfig.java | 42 +++++++++++++ test/freenet/config/PersistentConfigTest.java | 59 +++++++++++++++++++ test/freenet/config/SubConfigTest.java | 26 ++++++++ 3 files changed, 127 insertions(+) create mode 100644 test/freenet/config/PersistentConfigTest.java create mode 100644 test/freenet/config/SubConfigTest.java diff --git a/src/freenet/config/SubConfig.java b/src/freenet/config/SubConfig.java index cd65da735a4..8a2f5d28abb 100644 --- a/src/freenet/config/SubConfig.java +++ b/src/freenet/config/SubConfig.java @@ -152,6 +152,21 @@ public void register(String optionName, String[] defaultValue, int sortOrder, register(new StringArrOption(this, optionName, defaultValue, sortOrder, expert, forceWrite, shortDesc, longDesc, cb)); } + /** + * Registers an option that cannot be used. + *

+ * It is not listed, it is not exported, it is not persisted, it doesn’t + * have a value, you cannot change the value. It only exists so that + * Fred doesn’t log an error message if this particular option is used in + * a config file. + * + * @param optionName The name of the option to ignore + * @see PersistentConfig#finishedInit() + */ + public void registerIgnoredOption(String optionName) { + config.onRegister(this, new IgnoredOption(optionName)); + } + public int getInt(String optionName) { IntOption o; synchronized(this) { @@ -384,4 +399,31 @@ public String getRawOption(String name) { } else return null; } + private class IgnoredOption extends Option { + + public IgnoredOption(String optionName) { + super(SubConfig.this, optionName, new ConfigCallback() { + @Override + public Void get() { + return null; + } + + @Override + public void set(Void value) { + } + }, -1, false, false, null, null, null); + } + + @Override + protected Void parseString(String val) { + return null; + } + + @Override + protected String toString(Void val) { + return null; + } + + } + } diff --git a/test/freenet/config/PersistentConfigTest.java b/test/freenet/config/PersistentConfigTest.java new file mode 100644 index 00000000000..aeb5b1ac5ca --- /dev/null +++ b/test/freenet/config/PersistentConfigTest.java @@ -0,0 +1,59 @@ +package freenet.config; + +import java.util.ArrayList; +import java.util.List; + +import freenet.support.Logger; +import freenet.support.LoggerHook; +import freenet.support.SimpleFieldSet; +import org.junit.Test; + +import static freenet.support.Logger.LogLevel.MINIMAL; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalTo; + +public class PersistentConfigTest { + + @Test + public void configDoesNotLogAnErrorWhenIgnoredOptionIsRead() { + List messages = interceptLogger(config::finishedInit); + assertThat(messages, empty()); + } + + @Test + public void configDoesNotContainIgnoredOptionWhenExported() { + assertThat(config.exportFieldSet().isEmpty(), equalTo(true)); + } + + private List interceptLogger(Runnable runnable) { + List messages = new ArrayList<>(); + LoggerHook loggerHook = new LoggerHook(MINIMAL) { + @Override + public void log(Object o, Class source, String message, Throwable e, LogLevel priority) { + if (source == PersistentConfig.class) { + messages.add(message); + } + } + }; + Logger.globalAddHook(loggerHook); + runnable.run(); + Logger.globalRemoveHook(loggerHook); + return messages; + } + + private final SimpleFieldSet fieldSetWithIgnoredOption = new SimpleFieldSet(true); + + { + fieldSetWithIgnoredOption.put("sub.ignored", true); + } + + private final PersistentConfig config = new PersistentConfig(fieldSetWithIgnoredOption); + private final SubConfig subConfig = config.createSubConfig("sub"); + + { + subConfig.registerIgnoredOption("ignored"); + subConfig.finishedInitialization(); + } + +} diff --git a/test/freenet/config/SubConfigTest.java b/test/freenet/config/SubConfigTest.java new file mode 100644 index 00000000000..7f507ca96bc --- /dev/null +++ b/test/freenet/config/SubConfigTest.java @@ -0,0 +1,26 @@ +package freenet.config; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.emptyArray; +import static org.hamcrest.Matchers.equalTo; + +public class SubConfigTest { + + @Test + public void registeredIgnoredOptionDoesNotShowUpInRegisteredOptions() { + subConfig.registerIgnoredOption("ignored"); + assertThat(subConfig.getOptions(), emptyArray()); + } + + @Test + public void ignoredOptionIsNotExported() { + subConfig.registerIgnoredOption("ignored"); + assertThat(subConfig.exportFieldSet().isEmpty(), equalTo(true)); + } + + private final Config config = new Config(); + private final SubConfig subConfig = config.createSubConfig(""); + +} From e867e91b70bb861fb0dac90cef917b17d7382818 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 00:11:09 +0200 Subject: [PATCH 129/500] Fix by reference comparison for review review: https://github.com/hyphanet/fred/pull/839#discussion_r1271564482 --- .../support/io/InetAddressIpv6FirstComparator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/freenet/support/io/InetAddressIpv6FirstComparator.java b/src/freenet/support/io/InetAddressIpv6FirstComparator.java index 66c314524d9..17e8c5ecea9 100644 --- a/src/freenet/support/io/InetAddressIpv6FirstComparator.java +++ b/src/freenet/support/io/InetAddressIpv6FirstComparator.java @@ -22,8 +22,12 @@ public class InetAddressIpv6FirstComparator implements Comparator { @Override public int compare(InetAddress arg0, InetAddress arg1) { - if(arg0 == arg1) return 0; - // prefer everything over broadcast + if ((arg0 == null && arg1 == null)) return 0; + // prefer non-null over null + if (arg0 == null) return 1; + if (arg1 == null) return -1; + if(arg0.equals(arg1)) return 0; + // prefer everything to broadcast if (!arg0.isAnyLocalAddress() && arg1.isAnyLocalAddress()) { return -1; } else if (arg0.isAnyLocalAddress() && !arg1.isAnyLocalAddress()) { From 10cc324f51baf6cd2dae0d696172d5dc32a48b33 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 00:33:31 +0200 Subject: [PATCH 130/500] build from the current branch instead of hardcoded debian-package --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 154699573f1..22a1834ea50 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -40,7 +40,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag=debian-package -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="$GITHUB_REF" -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="$GITHUB_REF" -us -uc --git-ignore-new) - name: Get package info run: | From 6c746ebcc5ebd332dcbf74b95d04e032aabf360c Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 00:36:13 +0200 Subject: [PATCH 131/500] Also build the debian package on every pull-request --- .github/workflows/package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 22a1834ea50..553f017a30d 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -5,6 +5,7 @@ on: tags: - build** - testing-** + pull-request: jobs: build-deb: strategy: From 9ba46b86e6a9228d4c1c0ddffb6bab1af3461b5a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:26:43 +0000 Subject: [PATCH 132/500] =?UTF-8?q?fix:=20event=20pull-request=20=E2=86=92?= =?UTF-8?q?=20pull=5Frequest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 553f017a30d..39d79898954 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -5,7 +5,7 @@ on: tags: - build** - testing-** - pull-request: + pull_request: jobs: build-deb: strategy: From f9ec02e8258285986aee3b57ba70e24dbca95fc2 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:32:01 +0000 Subject: [PATCH 133/500] use head ref with fallback to ref if not avail --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 39d79898954..db3e078b64b 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -41,7 +41,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="$GITHUB_REF" -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="$GITHUB_REF" -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="${{ github.head_ref || github.ref }}" -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="${{ github.head_ref || github.ref }}" -us -uc --git-ignore-new) - name: Get package info run: | From 5c3b13b63f0499c544d00fa8a28a1c9a9b145e44 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:36:36 +0000 Subject: [PATCH 134/500] use HEAD --- .github/workflows/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index db3e078b64b..96229d3211f 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -41,7 +41,7 @@ jobs: - name: Build package run: | - sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="${{ github.head_ref || github.ref }}" -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="${{ github.head_ref || github.ref }}" -us -uc --git-ignore-new) + sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="HEAD" -us -uc --git-ignore-new || (EDITOR=true dpkg-source --commit . hack-1 && sudo gbp buildpackage --git-ignore-branch --git-upstream-tag="HEAD" -us -uc --git-ignore-new) - name: Get package info run: | From 9548df269c52ccf296b3e190547289b35f72e7df Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:50:04 +0000 Subject: [PATCH 135/500] keep the debian package as asset --- .github/workflows/package.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 96229d3211f..2d5eb0bbfed 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -48,3 +48,8 @@ jobs: dpkg -I ../freenet*.deb file ../freenet*.deb + - name: Provide Debian Package + uses: actions/upload-artifact@v3 + with: + name: debian-package + path: ../freenet_*.deb From a4d7c22beefd13cda6b358abff7f20d1aa092861 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:51:25 +0000 Subject: [PATCH 136/500] remove trailing empty line From 042e6b51546e16068fa94e02026a43c88d5edf3b Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:56:41 +0000 Subject: [PATCH 137/500] copy package to relative path --- .github/workflows/package.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 2d5eb0bbfed..d22e1b2a4c3 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -47,9 +47,10 @@ jobs: run: | dpkg -I ../freenet*.deb file ../freenet*.deb + cp ../freenet*.deb ./ - name: Provide Debian Package uses: actions/upload-artifact@v3 with: name: debian-package - path: ../freenet_*.deb + path: freenet_*.deb From 186bfbecf5cbe70489cfad1d5ede08a06dfd44e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Sep 2023 22:12:46 +0200 Subject: [PATCH 138/500] =?UTF-8?q?=F0=9F=94=A5=20Remove=20option=20to=20l?= =?UTF-8?q?oad=20plugins=20over=20HTTP(S)=20from=20web=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/freenet/clients/http/PproxyToadlet.java | 78 ++++++--------------- 1 file changed, 23 insertions(+), 55 deletions(-) diff --git a/src/freenet/clients/http/PproxyToadlet.java b/src/freenet/clients/http/PproxyToadlet.java index d413edcbf4b..12965a14b52 100644 --- a/src/freenet/clients/http/PproxyToadlet.java +++ b/src/freenet/clients/http/PproxyToadlet.java @@ -560,74 +560,42 @@ private void showOfficialPluginLoader(ToadletContext toadletContext, HTMLNode co HTMLNode addOfficialForm = toadletContext.addFormChild(addOfficialPluginContent, ".", "addOfficialPluginForm"); HTMLNode p = addOfficialForm.addChild("p"); - p.addChild("#", l10n("loadOfficialPluginText")); - // Over Freenet or over HTTP?? - - p.addChild("#", " " + l10n("pluginSourceChoice")); - - boolean loadFromWeb = pm.loadOfficialPluginsFromWeb(); - - HTMLNode input = addOfficialForm.addChild("input", - new String[] { "type", "name", "value", "id" }, - new String[] { "radio", "pluginSource", "freenet", "pluginSourceFreenet" }); - if(!loadFromWeb) - input.addAttribute("checked", "true"); - addOfficialForm.addChild("label", - new String[] { "for" }, - new String[] { "pluginSourceFreenet" }, - l10n("pluginSourceFreenet")); - addOfficialForm.addChild("br"); - input = addOfficialForm.addChild("input", - new String[] { "type", "name", "value", "id" }, - new String[] { "radio", "pluginSource", "https", "pluginSourceHTTPS" }); - if(loadFromWeb) - input.addAttribute("checked", "true"); - addOfficialForm.addChild("label", - new String[] { "for" }, - new String[] { "pluginSourceHTTPS" }, - l10n("pluginSourceHTTPS")); - addOfficialForm.addChild("#", " "); - if(node.getOpennet() == null) - addOfficialForm.addChild("b").addChild("font", "color", "red", l10n("pluginSourceHTTPSWarning")); - else - // FIXME CSS-ize this - addOfficialForm.addChild("b", l10n("pluginSourceHTTPSWarning")); - - p = addOfficialForm.addChild("p"); - - p.addChild("#", (l10n("loadOfficialPluginLabel") + ": ")); for (Entry> groupPlugins : availablePlugins.entrySet()) { List notLoadedPlugins = getNotLoadedPlugins(pm, groupPlugins.getValue()); if (notLoadedPlugins.isEmpty()) { continue; } - HTMLNode pluginGroupNode = addOfficialForm.addChild("div", "class", "plugin-group"); - pluginGroupNode.addChild("div", "class", "plugin-group-title", l10n("pluginGroupTitle", "pluginGroup", groupPlugins.getKey())); - for (OfficialPluginDescription pluginDescription : notLoadedPlugins) { - if (pluginDescription.unsupported) { - continue; - } - HTMLNode pluginNode = pluginGroupNode.addChild("div", "class", "plugin"); - HTMLNode option = pluginNode.addChild("input", + addPluginGroupForLoading(advancedModeEnabled, groupPlugins, addOfficialForm, notLoadedPlugins); + } + addOfficialForm.addChild("p").addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit-official", l10n("Load") }); + } + + private void addPluginGroupForLoading(boolean advancedModeEnabled, Entry> groupPlugins, HTMLNode addOfficialForm, List notLoadedPlugins) { + HTMLNode pluginGroupNode = addOfficialForm.addChild("div", "class", "plugin-group"); + pluginGroupNode.addChild("div", "class", "plugin-group-title", l10n("pluginGroupTitle", "pluginGroup", groupPlugins.getKey())); + for (OfficialPluginDescription pluginDescription : notLoadedPlugins) { + if (pluginDescription.unsupported) { + continue; + } + HTMLNode pluginNode = pluginGroupNode.addChild("div", "class", "plugin"); + HTMLNode option = pluginNode.addChild("input", new String[] { "type", "name", "value", "id" }, new String[] { "radio", "plugin-name", pluginDescription.name, "radioPlugin" + pluginDescription.name }); - option.addChild("label", + option.addChild("label", new String[] { "for" }, new String[] { "radioPlugin" + pluginDescription.name } - ).addChild("i", pluginDescription.getLocalisedPluginName()); - if(pluginDescription.deprecated) - option.addChild("b", " ("+l10n("loadLabelDeprecated")+")"); - if(pluginDescription.experimental) - option.addChild("b", " ("+l10n("loadLabelExperimental")+")"); - if (advancedModeEnabled && pluginDescription.minimumVersion >= 0) { - option.addChild("#", " ("+l10n("pluginVersion")+" " + pluginDescription.recommendedVersion + ")"); - } - option.addChild("#", " - "+pluginDescription.getLocalisedPluginDescription()); + ).addChild("i", pluginDescription.getLocalisedPluginName()); + if (pluginDescription.deprecated) + option.addChild("b", " (" + l10n("loadLabelDeprecated") + ")"); + if (pluginDescription.experimental) + option.addChild("b", " (" + l10n("loadLabelExperimental") + ")"); + if (advancedModeEnabled && pluginDescription.minimumVersion >= 0) { + option.addChild("#", " (" + l10n("pluginVersion") + " " + pluginDescription.recommendedVersion + ")"); } + option.addChild("#", " - " + pluginDescription.getLocalisedPluginDescription()); } - addOfficialForm.addChild("p").addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit-official", l10n("Load") }); } private List getNotLoadedPlugins(PluginManager pluginManager, List plugins) { From d6a6847bdcdf99d4f792746bb23c162aae31b128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Sep 2023 22:22:14 +0200 Subject: [PATCH 139/500] =?UTF-8?q?=F0=9F=94=A5=20Remove=20translation=20t?= =?UTF-8?q?exts=20for=20removed=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/freenet/l10n/freenet.l10n.de.properties | 5 ----- src/freenet/l10n/freenet.l10n.el.properties | 1 - src/freenet/l10n/freenet.l10n.en.properties | 5 ----- src/freenet/l10n/freenet.l10n.es.properties | 5 ----- src/freenet/l10n/freenet.l10n.fa.properties | 1 - src/freenet/l10n/freenet.l10n.fi.properties | 3 --- src/freenet/l10n/freenet.l10n.fr.properties | 5 ----- src/freenet/l10n/freenet.l10n.it.properties | 5 ----- src/freenet/l10n/freenet.l10n.ja.properties | 3 --- src/freenet/l10n/freenet.l10n.nb-no.properties | 4 ---- src/freenet/l10n/freenet.l10n.nl.properties | 5 ----- src/freenet/l10n/freenet.l10n.pl.properties | 2 -- src/freenet/l10n/freenet.l10n.pt-br.properties | 5 ----- src/freenet/l10n/freenet.l10n.pt_PT.properties | 1 - src/freenet/l10n/freenet.l10n.ru.properties | 5 ----- src/freenet/l10n/freenet.l10n.sv.properties | 3 --- src/freenet/l10n/freenet.l10n.zh-cn.properties | 5 ----- src/freenet/l10n/freenet.l10n.zh-tw.properties | 4 ---- 18 files changed, 67 deletions(-) diff --git a/src/freenet/l10n/freenet.l10n.de.properties b/src/freenet/l10n/freenet.l10n.de.properties index 198170ac05d..423a5a0e604 100644 --- a/src/freenet/l10n/freenet.l10n.de.properties +++ b/src/freenet/l10n/freenet.l10n.de.properties @@ -1395,7 +1395,6 @@ PproxyToadlet.loadLabelDeprecated=veraltet PproxyToadlet.loadLabelExperimental=experimentell PproxyToadlet.loadOfficialPlugin=Ein offizielles Plugin hinzufügen PproxyToadlet.loadOfficialPluginText=Sie können jedes dieser offiziellen Plugins (Erweiterungen) laden. Wir glauben, dass diese Plugins keine persönlichen Informationen ungefragt herausgeben, obwohl Fehler möglich sind. Wir geben kein Garantieversprechen. Sie können auch inoffizielle Plugins laden, siehe unten. -PproxyToadlet.loadOfficialPluginLabel=Offizielles Plugin laden PproxyToadlet.loadOtherPlugin=Ein inoffizielles Plugin hinzufügen PproxyToadlet.loadOtherPluginText=Hier können Sie den Dateinamen oder die Internet-Adresse (URL) eines Plugins eingeben, das geladen werden soll. Andere Plugins als die oben aufgelisteten, werden von uns noch nicht einmal im Entferntesten unterstützt oder darauf überprüft, ob sie persönliche Informationen herausgeben. Wenn Sie also hier ein inoffizielles Plugin laden wollen, sind Sie auf sich allein gestellt. PproxyToadlet.loadOtherURLLabel=Plugin-URL @@ -1432,10 +1431,6 @@ PproxyToadlet.pluginNotFoundReload=Das angegebene Plugin konnte nicht gefunden w PproxyToadlet.pluginNotFoundReloadTitle=Plugin nicht gefunden (neu laden) PproxyToadlet.pluginNotFoundUpdatingTitle=Neuste Version des Plugins nicht gefunden! PproxyToadlet.pluginNotFoundUpdating=Die neuete Version für das Plugin wurde nicht gefunden und konnte deshalb nicht geladen werden! -PproxyToadlet.pluginSourceChoice=Sie können die Plugins entweder über Freenet oder über unsere zentralen Server laden. -PproxyToadlet.pluginSourceFreenet=Abruf über Freenet. Dies ist schwer zu verfolgen, sicher und kann langsam sein. -PproxyToadlet.pluginSourceHTTPS=Lade über das Web von unserem zentralen Server. -PproxyToadlet.pluginSourceHTTPSWarning=WARNUNG: Dies wird zeigen, dass Sie Freenet nützen, und wird nicht funktionieren, wenn unsere Website geblockt ist! Es könnte für einen Abhörer sogar möglich sein, zu erraten, was Sie laden wollen, und es mit z.B. dem Erstellen eine Freemail Identität zu verbinden. PproxyToadlet.pluginUnloaded=Plugin entfernt PproxyToadlet.pluginUnloadedWithName=Das Plugin ${name} wurde entfernt. PproxyToadlet.pluginFilesWarning=WARNUNG: Wenn dieses Plug-in Dateien auf der Festplatte gespeichert hat, sind diese NICHT gelöscht worden. diff --git a/src/freenet/l10n/freenet.l10n.el.properties b/src/freenet/l10n/freenet.l10n.el.properties index 9aa323bb75e..ba88dd9606f 100644 --- a/src/freenet/l10n/freenet.l10n.el.properties +++ b/src/freenet/l10n/freenet.l10n.el.properties @@ -456,7 +456,6 @@ PproxyToadlet.loadFreenetURLLabel=Κλειδί πρόσθετου PproxyToadlet.loadLabelDeprecated=ξεπερασμένο PproxyToadlet.loadLabelExperimental=πειραματικό PproxyToadlet.loadOfficialPlugin=Εγκατάσταση ενός επίσημου πρόσθετου -PproxyToadlet.loadOfficialPluginLabel=Φόρτωση ενός επίσημου πρόσθετου PproxyToadlet.loadOtherPlugin=Εγκατάσταση ενός Ανεπίσημου Πρόσθετου PproxyToadlet.loadOtherURLLabel=Το URL του πρόσθετου PproxyToadlet.noPlugins=Δεν φωρτόθηκαν πρόσθετα diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 0d5da8d4958..297828923af 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -1529,7 +1529,6 @@ PproxyToadlet.loadLabelDeprecated=deprecated PproxyToadlet.loadLabelExperimental=experimental PproxyToadlet.loadOfficialPlugin=Add an Official Plugin PproxyToadlet.loadOfficialPluginText=You can load any of these official plugins. We believe these plugins are free of privacy leaks, although bugs are possible and we make no guarantees. You can also load unofficial plugins, see below. -PproxyToadlet.loadOfficialPluginLabel=Load an official plugin PproxyToadlet.loadOtherPlugin=Add an Unofficial Plugin PproxyToadlet.loadOtherPluginText=Here you can enter the filename or internet address (URL) of a plugin you want to load. Other plugins than the ones listed above are not even remotely supported or checked for privacy leaks by us, so if you load a remote plugin here, you are basically on your own. PproxyToadlet.loadOtherURLLabel=Plugin URL @@ -1593,10 +1592,6 @@ PproxyToadlet.pluginNotFoundReload=The specified plugin could not be located in PproxyToadlet.pluginNotFoundReloadTitle=Plugin Not Found (reloading) PproxyToadlet.pluginNotFoundUpdatingTitle=Plugin Not Found (updating) PproxyToadlet.pluginNotFoundUpdating=The plugin you are trying to update isn't loaded! -PproxyToadlet.pluginSourceChoice=You can either fetch the plugin over Freenet or from our central servers: -PproxyToadlet.pluginSourceFreenet=Fetch over Freenet. This is difficult to trace, safe, and may be slow. -PproxyToadlet.pluginSourceHTTPS=Fetch over the web from our central servers. -PproxyToadlet.pluginSourceHTTPSWarning=WARNING: This will give away the fact that you are running Freenet, and won't work if our website is blocked! It may even be possible for a wiretapper to tell what you are trying to load, and thus connect it with when e.g. a Freemail identity was created. PproxyToadlet.pluginUnloaded=Plugin unloaded PproxyToadlet.pluginUnloadedWithName=The plugin ${name} has been unloaded. PproxyToadlet.pluginFilesWarning=WARNING: If this plugin stored files on disk, they have NOT been deleted. diff --git a/src/freenet/l10n/freenet.l10n.es.properties b/src/freenet/l10n/freenet.l10n.es.properties index 4c15123f967..08ccc9999d3 100644 --- a/src/freenet/l10n/freenet.l10n.es.properties +++ b/src/freenet/l10n/freenet.l10n.es.properties @@ -1424,7 +1424,6 @@ PproxyToadlet.loadFreenetURLLabel=Clave de Freenet del complemento PproxyToadlet.loadLabelDeprecated=obsoleto PproxyToadlet.loadOfficialPlugin=Agregar complemento oficial PproxyToadlet.loadOfficialPluginText=Puede cargar cualquiera de estos complementos (plugins) oficiales. Creemos que estos complementos están libres de brechas en la privacidad, aunque los fallos son posibles y no damos garantías. También puede cargar complementos no oficiales, vea debajo. -PproxyToadlet.loadOfficialPluginLabel=Cargar complemento oficial PproxyToadlet.loadOtherPlugin=Agregar complemento no oficial PproxyToadlet.loadOtherPluginText=Aquí puede introducir el nombre de fichero o la dirección de Internet (URL) de un complemento (plugin) que desee cargar. Otros complementos distintos a los listados previamente no están ni de lejos soportados ni comprobados por nosotros en busca de brechas en la privacidad, así que si carga un complemento remoto aquí, básicamente lo hace por su cuenta y riesgo. PproxyToadlet.loadOtherURLLabel=URL del complemento @@ -1467,10 +1466,6 @@ PproxyToadlet.pluginNotFoundReload=No se pudo localizar el complemento (plugin) PproxyToadlet.pluginNotFoundReloadTitle=No se encontró el complemento (recargando) PproxyToadlet.pluginNotFoundUpdatingTitle=No se encontró el complemento (actualizando) PproxyToadlet.pluginNotFoundUpdating=¡El complemento que está tratando de actualizar no está cargado! -PproxyToadlet.pluginSourceChoice=Puede obtener el complemento (plugin) a través de Freenet o bien desde nuestros servidores centrales: -PproxyToadlet.pluginSourceFreenet=Descargar por Freenet. Así es difícil de trazar, seguro, y puede ser lento. -PproxyToadlet.pluginSourceHTTPS=Obtener vía web desde nuestros servidores centrales. -PproxyToadlet.pluginSourceHTTPSWarning=ADVERTENCIA: ¡Esto revelará el hecho de que está ejecutando Freenet, y no funcionará si nuestro sitio web está bloqueado! Incluso puede que para alguien a la escucha sea posible determinar lo que está intentando cargar, y de este modo asociarlo, por ejemplo, con el momento en que se creó una identidad de Freemail. PproxyToadlet.pluginUnloaded=Complemento purgado PproxyToadlet.pluginUnloadedWithName=Se ha purgado el complemento ${name}. PproxyToadlet.pluginFilesWarning=ADVERTENCIA: Si este complemento guardó ficheros en disco, NO han sido borrados. diff --git a/src/freenet/l10n/freenet.l10n.fa.properties b/src/freenet/l10n/freenet.l10n.fa.properties index 28bfeaed6b2..ed112a41dbe 100644 --- a/src/freenet/l10n/freenet.l10n.fa.properties +++ b/src/freenet/l10n/freenet.l10n.fa.properties @@ -641,7 +641,6 @@ PproxyToadlet.Load=بارگذاری PproxyToadlet.loadFreenetURLLabel=کلید افزونه PproxyToadlet.loadLabelExperimental=آزمایشی PproxyToadlet.loadOfficialPlugin=افزودن یک افزونه رسمی -PproxyToadlet.loadOfficialPluginLabel=بارگذاری یک افزونه رسمی PproxyToadlet.loadOtherPlugin=افزودن یک افزونه غیر رسمی PproxyToadlet.loadOtherURLLabel=آدرس اینترنتی افزونه PproxyToadlet.noPlugins=هیچ افزونه ای بارگذاری نشد diff --git a/src/freenet/l10n/freenet.l10n.fi.properties b/src/freenet/l10n/freenet.l10n.fi.properties index f9c73c378d0..1d204250134 100644 --- a/src/freenet/l10n/freenet.l10n.fi.properties +++ b/src/freenet/l10n/freenet.l10n.fi.properties @@ -892,7 +892,6 @@ PproxyToadlet.loadLabelDeprecated=vanhentunut PproxyToadlet.loadLabelExperimental=kokeellinen PproxyToadlet.loadOfficialPlugin=Lisää virallinen liitännäinen PproxyToadlet.loadOfficialPluginText=Nämä liitännäiset ovat The Freenet Projectin palvelimilla. Uskomme, että nämä liitännäiset ovat vapaita yksityisyysvuodoista, joskin emme takaa sitä. -PproxyToadlet.loadOfficialPluginLabel=Lataa virallinen liitännäinen PproxyToadlet.loadOtherPlugin=Lisää epävirallinen liitännäinen PproxyToadlet.loadOtherPluginText=Tähän voit syöttää sen liitännäisen osoitteen, jonka haluat hakea. Muut liitännäiset kuin yläpuolen listassa olevat, eivät ole edes etäisesti tuettuja tai tarkastettuja yksityisyysvuotojen varalta Freenetin kehittäjien toimesta, joten jos haluat hakea liitännäisen muualta, olet käytännössä omillasi. PproxyToadlet.loadOtherURLLabel=Liitännäisen verkko-osoite @@ -915,8 +914,6 @@ PproxyToadlet.pluginNotFoundReload=Määritettyä liitännäistä ei voitu paika PproxyToadlet.pluginNotFoundReloadTitle=Liitännäistä ei löydetty (uudelleenladataan) PproxyToadlet.pluginNotFoundUpdatingTitle=Liitännäinen ei löytynyt (päivitetään) PproxyToadlet.pluginNotFoundUpdating=Liitännäinen, jota yritit päivittää, ei latautunut! -PproxyToadlet.pluginSourceChoice=Voit noutaa lisäosan Freenetistä tai keskuspalvelimiltamme: -PproxyToadlet.pluginSourceHTTPS=Hae webistä keskuspalvelimiltamme. PproxyToadlet.pluginUnloaded=Liitännäinen poistettu käytöstä PproxyToadlet.pluginUnloadedWithName=Liitännäinen ${name} on poistettu käytöstä. PproxyToadlet.plugins=Liitännäiset diff --git a/src/freenet/l10n/freenet.l10n.fr.properties b/src/freenet/l10n/freenet.l10n.fr.properties index b859b0b75dc..f40574d6087 100644 --- a/src/freenet/l10n/freenet.l10n.fr.properties +++ b/src/freenet/l10n/freenet.l10n.fr.properties @@ -1424,7 +1424,6 @@ PproxyToadlet.loadLabelDeprecated=déconseillé PproxyToadlet.loadLabelExperimental=expérimental PproxyToadlet.loadOfficialPlugin=Ajouter un greffon officiel PproxyToadlet.loadOfficialPluginText=Vous pouvez charger n’importe lequel de ces greffons officiels. Nous pensons que ces greffons ne ne divulguent pas de données confidentielles, bien que des bogues soient possibles. Nous n’offrons aucune garantie. Vous pouvez aussi charger des greffons non officiels, voir ci-dessous. -PproxyToadlet.loadOfficialPluginLabel=Charger un greffon officiel PproxyToadlet.loadOtherPlugin=Ajouter un greffon non officiel PproxyToadlet.loadOtherPluginText=Vous pouvez saisir ici le nom ou l’adresse Internet (URL) d’un greffon que vous voulez charger. Nous n’offrons absolument aucun soutien pour les greffons qui ne sont pas listés ci-dessus et nous n’en avons pas testés les fuites potentielles de données confidentielles. Donc si vous chargez ici un greffon distant, vous êtes livré à vous même. PproxyToadlet.loadOtherURLLabel=URL du greffon @@ -1472,10 +1471,6 @@ PproxyToadlet.pluginNotFoundReload=Impossible de trouver le greffon spécifié a PproxyToadlet.pluginNotFoundReloadTitle=Greffon introuvable (rechargement) PproxyToadlet.pluginNotFoundUpdatingTitle=Greffon introuvable (mise à jour) PproxyToadlet.pluginNotFoundUpdating=Le greffon que vous essayez de mettre à jour n’est pas chargé ! -PproxyToadlet.pluginSourceChoice=Vous pouvez soit récupérer le greffon par Freenet, soit de nos serveurs centraux : -PproxyToadlet.pluginSourceFreenet=Récupérer sur Freenet. Cela est difficile à suivre à la trace, sûr et pourrait être lent. -PproxyToadlet.pluginSourceHTTPS=Récupérer par le Web à partir de nos serveurs centraux. -PproxyToadlet.pluginSourceHTTPSWarning=AVERTISSEMENT : cela divulguera le fait que vous utilisez Freenet et ne fonctionnera pas si notre site Web est bloqué ! Une personne à l’écoute pourrait même savoir ce que vous essayez de charger et par conséquent le relier, p. ex., à la création d’une identité Freemail. PproxyToadlet.pluginUnloaded=Greffon déchargé PproxyToadlet.pluginUnloadedWithName=Le greffon ${name} a été déchargé. PproxyToadlet.pluginFilesWarning=AVERTISSEMENT : si ce greffon a stocké des fichiers sur le disque, ils n’ont PAS été supprimés. diff --git a/src/freenet/l10n/freenet.l10n.it.properties b/src/freenet/l10n/freenet.l10n.it.properties index 040935d34fc..4e279fa1319 100644 --- a/src/freenet/l10n/freenet.l10n.it.properties +++ b/src/freenet/l10n/freenet.l10n.it.properties @@ -1330,7 +1330,6 @@ PproxyToadlet.loadLabelDeprecated=deprecato PproxyToadlet.loadLabelExperimental=sperimentale PproxyToadlet.loadOfficialPlugin=Carica plugin ufficiale PproxyToadlet.loadOfficialPluginText=Questi plugin ufficiali non dovrebbero mettere in pericolo la privacy dell'utente ma non è possibile offrire una garanzia al 100%. E' inoltre possibile caricare plugin non non ufficiali (vedi sotto) -PproxyToadlet.loadOfficialPluginLabel=Carica plugin ufficiale PproxyToadlet.loadOtherPlugin=Carica plugin non ufficiale PproxyToadlet.loadOtherPluginText=Inserire qui la URL del plugin che si vuole caricare. ATTENZIONE! I plugin non ufficiali non ricevono alcuna assistenza e non vengono controllati dai programmatory di Freenet, pertanto chi volesse utilizzarli lo farà A PROPRIO RISCHIO. PproxyToadlet.loadOtherURLLabel=URL del plugin @@ -1359,10 +1358,6 @@ PproxyToadlet.pluginNotFoundReload=Non è stato possibile trovare il plugin spec PproxyToadlet.pluginNotFoundReloadTitle=Plugin non trovato (ricaricamento in corso) PproxyToadlet.pluginNotFoundUpdatingTitle=Plugin non trovato (aggiornamento) PproxyToadlet.pluginNotFoundUpdating=Il plugin che state tentando di aggiornare non è caricato! -PproxyToadlet.pluginSourceChoice=È possibile scegliere se scaricare il plugin da Freenet o dai server del Progetto: -PproxyToadlet.pluginSourceFreenet=Scarica via Freenet. Sarai difficile da rintracciare, sicuro, ma scaricherai lentamente. -PproxyToadlet.pluginSourceHTTPS=Scarica dai server sul web non anonimo. -PproxyToadlet.pluginUnloaded=Plugin terminato PproxyToadlet.pluginUnloadedWithName=Il plugin ${name} è stato terminato. PproxyToadlet.plugins=Plugin PproxyToadlet.reloadOnStartupShort=Ricarica all'avvio diff --git a/src/freenet/l10n/freenet.l10n.ja.properties b/src/freenet/l10n/freenet.l10n.ja.properties index dc051b5f85c..43ed808d927 100644 --- a/src/freenet/l10n/freenet.l10n.ja.properties +++ b/src/freenet/l10n/freenet.l10n.ja.properties @@ -898,7 +898,6 @@ PproxyToadlet.loadLabelDeprecated=非推奨(廃止予定) PproxyToadlet.loadLabelExperimental=実験的 PproxyToadlet.loadOfficialPlugin=公式プラグインを追加 PproxyToadlet.loadOfficialPluginText=これらの公式プラグインのいずれもロードできます。これらのプラグインはプライバシーの漏洩とは無縁であることを我々は信じていますが、バグの可能性も拭えないことから保証はできかねます。非公式プラグインもロードできます。下を見てください。 -PproxyToadlet.loadOfficialPluginLabel=非公式プラグインをロード: PproxyToadlet.loadOtherPlugin=非公式プラグインを追加 PproxyToadlet.loadOtherPluginText=ここにロードしたいプラグインのファイル名かインターネットアドレス(URL)を入力できます。他のプラグインは上にリストされたものよりも外部でプライバシー流出について我々に検証されてすらいないため、ここでリモートプラグインをロードすることは、基本的にあなたの責任となります。 PproxyToadlet.loadOtherURLLabel=プラグインURL @@ -911,8 +910,6 @@ PproxyToadlet.pluginNotFoundReload=リロードする為、指定したプラグ PproxyToadlet.pluginNotFoundReloadTitle=プラグインが見付かりません (リロード中) PproxyToadlet.pluginNotFoundUpdatingTitle=プラグインが見付かりませんでした (アップデート中) PproxyToadlet.pluginNotFoundUpdating=あなたがアップデートしようとしたプラグインはロードされていません! -PproxyToadlet.pluginSourceChoice=Freenetか我々の中央サーバからプラグインをフェッチすることができます: -PproxyToadlet.pluginSourceHTTPS=Web経由で我々の中央サーバからフェッチします。 PproxyToadlet.pluginUnloaded=プラグインはアンロードされました PproxyToadlet.pluginUnloadedWithName=プラグイン ${name} はアンロードされました。 PproxyToadlet.plugins=プラグイン diff --git a/src/freenet/l10n/freenet.l10n.nb-no.properties b/src/freenet/l10n/freenet.l10n.nb-no.properties index 5fddf9cb177..619bbad1a3c 100644 --- a/src/freenet/l10n/freenet.l10n.nb-no.properties +++ b/src/freenet/l10n/freenet.l10n.nb-no.properties @@ -1110,7 +1110,6 @@ PproxyToadlet.loadLabelDeprecated=avleggs PproxyToadlet.loadLabelExperimental=eksperimentelt PproxyToadlet.loadOfficialPlugin=Start et offisielt programtillegg PproxyToadlet.loadOfficialPluginText=Disse tilleggene ligger på tjenere hos Freenet-prosjektet. Det har blitt tatt høyde for at disse programtilleggene ikke lekker privat informasjon, men vi kan ikke garantere dette. Du kan også laste inn uoffisielle tillegg, se nedenfor. -PproxyToadlet.loadOfficialPluginLabel=Start et offisielt programtillegg PproxyToadlet.loadOtherPlugin=Start et uoffisielt programtillegg PproxyToadlet.loadOtherPluginText=Her kan du skrive inn filnavn eller legge inn en nettadresse (URL) til et programtillegg du vil starte. Programtillegg som ikke er i listen ovenfor er ikke støttet eller sjekket for personvernslekkasjer av Freenet-utviklere, innlasting av uoffisielle programtillegg skjer på eget ansvar. PproxyToadlet.loadOtherURLLabel=URL til programtillegg @@ -1148,9 +1147,6 @@ PproxyToadlet.pluginNotFoundReload=Kunne ikke laste inn spesifisert programtille PproxyToadlet.pluginNotFoundReloadTitle=Fant ikke programtillegget (laster inn på ny) PproxyToadlet.pluginNotFoundUpdatingTitle=Programtillegg ikke funnet (oppdaterer) PproxyToadlet.pluginNotFoundUpdating=Programtillegget du prøver å oppdatere er ikke lastet inn! -PproxyToadlet.pluginSourceChoice=Du kan enten hente programtillegget fra Freenet eller installere det fra en av våre sentrale tjenere: -PproxyToadlet.pluginSourceHTTPS=Hent over nettet fra en av våre sentrale tjenere. -PproxyToadlet.pluginSourceHTTPSWarning=ADVARSEL: Dette avslører at du bruker Freenet, og fungerer ikke hvis nettsiden er blokkert! For en overvåker kan det være mulig å ta rede på hva du forsøker å laste, og dermed knytte det til når for eksempel en Freemail-identitet har blitt opprettet. PproxyToadlet.pluginUnloaded=Programtillegg stoppet PproxyToadlet.pluginUnloadedWithName=Programtillegget ${name} ble lastet ut. PproxyToadlet.plugins=Programtillegg diff --git a/src/freenet/l10n/freenet.l10n.nl.properties b/src/freenet/l10n/freenet.l10n.nl.properties index 0e4541e3221..4ff487f0c3d 100644 --- a/src/freenet/l10n/freenet.l10n.nl.properties +++ b/src/freenet/l10n/freenet.l10n.nl.properties @@ -1380,7 +1380,6 @@ PproxyToadlet.loadLabelDeprecated=wordt ontraden PproxyToadlet.loadLabelExperimental=experimenteel PproxyToadlet.loadOfficialPlugin=Officiële plugin toevoegen PproxyToadlet.loadOfficialPluginText=Deze plugins staan op de servers van The Freenet Project. We staan ervoor in dat deze plugins geen privacy-gevoelige informatie lekken, maar kunnen het helaas niet garanderen. -PproxyToadlet.loadOfficialPluginLabel=Officiële plugin laden PproxyToadlet.loadOtherPlugin=Onofficiële plugin toevoegen PproxyToadlet.loadOtherPluginText=Hier kun je de URL invullen van de plugin die je wilt laden. Plugins die niet in de standaard lijst staan worden niet ondersteund en niet gecontroleerd op beveiligingslekken. Gebruik daarvan is geheel op eigen risico. PproxyToadlet.noPlugins=Geen plugins geladen @@ -1423,10 +1422,6 @@ PproxyToadlet.pluginNotFoundReload=De opgegeven plugin kon niet worden gevonden PproxyToadlet.pluginNotFoundReloadTitle=Plugin niet gevonden (bezig met opnieuw laden) PproxyToadlet.pluginNotFoundUpdatingTitle=Plugin niet gevonden (aan het bijwerken) PproxyToadlet.pluginNotFoundUpdating=De plugin die je probeert bij te werken is niet geladen! -PproxyToadlet.pluginSourceChoice=Je kunt de plugin binnenhalen via Freenet of vanaf de centrale Freenet-servers: -PproxyToadlet.pluginSourceFreenet=Haal over Freenet. Dit is moeilijk te traceren, veilig en kan langzaam zijn. -PproxyToadlet.pluginSourceHTTPS=Binnenhalen via het web van de centrale servers. -PproxyToadlet.pluginSourceHTTPSWarning=WAARSCHUWING: Dit onthult het feit dat je Freenet draait, en werkt niet als onze website is geblokkeerd! Het zou voor een afluisteraar zelfs mogelijk kunnen zijn om af te leiden wat je probeert te laden, en dit bijvoorbeeld te koppelen met wanneer een Freemail-pseudoniem is aangemaakt. PproxyToadlet.pluginUnloaded=Plugin uitgeladen PproxyToadlet.pluginUnloadedWithName=De plugin met de naam ${name} is uitgeladen. PproxyToadlet.pluginFilesWarning=WAARSCHUWING: als deze plug-in bestanden op de harde schijf heeft opgeslagen, zijn deze NIET verwijderd. diff --git a/src/freenet/l10n/freenet.l10n.pl.properties b/src/freenet/l10n/freenet.l10n.pl.properties index 5c81a42ffa3..dedd516810e 100644 --- a/src/freenet/l10n/freenet.l10n.pl.properties +++ b/src/freenet/l10n/freenet.l10n.pl.properties @@ -329,8 +329,6 @@ PproxyToadlet.pluginGroup.example=Przykład PproxyToadlet.pluginGroup.file-transfer=Transfer pliku PproxyToadlet.pluginGroup.index=Indeksowanie PproxyToadlet.pluginVersion=wersja -PproxyToadlet.pluginSourceChoice=Możesz pobrać wtyczki poprzez FreeNet lub z naszych centralnych serwerów: -PproxyToadlet.pluginSourceHTTPS=Pobieranie poprzez zwykłą sieć z naszych centralnych serwerów. PproxyToadlet.pluginUnloadedWithName=Wtyczka ${name} została wyładowana. PproxyToadlet.plugins=Wtyczki PproxyToadlet.reload=Przeładuj diff --git a/src/freenet/l10n/freenet.l10n.pt-br.properties b/src/freenet/l10n/freenet.l10n.pt-br.properties index 46bd0382e65..ca1e22d89bf 100644 --- a/src/freenet/l10n/freenet.l10n.pt-br.properties +++ b/src/freenet/l10n/freenet.l10n.pt-br.properties @@ -1321,7 +1321,6 @@ PproxyToadlet.loadFreenetURLLabel=Chave da extensão PproxyToadlet.loadLabelDeprecated=obsoletada PproxyToadlet.loadOfficialPlugin=Adicionar uma extensão oficial PproxyToadlet.loadOfficialPluginText=Você pode carregar qualquer uma dessas extensões que são oficiais. Acreditamos que essas extensões estão livres de brechas quanto à privacidade, embora falhas sejam possíveis e não podemos oferecer garantias. Você pode carregar também extensões não-oficiais, veja abaixo. -PproxyToadlet.loadOfficialPluginLabel=Carregar uma extensão oficial PproxyToadlet.loadOtherPlugin=Adicionar uma extensão não-oficial PproxyToadlet.loadOtherPluginText=Você pode digitar aqui o nome do arquivo ou o endereço de internet (URL) da extensão que deseja carregar. Outras extensões, excetuando-se as listadas acima, não possuem suporte remoto, tampouco são verificadas por nós quanto a brechas de privacidade, portanto, se você carregar uma extensão remota aqui, estará fazendo-o por sua conta e risco. PproxyToadlet.loadOtherURLLabel=URL da extensão @@ -1362,10 +1361,6 @@ PproxyToadlet.pluginNotFoundReload=A extensão especificada não pôde ser local PproxyToadlet.pluginNotFoundReloadTitle=Extensão não encontrada (recarregando) PproxyToadlet.pluginNotFoundUpdatingTitle=Extensão não encontrada (atualizando) PproxyToadlet.pluginNotFoundUpdating=A extensão que você está querendo atualizar não foi carregada! -PproxyToadlet.pluginSourceChoice=Você tanto pode obter a extensão na Freenet como de nossos servidores centrais: -PproxyToadlet.pluginSourceFreenet=Obter da Freenet. Esta é uma forma difícil de rastrear, segura e talvez lenta. -PproxyToadlet.pluginSourceHTTPS=Obter na web, a partir dos nossos servidores centrais. -PproxyToadlet.pluginSourceHTTPSWarning=ALERTA: Isso fará com que saibam que você acessa a Freenet, e não funcionará se o seu website estiver bloqueado! Talvez seja mesmo possível para um grampeador dizer o que você está tentando carregar, e assim conectar-se com quando, por exemplo, uma identidade do Freemail for criada. PproxyToadlet.pluginUnloaded=Extensão liberada PproxyToadlet.pluginUnloadedWithName=A extensão ${name} foi liberada/desativada. PproxyToadlet.pluginFilesWarning=ALERTA: Se esta extensão armazenar arquivos no disco, tais arquivos NÃO podem ser deletados. diff --git a/src/freenet/l10n/freenet.l10n.pt_PT.properties b/src/freenet/l10n/freenet.l10n.pt_PT.properties index e3e063ebf04..336e51d5c78 100644 --- a/src/freenet/l10n/freenet.l10n.pt_PT.properties +++ b/src/freenet/l10n/freenet.l10n.pt_PT.properties @@ -498,7 +498,6 @@ PproxyToadlet.internalIDTitle=Id. Interna PproxyToadlet.Load=Carregar PproxyToadlet.loadFreenetURLLabel=Código de Plug-in PproxyToadlet.loadOfficialPlugin=Adicionar um Plug-in Oficial -PproxyToadlet.loadOfficialPluginLabel=carregar um plug-in oficial PproxyToadlet.loadOtherPlugin=Adicionar um Plug-in Não Oficial PproxyToadlet.loadOtherURLLabel=URL de Plug-in PproxyToadlet.noPlugins=Sem plug-ins carregados diff --git a/src/freenet/l10n/freenet.l10n.ru.properties b/src/freenet/l10n/freenet.l10n.ru.properties index fa157123cc3..229b85d0a30 100644 --- a/src/freenet/l10n/freenet.l10n.ru.properties +++ b/src/freenet/l10n/freenet.l10n.ru.properties @@ -1324,7 +1324,6 @@ PproxyToadlet.loadLabelDeprecated=устаревшее PproxyToadlet.loadLabelExperimental=экспериментальное PproxyToadlet.loadOfficialPlugin=Добавить официальное дополнение PproxyToadlet.loadOfficialPluginText=Вы можете загрузить любое из этих официальных дополнений. Мы считаем что эти дополнения безопасны, однако не можем гарантировать отсутствие в них ошибок. Ниже вы можете загрузить и неофициальные дополнения. -PproxyToadlet.loadOfficialPluginLabel=Загрузить официальное дополнение PproxyToadlet.loadOtherPlugin=Добавить неофициальное дополнение PproxyToadlet.loadOtherPluginText=Здесь вы можете ввести имя файла либо интернет-адрес (URL) дополнения, которое хотите загрузить. Дополнения, не перечисленные в списке официальных, никоим образом не поддерживаются и не проверяются нами, так что если вы загружаете какое-либо постороннее дополнение, вы делаете это на свой страх и риск. PproxyToadlet.loadOtherURLLabel=URL-адрес дополнения @@ -1347,10 +1346,6 @@ PproxyToadlet.pluginNotFoundReload=Указанное дополнение не PproxyToadlet.pluginNotFoundReloadTitle=Дополнение не найдено (повторный запуск) PproxyToadlet.pluginNotFoundUpdatingTitle=Дополнение не найдено (обновление) PproxyToadlet.pluginNotFoundUpdating=Дополнение, которое вы хотите обновить, не загружено! -PproxyToadlet.pluginSourceChoice=Вы можете получить дополнение через Фринет или с наших серверов: -PproxyToadlet.pluginSourceFreenet=Получить через Фринет. Загрузку трудно отследить, это безопасно, но может занять много времени. -PproxyToadlet.pluginSourceHTTPS=Получить через интернет с наших серверов. -PproxyToadlet.pluginSourceHTTPSWarning=ВНИМАНИЕ: Загрузка через интернет выдаст тот факт, что вы пользуетесь Фринетом, и не будет работать, если наш веб-сайт заблокирован. Кроме того, возможный "человек-в-середине" сможет получить информацию о том, что вы пытаетесь загрузить, и сопоставить её со временем, когда, например, была создана личность во Freemail. PproxyToadlet.pluginUnloaded=Дополнение выгружено PproxyToadlet.pluginUnloadedWithName=Дополнение ${name} было выгружено. PproxyToadlet.pluginFilesWarning=ВНИМАНИЕ: если этот плагин хранил файлы на диске, они НЕ будут удалены. diff --git a/src/freenet/l10n/freenet.l10n.sv.properties b/src/freenet/l10n/freenet.l10n.sv.properties index 97fc05a5285..5fd8722162f 100644 --- a/src/freenet/l10n/freenet.l10n.sv.properties +++ b/src/freenet/l10n/freenet.l10n.sv.properties @@ -626,15 +626,12 @@ PproxyToadlet.loadLabelDeprecated=gammal PproxyToadlet.loadLabelExperimental=experimentiell PproxyToadlet.loadOfficialPlugin=Lägg till en officiell plugin PproxyToadlet.loadOfficialPluginText=Du kan ladda någon av dessa officiella pluginer. Vi tror att dessa pluginer inte läcker någon känslig information, men buggar kan finnas och vi gör inga garantier. Du kan också ladda inofficiella pluginer, se nedan. -PproxyToadlet.loadOfficialPluginLabel=Starta en officiell plugin PproxyToadlet.loadOtherPlugin=Lägg till en inofficiell plugin PproxyToadlet.loadOtherPluginText=Här kan du ange en sökväg till en plugin som du vill ladda. Andra pluginer än de listade ovan har inget stöd alls av oss och kan innehålla allvarliga säkerhetsbrister som avslöjar allt om dig. Laddande av inofficiella pluginer görs helt på egen risk. PproxyToadlet.loadOtherURLLabel=Plugin sökväg PproxyToadlet.noPlugins=Inga plugins laddade PproxyToadlet.pluginFilename=Namn PproxyToadlet.pluginNotFoundReloadTitle=Pluginen kunde inte hittas (laddar om) -PproxyToadlet.pluginSourceChoice=Du kan antingen hämta pluginen över Freenet eller från våra centrala servrar: -PproxyToadlet.pluginSourceHTTPS=Hämta över nätet från våra centrala servrar. PproxyToadlet.pluginUnloaded=Plugin stoppad PproxyToadlet.pluginUnloadedWithName=Pluginen ${name} har laddats ur. PproxyToadlet.plugins=Pluginer diff --git a/src/freenet/l10n/freenet.l10n.zh-cn.properties b/src/freenet/l10n/freenet.l10n.zh-cn.properties index e263549006a..b4640f7c659 100644 --- a/src/freenet/l10n/freenet.l10n.zh-cn.properties +++ b/src/freenet/l10n/freenet.l10n.zh-cn.properties @@ -1432,7 +1432,6 @@ PproxyToadlet.loadLabelDeprecated=已弃用 PproxyToadlet.loadLabelExperimental=实验性 PproxyToadlet.loadOfficialPlugin=添加官方插件 PproxyToadlet.loadOfficialPluginText=您可以随意加载这些官方插件。我们相信这些插件不会泄露隐私,虽然可能会有 Bug 且我们不提供任何担保。您也可以加载非官方插件,详见下文。 -PproxyToadlet.loadOfficialPluginLabel=加载官方插件 PproxyToadlet.loadOtherPlugin=添加非官方插件 PproxyToadlet.loadOtherPluginText=这里您可以输入您要加载的插件的 URL 网址。除了上面列出的插件以外的其他插件均不被远程支持,我们也没有对其进行过隐私泄露测试,所以如果您在这里远程加载插件,您需要自己留心。 PproxyToadlet.loadOtherURLLabel=插件 URL @@ -1476,10 +1475,6 @@ PproxyToadlet.pluginNotFoundReload=指定的插件无法被定位以加载。 PproxyToadlet.pluginNotFoundReloadTitle=没有找到插件 (正在重新载入) PproxyToadlet.pluginNotFoundUpdatingTitle=插件没有找到 (正在更新) PproxyToadlet.pluginNotFoundUpdating=您正在尝试更新的插件没有被加载! -PproxyToadlet.pluginSourceChoice=您可以通过 Freenet 或我们的中央服务器获取插件: -PproxyToadlet.pluginSourceFreenet=从 Freenet 获取。这是无法追踪的,安全但是比较慢。 -PproxyToadlet.pluginSourceHTTPS=通过 Web 从我们的中央服务器获取。 -PproxyToadlet.pluginSourceHTTPSWarning=警告:这将泄露你正在运行 Freenet 的事实,并且如果我们的网站被封锁则将无法正常工作!它甚至可能窃听你尝试加载的是什么,因为当例如 Freemail 身份创建时会有连接。 PproxyToadlet.pluginUnloaded=插件已卸载 PproxyToadlet.pluginUnloadedWithName=插件 ${name} 已被卸载。 PproxyToadlet.pluginFilesWarning=警告: 如果插件存储在磁盘,它们不会被删除。 diff --git a/src/freenet/l10n/freenet.l10n.zh-tw.properties b/src/freenet/l10n/freenet.l10n.zh-tw.properties index b42408e26cc..ba6a62f588a 100644 --- a/src/freenet/l10n/freenet.l10n.zh-tw.properties +++ b/src/freenet/l10n/freenet.l10n.zh-tw.properties @@ -1422,7 +1422,6 @@ PproxyToadlet.loadLabelDeprecated=已棄用 PproxyToadlet.loadLabelExperimental=實驗性 PproxyToadlet.loadOfficialPlugin=新增官方外掛 PproxyToadlet.loadOfficialPluginText=這些外掛程式位於 Freenet 專案的伺服器上. 我們相信這些外掛不會洩漏隱私資料, 然而不能對此擔保. -PproxyToadlet.loadOfficialPluginLabel=載入官方外掛 PproxyToadlet.loadOtherPlugin=新增非官方外掛 PproxyToadlet.loadOtherPluginText=你可以在這裡輸入欲載入外掛的 URL. 我們不支援以上列出的外掛之外的其他外掛, 也不會去檢查它們是否會有洩漏隱私的問題. 所以如果你要在這裡載入一個遠方的外掛的話, 就必須要自行負責. PproxyToadlet.loadOtherURLLabel=外掛的 URL @@ -1463,9 +1462,6 @@ PproxyToadlet.pluginNotFoundReload=找不到指定要載入的外掛. PproxyToadlet.pluginNotFoundReloadTitle=無法找到外掛(重新載入) PproxyToadlet.pluginNotFoundUpdatingTitle=外掛沒有找到 (正在更新) PproxyToadlet.pluginNotFoundUpdating=您正在嘗試更新的外掛沒有被載入! -PproxyToadlet.pluginSourceChoice=你可以透過 Freenet 或我們的中央伺服器取得外掛程式: -PproxyToadlet.pluginSourceHTTPS=透過網頁從我們的中央伺服器取得. -PproxyToadlet.pluginSourceHTTPSWarning=警告:這將洩露你正在執行 Freenet 的事實,並且如果我們的網站被封鎖則將無法正常工作!它甚至可能竊聽你嘗試載入的是什麼,因為當例如 Freemail 身份建立時會有連線。 PproxyToadlet.pluginUnloaded=已經卸載外掛 PproxyToadlet.pluginUnloadedWithName=已經卸載外掛 ${name} 了. PproxyToadlet.plugins=外掛程式 From c648a651143086d88422c7814f9f1dd9f821f598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Sep 2023 22:27:15 +0200 Subject: [PATCH 140/500] =?UTF-8?q?=F0=9F=94=A5=20Remove=20option=20that?= =?UTF-8?q?=20would=20always=20load=20plugins=20from=20central=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/freenet/pluginmanager/PluginManager.java | 29 ++------------------ 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/freenet/pluginmanager/PluginManager.java b/src/freenet/pluginmanager/PluginManager.java index acdbc3bad67..09ba6132b75 100644 --- a/src/freenet/pluginmanager/PluginManager.java +++ b/src/freenet/pluginmanager/PluginManager.java @@ -169,29 +169,8 @@ public boolean isReadOnly() { System.err.println("KeyExplorer plugin renamed to KeyUtils"); } - // This should default to false. Even though we use SSL, a wiretapper may be able to tell which - // plugin is being loaded, and correlate that with identity creation; plus of course they can see - // that somebody is using Freenet. - pmconfig.register("alwaysLoadOfficialPluginsFromCentralServer", false, 0, false, false, "PluginManager.alwaysLoadPluginsFromCentralServer", "PluginManager.alwaysLoadPluginsFromCentralServerLong", new BooleanCallback() { - - @Override - public Boolean get() { - return alwaysLoadOfficialPluginsFromCentralServer; - } - - @Override - public void set(Boolean val) throws InvalidConfigValueException, NodeNeedRestartException { - alwaysLoadOfficialPluginsFromCentralServer = val; - } - - }); - - alwaysLoadOfficialPluginsFromCentralServer = pmconfig.getBoolean("alwaysLoadOfficialPluginsFromCentralServer"); - if (lastVersion <= 1437) { - // Overwrite this setting, since it will have been set by the old callback and then written as it's not default. - // FIXME remove back compatibility code. - alwaysLoadOfficialPluginsFromCentralServer = false; - } + // ignore this in config files. + pmconfig.registerIgnoredOption("alwaysLoadOfficialPluginsFromCentralServer"); pmconfig.finishedInitialization(); @@ -1582,10 +1561,6 @@ public THEME getFProxyTheme() { return fproxyTheme; } - public boolean loadOfficialPluginsFromWeb() { - return alwaysLoadOfficialPluginsFromCentralServer; - } - public void unregisterPlugin(PluginInfoWrapper wrapper, FredPlugin plug, boolean reloading) { unregisterPluginToadlet(wrapper); if(wrapper.isConfigurablePlugin()) { From 7ad47457f9fcb6702fff27e71b3103192233161b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Sep 2023 22:39:28 +0200 Subject: [PATCH 141/500] =?UTF-8?q?=F0=9F=94=A5=20Remove=20code=20that=20h?= =?UTF-8?q?as=20been=20obsoleted=20by=20removal=20of=20HTTP(S)=20downloads?= =?UTF-8?q?=20for=20official=20plugins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/freenet/clients/fcp/LoadPlugin.java | 19 +- src/freenet/clients/http/PproxyToadlet.java | 5 +- .../clients/http/staticfiles/globalsign.pem | 21 -- .../clients/http/wizardsteps/MISC.java | 2 +- src/freenet/node/Node.java | 38 ---- src/freenet/node/TextModeClientInterface.java | 2 +- .../PluginDownLoaderOfficialHTTPS.java | 180 ------------------ src/freenet/pluginmanager/PluginManager.java | 17 +- 8 files changed, 11 insertions(+), 273 deletions(-) delete mode 100644 src/freenet/clients/http/staticfiles/globalsign.pem delete mode 100644 src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java diff --git a/src/freenet/clients/fcp/LoadPlugin.java b/src/freenet/clients/fcp/LoadPlugin.java index 3473e762029..6a6c55da6f1 100644 --- a/src/freenet/clients/fcp/LoadPlugin.java +++ b/src/freenet/clients/fcp/LoadPlugin.java @@ -29,8 +29,6 @@ public class LoadPlugin extends FCPMessage { private final String pluginURL; private final String urlType; private final boolean store; - private final boolean force; - private final boolean forceHTTPS; public LoadPlugin(SimpleFieldSet fs) throws MessageInvalidException { identifier = fs.get("Identifier"); @@ -51,21 +49,6 @@ public LoadPlugin(SimpleFieldSet fs) throws MessageInvalidException { TYPENAME_URL.equalsIgnoreCase(urlType))) throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Unknown URL type: '"+urlType+"'", identifier, false); } - String officialSource = fs.get("OfficialSource"); - if(officialSource != null) { - if(officialSource.equalsIgnoreCase("https")) { - force = true; - forceHTTPS = true; - } else if(officialSource.equalsIgnoreCase("freenet")) { - force = true; - forceHTTPS = false; - } else { - throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Unknown OfficialSource '"+officialSource+"'", identifier, false); - } - } else { - force = false; - forceHTTPS = false; - } store = fs.getBoolean("Store", false); } @@ -124,7 +107,7 @@ public void run() { } PluginInfoWrapper pi; if (TYPENAME_OFFICIAL.equals(type)) { - pi = node.pluginManager.startPluginOfficial(pluginURL, store, force, forceHTTPS); + pi = node.pluginManager.startPluginOfficial(pluginURL, store); } else if (TYPENAME_FILE.equals(type)) { pi = node.pluginManager.startPluginFile(pluginURL, store); } else if (TYPENAME_FREENET.equals(type)) { diff --git a/src/freenet/clients/http/PproxyToadlet.java b/src/freenet/clients/http/PproxyToadlet.java index 12965a14b52..65008f84d8c 100644 --- a/src/freenet/clients/http/PproxyToadlet.java +++ b/src/freenet/clients/http/PproxyToadlet.java @@ -134,12 +134,11 @@ public void handleMethodPOST(URI uri, final HTTPRequest request, ToadletContext if (request.isPartSet("submit-official")) { final String pluginName = request.getPartAsStringFailsafe("plugin-name", 40); - final String pluginSource = request.getPartAsStringFailsafe("pluginSource", 10); - + node.executor.execute(new Runnable() { @Override public void run() { - pm.startPluginOfficial(pluginName, true, true, "https".equals(pluginSource)); + pm.startPluginOfficial(pluginName, true); } }); diff --git a/src/freenet/clients/http/staticfiles/globalsign.pem b/src/freenet/clients/http/staticfiles/globalsign.pem deleted file mode 100644 index f4ce4ca43dc..00000000000 --- a/src/freenet/clients/http/staticfiles/globalsign.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG -A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv -b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw -MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i -YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT -aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ -jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp -xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp -1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG -snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ -U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 -9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E -BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B -AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz -yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE -38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP -AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad -DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME -HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== ------END CERTIFICATE----- diff --git a/src/freenet/clients/http/wizardsteps/MISC.java b/src/freenet/clients/http/wizardsteps/MISC.java index 3c33da0f091..d297fcac809 100644 --- a/src/freenet/clients/http/wizardsteps/MISC.java +++ b/src/freenet/clients/http/wizardsteps/MISC.java @@ -99,7 +99,7 @@ public void setUPnP(final boolean enableUPnP) { @Override public void run() { if(enable) { - core.node.pluginManager.startPluginOfficial("UPnP", true, false, false); + core.node.pluginManager.startPluginOfficial("UPnP", true); } else { core.node.pluginManager.killPluginByClass("plugins.UPnP.UPnP", 5000); } diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index ff707988a5f..3c34ca83765 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -99,7 +99,6 @@ import freenet.node.stats.StoreCallbackStats; import freenet.node.updater.NodeUpdateManager; import freenet.pluginmanager.ForwardPort; -import freenet.pluginmanager.PluginDownLoaderOfficialHTTPS; import freenet.pluginmanager.PluginManager; import freenet.store.BlockMetadata; import freenet.store.CHKStore; @@ -956,7 +955,6 @@ public NodeStarter getNodeStarter(){ this.shutdownHook = SemiOrderedShutdownHook.get(); // Easy stuff String tmp = "Initializing Node using Freenet Build #"+Version.buildNumber()+" r"+Version.cvsRevision()+" and freenet-ext Build #"+NodeStarter.extBuildNumber+" r"+NodeStarter.extRevisionNumber+" with "+System.getProperty("java.vendor")+" JVM version "+System.getProperty("java.version")+" running on "+System.getProperty("os.arch")+' '+System.getProperty("os.name")+' '+System.getProperty("os.version"); - fixCertsFiles(); Logger.normal(this, tmp); System.out.println(tmp); collector = new IOStatisticCollector(); @@ -2709,42 +2707,6 @@ private void deleteOldBDBIndexStoreFiles() { } } - private void fixCertsFiles() { - // Hack to update certificates file to fix update.cmd - // startssl.pem: Might be useful for old versions of update.sh too? - File certs = new File(PluginDownLoaderOfficialHTTPS.certfileOld); - fixCertsFile(certs); - if(FileUtil.detectedOS.isWindows) { - // updater\startssl.pem: Needed for Windows update.cmd. - certs = new File("updater", PluginDownLoaderOfficialHTTPS.certfileOld); - fixCertsFile(certs); - } - } - - private void fixCertsFile(File certs) { - long oldLength = certs.exists() ? certs.length() : -1; - try { - File tmpFile = File.createTempFile(PluginDownLoaderOfficialHTTPS.certfileOld, ".tmp", new File(".")); - PluginDownLoaderOfficialHTTPS.writeCertsTo(tmpFile); - if(FileUtil.renameTo(tmpFile, certs)) { - long newLength = certs.length(); - if(newLength != oldLength) - System.err.println("Updated "+certs+" so that update scripts will work"); - } else { - if(certs.length() != tmpFile.length()) { - System.err.println("Cannot update "+certs+" : last-resort update scripts (in particular update.cmd on Windows) may not work"); - File manual = new File(PluginDownLoaderOfficialHTTPS.certfileOld+".new"); - manual.delete(); - if(tmpFile.renameTo(manual)) - System.err.println("Please delete "+certs+" and rename "+manual+" over it"); - else - tmpFile.delete(); - } - } - } catch (IOException e) { - } - } - /** ** Sets up a program directory using the config value defined by the given ** parameters. diff --git a/src/freenet/node/TextModeClientInterface.java b/src/freenet/node/TextModeClientInterface.java index 004cb523f43..3e11df6524b 100644 --- a/src/freenet/node/TextModeClientInterface.java +++ b/src/freenet/node/TextModeClientInterface.java @@ -936,7 +936,7 @@ else if(uline.startsWith("PUTSSKDIR:")) { } else if(uline.startsWith("PLUGLOAD")) { if(uline.startsWith("PLUGLOAD:O:")) { String name = line.substring("PLUGLOAD:O:".length()).trim(); - n.pluginManager.startPluginOfficial(name, true, false, false); + n.pluginManager.startPluginOfficial(name, true); } else if(uline.startsWith("PLUGLOAD:F:")) { String name = line.substring("PLUGLOAD:F:".length()).trim(); n.pluginManager.startPluginFile(name, true); diff --git a/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java b/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java deleted file mode 100644 index 6b9f7cc469e..00000000000 --- a/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java +++ /dev/null @@ -1,180 +0,0 @@ -/* This code is part of Freenet. It is distributed under the GNU General - * Public License, version 2 (or at your option any later version). See - * http://www.gnu.org/ for further details of the GPL. */ -package freenet.pluginmanager; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.security.KeyStore; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.util.Collection; -import java.util.Iterator; - -import freenet.pluginmanager.PluginManager.PluginProgress; -import freenet.support.api.Bucket; -import freenet.support.io.ArrayBucket; -import freenet.support.io.Closer; -import freenet.support.io.FileBucket; -import freenet.support.io.FileUtil; - -public class PluginDownLoaderOfficialHTTPS extends PluginDownLoaderURL { - private static final String certurlNew = "freenet/clients/http/staticfiles/globalsign.pem"; - private static final String[] certURLs = new String[] { certurlNew }; - public static final String certfileOld = "startssl.pem"; - private static final String certfile = "sslcerts.pem"; - - @Override - public URL checkSource(String source) throws PluginNotFoundException { - return super.checkSource("https://downloads.freenetproject.org/latest/" + - source + ".jar"); - } - - @Override - String getPluginName(String source) throws PluginNotFoundException { - return source + ".jar"; - } - - @Override - String getSHA1sum() throws PluginNotFoundException { - try { - URL sha1url = new URL(getSource().toString()+".sha1"); - URLConnection urlConnection = sha1url.openConnection(); - urlConnection.setUseCaches(false); - urlConnection.setAllowUserInteraction(false); - - InputStream is = openConnectionCheckRedirects(urlConnection); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[1024]; - int read; - - while ((read = is.read(buffer)) != -1) { - bos.write(buffer, 0, read); - } - - return new String(bos.toByteArray(), "ISO-8859-1").split(" ")[0]; - - } catch (MalformedURLException e) { - throw new PluginNotFoundException("impossible: "+e,e); - } catch (IOException e) { - throw new PluginNotFoundException("Error while fetching sha1 for plugin: "+e,e); - } - } - - @Override - InputStream getInputStream(PluginProgress progress) throws IOException { - File TMP_KEYSTORE = null; - FileInputStream fis = null; - InputStream is = null; - try { - TMP_KEYSTORE = File.createTempFile("keystore", ".tmp"); - TMP_KEYSTORE.deleteOnExit(); - - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(null, new char[0]); - - is = getCert(); - - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - Collection c = cf.generateCertificates(is); - Iterator it = c.iterator(); - while(it.hasNext()) { - Certificate cert = it.next(); - ks.setCertificateEntry(cert.getPublicKey().toString(), cert); - } - FileOutputStream tmpFOS = new FileOutputStream(TMP_KEYSTORE); - try { - ks.store(tmpFOS, new char[0]); - } finally { - Closer.close(tmpFOS); - } - System.out.println("The CA has been imported into the trustStore"); - } catch(Exception e) { - System.err.println("Error while handling the CA :" + e.getMessage()); - throw new IOException("Error while handling the CA : "+e); - } finally { - Closer.close(fis); - } - - System.setProperty("javax.net.ssl.trustStore", TMP_KEYSTORE.toString()); - - return super.getInputStream(progress); - } - - private InputStream getCert() throws IOException { - - // normal the file should be here, - // left by installer or update script - File certFile = new File(certfile).getAbsoluteFile(); - - if (certFile.exists()) { - return new FileInputStream(certFile); - } - - Bucket bucket; - OutputStream os = null; - - try { - try { - bucket = new FileBucket(certFile, false, false, false, false); - os = bucket.getOutputStream(); - writeCerts(os); - // If this fails, we need the whole fetch to fail. - os.close(); os = null; - } finally { - Closer.close(os); - } - return bucket.getInputStream(); - } catch (IOException e) { - // We don't have access to TempBucketFactory here. - // But the certs should be small, so just keep them in memory. - bucket = new ArrayBucket(); - os = bucket.getOutputStream(); - writeCerts(os); - os.close(); - return bucket.getInputStream(); - } - } - - private static void writeCerts(OutputStream os) throws IOException { - // try to create pem file - ClassLoader loader = ClassLoader.getSystemClassLoader(); - InputStream in = null; - for(String certurl : certURLs) { - try { - in = loader.getResourceAsStream(certurl); - if (in != null) { - FileUtil.copy(in, os, -1); - } else { - throw new IOException("Could not find certificates in fred source nor find certificates file"); - } - } finally { - if (in != null) { - in.close(); - } - } - } - } - - /** For the benefit mainly of the Windows updater script. - * It uses startssl.pem */ - public static void writeCertsTo(File file) throws IOException { - FileOutputStream fos = new FileOutputStream(file); - writeCerts(fos); - fos.close(); - } - - public boolean isOfficialPluginLoader() { - return true; - } - -} diff --git a/src/freenet/pluginmanager/PluginManager.java b/src/freenet/pluginmanager/PluginManager.java index 09ba6132b75..1221b7687fb 100644 --- a/src/freenet/pluginmanager/PluginManager.java +++ b/src/freenet/pluginmanager/PluginManager.java @@ -298,7 +298,7 @@ public PluginInfoWrapper startPluginAuto(final String pluginname, boolean store) OfficialPluginDescription desc; if((desc = isOfficialPlugin(pluginname)) != null) { - return startPluginOfficial(pluginname, store, desc, false, false); + return startPluginOfficial(pluginname, store, desc); } try { @@ -318,18 +318,13 @@ public PluginInfoWrapper startPluginAuto(final String pluginname, boolean store) return startPluginURL(pluginname, store); } - public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, boolean force, boolean forceHTTPS) { - return startPluginOfficial(pluginname, store, officialPlugins.get(pluginname), force, forceHTTPS); + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store) { + return startPluginOfficial(pluginname, store, officialPlugins.get(pluginname)); } - public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, OfficialPluginDescription desc, boolean force, boolean forceHTTPS) { - if((alwaysLoadOfficialPluginsFromCentralServer && !force)|| force && forceHTTPS) { - return realStartPlugin(new PluginDownLoaderOfficialHTTPS(), pluginname, store, - desc.alwaysFetchLatestVersion); - } else { - return realStartPlugin(new PluginDownLoaderOfficialFreenet(client, node, false), - pluginname, store, desc.alwaysFetchLatestVersion); - } + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, OfficialPluginDescription desc) { + return realStartPlugin(new PluginDownLoaderOfficialFreenet(client, node, false), + pluginname, store, desc.alwaysFetchLatestVersion); } public PluginInfoWrapper startPluginFile(final String filename, boolean store) { From 183759b8ec89a133fa3750658537de6d864a3f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 5 Sep 2023 22:56:43 +0200 Subject: [PATCH 142/500] =?UTF-8?q?=F0=9F=92=84=20Add=20a=20bit=20of=20sty?= =?UTF-8?q?ling=20to=20the=20plugin=20list=20(for=20winterfacey)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../http/staticfiles/themes/winterfacey/theme.css | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/freenet/clients/http/staticfiles/themes/winterfacey/theme.css b/src/freenet/clients/http/staticfiles/themes/winterfacey/theme.css index ae72cfaf8a0..f8fd84ced0f 100644 --- a/src/freenet/clients/http/staticfiles/themes/winterfacey/theme.css +++ b/src/freenet/clients/http/staticfiles/themes/winterfacey/theme.css @@ -1424,6 +1424,14 @@ body[id*="Sone"] { word-break: break-all; } +#page-_plugins_ .plugin-group { + margin: 1em 0; +} + +#page-_plugins_ .plugin-group-title { + font-weight: bold; +} + #masterPasswordForm label { margin: 0 10px 0 0; } @@ -1972,4 +1980,4 @@ body[id*="Sone"] { #page-_downloads_ #queue-legend td { font-size: 10px; } -} \ No newline at end of file +} From b3b7faa216579f1fdcedc6328604e8a585ecee00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 7 Sep 2023 22:23:39 +0200 Subject: [PATCH 143/500] =?UTF-8?q?=F0=9F=94=A5=20Remove=20http(s)=20downl?= =?UTF-8?q?oad=20from=20user=20alert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The user alert for failed plugin downloads suggested that it was still possible to download an official plugin over http(s). It was not, that code has already been removed. Now the user alert doesn’t suggest it anymore. --- src/freenet/l10n/freenet.l10n.de.properties | 4 +- src/freenet/l10n/freenet.l10n.en.properties | 4 +- src/freenet/l10n/freenet.l10n.es.properties | 3 -- src/freenet/l10n/freenet.l10n.fi.properties | 1 - src/freenet/l10n/freenet.l10n.fr.properties | 3 -- src/freenet/l10n/freenet.l10n.it.properties | 3 -- src/freenet/l10n/freenet.l10n.ja.properties | 3 -- .../l10n/freenet.l10n.nb-no.properties | 3 -- src/freenet/l10n/freenet.l10n.nl.properties | 3 -- .../l10n/freenet.l10n.pt-br.properties | 3 -- src/freenet/l10n/freenet.l10n.ru.properties | 3 -- .../l10n/freenet.l10n.zh-cn.properties | 3 -- .../l10n/freenet.l10n.zh-tw.properties | 3 -- src/freenet/pluginmanager/PluginManager.java | 39 +++++++------------ 14 files changed, 15 insertions(+), 63 deletions(-) diff --git a/src/freenet/l10n/freenet.l10n.de.properties b/src/freenet/l10n/freenet.l10n.de.properties index 423a5a0e604..c156a876c9d 100644 --- a/src/freenet/l10n/freenet.l10n.de.properties +++ b/src/freenet/l10n/freenet.l10n.de.properties @@ -1360,10 +1360,8 @@ PluginManager.pluginLoadingFailedShort=Das Plugin ${name} konnte nicht geladen w PluginManager.pluginLoadingFailed=Das Plugin (Erweiterung) ${name} konnte nicht geladen werden. PluginManager.pluginLoadingFailedStillTryingOverFreenet=Es wird immer noch versucht, das Plugin über das Freenet zu laden. PluginManager.pluginLoadingFailedWithMessage=Das Plugin (Erweiterung) ${name} konnte nicht geladen werden: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Sie können versuchen, dieses Plugin erneut über Freenet herunterladen, oder es über das Web probieren. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Sie können dieses Plugin über Freenet herunterladen, oder es noch einmal über das Web versuchen. +PluginManager.officialPluginLoadFailedSuggestTryAgain=Sie können es erneut versuchen. PluginManager.officialPluginLoadFailedTryAgainFreenet=Lade das Plugin aus dem Freenet -PluginManager.officialPluginLoadFailedTryAgain=Neuer Versuch, das offizielle Plugin von den Freenet-Webservern herunterzuladen (NICHT ANONYM!) PluginToadlet.addPluginTitle=Ein Plugin hinzufügen PluginToadlet.failedToLoadPlugin=Laden des Plugins fehlgeschlagen. PluginToadlet.failedToLoadPluginCheckClass=Das Plugin (Erweiterung), das Sie angefordert haben, konnte nicht geladen werden. Bitte überprüfen Sie den Namen der Klasse des Plugins und die URL, wenn Sie eine angegeben haben. diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 297828923af..4f7a4194556 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -1494,10 +1494,8 @@ PluginManager.pluginLoadingFailedShort=Could not load plugin ${name}! PluginManager.pluginLoadingFailed=The plugin ${name} could not be loaded PluginManager.pluginLoadingFailedStillTryingOverFreenet=We are still trying to load the plugin over Freenet. PluginManager.pluginLoadingFailedWithMessage=The plugin ${name} could not be loaded: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=You can try again over Freenet, or you can fetch it over the web. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=You can fetch the plugin over Freenet, or you can try again over the web. +PluginManager.officialPluginLoadFailedSuggestTryAgain=You can try again. PluginManager.officialPluginLoadFailedTryAgainFreenet=Load the plugin from Freenet -PluginManager.officialPluginLoadFailedTryAgain=Load the plugin over the web from our server (NOT ANONYMOUS!) PluginToadlet.addPluginTitle=Add a plugin PluginToadlet.failedToLoadPlugin=Failed to load plugin. PluginToadlet.failedToLoadPluginCheckClass=The plugin you requested could not be loaded. Please verify the name of the plugin's class and the URL, if you gave one. diff --git a/src/freenet/l10n/freenet.l10n.es.properties b/src/freenet/l10n/freenet.l10n.es.properties index 08ccc9999d3..b51e640fb45 100644 --- a/src/freenet/l10n/freenet.l10n.es.properties +++ b/src/freenet/l10n/freenet.l10n.es.properties @@ -1391,10 +1391,7 @@ PluginManager.pluginLoadingFailedShort=¡No se pudo cargar el complemento ${name PluginManager.pluginLoadingFailed=No se pudo cargar el complemento ${name} PluginManager.pluginLoadingFailedStillTryingOverFreenet=Aún estamos intentando cargar el complemento desde Freenet. PluginManager.pluginLoadingFailedWithMessage=El complemento ${name} no se pudo cargar: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Puede intentarlo de nuevo a través de Freenet, o puede obtenerlo desde la web. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Puede obtener el complemento (plugin) a través de Freenet, o puede intentarlo de nuevo desde la web. PluginManager.officialPluginLoadFailedTryAgainFreenet=Cargar el complemento desde Freenet -PluginManager.officialPluginLoadFailedTryAgain=Cargar el complemento vía web desde nuestros servidores (¡NO ES ANÓNIMO!) PluginToadlet.addPluginTitle=Añadir un complemento PluginToadlet.failedToLoadPlugin=Fallo al cargar el complemento. PluginToadlet.failedToLoadPluginCheckClass=No se pudo cargar el complemento (plugin) solicitado. Verifique por favor el nombre de clase del complemento y su URL, si dio una. diff --git a/src/freenet/l10n/freenet.l10n.fi.properties b/src/freenet/l10n/freenet.l10n.fi.properties index 1d204250134..e59240740cb 100644 --- a/src/freenet/l10n/freenet.l10n.fi.properties +++ b/src/freenet/l10n/freenet.l10n.fi.properties @@ -860,7 +860,6 @@ PluginManager.pluginLoadingFailedShort=Liitännäistä ${name} ei voitu ottaa k PluginManager.pluginLoadingFailed=Määritettyä liitännäistä ${name} ei voitu ottaa käyttöön PluginManager.pluginLoadingFailedStillTryingOverFreenet=Yritämme yhä ladata lisäosaa Freenetistä. PluginManager.pluginLoadingFailedWithMessage=Määritettyä liitännäistä ${name} ei voitu ottaa käyttöön: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Voit yrittää uudelleen Freenetistä tai voit hakea sen webistä. PluginManager.officialPluginLoadFailedTryAgainFreenet=Lataa lisäosa Freenetistä. PluginToadlet.addPluginTitle=Lisää liitännäinen PluginToadlet.failedToLoadPlugin=Liitännäisen lisäys epäonnistui. diff --git a/src/freenet/l10n/freenet.l10n.fr.properties b/src/freenet/l10n/freenet.l10n.fr.properties index f40574d6087..4b9184ab36d 100644 --- a/src/freenet/l10n/freenet.l10n.fr.properties +++ b/src/freenet/l10n/freenet.l10n.fr.properties @@ -1389,10 +1389,7 @@ PluginManager.pluginLoadingFailedShort=Impossible de charger le greffon ${name} PluginManager.pluginLoadingFailed=Le greffon ${name} n’a pas pu être chargé PluginManager.pluginLoadingFailedStillTryingOverFreenet=Nous essayons toujours de charger le greffon depuis Freenet. PluginManager.pluginLoadingFailedWithMessage=Le greffon ${name} n’a pas pu être chargé : ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Vous pouvez réessayer sur Freenet ou vous pouvez le récupérer sur le Web. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Vous pouvez récupérer le greffon depuis Freenet, ou vous pouvez réessayer par le Web. PluginManager.officialPluginLoadFailedTryAgainFreenet=Charger le greffon depuis Freenet -PluginManager.officialPluginLoadFailedTryAgain=Charger le greffon à partir de notre serveur par le Web (N’EST PAS ANONYME !) PluginToadlet.addPluginTitle=Ajouter un greffon PluginToadlet.failedToLoadPlugin=Échec de chargement du greffon. PluginToadlet.failedToLoadPluginCheckClass=Le greffon que vous avez demandé n’a pas pu être chargé. Veuillez vérifier le nom de la classe du greffon et l’URL, si vous en avez donné une. diff --git a/src/freenet/l10n/freenet.l10n.it.properties b/src/freenet/l10n/freenet.l10n.it.properties index 4e279fa1319..fb5469ba667 100644 --- a/src/freenet/l10n/freenet.l10n.it.properties +++ b/src/freenet/l10n/freenet.l10n.it.properties @@ -1296,10 +1296,7 @@ PluginManager.pluginLoadingFailedShort=Impossibile caricare il plugin ${name}! PluginManager.pluginLoadingFailed=Non è stato possibile caricare il plugin specificato ${name}. PluginManager.pluginLoadingFailedStillTryingOverFreenet=Il caricamento del plugin da Freenet è ancora in corso. PluginManager.pluginLoadingFailedWithMessage=Non è stato possibile caricare il plugin specificato ${name}: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=È possibile riprovare a scaricare da Freenet, o scaricare dal web -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=È possibile scaricare il plugin via Freenet o riprovare a scaricarlo via web. PluginManager.officialPluginLoadFailedTryAgainFreenet=Carica il plugin da Freenet -PluginManager.officialPluginLoadFailedTryAgain=Carica il plugin sul web dal nostro server (NON ANONIMO!) PluginToadlet.addPluginTitle=Carica plugin PluginToadlet.failedToLoadPlugin=Caricamento plugin fallito. PluginToadlet.failedToLoadPluginCheckClass=Non è stato possibile caricare il plugin richiesto. Verificare il nome del plugin, class, e URL se se ne è usata una. diff --git a/src/freenet/l10n/freenet.l10n.ja.properties b/src/freenet/l10n/freenet.l10n.ja.properties index 43ed808d927..9f805522dc9 100644 --- a/src/freenet/l10n/freenet.l10n.ja.properties +++ b/src/freenet/l10n/freenet.l10n.ja.properties @@ -872,10 +872,7 @@ PluginManager.pluginLoadingFailedShort=プラグイン${name}をロードでき PluginManager.pluginLoadingFailed=プラグイン ${name} はロードできませんでした PluginManager.pluginLoadingFailedStillTryingOverFreenet=我々はまだFreeenetからプラグインをロードしようとしています。 PluginManager.pluginLoadingFailedWithMessage=プラグイン ${name} をロードできませんでした: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Freenet経由で再トライできますが、web経由でフェッチすることもできます。 -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Freenetからプラグインをフェッチできますが、web経由で再トライすることもできます。 PluginManager.officialPluginLoadFailedTryAgainFreenet=Freenetからプラグインを読み込む -PluginManager.officialPluginLoadFailedTryAgain=Web経由で我々のサーバからプラグインをロードする (匿名ではありません!) PluginToadlet.addPluginTitle=プラグインを追加 PluginToadlet.failedToLoadPlugin=プラグインのロードに失敗しました。 PluginToadlet.failedToLoadPluginCheckClass=リクエストされたプラグインが読み込めませんでした。プラグインのクラス名と、URLを指定している場合はそのURLを確認してください。 diff --git a/src/freenet/l10n/freenet.l10n.nb-no.properties b/src/freenet/l10n/freenet.l10n.nb-no.properties index 619bbad1a3c..23dc8ee9413 100644 --- a/src/freenet/l10n/freenet.l10n.nb-no.properties +++ b/src/freenet/l10n/freenet.l10n.nb-no.properties @@ -1075,10 +1075,7 @@ PluginManager.pluginLoadingFailedShort=Kunne ikke å laste programtillegget ${na PluginManager.pluginLoadingFailed=Kunne ikke laste inn programtillegget ${name} PluginManager.pluginLoadingFailedStillTryingOverFreenet=Prøver fremdeles å laste programtillegget over Freenet. PluginManager.pluginLoadingFailedWithMessage=Kunne ikke laste inn programtillegget ${name}: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Du kan prøve igjen over Freenet, eller hente det ned over nettet. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Du kan hente inn programtillegget over Freenet, eller du kan prøve igjen via vev-en. PluginManager.officialPluginLoadFailedTryAgainFreenet=Last programtillegget fra Freenet -PluginManager.officialPluginLoadFailedTryAgain=Last inn et programtillegg fra vev-en fra våre tjenere (IKKE ANONYMT!) PluginToadlet.addPluginTitle=Legg til et programtillegg PluginToadlet.failedToLoadPlugin=Innlasting av programtillegg mislyktes. PluginToadlet.failedToLoadPluginCheckClass=Programtillegget du bad om kunne ikke lastes. Sjekk navnet på tilleggets klasse og URL, hvis du har angitt det. diff --git a/src/freenet/l10n/freenet.l10n.nl.properties b/src/freenet/l10n/freenet.l10n.nl.properties index 4ff487f0c3d..3f65ee1a150 100644 --- a/src/freenet/l10n/freenet.l10n.nl.properties +++ b/src/freenet/l10n/freenet.l10n.nl.properties @@ -1345,10 +1345,7 @@ PluginManager.pluginLoadingFailedShort=Plugin ${name} kon niet geladen worden. PluginManager.pluginLoadingFailed=De opgegeven plugin ${name} kon niet worden geladen PluginManager.pluginLoadingFailedStillTryingOverFreenet=Deze node probeert nog steeds de plugin te laden via Freenet. PluginManager.pluginLoadingFailedWithMessage=De opgegeven plugin ${name} kon niet worden geladen: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Je kunt de plugin opnieuw proberen binnen te halen via Freenet of via het web. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Je kunt de plugin binnenhalen via Freenet of het opnieuw proberen via het web. PluginManager.officialPluginLoadFailedTryAgainFreenet=De plugin laden van Freenet -PluginManager.officialPluginLoadFailedTryAgain=Haal de laatste versie van Freenet op van de servers van het Freenet project. (NIET ANONIEM!) PluginToadlet.addPluginTitle=Plugin toevoegen PluginToadlet.failedToLoadPlugin=Laden van plugin mislukt. PluginToadlet.failedToLoadPluginCheckClass=De opgegeven plugin kan niet worden geladen. Controleer de naam van de plugin in de URL (indien opgegeven). diff --git a/src/freenet/l10n/freenet.l10n.pt-br.properties b/src/freenet/l10n/freenet.l10n.pt-br.properties index ca1e22d89bf..bd9b1ee867d 100644 --- a/src/freenet/l10n/freenet.l10n.pt-br.properties +++ b/src/freenet/l10n/freenet.l10n.pt-br.properties @@ -1287,10 +1287,7 @@ PluginManager.pluginLoadingFailedShort=A extensão ${name} não pôde ser carreg PluginManager.pluginLoadingFailed=Não foi possível carregar a extensão ${name} PluginManager.pluginLoadingFailedStillTryingOverFreenet=Estamos ainda tentando carregar a extensão a partir da Freenet. PluginManager.pluginLoadingFailedWithMessage=Não foi possível carregar a extensão ${name}: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Você pode tentar novamente na Freenet ou pode obtê-la via web. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Você pode obter a extensão via Freenet, ou pode tentar novamente através da Web. PluginManager.officialPluginLoadFailedTryAgainFreenet=Carregar a extensão via Freenet -PluginManager.officialPluginLoadFailedTryAgain=Carregar a extensão através da web a partir do nosso servidor (NÃO ANÔNIMO!) PluginToadlet.addPluginTitle=Adicionar uma extensão PluginToadlet.failedToLoadPlugin=Falha ao carregar extensão. PluginToadlet.failedToLoadPluginCheckClass=A extensão que você solicitou não pôde ser carregada. Por favor, verifique o nome da classe da extensão e o URL, caso tenha fornecido um. diff --git a/src/freenet/l10n/freenet.l10n.ru.properties b/src/freenet/l10n/freenet.l10n.ru.properties index 229b85d0a30..b449499f67a 100644 --- a/src/freenet/l10n/freenet.l10n.ru.properties +++ b/src/freenet/l10n/freenet.l10n.ru.properties @@ -1289,10 +1289,7 @@ PluginManager.pluginLoadingFailedShort=Не могу загрузить допо PluginManager.pluginLoadingFailed=Сбой при загрузке дополнения ${name} PluginManager.pluginLoadingFailedStillTryingOverFreenet=Мы все еще пытаемся загрузить дополнение через Фринет. PluginManager.pluginLoadingFailedWithMessage=Сбой при загрузке дополнения ${name}: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=Вы можете еще раз попробовать получить дополнение через Фринет, или загрузить его через Веб. -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=Вы можете получить дополнение через Фринет или попробовать загрузить его через Веб. PluginManager.officialPluginLoadFailedTryAgainFreenet=Загрузить дополнение из Фринета -PluginManager.officialPluginLoadFailedTryAgain=Загрузить дополнение с нашего сервера через Веб (НЕ АНОНИМНО!) PluginToadlet.addPluginTitle=Добавить дополнение PluginToadlet.failedToLoadPlugin=Сбой при загрузке дополнения. PluginToadlet.failedToLoadPluginCheckClass=Запрашиваемое дополнение не может быть загружено. Проверьте название класса дополнения и URL, если вы указывали его. diff --git a/src/freenet/l10n/freenet.l10n.zh-cn.properties b/src/freenet/l10n/freenet.l10n.zh-cn.properties index b4640f7c659..13eed4848ab 100644 --- a/src/freenet/l10n/freenet.l10n.zh-cn.properties +++ b/src/freenet/l10n/freenet.l10n.zh-cn.properties @@ -1397,10 +1397,7 @@ PluginManager.pluginLoadingFailedShort=无法加载插件 ${name}! PluginManager.pluginLoadingFailed=插件 ${name} 无法加载 PluginManager.pluginLoadingFailedStillTryingOverFreenet=我们仍然在尝试从 Freenet 加载插件。 PluginManager.pluginLoadingFailedWithMessage=插件 ${name} 无法加载: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=您可以重试通过 Freenet 获取插件,或者通过 Web 获取。 -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=您可以从 Freenet 获取插件,或者重试通过 Web 获取。 PluginManager.officialPluginLoadFailedTryAgainFreenet=从 Freenet 加载插件 -PluginManager.officialPluginLoadFailedTryAgain=通过 Web 从我们的服务器加载插件 (不是匿名的!) PluginToadlet.addPluginTitle=添加插件 PluginToadlet.failedToLoadPlugin=加载插件失败。 PluginToadlet.failedToLoadPluginCheckClass=您请求的插件无法被加载。如果您指定了插件类名和 URL ,请确认它们是否正确。 diff --git a/src/freenet/l10n/freenet.l10n.zh-tw.properties b/src/freenet/l10n/freenet.l10n.zh-tw.properties index ba6a62f588a..66091452892 100644 --- a/src/freenet/l10n/freenet.l10n.zh-tw.properties +++ b/src/freenet/l10n/freenet.l10n.zh-tw.properties @@ -1387,10 +1387,7 @@ PluginManager.pluginLoadingFailedShort=無法載入外掛 ${name}! PluginManager.pluginLoadingFailed=指定的外掛 ${name} 無法載入 PluginManager.pluginLoadingFailedStillTryingOverFreenet=我們仍然在嘗試從 Freenet 載入外掛。 PluginManager.pluginLoadingFailedWithMessage=指定的外掛 ${name} 無法載入: ${message} -PluginManager.officialPluginLoadFailedSuggestTryAgainFreenet=您可以重試通過 Freenet 獲取外掛,或者通過 Web 獲取。 -PluginManager.officialPluginLoadFailedSuggestTryAgainHTTPS=您可以從 Freenet 獲取外掛,或者重試通過 Web 獲取。 PluginManager.officialPluginLoadFailedTryAgainFreenet=從 Freenet 載入外掛 -PluginManager.officialPluginLoadFailedTryAgain=通過 Web 從我們的伺服器載入外掛 (不是匿名的!) PluginToadlet.addPluginTitle=新增外掛 PluginToadlet.failedToLoadPlugin=載入外掛失敗. PluginToadlet.failedToLoadPluginCheckClass=你要求的外掛無法備載入. 請檢查外掛程式的類別名稱是否正確, 如果你指定了 URL 也請加以檢查. diff --git a/src/freenet/pluginmanager/PluginManager.java b/src/freenet/pluginmanager/PluginManager.java index 1221b7687fb..7f09125ba85 100644 --- a/src/freenet/pluginmanager/PluginManager.java +++ b/src/freenet/pluginmanager/PluginManager.java @@ -378,7 +378,7 @@ public void run() { } } PluginLoadFailedUserAlert newAlert = - new PluginLoadFailedUserAlert(filename, pdl.isOfficialPluginLoader(), pdl.isOfficialPluginLoader() && pdl.isLoadingFromFreenet(), stillTrying, e); + new PluginLoadFailedUserAlert(filename, pdl.isOfficialPluginLoader(), stillTrying, e); PluginLoadFailedUserAlert oldAlert = loadedPlugins.replaceUserAlert(filename, newAlert); core.alerts.register(newAlert); core.alerts.unregister(oldAlert); @@ -390,7 +390,7 @@ public void run() { System.err.println("Plugin " + filename + " appears to require a later JVM"); Logger.error(this, "Plugin " + filename + " appears to require a later JVM"); PluginLoadFailedUserAlert newAlert = - new PluginLoadFailedUserAlert(filename, pdl.isOfficialPluginLoader(), pdl.isOfficialPluginLoader() && pdl.isLoadingFromFreenet(), false, l10n("pluginReqNewerJVMTitle", "name", filename)); + new PluginLoadFailedUserAlert(filename, pdl.isOfficialPluginLoader(), false, l10n("pluginReqNewerJVMTitle", "name", filename)); PluginLoadFailedUserAlert oldAlert = loadedPlugins.replaceUserAlert(filename, newAlert); core.alerts.register(newAlert); core.alerts.unregister(oldAlert); @@ -401,7 +401,7 @@ public void run() { System.err.println("Plugin "+filename+" is broken, but we want to retry after next startup"); Logger.error(this, "Plugin "+filename+" is broken, but we want to retry after next startup"); PluginLoadFailedUserAlert newAlert = - new PluginLoadFailedUserAlert(filename, pdl.isOfficialPluginLoader(), pdl.isOfficialPluginLoader() && pdl.isLoadingFromFreenet(), false, e); + new PluginLoadFailedUserAlert(filename, pdl.isOfficialPluginLoader(), false, e); PluginLoadFailedUserAlert oldAlert = loadedPlugins.replaceUserAlert(filename, newAlert); core.alerts.register(newAlert); core.alerts.unregister(oldAlert); @@ -435,22 +435,20 @@ class PluginLoadFailedUserAlert extends AbstractUserAlert { final String message; final StackTraceElement[] stacktrace; final boolean official; - final boolean officialFromFreenet; - final boolean stillTryingOverFreenet; + final boolean stillTrying; - public PluginLoadFailedUserAlert(String filename, boolean official, boolean officialFromFreenet, boolean stillTryingOverFreenet, String message) { + public PluginLoadFailedUserAlert(String filename, boolean official, boolean stillTrying, String message) { this.filename = filename; this.official = official; this.message = message; this.stacktrace = null; - this.officialFromFreenet = officialFromFreenet; - this.stillTryingOverFreenet = stillTryingOverFreenet; + this.stillTrying = stillTrying; } - public PluginLoadFailedUserAlert(String filename, boolean official, boolean officialFromFreenet, boolean stillTryingOverFreenet, Throwable e) { + public PluginLoadFailedUserAlert(String filename, boolean official, boolean stillTrying, Throwable e) { this.filename = filename; this.official = official; - this.stillTryingOverFreenet = stillTryingOverFreenet; + this.stillTrying = stillTrying; String msg; if(e instanceof PluginNotFoundException) { msg = e.getMessage(); @@ -462,7 +460,6 @@ public PluginLoadFailedUserAlert(String filename, boolean official, boolean offi } if(msg == null) msg = e.toString(); this.message = msg; - this.officialFromFreenet = officialFromFreenet; } @Override @@ -502,28 +499,18 @@ public HTMLNode getHTMLText() { } } - if(stillTryingOverFreenet) { + if(stillTrying) { div.addChild("p", l10n("pluginLoadingFailedStillTryingOverFreenet")); } if(official) { p = div.addChild("p"); - if(officialFromFreenet) - p.addChild("#", l10n("officialPluginLoadFailedSuggestTryAgainFreenet")); - else - p.addChild("#", l10n("officialPluginLoadFailedSuggestTryAgainHTTPS")); - - HTMLNode reloadForm = div.addChild("form", new String[] { "action", "method" }, new String[] { "/plugins/", "post" }); - reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword }); - reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "plugin-name", filename }); - reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "pluginSource", "https" }); - reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit-official", l10n("officialPluginLoadFailedTryAgain") }); - - if(!stillTryingOverFreenet) { - reloadForm = div.addChild("form", new String[] { "action", "method" }, new String[] { "/plugins/", "post" }); + p.addChild("#", l10n("officialPluginLoadFailedSuggestTryAgain")); + + if(!stillTrying) { + HTMLNode reloadForm = div.addChild("form", new String[] { "action", "method" }, new String[] { "/plugins/", "post" }); reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "formPassword", node.clientCore.formPassword }); reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "plugin-name", filename }); - reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "pluginSource", "freenet" }); reloadForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "submit", "submit-official", l10n("officialPluginLoadFailedTryAgainFreenet") }); } } From 80cbda87bbc1af128fea5cda2c8a272c101630a5 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 19 Apr 2023 23:04:01 +0200 Subject: [PATCH 144/500] Use logging instead of backtrace for IPv6-addresses when unsupported Throwing backtraces is needlessly expensive and spams the log with no additional gain. --- src/freenet/io/comm/UdpSocketHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/io/comm/UdpSocketHandler.java b/src/freenet/io/comm/UdpSocketHandler.java index c004613a9d2..d21abc8b415 100644 --- a/src/freenet/io/comm/UdpSocketHandler.java +++ b/src/freenet/io/comm/UdpSocketHandler.java @@ -17,6 +17,7 @@ import java.net.InetAddress; import java.net.SocketException; import java.net.SocketTimeoutException; +import java.nio.channels.UnsupportedAddressTypeException; import java.util.Random; import freenet.io.AddressTracker; @@ -338,7 +339,7 @@ public void sendPacket(byte[] blockToSend, Peer destination, boolean allowLocalA boolean isLocal = (!IPUtil.isValidAddress(address, false)) && (IPUtil.isValidAddress(address, true)); collector.addInfo(address, port, 0, getHeadersLength(address) + blockToSend.length, isLocal); if(logMINOR) Logger.minor(this, "Sent packet length "+blockToSend.length+" to "+address+':'+port); - } catch (IOException e) { + } catch (IOException | UnsupportedAddressTypeException e) { if(packet.getAddress() instanceof Inet6Address) { Logger.normal(this, "Error while sending packet to IPv6 address: "+destination+": "+e); } else { From e02edc2d6b603ca1d081d1fcb6a1ba3688b0cc1e Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 00:47:56 +0200 Subject: [PATCH 145/500] =?UTF-8?q?fix=20the=20flag=20size=20of=20nepal=20?= =?UTF-8?q?=E2=80=94=20thanks=20to=20Percept0r@NYZkOs7eQ=E2=80=A6!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clients/http/staticfiles/icon/flags/np.png | Bin 443 -> 451 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/freenet/clients/http/staticfiles/icon/flags/np.png b/src/freenet/clients/http/staticfiles/icon/flags/np.png index aeb058b7ea8b5d88519dadc69cfe7cdba77a587f..19ccd010e37fa078819af357fbd73b01a49f8e9f 100755 GIT binary patch literal 451 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~o!3-oFZT@ltsgnUdA+A4f-{#=8dJ-GU$!Bwi zfq{d^f?L4-Rc)=Hbg7_J5to1qx1gtzOpcID#m@&1q(tou)ORWvUK0~CJI=uHY2CWb z3=GO9*Y10J|9bZ9*OMoYgMwBwFv#jo6PB(2dH=q==KMb&KD=RIkdp{~)ztL+^=ozc zW@D|Bd}6T@a`oC4yPxOgK4)S&#K54Zy7~qKgO<|FHys^poMsmo7>pdx9b{m*%fRsS z&K(_>E$rMD>|Ex?n#Z{K?d~x!{C@T7NqG1NpzPhd-!5PN|Nnndi5AdF49+D%e!)O4 zg@C~^iRC@exHL}}$B>F!Nddwl#ZGKIVc%{Y(_muin$$Pz1k)}qJ|3Y@9!$TKw6-mC zlj2|ul@=?OjEwW!!O%ai(TIJMq}Q98qDQYhnEphi@%Svt;b2ruwAPdr&UD+sU_RZ{ jSb25pQpFGkg#!$SKdV?5dqmj)ZDjCt^>bP0l+XkK;nvCI literal 443 zcmV;s0Yv_ZP)KAO>U2WB)$@6+CBT{3ok>^7H@y{~6FRKmalQ{r8#S z4^Xx6Je&%q%J2@E@iKAb=Rv<(vO+e^|@#56B5{*~0Mg z Date: Sat, 9 Sep 2023 17:08:41 +0200 Subject: [PATCH 146/500] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Add=20deprecate?= =?UTF-8?q?d=20methods=20for=20legacy=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As basically all of Fred is public API, someone might actually use these methods. --- src/freenet/pluginmanager/PluginManager.java | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/freenet/pluginmanager/PluginManager.java b/src/freenet/pluginmanager/PluginManager.java index 7f09125ba85..4a36e821f1d 100644 --- a/src/freenet/pluginmanager/PluginManager.java +++ b/src/freenet/pluginmanager/PluginManager.java @@ -322,11 +322,33 @@ public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean st return startPluginOfficial(pluginname, store, officialPlugins.get(pluginname)); } + /** + * Use {@link #startPluginOfficial(String, boolean)}. + * + * @param force This parameter is ignored. + * @param forceHTTPS This parameter is ignored. + */ + @Deprecated + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, boolean force, boolean forceHTTPS) { + return startPluginOfficial(pluginname, store); + } + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, OfficialPluginDescription desc) { return realStartPlugin(new PluginDownLoaderOfficialFreenet(client, node, false), pluginname, store, desc.alwaysFetchLatestVersion); } + /** + * Use {@link #startPluginOfficial(String, boolean, OfficialPluginDescription)}. + * + * @param force This parameter is ignored. + * @param forceHTTPS This parameter is ignored. + */ + @Deprecated + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, OfficialPluginDescription officialPluginDescription, boolean force, boolean forceHTTPS) { + return startPluginOfficial(pluginname, store, officialPluginDescription); + } + public PluginInfoWrapper startPluginFile(final String filename, boolean store) { return realStartPlugin(new PluginDownLoaderFile(), filename, store, false); } From c0b666deb69519d90be9a2af1b3087e5e7b70b5e Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 19 Apr 2023 22:56:42 +0200 Subject: [PATCH 147/500] html-filter: allow summary and details html element. Thanks to naejadu --- src/freenet/client/filter/HTMLFilter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/freenet/client/filter/HTMLFilter.java b/src/freenet/client/filter/HTMLFilter.java index 1372b571cd2..62d46126488 100644 --- a/src/freenet/client/filter/HTMLFilter.java +++ b/src/freenet/client/filter/HTMLFilter.java @@ -993,7 +993,9 @@ private static Map getAllowedTagVerifiers() "article", "section", "hgroup", - "wbr"}; + "wbr", + "summary", + "details"}; for (String x: group2) allowedTagsVerifiers.put( x, From 8d12ea0dfa8d50c462c9e6584617cbfd13792d83 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 21:10:00 +0200 Subject: [PATCH 148/500] Add test for article, details, wbr, and summary tags --- .../client/filter/ContentFilterTest.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index 9da9cfe2505..007fb3d56df 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -113,13 +113,15 @@ public class ContentFilterTest { private static final String SPAN_WITH_STYLE = ""; - private static final String BASE_HREF = ""; - private static final String BAD_BASE_HREF = ""; - private static final String BAD_BASE_HREF2 = ""; - private static final String BAD_BASE_HREF3 = ""; - private static final String BAD_BASE_HREF4 = ""; - private static final String BAD_BASE_HREF5 = ""; - private static final String DELETED_BASE_HREF = ""; + private static final String HTML5_TAGS = "

TLDR
Too Long Didn’t Read
"; + + private static final String BASE_HREF = ""; + private static final String BAD_BASE_HREF = ""; + private static final String BAD_BASE_HREF2 = ""; + private static final String BAD_BASE_HREF3 = ""; + private static final String BAD_BASE_HREF4 = ""; + private static final String BAD_BASE_HREF5 = ""; + private static final String DELETED_BASE_HREF = ""; // From CSS spec @@ -182,7 +184,8 @@ public void testHTMLFilter() throws Exception { assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1)); - assertEquals(SPAN_WITH_STYLE, htmlFilter(SPAN_WITH_STYLE)); + assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); + assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS)); assertEquals(BASE_HREF, htmlFilter(BASE_HREF)); assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF)); From b061af641de8f8d691b782d9fe4d7d3bfe16061e Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 9 Sep 2023 18:17:32 +0200 Subject: [PATCH 149/500] Fix whitespace --- test/freenet/client/filter/ContentFilterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index 007fb3d56df..a680db592e3 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -184,8 +184,8 @@ public void testHTMLFilter() throws Exception { assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1)); - assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); - assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS)); + assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); + assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS)); assertEquals(BASE_HREF, htmlFilter(BASE_HREF)); assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF)); From 3c33e770956a7d42dd82ef416b7a047c30e499cd Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 9 Sep 2023 14:34:04 +0200 Subject: [PATCH 150/500] Set the new load management option to ignored. --- src/freenet/node/NodeStats.java | 44 +++------------------------------ 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/src/freenet/node/NodeStats.java b/src/freenet/node/NodeStats.java index db80bacc847..94c138836f5 100644 --- a/src/freenet/node/NodeStats.java +++ b/src/freenet/node/NodeStats.java @@ -319,8 +319,8 @@ public void shouldUpdate(){ public final DecayingKeyspaceAverage avgClientCacheSSKSuccess; public final DecayingKeyspaceAverage avgStoreSSKSuccess; - private volatile boolean enableNewLoadManagementRT; - private volatile boolean enableNewLoadManagementBulk; + private final boolean enableNewLoadManagementRT = false; + private final boolean enableNewLoadManagementBulk = false; NodeStats(Node node, int sortOrder, SubConfig statsConfig, int obwLimit, int ibwLimit, int lastVersion) throws NodeInitException { this.node = node; @@ -509,44 +509,8 @@ public void onChange(NETWORK_THREAT_LEVEL oldLevel, NETWORK_THREAT_LEVEL newLeve }); - statsConfig.register("enableNewLoadManagementRT", false, sortOrder++, true, false, "Node.enableNewLoadManagementRT", "Node.enableNewLoadManagementRTLong", new BooleanCallback() { - - @Override - public Boolean get() { - return enableNewLoadManagementRT; - } - - @Override - public void set(Boolean val) throws InvalidConfigValueException, - NodeNeedRestartException { - enableNewLoadManagementRT = val; - } - - }); - enableNewLoadManagementRT = statsConfig.getBoolean("enableNewLoadManagementRT"); - statsConfig.register("enableNewLoadManagementBulk", false, sortOrder++, true, false, "Node.enableNewLoadManagementBulk", "Node.enableNewLoadManagementBulkLong", new BooleanCallback() { - - @Override - public Boolean get() { - return enableNewLoadManagementBulk; - } - - @Override - public void set(Boolean val) throws InvalidConfigValueException, - NodeNeedRestartException { - enableNewLoadManagementBulk = val; - } - - }); - enableNewLoadManagementBulk = statsConfig.getBoolean("enableNewLoadManagementBulk"); - - if(node.lastVersion <= 1455 && (enableNewLoadManagementRT || enableNewLoadManagementBulk)) { - // FIXME remove - enableNewLoadManagementRT = false; - enableNewLoadManagementBulk = false; - System.err.println("Turning off NLM when upgrading from pre-1455. The load stats messages aren't being sent at the moment so it won't work anyway."); - statsConfig.config.store(); - } + statsConfig.registerIgnoredOption("enableNewLoadManagementRT"); + statsConfig.registerIgnoredOption("enableNewLoadManagementBulk"); persister = new ConfigurablePersister(this, statsConfig, "nodeThrottleFile", "node-throttle.dat", sortOrder++, true, false, "NodeStat.statsPersister", "NodeStat.statsPersisterLong", node.ticker, node.getRunDir()); From e276a83e509396c77d0c427ff70bbe0452c7ee13 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 10 Sep 2023 07:45:41 +0200 Subject: [PATCH 151/500] Move Library to advanced plugins because new users tend to get lost Before moving it back to the default list of plugins, we need to figure out a good user experience for it. At the moment either it does not work or it floods users with bad results. --- src/freenet/pluginmanager/OfficialPlugins.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/pluginmanager/OfficialPlugins.java b/src/freenet/pluginmanager/OfficialPlugins.java index 8252f6d67e8..a0adbfb59b5 100644 --- a/src/freenet/pluginmanager/OfficialPlugins.java +++ b/src/freenet/pluginmanager/OfficialPlugins.java @@ -107,7 +107,8 @@ public OfficialPlugins() { .recommendedVersion(37) .minimumVersion(36) .usesXml() - .loadedFrom("CHK@RrYmOu8RGoEY44LOgGBBgY9qRxmiev0SFAVxWAbwROI,cfYMrDcBdewk4I7AC4J3mAq0g~NH3TxVpfeSkQ9Xaa8,AAMC--8/Library.jar"); + .loadedFrom("CHK@RrYmOu8RGoEY44LOgGBBgY9qRxmiev0SFAVxWAbwROI,cfYMrDcBdewk4I7AC4J3mAq0g~NH3TxVpfeSkQ9Xaa8,AAMC--8/Library.jar") + .advanced(); addPlugin("Spider") .inGroup("index") .minimumVersion(53) From 0f40c12fe475da58d51bd597ead4b1380ad00ca8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 10 Sep 2023 07:49:11 +0200 Subject: [PATCH 152/500] Move UPnP2 to normal plugins. It does not seem broken, but UPnP does There were several reports from users that UPnP did not start. We should give UPnP2 more testing so we can enable it by default. --- src/freenet/pluginmanager/OfficialPlugins.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/freenet/pluginmanager/OfficialPlugins.java b/src/freenet/pluginmanager/OfficialPlugins.java index 8252f6d67e8..1cd87e0782a 100644 --- a/src/freenet/pluginmanager/OfficialPlugins.java +++ b/src/freenet/pluginmanager/OfficialPlugins.java @@ -83,8 +83,7 @@ public OfficialPlugins() { .loadedFrom("CHK@ZiX8yeMHTUtNfJAgxpwH~jLRnnbb41BKEkAxOD~33tY,aBTvD3IoPKPLjnHOCNQ4-iRwqVED5kHgkmD4UhGdITk,AAMC--8/UPnP-10007.jar"); addPlugin("UPnP2") .inGroup("connectivity") - .loadedFrom("CHK@oFNunyhic~ug3lWas8Jabpwbt3heHhrFzHswN~GhPNc,j~2AHw~ZyZGNMuqW3zmukTJHysDg5lBTvrySerSPxkI,AAMC--8/freenet-UPnP2.jar") - .advanced(); + .loadedFrom("CHK@oFNunyhic~ug3lWas8Jabpwbt3heHhrFzHswN~GhPNc,j~2AHw~ZyZGNMuqW3zmukTJHysDg5lBTvrySerSPxkI,AAMC--8/freenet-UPnP2.jar"); addPlugin("XMLLibrarian") .inGroup("index") .minimumVersion(26) From 2d479f29cf7ea06cdc7977cab63d236c5110fbc9 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 10 Sep 2023 17:10:45 +0200 Subject: [PATCH 153/500] Fix merge error. --- test/freenet/client/filter/ContentFilterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index a680db592e3..0a779dfbade 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -184,8 +184,8 @@ public void testHTMLFilter() throws Exception { assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1)); - assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); - assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS)); + assertEquals(SPAN_WITH_STYLE, htmlFilter(SPAN_WITH_STYLE)); + assertEquals(HTML5_TAGS, htmlFilter(HTML5_TAGS)); assertEquals(BASE_HREF, htmlFilter(BASE_HREF)); assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF)); From 19f8017b56256493b3f3a7245ffc7f384cd24027 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 10 Sep 2023 18:43:53 +0200 Subject: [PATCH 154/500] Open module java.util.zip for tests --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 4f0cb84e7f7..cf3f9768087 100644 --- a/build.gradle +++ b/build.gradle @@ -184,6 +184,7 @@ test { jvmArgs '--add-opens=java.base/java.lang=ALL-UNNAMED' jvmArgs '--add-opens=java.base/java.util=ALL-UNNAMED' jvmArgs '--add-opens=java.base/java.io=ALL-UNNAMED' + jvmArgs '--add-opens=java.base/java.util.zip=ALL-UNNAMED' } minHeapSize = "128m" maxHeapSize = "512m" From 5beb53b739f166fff786d92c15f175791a1fa5a2 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 10 Sep 2023 18:44:28 +0200 Subject: [PATCH 155/500] gzip: replace test workaround by fixing the output of the compressor --- .../support/compress/GzipCompressor.java | 17 ++++++++++++++++- .../support/compress/GzipCompressorTest.java | 6 ------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/freenet/support/compress/GzipCompressor.java b/src/freenet/support/compress/GzipCompressor.java index 4afe3a984ac..89463fc579d 100644 --- a/src/freenet/support/compress/GzipCompressor.java +++ b/src/freenet/support/compress/GzipCompressor.java @@ -5,12 +5,16 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.text.MessageFormat; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import freenet.support.Logger; import freenet.support.api.Bucket; import freenet.support.api.BucketFactory; +import freenet.support.api.RandomAccessBucket; +import freenet.support.api.RandomAccessBuffer; +import freenet.support.io.ArrayBucket; import freenet.support.io.Closer; import freenet.support.io.CountedOutputStream; @@ -19,7 +23,7 @@ public class GzipCompressor extends AbstractCompressor { @Override public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long maxWriteLength) throws IOException, CompressionOutputSizeException { - Bucket output = bf.makeBucket(maxWriteLength); + RandomAccessBucket output = bf.makeBucket(maxWriteLength); InputStream is = null; OutputStream os = null; try { @@ -33,6 +37,17 @@ public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long m Closer.close(is); Closer.close(os); } + // force OS byte to 0 regardless of Java version (java 16 changed to setting 255 which would break hashes) + if (output instanceof ArrayBucket) { + byte[] dataArray = ((ArrayBucket) output).toByteArray(); + dataArray[9] = 0; + return new ArrayBucket(dataArray); + } else { + Logger.warning(this, MessageFormat.format( + "Harmonizing gzip compression over Java versions requires an ArrayBucket, but a {} was created by the BucketFactory {}.", + output.getClass(), + bf.getClass())); + } return output; } diff --git a/test/freenet/support/compress/GzipCompressorTest.java b/test/freenet/support/compress/GzipCompressorTest.java index c550187bf10..00e89db32b9 100644 --- a/test/freenet/support/compress/GzipCompressorTest.java +++ b/test/freenet/support/compress/GzipCompressorTest.java @@ -161,12 +161,6 @@ private byte[] doCompress(byte[] uncompressedData) throws IOException { Bucket outBucket = GZIP.compress(inBucket, factory, 32768, 32768); byte[] outBuffer = BucketTools.toByteArray(outBucket); - // Newer JVM versions have different OS (Operating System) GZIP member header value - // https://www.rfc-editor.org/rfc/rfc1952#section-2.3.1 - // https://bugs.openjdk.org/browse/JDK-8244706 - // Set OS byte to zero to produce stable results in this test - outBuffer[9] = 0; - return outBuffer; } } From e04cf9007a269ec6ef4b3c72ae0291223231308f Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 14 Sep 2023 09:09:36 +0200 Subject: [PATCH 156/500] Support word-wrap: anywhere --- src/freenet/client/filter/CSSTokenizerFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index 9beec171ff8..4158fb8dcff 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1617,7 +1617,7 @@ else if("word-spacing".equalsIgnoreCase(element)) } else if("word-wrap".equalsIgnoreCase(element)) { - elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal", "break-word"),ElementInfo.VISUALMEDIA)); + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal", "break-word", "anywhere"),ElementInfo.VISUALMEDIA)); allelementVerifiers.remove(element); } else if("z-index".equalsIgnoreCase(element)) From 38d7f61a773236dad15aa98b0828d5005bf94278 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 26 Sep 2023 07:32:54 +0200 Subject: [PATCH 157/500] fix merge error --- test/freenet/client/filter/ContentFilterTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index a680db592e3..0a779dfbade 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -184,8 +184,8 @@ public void testHTMLFilter() throws Exception { assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1)); - assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); - assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS)); + assertEquals(SPAN_WITH_STYLE, htmlFilter(SPAN_WITH_STYLE)); + assertEquals(HTML5_TAGS, htmlFilter(HTML5_TAGS)); assertEquals(BASE_HREF, htmlFilter(BASE_HREF)); assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF)); From 62d75a46f7e8d63d9eaf2bb01bd9a8ede1b1b458 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 26 Sep 2023 07:33:04 +0200 Subject: [PATCH 158/500] add word-wrap test --- test/freenet/client/filter/CSSParserTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index 46e480b24fa..f87d6ca7f7c 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -749,6 +749,8 @@ public class CSSParserTest { propertyTests.put("blockquote { letter-spacing: 0.1em }", "blockquote { letter-spacing: 0.1em }"); propertyTests.put("blockquote { letter-spacing: normal }", "blockquote { letter-spacing: normal }"); propertyTests.put("h1 { word-spacing: 1em }", "h1 { word-spacing: 1em }"); + propertyTests.put("h1 { word-wrap: normal } h2 { word-wrap: break-word } h1 { word-wrap: anywhere }", + "h1 { word-wrap: normal } h2 { word-wrap: break-word } h1 { word-wrap: anywhere }"); propertyTests.put("h1 { text-transform: uppercase }", "h1 { text-transform: uppercase }"); propertyTests.put("pre { white-space: pre } p { white-space: normal } td[nowrap] { white-space: nowrap }", "pre { white-space: pre } p { white-space: normal } td[nowrap] { white-space: nowrap }"); propertyTests.put("pre[wrap] { white-space: pre-wrap }", "pre[wrap] { white-space: pre-wrap }"); From a5b45128043c206700a8b964e4a697a15868af51 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 26 Sep 2023 21:02:13 +0200 Subject: [PATCH 159/500] Add fallback for non-ArrayBuckets so every path fixes the OS byte --- .../support/compress/GzipCompressor.java | 42 ++++++++++++++++--- .../client/filter/ContentFilterTest.java | 4 +- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/src/freenet/support/compress/GzipCompressor.java b/src/freenet/support/compress/GzipCompressor.java index 89463fc579d..82b10f150c3 100644 --- a/src/freenet/support/compress/GzipCompressor.java +++ b/src/freenet/support/compress/GzipCompressor.java @@ -43,12 +43,44 @@ public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long m dataArray[9] = 0; return new ArrayBucket(dataArray); } else { - Logger.warning(this, MessageFormat.format( - "Harmonizing gzip compression over Java versions requires an ArrayBucket, but a {} was created by the BucketFactory {}.", - output.getClass(), - bf.getClass())); + // slower fallback + return copyBucketPatchingOSByte(bf, maxWriteLength, output); } - return output; + } + + private static RandomAccessBucket copyBucketPatchingOSByte( + BucketFactory bf, + long maxWriteLength, + RandomAccessBucket output) throws IOException { + RandomAccessBucket consistentOutput = bf.makeBucket(maxWriteLength); + InputStream inputStream = null; + OutputStream consistentOutputStream = null; + try { + inputStream = output.getInputStream(); + consistentOutputStream = consistentOutput.getOutputStream(); + byte[] buf = new byte[8192]; + int previousRead = 0; + int length = inputStream.read(buf); + int read = length; + while (read < 8 && length != -1) { + previousRead = read; + consistentOutputStream.write(buf, 0, length); + length = inputStream.read(buf); + read += length; + } + // fix OS byte + buf[9 - previousRead] = 0; + consistentOutputStream.write(buf, 0, length); + while ((length = inputStream.read(buf)) != -1) { + consistentOutputStream.write(buf, 0, length); + } + inputStream.close(); inputStream = null; + consistentOutputStream.close(); consistentOutputStream = null; + } finally { + Closer.close(inputStream); + Closer.close(consistentOutputStream); + } + return consistentOutput; } @Override diff --git a/test/freenet/client/filter/ContentFilterTest.java b/test/freenet/client/filter/ContentFilterTest.java index a680db592e3..0a779dfbade 100644 --- a/test/freenet/client/filter/ContentFilterTest.java +++ b/test/freenet/client/filter/ContentFilterTest.java @@ -184,8 +184,8 @@ public void testHTMLFilter() throws Exception { assertEquals(CSS_SPEC_EXAMPLE1, htmlFilter(CSS_SPEC_EXAMPLE1)); - assertEquals(SPAN_WITH_STYLE, HTMLFilter(SPAN_WITH_STYLE)); - assertEquals(HTML5_TAGS, HTMLFilter(HTML5_TAGS)); + assertEquals(SPAN_WITH_STYLE, htmlFilter(SPAN_WITH_STYLE)); + assertEquals(HTML5_TAGS, htmlFilter(HTML5_TAGS)); assertEquals(BASE_HREF, htmlFilter(BASE_HREF)); assertEquals(DELETED_BASE_HREF, htmlFilter(BAD_BASE_HREF)); From 564ad56e8f3137fcef5b99543128fa47480fc25c Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 8 Oct 2023 11:47:41 +0300 Subject: [PATCH 160/500] restore the Util.hashString() method Also removes stacktrace printout and exception suppression. This slightly changes behavior, but exceptions are not silenced anymore. --- src/freenet/crypt/Util.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/freenet/crypt/Util.java b/src/freenet/crypt/Util.java index 34976631695..db22bafd720 100644 --- a/src/freenet/crypt/Util.java +++ b/src/freenet/crypt/Util.java @@ -8,6 +8,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.security.DigestException; import java.security.GeneralSecurityException; import java.security.MessageDigest; @@ -108,6 +109,14 @@ public static byte[] hashBytes( return d.digest(); } + /** + * Hashes a string in a consistent manner + */ + public static byte[] hashString(MessageDigest d, String s) { + byte[] sbytes = s.getBytes(StandardCharsets.UTF_8); + d.update(sbytes, 0, sbytes.length); + return d.digest(); + } public static byte[] xor(byte[] b1, byte[] b2) { int maxl = Math.max(b1.length, b2.length); From 9559b0c18dca6a9f161789a774541b18dfdd0e49 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 8 Oct 2023 12:11:56 +0300 Subject: [PATCH 161/500] Fix indentation according to code review comments in #836 Note: I changed only places mentioned in the review comments. Some better and massive tabs-vs-spaces fix is required to solve all other issues. --- src/freenet/node/MasterKeys.java | 4 ++-- src/freenet/node/updater/MainJarDependenciesChecker.java | 2 +- src/freenet/support/SimpleFieldSet.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/freenet/node/MasterKeys.java b/src/freenet/node/MasterKeys.java index 22ef1129fe6..254bf39b367 100644 --- a/src/freenet/node/MasterKeys.java +++ b/src/freenet/node/MasterKeys.java @@ -269,8 +269,8 @@ private void write(File masterKeysFile, String newPassword, Random hardRandom) t byte[] salt = new byte[32]; hardRandom.nextBytes(salt); - byte[] pwd = newPassword.getBytes(StandardCharsets.UTF_8); - MessageDigest md = SHA256.getMessageDigest(); + byte[] pwd = newPassword.getBytes(StandardCharsets.UTF_8); + MessageDigest md = SHA256.getMessageDigest(); md.update(pwd); md.update(salt); byte[] outerKey = md.digest(); diff --git a/src/freenet/node/updater/MainJarDependenciesChecker.java b/src/freenet/node/updater/MainJarDependenciesChecker.java index ee8c41c1e85..1a5daea3bc6 100644 --- a/src/freenet/node/updater/MainJarDependenciesChecker.java +++ b/src/freenet/node/updater/MainJarDependenciesChecker.java @@ -1527,7 +1527,7 @@ private File createRestartScript() throws IOException { * just get rid of this - in which case maybe we want to improve on this. * @throws IOException */ private boolean createRunShNoNice(File input, File output) throws IOException { - InputStream is = null; + InputStream is = null; OutputStream os = null; boolean failed = false; try { diff --git a/src/freenet/support/SimpleFieldSet.java b/src/freenet/support/SimpleFieldSet.java index 321840044f0..fa481bc3162 100644 --- a/src/freenet/support/SimpleFieldSet.java +++ b/src/freenet/support/SimpleFieldSet.java @@ -987,8 +987,8 @@ public void writeTo(OutputStream os, int bufferSize) throws IOException { BufferedWriter bw = null; bos = new BufferedOutputStream(os, bufferSize); - osw = new OutputStreamWriter(bos, StandardCharsets.UTF_8); - bw = new BufferedWriter(osw); + osw = new OutputStreamWriter(bos, StandardCharsets.UTF_8); + bw = new BufferedWriter(osw); writeTo(bw); bw.flush(); } From 5eb30e7f4443f4b01a63636cc822f3978e2cb270 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 8 Oct 2023 12:36:40 +0300 Subject: [PATCH 162/500] Use StandardCharsets.UTF_8 in the FileLoggerHook --- src/freenet/support/FileLoggerHook.java | 40 +++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/freenet/support/FileLoggerHook.java b/src/freenet/support/FileLoggerHook.java index 072c8a29bf3..62cc0d427e1 100644 --- a/src/freenet/support/FileLoggerHook.java +++ b/src/freenet/support/FileLoggerHook.java @@ -56,7 +56,7 @@ public class FileLoggerHook extends LoggerHook implements Closeable { protected int INTERVAL = Calendar.MINUTE; protected int INTERVAL_MULTIPLIER = 5; - private static final String ENCODING = "UTF-8"; + private static final Charset ENCODING = StandardCharsets.UTF_8; private static volatile boolean logMINOR; static { @@ -527,15 +527,7 @@ protected OutputStream openNewLogFile(File filename, boolean compress) { } } - private static final byte[] BOM; - - static { - try { - BOM = "\uFEFF".getBytes(ENCODING); - } catch (UnsupportedEncodingException e) { - throw new Error(e); - } - } + private static final byte[] BOM = "\uFEFF".getBytes(ENCODING); protected int runningCompressors = 0; protected Object runningCompressorsSync = new Object(); @@ -799,9 +791,23 @@ public FileLoggerHook( public void start() { if(redirectStdOut) { try { - System.setOut(new PrintStream(new OutputStreamLogger(LogLevel.NORMAL, "Stdout: ", ENCODING), false, ENCODING)); - if(redirectStdErr) - System.setErr(new PrintStream(new OutputStreamLogger(LogLevel.ERROR, "Stderr: ", ENCODING), false, ENCODING)); + String encName = ENCODING.name(); + System.setOut( + new PrintStream( + new OutputStreamLogger(LogLevel.NORMAL, "Stdout: ", encName), + false, + encName + ) + ); + if(redirectStdErr) { + System.setErr( + new PrintStream( + new OutputStreamLogger(LogLevel.ERROR, "Stderr: ", encName), + false, + encName + ) + ); + } } catch (UnsupportedEncodingException e) { throw new Error(e); } @@ -990,17 +996,13 @@ else if(trace.length == 0) else break; } - try { - logString(sb.toString().getBytes(ENCODING)); - } catch (UnsupportedEncodingException e1) { - throw new Error(e1); - } + logString(sb.toString().getBytes(ENCODING)); } /** Memory allocation overhead (estimated through experimentation with bsh) */ private static final int LINE_OVERHEAD = 60; - public void logString(byte[] b) throws UnsupportedEncodingException { + public void logString(byte[] b) { synchronized (list) { int sz = list.size(); if(!list.offer(b)) { From f5f6a285d987c195c396dd7a46d6ef4fc3729886 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 8 Oct 2023 14:45:37 +0300 Subject: [PATCH 163/500] replace GregorianCalendar with java.time.OffsetDateTime in CurrentTimeUTC Now CurrentTimeUTC uses newer java.time API. This change also removes unnecessary synchronization on the GregorianCalendar object. --- src/freenet/support/CurrentTimeUTC.java | 87 +++++++++++-------------- 1 file changed, 37 insertions(+), 50 deletions(-) diff --git a/src/freenet/support/CurrentTimeUTC.java b/src/freenet/support/CurrentTimeUTC.java index 5fe8a1a8896..b87f30e5ef8 100644 --- a/src/freenet/support/CurrentTimeUTC.java +++ b/src/freenet/support/CurrentTimeUTC.java @@ -3,61 +3,48 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.support; -import java.util.Calendar; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.time.temporal.ChronoField; import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; /** - * A wrapper class around a GregorianCalendar which always returns the current time. - * This is useful for working around the pitfall of class Calendar: It only returns the current time when you first use a get*() function, - * in any get*() calls after the first call, the time value of the first call is returned. One would have to call Calendar.clear() before each - * get to obtain the current time and this class takes care of that for you. - * - * Further, this class is synchronized so you do not need to worry about synchronization of a Calendar anymore. + * A helper class, which returns the current time and date in UTC timezone. */ public class CurrentTimeUTC { - private static final GregorianCalendar mCalendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - - public static Date get() { - synchronized(mCalendar) { - mCalendar.setTimeInMillis(System.currentTimeMillis()); - return mCalendar.getTime(); - } - } - - /** - * Get the current time in milliseconds. - * - * In the current implementation, this just returns System.currentTimeMilis(). You should however use CurrenTimeUTC.getInMillis() instead because - * the JavaDoc of System.currentTimeMilis() does not explicitly state what time zone it returns. Therefore, by using this wrapper function, your code - * clearly states that it uses UTC time. - */ - public static long getInMillis() { - return System.currentTimeMillis(); - } - - public static int getYear() { - synchronized(mCalendar) { - mCalendar.setTimeInMillis(System.currentTimeMillis()); - return mCalendar.get(Calendar.YEAR); - } - } - - public static int getMonth() { - synchronized(mCalendar) { - mCalendar.setTimeInMillis(System.currentTimeMillis()); - return mCalendar.get(Calendar.MONTH); - } - } - - public static int getDayOfMonth() { - synchronized(mCalendar) { - mCalendar.setTimeInMillis(System.currentTimeMillis()); - return mCalendar.get(Calendar.DAY_OF_MONTH); - } - } - + public static Date get() { + return Date.from(nowUtc().toInstant()); + } + + /** + * Get the current time in milliseconds. + * + * In the current implementation, this just returns System.currentTimeMilis(). You should however use CurrenTimeUTC.getInMillis() instead because + * the JavaDoc of System.currentTimeMilis() does not explicitly state what time zone it returns. Therefore, by using this wrapper function, your code + * clearly states that it uses UTC time. + */ + public static long getInMillis() { + return System.currentTimeMillis(); + } + + public static int getYear() { + return nowUtc().get(ChronoField.YEAR); + } + + public static int getMonth() { + // Previously, this method used java.util.GregorianCalendar and Calendar.MONTH, which is zero-based. + // Newer java.time API returns months values starting with one, + // and subtraction is required to preserve backward compatibility. + return nowUtc().get(ChronoField.MONTH_OF_YEAR) - 1; + } + + public static int getDayOfMonth() { + return nowUtc().get(ChronoField.DAY_OF_MONTH); + } + + private static OffsetDateTime nowUtc() { + return OffsetDateTime.now(ZoneOffset.UTC); + } } From ca4c67f389b28dab236ec86ca1a22290f6e75e18 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sun, 8 Oct 2023 14:58:49 +0300 Subject: [PATCH 164/500] fix typo in the javadoc freenet.support.CurrentTimeUTC#getInMillis s/currentTimeMilis/currentTimeMillis/g add javadoc link to System#currentTimeMillis() --- src/freenet/support/CurrentTimeUTC.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/freenet/support/CurrentTimeUTC.java b/src/freenet/support/CurrentTimeUTC.java index b87f30e5ef8..8b2ca4d4aaa 100644 --- a/src/freenet/support/CurrentTimeUTC.java +++ b/src/freenet/support/CurrentTimeUTC.java @@ -21,9 +21,10 @@ public static Date get() { /** * Get the current time in milliseconds. * - * In the current implementation, this just returns System.currentTimeMilis(). You should however use CurrenTimeUTC.getInMillis() instead because - * the JavaDoc of System.currentTimeMilis() does not explicitly state what time zone it returns. Therefore, by using this wrapper function, your code - * clearly states that it uses UTC time. + * In the current implementation, this just returns {@link System#currentTimeMillis()}. + * You should however use CurrentTimeUTC#getInMillis() instead because + * the JavaDoc of {@link System#currentTimeMillis()} does not explicitly state what time zone it returns. + * Therefore, by using this wrapper function, your code clearly states that it uses UTC time. */ public static long getInMillis() { return System.currentTimeMillis(); From 584ffc6be0aab543c2315e746571eedf64bf373f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 28 Sep 2023 00:44:56 +0200 Subject: [PATCH 165/500] =?UTF-8?q?=E2=9C=A8=20Add=20output=20stream=20to?= =?UTF-8?q?=20fix=20other=20output=20streams?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To be more specific, this FilterOutputStream can be used to “fix” a GzipOutputStream for continued use in Freenet. Prior to Java 17, the “OS” field in the GZIP header was set to 0; Java 17 changed this to 0xff, to match the spec, which is lovely but breaks Freenet (because it changes hashes calculated for keys). By replacing a single byte in the GZIP-compressed output stream, everything can be made as it was. --- .../SingleOffsetReplacingOutputStream.java | 53 +++++++++++ ...SingleOffsetReplacingOutputStreamTest.java | 93 +++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 src/freenet/support/compress/SingleOffsetReplacingOutputStream.java create mode 100644 test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java diff --git a/src/freenet/support/compress/SingleOffsetReplacingOutputStream.java b/src/freenet/support/compress/SingleOffsetReplacingOutputStream.java new file mode 100644 index 00000000000..768e186d07e --- /dev/null +++ b/src/freenet/support/compress/SingleOffsetReplacingOutputStream.java @@ -0,0 +1,53 @@ +package freenet.support.compress; + +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.zip.GZIPOutputStream; + +/** + * A {@link FilterOutputStream} that replaces a single byte at a specific + * offset when being written to. It can be used to change the operating system + * byte in the header of a {@link GZIPOutputStream}. + *

+ * This class is not safe for usage from multiple threads. + */ +public class SingleOffsetReplacingOutputStream extends FilterOutputStream { + + private final int replacementOffset; + private final int replacementValue; + private int currentOffset = 0; + + public SingleOffsetReplacingOutputStream(OutputStream outputStream, int replacementOffset, int replacementValue) { + super(outputStream); + this.replacementOffset = replacementOffset; + this.replacementValue = replacementValue; + } + + @Override + public void write(int b) throws IOException { + if (currentOffset == replacementOffset) { + out.write(replacementValue); + } else { + out.write(b); + } + currentOffset++; + } + + @Override + public void write(byte[] buffer, int offset, int length) throws IOException { + if (offsetToReplaceIsInBufferBeingWritten(length)) { + out.write(buffer, offset, replacementOffset - currentOffset); + out.write(replacementValue); + out.write(buffer, offset + (replacementOffset - currentOffset) + 1, length - (replacementOffset - currentOffset) - 1); + } else { + out.write(buffer, offset, length); + } + currentOffset += length; + } + + private boolean offsetToReplaceIsInBufferBeingWritten(int length) { + return (currentOffset <= replacementOffset) && ((currentOffset + length) > replacementOffset); + } + +} diff --git a/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java b/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java new file mode 100644 index 00000000000..67dc71ca1e6 --- /dev/null +++ b/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java @@ -0,0 +1,93 @@ +package freenet.support.compress; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Random; + +import org.junit.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; + +public class SingleOffsetReplacingOutputStreamTest { + + @Test + public void allBytesBeforeTheOffsetAreUnchanged() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingByteArrays(32768, 1, 65536); + } + + @Test + public void byteAtOffsetZeroCanBeReplaced() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingByteArrays(10, 1, 0); + } + + @Test + public void byteAtOffsetOneCanBeReplaced() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingByteArrays(10, 1, 1); + } + + @Test + public void byteAtEndOfBufferCanBeReplaced() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingByteArrays(10, 1, 9); + } + + @Test + public void byteAtBeginningOfSecondBufferCanBeReplaced() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingByteArrays(10, 2, 10); + } + + @Test + public void byteInTheMiddleOfSecondBufferCanBeReplaced() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingByteArrays(10, 3, 15); + } + + @Test + public void byteAtOffsetZeroCanBeReplacedWhenWritingSingleBytes() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingSingleBytes(4096, 16, 0); + } + + @Test + public void byteInMiddleOfStreamBeReplacedWhenWritingSingleBytes() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingSingleBytes(8192, 8, 12345); + } + + @Test + public void byteAtEndOfStreamCanBeReplacedWhenWritingSingleBytes() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingSingleBytes(16384, 4, 65535); + } + + private void filterOutputStreamWithOffsetAndReplacementWritingSingleBytes(int blockSize, int numberOfBlocks, int replacementOffset) throws IOException { + filterOutputStreamWithOffsetAndReplacement(blockSize, numberOfBlocks, replacementOffset, (buffer, length, repetitions, outputStream) -> { + for (int index = 0; index < length * repetitions; index++) { + outputStream.write(buffer[index % length]); + } + }); + } + + private void filterOutputStreamWithOffsetAndReplacementWritingByteArrays(int blockSize, int numberOfBlocks, int replacementOffset) throws IOException { + filterOutputStreamWithOffsetAndReplacement(blockSize, numberOfBlocks, replacementOffset, (buffer, length, repetitions, outputStream) -> { + for (int blockIndex = 0; blockIndex < repetitions; blockIndex++) { + outputStream.write(buffer, 0, length); + } + }); + } + + private void filterOutputStreamWithOffsetAndReplacement(int blockSize, int numberOfBlocks, int replacementOffset, BufferToOutputStreamCopierStrategy bufferToOutputStreamCopierStrategy) throws IOException { + byte[] bufferToWrite = new byte[blockSize]; + new Random().nextBytes(bufferToWrite); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + SingleOffsetReplacingOutputStream outputStream = new SingleOffsetReplacingOutputStream(byteArrayOutputStream, replacementOffset, (byte) (bufferToWrite[replacementOffset % blockSize] ^ 0xff)); + bufferToOutputStreamCopierStrategy.copyBufferToOutput(bufferToWrite, blockSize, numberOfBlocks, outputStream); + byte[] writtenBuffer = byteArrayOutputStream.toByteArray(); + for (int offset = 0; offset < blockSize * numberOfBlocks; offset++) { + assertThat("offset " + offset, writtenBuffer[offset], equalTo((byte) (bufferToWrite[offset % blockSize] ^ ((offset == replacementOffset) ? 0xff : 0x00)))); + } + } + + @FunctionalInterface + private interface BufferToOutputStreamCopierStrategy { + void copyBufferToOutput(byte[] buffer, int length, int repetitions, OutputStream outputStream) throws IOException; + } + +} From 7ea16270bc55b4bde3d46e5960b99d4a36473d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 30 Sep 2023 14:39:40 +0200 Subject: [PATCH 166/500] =?UTF-8?q?=E2=9C=85=20Add=20more=20tests=20for=20?= =?UTF-8?q?writing=20buffers=20with=20offset=20!=3D=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...SingleOffsetReplacingOutputStreamTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java b/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java index 67dc71ca1e6..6298500330d 100644 --- a/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java +++ b/test/freenet/support/compress/SingleOffsetReplacingOutputStreamTest.java @@ -57,6 +57,21 @@ public void byteAtEndOfStreamCanBeReplacedWhenWritingSingleBytes() throws IOExce filterOutputStreamWithOffsetAndReplacementWritingSingleBytes(16384, 4, 65535); } + @Test + public void byteAtStartOfBufferCanBeReplacedWhenWritingHalfBuffers() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingHalfBuffers(4096, 16, 0); + } + + @Test + public void byteAtMiddleOfBufferCanBeReplacedWhenWritingHalfBuffers() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingHalfBuffers(8192, 8, 12345); + } + + @Test + public void byteAtEndOfBufferCanBeReplacedWhenWritingHalfBuffers() throws IOException { + filterOutputStreamWithOffsetAndReplacementWritingHalfBuffers(16384, 4, 65535); + } + private void filterOutputStreamWithOffsetAndReplacementWritingSingleBytes(int blockSize, int numberOfBlocks, int replacementOffset) throws IOException { filterOutputStreamWithOffsetAndReplacement(blockSize, numberOfBlocks, replacementOffset, (buffer, length, repetitions, outputStream) -> { for (int index = 0; index < length * repetitions; index++) { @@ -73,6 +88,15 @@ private void filterOutputStreamWithOffsetAndReplacementWritingByteArrays(int blo }); } + private void filterOutputStreamWithOffsetAndReplacementWritingHalfBuffers(int blockSize, int numberOfBlocks, int replacementOffset) throws IOException { + filterOutputStreamWithOffsetAndReplacement(blockSize, numberOfBlocks, replacementOffset, ((buffer, length, repetitions, outputStream) -> { + for (int blockIndex = 0; blockIndex < repetitions; blockIndex++) { + outputStream.write(buffer, 0, length / 2); + outputStream.write(buffer, length / 2, length - (length / 2)); + } + })); + } + private void filterOutputStreamWithOffsetAndReplacement(int blockSize, int numberOfBlocks, int replacementOffset, BufferToOutputStreamCopierStrategy bufferToOutputStreamCopierStrategy) throws IOException { byte[] bufferToWrite = new byte[blockSize]; new Random().nextBytes(bufferToWrite); From eba144ab7df973b2c6deba2e8165f1fb5a5c87ba Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 12 Oct 2023 00:13:22 +0200 Subject: [PATCH 167/500] =?UTF-8?q?Use=20the=20much=20nicer=20SingleOffset?= =?UTF-8?q?ReplacingOutputStream=20by=20Bombe=20=E2=80=94=20=F0=9F=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/compress/GzipCompressor.java | 49 ++----------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/src/freenet/support/compress/GzipCompressor.java b/src/freenet/support/compress/GzipCompressor.java index 82b10f150c3..385fccea4bd 100644 --- a/src/freenet/support/compress/GzipCompressor.java +++ b/src/freenet/support/compress/GzipCompressor.java @@ -29,7 +29,9 @@ public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long m try { is = data.getInputStream(); os = output.getOutputStream(); - compress(is, os, maxReadLength, maxWriteLength); + // force OS byte to 0 regardless of Java version (java 16 changed to setting 255 which would break hashes) + SingleOffsetReplacingOutputStream osByteFixingOs = new SingleOffsetReplacingOutputStream(os, 9, 0); + compress(is, osByteFixingOs, maxReadLength, maxWriteLength); // It is essential that the close()'s throw if there is any problem. is.close(); is = null; os.close(); os = null; @@ -37,50 +39,7 @@ public Bucket compress(Bucket data, BucketFactory bf, long maxReadLength, long m Closer.close(is); Closer.close(os); } - // force OS byte to 0 regardless of Java version (java 16 changed to setting 255 which would break hashes) - if (output instanceof ArrayBucket) { - byte[] dataArray = ((ArrayBucket) output).toByteArray(); - dataArray[9] = 0; - return new ArrayBucket(dataArray); - } else { - // slower fallback - return copyBucketPatchingOSByte(bf, maxWriteLength, output); - } - } - - private static RandomAccessBucket copyBucketPatchingOSByte( - BucketFactory bf, - long maxWriteLength, - RandomAccessBucket output) throws IOException { - RandomAccessBucket consistentOutput = bf.makeBucket(maxWriteLength); - InputStream inputStream = null; - OutputStream consistentOutputStream = null; - try { - inputStream = output.getInputStream(); - consistentOutputStream = consistentOutput.getOutputStream(); - byte[] buf = new byte[8192]; - int previousRead = 0; - int length = inputStream.read(buf); - int read = length; - while (read < 8 && length != -1) { - previousRead = read; - consistentOutputStream.write(buf, 0, length); - length = inputStream.read(buf); - read += length; - } - // fix OS byte - buf[9 - previousRead] = 0; - consistentOutputStream.write(buf, 0, length); - while ((length = inputStream.read(buf)) != -1) { - consistentOutputStream.write(buf, 0, length); - } - inputStream.close(); inputStream = null; - consistentOutputStream.close(); consistentOutputStream = null; - } finally { - Closer.close(inputStream); - Closer.close(consistentOutputStream); - } - return consistentOutput; + return output; } @Override From 783279c6ed77b93704acf49055c41bc87179680a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 14 Oct 2023 10:36:09 +0200 Subject: [PATCH 168/500] Shorten description of sharesite freesite for english --- src/freenet/l10n/freenet.l10n.en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 4f7a4194556..065c3eb3aa2 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -149,7 +149,7 @@ Bookmarks.Defaults.ShortDescription.Sone=Social chat over Freenet Bookmarks.Defaults.ShortDescription.freenetdocwiki=Freenet documentation wiki Bookmarks.Defaults.ShortDescription.FSNG=Step by step guide to how to set up anonymous email, forums, chat, social tools etc on Freenet. Strongly recommended! Bookmarks.Defaults.ShortDescription.jSite=Essential tool for uploading websites to Freenet -Bookmarks.Defaults.ShortDescription.Sharesite=Plugin that manages a list of sites for which you only need to set title and content, save and click insert. The rest is done by the plugin. +Bookmarks.Defaults.ShortDescription.Sharesite=Plugin that manages a list of sites for which you only need to set title and content, save and click insert. Bookmarks.Defaults.ShortDescription.GenerateMediaSite=Tool to create video- or audio-freesites. Bookmarks.Defaults.ShortDescription.SeedNodesUptimeStats=Uptime statistics for the Opennet Seednodes Bookmarks.Defaults.ShortDescription.Flog.Toad=Former chief Freenet developer's personal blog From 5e600d889e331ef37015065c37d42a2674867959 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 14 Oct 2023 10:37:59 +0200 Subject: [PATCH 169/500] Support the Schemas hypha: hyphanet: with web+ and ext+ --- src/freenet/keys/FreenetURI.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/keys/FreenetURI.java b/src/freenet/keys/FreenetURI.java index 053468c83cd..b451a8b24ef 100644 --- a/src/freenet/keys/FreenetURI.java +++ b/src/freenet/keys/FreenetURI.java @@ -326,7 +326,7 @@ public FreenetURI( } // Strip http(s):// and (web+|ext+)freenet: prefix - protected final static Pattern URI_PREFIX = Pattern.compile("^(https?://[^/]+/+)?(((ext|web)\\+)?freenet:)?"); + protected final static Pattern URI_PREFIX = Pattern.compile("^(https?://[^/]+/+)?(((ext|web)\\+)?(freenet|hyphanet|hypha):)?"); public FreenetURI(String URI) throws MalformedURLException { this(URI, false); From 52f5d3adf7da03a52c22af02ef466e167045c21b Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 14 Oct 2023 10:38:57 +0200 Subject: [PATCH 170/500] Add tests for schema in FreenetURI --- test/freenet/keys/FreenetURITest.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/freenet/keys/FreenetURITest.java b/test/freenet/keys/FreenetURITest.java index e7edfe970da..aa4ab1491a5 100644 --- a/test/freenet/keys/FreenetURITest.java +++ b/test/freenet/keys/FreenetURITest.java @@ -4,6 +4,8 @@ import static org.junit.Assert.fail; import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Arrays; import org.junit.Test; @@ -12,6 +14,7 @@ public class FreenetURITest { private static final String WANNA_USK_1 = "USK@5hH~39FtjA7A9~VXWtBKI~prUDTuJZURudDG0xFn3KA,GDgRGt5f6xqbmo-WraQtU54x4H~871Sho9Hz6hC-0RA,AQACAAE/Search/17/index_d51.xml"; private static final String WANNA_SSK_1 = "SSK@5hH~39FtjA7A9~VXWtBKI~prUDTuJZURudDG0xFn3KA,GDgRGt5f6xqbmo-WraQtU54x4H~871Sho9Hz6hC-0RA,AQACAAE/Search-17/index_d51.xml"; private static final String WANNA_CHK_1 = "CHK@DTCDUmnkKFlrJi9UlDDVqXlktsIXvAJ~ZTseyx5cAZs,PmA2rLgWZKVyMXxSn-ZihSskPYDTY19uhrMwqDV-~Sk,AAICAAI/index_d51.xml"; + private static final String KSK_EXAMPLE = "KSK@gpl.txt"; @Test public void testSskForUSK() throws MalformedURLException { @@ -136,4 +139,27 @@ public void internedUskIsPreserved() throws MalformedURLException { FreenetURI uri1 = new FreenetURI(WANNA_USK_1); assertEquals(uri1.toString(), uri1.intern().toString()); } + + @Test + public void addedValidSchemaPrefixesAreIgnored() throws MalformedURLException { + for (String prefix : Arrays.asList( + "freenet", + "web+freenet", + "ext+freenet", + "hypha", + "hyphanet", + "web+hypha", + "web+hyphanet", + "ext+hypha", + "ext+hyphanet")) { + FreenetURI uri = new FreenetURI(prefix + ":" + WANNA_USK_1); + assertEquals(uri.toString(), WANNA_USK_1); + uri = new FreenetURI(prefix + ":" + WANNA_SSK_1); + assertEquals(uri.toString(), WANNA_SSK_1); + uri = new FreenetURI(prefix + ":" + WANNA_CHK_1); + assertEquals(uri.toString(), WANNA_CHK_1); + uri = new FreenetURI(prefix + ":" + KSK_EXAMPLE); + assertEquals(uri.toString(), KSK_EXAMPLE); + } + } } From c36913d9eb3267acc4ebfe0830212175fa2599c0 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 14 Oct 2023 10:56:20 +0200 Subject: [PATCH 171/500] Update sharesite plugin to 0.5.1 --- src/freenet/pluginmanager/OfficialPlugins.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freenet/pluginmanager/OfficialPlugins.java b/src/freenet/pluginmanager/OfficialPlugins.java index da989ba81cb..c8bc5af72b5 100644 --- a/src/freenet/pluginmanager/OfficialPlugins.java +++ b/src/freenet/pluginmanager/OfficialPlugins.java @@ -134,9 +134,9 @@ public OfficialPlugins() { .loadedFrom("CHK@zAvWPxjh2rJ7j2cAiXcm2wnDYlURL9BFDGfLBaVtjqU,Ak90k0Qw1b6CWoWZ1AMdvrUj~evz4p9vl75mg7BsEp0,AAMC--8/FlogHelper.jar"); addPlugin("Sharesite") .inGroup("communication") - .recommendedVersion(5) + .recommendedVersion(7) .minimumVersion(2) - .loadedFrom("CHK@MDQlAV6EcyIvkomR~~YUx7YOS7BbicvAC9hpedmUlUw,rf3V7plsMOf650hNXOWqmF35dGs1LXRf3TiFOwdghyU,AAMC--8/Sharesite-0-4-8.jar"); + .loadedFrom("CHK@~JCtW4wZDI3dX1vKejUQ-y19sC6tfc5L87hcknvAT-g,x5jFuw2KkDVEQ5d31zi47y7lXAHDfcvfu6rOgQpZkHs,AAMC--8/Sharesite-0-5-1.jar"); } catch (MalformedURLException mue1) { throw new RuntimeException("Could not create FreenetURI.", mue1); } From 00673d1393542de5f5d4702e037395b57e415b50 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sat, 14 Oct 2023 12:58:52 +0300 Subject: [PATCH 172/500] improve date object construction in CurrentTimeUTC.get() java.util.Date default constructor creates a date value, which has UTC zone offset by default. This time value comes from System.currentTimeMillis(). --- src/freenet/support/CurrentTimeUTC.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/support/CurrentTimeUTC.java b/src/freenet/support/CurrentTimeUTC.java index 8b2ca4d4aaa..d86b6b1e83a 100644 --- a/src/freenet/support/CurrentTimeUTC.java +++ b/src/freenet/support/CurrentTimeUTC.java @@ -15,7 +15,7 @@ public class CurrentTimeUTC { public static Date get() { - return Date.from(nowUtc().toInstant()); + return new Date(); } /** From 1aa429bf241b7c54584ab9000ce67ec6c4888f0c Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sat, 14 Oct 2023 13:18:09 +0300 Subject: [PATCH 173/500] Replace OffsetDateTime with LocalDate in CurrentTimeUTC LocalDate has additional methods to access parts of the date. Public methods in the CurrentTimeUTC provide values related to dates only, therefore using LocalDate there is more natural than OffsetDateTime. --- src/freenet/support/CurrentTimeUTC.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/freenet/support/CurrentTimeUTC.java b/src/freenet/support/CurrentTimeUTC.java index d86b6b1e83a..e44b27b2b64 100644 --- a/src/freenet/support/CurrentTimeUTC.java +++ b/src/freenet/support/CurrentTimeUTC.java @@ -3,9 +3,8 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.support; -import java.time.OffsetDateTime; +import java.time.LocalDate; import java.time.ZoneOffset; -import java.time.temporal.ChronoField; import java.util.Date; @@ -31,21 +30,17 @@ public static long getInMillis() { } public static int getYear() { - return nowUtc().get(ChronoField.YEAR); + return LocalDate.now(ZoneOffset.UTC).getYear(); } public static int getMonth() { // Previously, this method used java.util.GregorianCalendar and Calendar.MONTH, which is zero-based. - // Newer java.time API returns months values starting with one, + // Newer java.time API returns months values starting from one, // and subtraction is required to preserve backward compatibility. - return nowUtc().get(ChronoField.MONTH_OF_YEAR) - 1; + return LocalDate.now(ZoneOffset.UTC).getMonthValue() - 1; } public static int getDayOfMonth() { - return nowUtc().get(ChronoField.DAY_OF_MONTH); - } - - private static OffsetDateTime nowUtc() { - return OffsetDateTime.now(ZoneOffset.UTC); + return LocalDate.now(ZoneOffset.UTC).getDayOfMonth(); } } From f2aca2a278fbaf1c546d8b3ec31640b70b76f59e Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sat, 14 Oct 2023 15:47:42 +0300 Subject: [PATCH 174/500] improve method deprecation guidelines in MasterKeys and DatabaseKey --- src/freenet/node/DatabaseKey.java | 5 +++++ src/freenet/node/MasterKeys.java | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/freenet/node/DatabaseKey.java b/src/freenet/node/DatabaseKey.java index 141019a4bfd..59b0b83f404 100644 --- a/src/freenet/node/DatabaseKey.java +++ b/src/freenet/node/DatabaseKey.java @@ -17,6 +17,11 @@ public class DatabaseKey { private final byte[] databaseKey; + /** + * @param key key material bytes + * @param unused randomness source object. Note: this parameter is not used in this object. + * @deprecated use other constructor {@link #DatabaseKey(byte[])} + */ @Deprecated DatabaseKey(byte[] key, Random unused) { this(key); diff --git a/src/freenet/node/MasterKeys.java b/src/freenet/node/MasterKeys.java index 254bf39b367..111f5fe89aa 100644 --- a/src/freenet/node/MasterKeys.java +++ b/src/freenet/node/MasterKeys.java @@ -336,9 +336,16 @@ public static void killMasterKeys(File masterKeysFile) throws IOException { FileUtil.secureDelete(masterKeysFile); } + /** + * @param unused randomness source object. Note: this parameter is not used in this call, + * and database key material is generated + * during or before construction of the {@link MasterKeys} object. + * @return database key object + * @deprecated use other {@link #createDatabaseKey()} method without parameters + */ @Deprecated public DatabaseKey createDatabaseKey(Random unused) { - return new DatabaseKey(databaseKey); + return createDatabaseKey(); } public DatabaseKey createDatabaseKey() { From 858ef08da8e793e682ee7dcaaeb3ed45e78af3b5 Mon Sep 17 00:00:00 2001 From: Veniamin Fernandes Date: Sat, 14 Oct 2023 16:06:06 +0300 Subject: [PATCH 175/500] restore checked exception in the FileLoggerHook.logString() method signature Checked UnsupportedEncodingException cannot be removed because of backward compatibility. --- src/freenet/support/FileLoggerHook.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/freenet/support/FileLoggerHook.java b/src/freenet/support/FileLoggerHook.java index 62cc0d427e1..751654c76f9 100644 --- a/src/freenet/support/FileLoggerHook.java +++ b/src/freenet/support/FileLoggerHook.java @@ -996,13 +996,20 @@ else if(trace.length == 0) else break; } - logString(sb.toString().getBytes(ENCODING)); + try { + logString(sb.toString().getBytes(ENCODING)); + } catch (UnsupportedEncodingException e1) { + throw new IllegalStateException( + "Failed to convert log message to bytes. Unsupported charset encoding: " + ENCODING.name(), + e1 + ); + } } /** Memory allocation overhead (estimated through experimentation with bsh) */ private static final int LINE_OVERHEAD = 60; - public void logString(byte[] b) { + public void logString(byte[] b) throws UnsupportedEncodingException { synchronized (list) { int sz = list.size(); if(!list.offer(b)) { From acd309adeda0165c53c0ea6158f32b16174b2087 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 14 Oct 2023 16:02:14 +0200 Subject: [PATCH 176/500] Update KeepAlive to commit 86e47a101f26fd1d3be0437681a043aa4ae3f22c --- src/freenet/pluginmanager/OfficialPlugins.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/pluginmanager/OfficialPlugins.java b/src/freenet/pluginmanager/OfficialPlugins.java index da989ba81cb..d662bf4ef85 100644 --- a/src/freenet/pluginmanager/OfficialPlugins.java +++ b/src/freenet/pluginmanager/OfficialPlugins.java @@ -56,7 +56,7 @@ public OfficialPlugins() { .advanced(); addPlugin("KeepAlive") .inGroup("file-transfer") - .loadedFrom("CHK@bT1sdJ8VC0QT80kcefY95FYHEaqrHLlWVYgMX2bqeHg,AnvF8F7T9nJP8DY4snYsNJwz1np5JG73OaXeHJUqyZw,AAMC--8/plugin-KeepAlive.jar "); + .loadedFrom("CHK@mR-kJQNZYRaMRdO0D36NhLv8WnfF1sqsBe1ixKUg5lo,i-HExcBFiue3u4q5jooqRZUzRBGZJ0DSpd~~1T7fW6Q,AAMC--8/plugin-KeepAlive.jar"); addPlugin("MDNSDiscovery") .inGroup("connectivity") .minimumVersion(2) From cb37a8b071f7545f4fc932725edc0ca9656e94de Mon Sep 17 00:00:00 2001 From: "Arne Babenhauserheide (freenet releases)" Date: Sat, 14 Oct 2023 22:22:59 +0000 Subject: [PATCH 177/500] Update default bookmark editions --- .../http/staticfiles/defaultbookmarks.dat | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index f8727655333..8f744a190b4 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -8,12 +8,12 @@ BookmarkCategory0.Content.Bookmark0.Name=Freenet First Steps BookmarkCategory0.Content.Bookmark0.ShortDescription=L10N:FFS BookmarkCategory0.Content.Bookmark0.Description=L10N:FFS BookmarkCategory0.Content.Bookmark0.hasAnActivelink=true -BookmarkCategory0.Content.Bookmark0.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsVfWQ-HQo,cJrPvdNz4AnrHJQXNteDV7k3YnAVY-MClt84gwH2qEo,AQACAAE/freenet-first-steps/23/ +BookmarkCategory0.Content.Bookmark0.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsVfWQ-HQo,cJrPvdNz4AnrHJQXNteDV7k3YnAVY-MClt84gwH2qEo,AQACAAE/freenet-first-steps/24/ BookmarkCategory0.Content.Bookmark1.Name=Clean Spider BookmarkCategory0.Content.Bookmark1.Description=L10N:CleanSpider BookmarkCategory0.Content.Bookmark1.ShortDescription=L10N:CleanSpider BookmarkCategory0.Content.Bookmark1.hasAnActivelink=true -BookmarkCategory0.Content.Bookmark1.URI=USK@5ijbfKSJ4kPZTRDzq363CHteEUiSZjrO-E36vbHvnIU,ZEZqPXeuYiyokY2r0wkhJr5cy7KBH9omkuWDqSC6PLs,AQACAAE/clean-spider/129/ +BookmarkCategory0.Content.Bookmark1.URI=USK@5ijbfKSJ4kPZTRDzq363CHteEUiSZjrO-E36vbHvnIU,ZEZqPXeuYiyokY2r0wkhJr5cy7KBH9omkuWDqSC6PLs,AQACAAE/clean-spider/214/ BookmarkCategory0.Content.Bookmark2.Name=Index of Indexes BookmarkCategory0.Content.Bookmark2.ShortDescription=L10N:JFnikiIndex BookmarkCategory0.Content.Bookmark2.Description=L10N:JFnikiIndex @@ -22,7 +22,7 @@ BookmarkCategory0.Content.Bookmark2.URI=USK@t-YmshUm43nS16QFieoZMfBdfieb9Opy0a2a BookmarkCategory1.Name=L10N:categorySoftware BookmarkCategory1.Content.BookmarkCategory=0 BookmarkCategory1.Content.Bookmark=8 -BookmarkCategory1.Content.Bookmark0.URI=USK@dCnkUL22fAmKbKg-Cftx9j2m4IwyWB0QbGoiq1RSLP8,4d1TDqwRr4tYlsubLrQK~c4h0~FtmE-OXCDmFiI8BB4,AQACAAE/Sharesite/36/ +BookmarkCategory1.Content.Bookmark0.URI=USK@dCnkUL22fAmKbKg-Cftx9j2m4IwyWB0QbGoiq1RSLP8,4d1TDqwRr4tYlsubLrQK~c4h0~FtmE-OXCDmFiI8BB4,AQACAAE/Sharesite/41/ BookmarkCategory1.Content.Bookmark0.Name=Sharesite BookmarkCategory1.Content.Bookmark0.Description=L10N:Sharesite BookmarkCategory1.Content.Bookmark0.ShortDescription=L10N:Sharesite @@ -36,7 +36,7 @@ BookmarkCategory1.Content.Bookmark2.Name=Freemail BookmarkCategory1.Content.Bookmark2.Description=L10N:Freemail BookmarkCategory1.Content.Bookmark2.ShortDescription=L10N:Freemail BookmarkCategory1.Content.Bookmark2.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark2.URI=USK@cZu5Jx1eTvsN-p0c22uD3y3DvjKwv6bPRIHlCM5~4zQ,IOBbCUJWoNsYYPYcmscE70tFM-QjfWFW~myTPbeGIHg,AQACAAE/index/2/ +BookmarkCategory1.Content.Bookmark2.URI=USK@cZu5Jx1eTvsN-p0c22uD3y3DvjKwv6bPRIHlCM5~4zQ,IOBbCUJWoNsYYPYcmscE70tFM-QjfWFW~myTPbeGIHg,AQACAAE/index/4/ BookmarkCategory1.Content.Bookmark3.URI=USK@MYLAnId-ZEyXhDGGbYOa1gOtkZZrFNTXjFl1dibLj9E,Xpu27DoAKKc8b0718E-ZteFrGqCYROe7XBBJI57pB4M,AQACAAE/Shoeshop/3/ BookmarkCategory1.Content.Bookmark3.Name=Shoeshop BookmarkCategory1.Content.Bookmark3.Description=L10N:Shoeshop @@ -51,7 +51,7 @@ BookmarkCategory1.Content.Bookmark5.Name=Freenet Message System BookmarkCategory1.Content.Bookmark5.Description=L10N:FMS BookmarkCategory1.Content.Bookmark5.ShortDescription=L10N:FMS BookmarkCategory1.Content.Bookmark5.hasAnActivelink=true -BookmarkCategory1.Content.Bookmark5.URI=USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/153/ +BookmarkCategory1.Content.Bookmark5.URI=USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/154/ BookmarkCategory1.Content.Bookmark6.URI=USK@pGQPA-9PcFiE3A2tCuCjacK165UaX07AQYw98iDQrNA,8gwQ67ytBNR03hNj7JU~ceeew22HVq6G50dcEeMcgks,AQACAAE/flip/17/ BookmarkCategory1.Content.Bookmark6.Name=FLIP BookmarkCategory1.Content.Bookmark6.Description=L10N:FLIP @@ -105,7 +105,7 @@ BookmarkCategory2.Content.Bookmark7.hasAnActivelink=true BookmarkCategory2.Content.Bookmark7.Name=Freenet Statistics BookmarkCategory2.Content.Bookmark7.Description=L10N:statistics BookmarkCategory2.Content.Bookmark7.ShortDescription=L10N:statistics -BookmarkCategory2.Content.Bookmark8.URI=USK@lwR9sLnZD3QHveZa1FB0dAHgeck~dFNBg368mY09wSU,0Vq~4FXSUj1-op3QdzqjZsIvrNMYWlnSdUwCl-Z1fYA,AQACAAE/fetchpullstats/698/ +BookmarkCategory2.Content.Bookmark8.URI=USK@lwR9sLnZD3QHveZa1FB0dAHgeck~dFNBg368mY09wSU,0Vq~4FXSUj1-op3QdzqjZsIvrNMYWlnSdUwCl-Z1fYA,AQACAAE/fetchpullstats/863/ BookmarkCategory2.Content.Bookmark8.hasAnActivelink=true BookmarkCategory2.Content.Bookmark8.Name=Fetch-pull stats BookmarkCategory2.Content.Bookmark8.Description=L10N:fetchpull @@ -115,12 +115,12 @@ BookmarkCategory2.Content.Bookmark9.hasAnActivelink=true BookmarkCategory2.Content.Bookmark9.Name=Sharesite Documentation BookmarkCategory2.Content.Bookmark9.Description=L10N:sharesitedocumentation BookmarkCategory2.Content.Bookmark9.ShortDescription=L10N:sharesitedocumentation -BookmarkCategory2.Content.Bookmark10.URI=USK@~osOPnNLdMLVrYVNTahLufdwOuMhhC4GkpIHulnSm04,bwAmjkK-BZZnj-bujBQehwgGqUM1AUFhzTW4hcDGXQ0,AQACAAE/infocalypse_and_pyFreenet/10/ +BookmarkCategory2.Content.Bookmark10.URI=USK@~osOPnNLdMLVrYVNTahLufdwOuMhhC4GkpIHulnSm04,bwAmjkK-BZZnj-bujBQehwgGqUM1AUFhzTW4hcDGXQ0,AQACAAE/infocalypse_and_pyFreenet/11/ BookmarkCategory2.Content.Bookmark10.Name=Infocalypse and pyFreenet BookmarkCategory2.Content.Bookmark10.Description=L10N:InfocalypsePyFreenet BookmarkCategory2.Content.Bookmark10.ShortDescription=L10N:InfocalypsePyFreenet BookmarkCategory2.Content.Bookmark10.hasAnActivelink=true -BookmarkCategory2.Content.Bookmark11.URI=USK@SYsHNvVtTUa5h12MnZ9Bvqhyk9yTma2~IKk2uFk1HMo,7k4bmQkXE-oxbjeUPKy1QZkPWfLDkNB8XR-2EpEs-eY,AQACAAE/opennet-seednodes-stats/3/ +BookmarkCategory2.Content.Bookmark11.URI=USK@SYsHNvVtTUa5h12MnZ9Bvqhyk9yTma2~IKk2uFk1HMo,7k4bmQkXE-oxbjeUPKy1QZkPWfLDkNB8XR-2EpEs-eY,AQACAAE/opennet-seednodes-stats/5/ BookmarkCategory2.Content.Bookmark11.Name=Opennet SeedNodes Uptime Statistics BookmarkCategory2.Content.Bookmark11.Description=L10N:SeedNodesUptimeStats BookmarkCategory2.Content.Bookmark11.ShortDescription=L10N:SeedNodesUptimeStats @@ -132,12 +132,12 @@ BookmarkCategory3.Content.Bookmark0.Name=ArneBab BookmarkCategory3.Content.Bookmark0.Description=L10N:Flog.ArneBab BookmarkCategory3.Content.Bookmark0.ShortDescription=L10N:Flog.ArneBab BookmarkCategory3.Content.Bookmark0.hasAnActivelink=true -BookmarkCategory3.Content.Bookmark0.URI=USK@sUm3oJISSEU4pl2Is9qa1eRoCLyz6r2LPkEqlXc3~oc,yBEbf-IJrcB8Pe~gAd53DEEHgbugUkFSHtzzLqnYlbs,AQACAAE/random_babcom/479/ +BookmarkCategory3.Content.Bookmark0.URI=USK@sUm3oJISSEU4pl2Is9qa1eRoCLyz6r2LPkEqlXc3~oc,yBEbf-IJrcB8Pe~gAd53DEEHgbugUkFSHtzzLqnYlbs,AQACAAE/random_babcom/504/ BookmarkCategory3.Content.Bookmark1.Name=Bombe BookmarkCategory3.Content.Bookmark1.Description=L10N:Flog.Bombe BookmarkCategory3.Content.Bookmark1.ShortDescription=L10N:Flog.Bombe BookmarkCategory3.Content.Bookmark1.hasAnActivelink=true -BookmarkCategory3.Content.Bookmark1.URI=USK@e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U,QvbWT0ImE0TwLODTl7EoJx2NBnwDxTbLTE6zkB-eGPs,AQACAAE/bombe/124/ +BookmarkCategory3.Content.Bookmark1.URI=USK@e3myoFyp5avg6WYN16ImHri6J7Nj8980Fm~aQe4EX1U,QvbWT0ImE0TwLODTl7EoJx2NBnwDxTbLTE6zkB-eGPs,AQACAAE/bombe/128/ BookmarkCategory3.Content.Bookmark2.Name=xor BookmarkCategory3.Content.Bookmark2.Description=L10N:Flog.Xor BookmarkCategory3.Content.Bookmark2.ShortDescription=L10N:Flog.Xor From 206a7a920e5aa28a69d078bf0e78bac793821bce Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 15 Oct 2023 00:48:42 +0200 Subject: [PATCH 178/500] update NEWS --- NEWS.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 1a86e50f1d0..f7cd55f8988 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,39 @@ next: -- merge debian package build for 1494 (not yet updated for 1497). +- + + +1498: + +- Shorten description of sharesite freesite for english +- gzip: replace test workaround by fixing the output of the compressor — thanks to Bombe for the SingleOffsetReplacingOutputStream! +- replace GregorianCalendar with java.time.OffsetDateTime in CurrentTimeUTC — thanks to Veniamin Fernandes +- CSS: Support word-wrap: anywhere +- Move UPnP2 to normal plugins. It does not seem broken, but UPnP does +- Move Library plugin to advanced plugins because new users tend to get lost with it +- html-filter: allow summary and details html element. Thanks to naejadu +- 💄 Add a bit of styling to the plugin list (for winterfacey) — thanks to Bombe +- 🔥 Remove option that to load plugins from central server — thanks to Bombe! +- fix: invalid max store size showed bytes with GiB suffix +- polish: show datastore size warning with GiB suffix +- Refine ClientRequestSelectorTest, PersistentJobRunnerImplTest, SplitFileFetcherStorageTest, and SplitFileInserterStorageTest — thanks to Veniamin Fernandes +- Change deprecated jcenter() maven repo to mavenCentral() — thanks to Veniamin Fernandes +- 🐛 Fix JarClassLoader’s ability to work with ServiceLoader — thanks to Bombe! +- refactor the browser warning wizard page +- fix the flag size of nepal — thanks to Percept0r@NYZkOs7eQ…! +- Switch swiss flag to civil and state ensign — thanks to Percept0r@NY +- bookmarks: Add Opennet SeedNodes stats site +- Reorder starting bookmarks: FFS → clean spider → Index of Indexes +- Re-order default software bookmarks by ease of use from fproxy +- Add generate media site to the default bookmarks +- Show the noderef in basic-mode: it is now robust enough +- Added tests for PebbleUtils — thanks to Bombe! +- 🐛 Fix NPE when subsets are not initialized — thanks to Bombe +- reduce logging for too many excluded sub-arrays thanks to Hiina +- disable setting for new-load-management (NLM broke nodes) +- add utility to disable a config option, thanks to Bombe +- merge debian package as default build action thanks to DC*/desyncr! This resolves one of our high impact tasks. + 1497: From b682eaa6eee18938e2537500f5fe7c4ac104b4ad Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 15 Oct 2023 00:54:41 +0200 Subject: [PATCH 179/500] note --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index f7cd55f8988..88a86283754 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,7 @@ next: 1498: +- ⚠ The Windows installer is currently not signed! - Shorten description of sharesite freesite for english - gzip: replace test workaround by fixing the output of the compressor — thanks to Bombe for the SingleOffsetReplacingOutputStream! - replace GregorianCalendar with java.time.OffsetDateTime in CurrentTimeUTC — thanks to Veniamin Fernandes From e9a6173b2b4e5c79f6f0b7c9f2f935aba7bead79 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 15 Oct 2023 01:12:29 +0200 Subject: [PATCH 180/500] Update Debian package to Version 1498 --- debian/changelog | 6 ++++++ debian/files | 4 ++-- debian/freenet.init | 6 +++--- debian/rules | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 287221a42a2..947e77471bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +freenet (0.7.5+1498-1) unstable; urgency=medium + + * Build 1498 + + -- Arne Sun, 15 Oct 2023 23:42:30 +0100 + freenet (0.7.5+1497-1) unstable; urgency=medium * Build 1497 diff --git a/debian/files b/debian/files index 95be461c9e4..412595d9430 100644 --- a/debian/files +++ b/debian/files @@ -1,2 +1,2 @@ -freenet_0.7.5+1497-1_amd64.buildinfo net optional -freenet_0.7.5+1497-1_amd64.deb net optional +freenet_0.7.5+1498-1_amd64.buildinfo net optional +freenet_0.7.5+1498-1_amd64.deb net optional diff --git a/debian/freenet.init b/debian/freenet.init index 83baebd24e9..985a6c36f37 100644 --- a/debian/freenet.init +++ b/debian/freenet.init @@ -43,7 +43,7 @@ # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Freenet 0.7.5 build 1497 (experimental release) +# Short-Description: Freenet 0.7.5 build 1498 (experimental release) # Description: Freenet reference daemon ### END INIT INFO @@ -51,7 +51,7 @@ # the default tokens), APP_NAME will default to the name of the script, then # APP_LONG_NAME will default to the value of APP_NAME. APP_NAME="freenet" -APP_LONG_NAME="Freenet 0.7.5 build 1497 (experimental release)" +APP_LONG_NAME="Freenet 0.7.5 build 1498 (experimental release)" # If uncommented (and set to false), APP_NAME and APP_LONG_NAME will no longer # be passed to the wrapper. See documentation for details. @@ -186,7 +186,7 @@ MACOSX_KEEP_RUNNING="false" # The following two lines are used by the chkconfig command. Change as is # appropriate for your application. They should remain commented. # chkconfig: 2345 20 80 -# description: Freenet 0.7.5 build 1497 (experimental release) +# description: Freenet 0.7.5 build 1498 (experimental release) # Set run level to use when installing the application to start and stop on # system startup and shutdown. It is important that the application always diff --git a/debian/rules b/debian/rules index bd47d16205e..60026f8d707 100755 --- a/debian/rules +++ b/debian/rules @@ -4,7 +4,7 @@ # Uncomment this to turn on verbose mode. export DH_VERBOSE=0 FREENET_VERSION := 0.7.5 -FREENET_BUILD := 1497 +FREENET_BUILD := 1498 WRAPPER_INIT := /usr/share/wrapper/make-wrapper-init.sh BUILD_DIR := /tmp/fred-build From 9cb1d68dee5064b85fe44be48d357a8543a5ab83 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 15 Oct 2023 01:44:50 +0200 Subject: [PATCH 181/500] remove special casing of freenet: keys in WelcomeToadlet, because FreenetURI supports that already --- src/freenet/clients/http/WelcomeToadlet.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/freenet/clients/http/WelcomeToadlet.java b/src/freenet/clients/http/WelcomeToadlet.java index 944ba16bb67..cd3bd591943 100644 --- a/src/freenet/clients/http/WelcomeToadlet.java +++ b/src/freenet/clients/http/WelcomeToadlet.java @@ -451,9 +451,6 @@ public void handleMethodGET(URI uri, HTTPRequest request, ToadletContext ctx) th addForm.addChild("#", l10n("confirmAddBookmarkWithKey", "key", request.getParam("newbookmark"))); addForm.addChild("br"); String key = request.getParam("newbookmark"); - if (key.startsWith("freenet:")) { - key = key.substring(8); - } addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden", "key", key}); if(request.isParameterSet("hasAnActivelink")) { addForm.addChild("input", new String[]{"type", "name", "value"}, new String[]{"hidden","hasAnActivelink",request.getParam("hasAnActivelink")}); From 3f46abd2f4ff934ec866dd646578346eed89d01d Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 15 Oct 2023 08:52:50 +0200 Subject: [PATCH 182/500] Add focus-within to NEWS --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 88a86283754..084766068da 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,7 +9,7 @@ next: - Shorten description of sharesite freesite for english - gzip: replace test workaround by fixing the output of the compressor — thanks to Bombe for the SingleOffsetReplacingOutputStream! - replace GregorianCalendar with java.time.OffsetDateTime in CurrentTimeUTC — thanks to Veniamin Fernandes -- CSS: Support word-wrap: anywhere +- CSS: Support word-wrap: anywhere and CSS selector focus-within. - Move UPnP2 to normal plugins. It does not seem broken, but UPnP does - Move Library plugin to advanced plugins because new users tend to get lost with it - html-filter: allow summary and details html element. Thanks to naejadu From a01b276e1e9500425732c31318516e3bb4223fd6 Mon Sep 17 00:00:00 2001 From: Bert Massop Date: Sun, 15 Oct 2023 17:26:51 +0200 Subject: [PATCH 183/500] Deprecate freenet.support.CurrentTimeUTC The Java 8 Date-Time APIs provide superior alternatives for the methods provided in this class. --- src/freenet/support/CurrentTimeUTC.java | 49 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/freenet/support/CurrentTimeUTC.java b/src/freenet/support/CurrentTimeUTC.java index e44b27b2b64..27acf1e83c8 100644 --- a/src/freenet/support/CurrentTimeUTC.java +++ b/src/freenet/support/CurrentTimeUTC.java @@ -10,37 +10,62 @@ /** * A helper class, which returns the current time and date in UTC timezone. + * + * @deprecated use the Java 8 Date-Time APIs instead + * @see java.time.Instant + * @see java.time.LocalDate + * @see java.time.ZoneOffset#UTC */ +@Deprecated public class CurrentTimeUTC { + /** + * Get the current date. + * @deprecated use {@link Date#Date() new Date()} or {@link java.time.Instant} + */ + @Deprecated public static Date get() { return new Date(); } /** - * Get the current time in milliseconds. - * - * In the current implementation, this just returns {@link System#currentTimeMillis()}. - * You should however use CurrentTimeUTC#getInMillis() instead because - * the JavaDoc of {@link System#currentTimeMillis()} does not explicitly state what time zone it returns. - * Therefore, by using this wrapper function, your code clearly states that it uses UTC time. + * Get the current time in milliseconds since epoch. + * @return the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. + * @deprecated use {@link System#currentTimeMillis()} */ + @Deprecated public static long getInMillis() { return System.currentTimeMillis(); } - public static int getYear() { - return LocalDate.now(ZoneOffset.UTC).getYear(); + /** + * Get the current calendar year. + * @deprecated use {@link LocalDate#getYear() LocalDate.now(ZoneOffset.UTC).getYear()} + */ + @Deprecated + public static int getYear() { + return LocalDate.now(ZoneOffset.UTC).getYear(); } - public static int getMonth() { - // Previously, this method used java.util.GregorianCalendar and Calendar.MONTH, which is zero-based. + /** + * Get the zero-indexed current calendar month. + * @return the zero-indexed month number, where 0 indicates January and 11 indicates December + * @deprecated use {@link LocalDate#getMonthValue() LocalDate.now(ZoneOffset.UTC).getMonthValue() - 1} + */ + @Deprecated + public static int getMonth() { + // Previously, this method used java.util.GregorianCalendar and Calendar.MONTH, which is zero-based. // Newer java.time API returns months values starting from one, // and subtraction is required to preserve backward compatibility. return LocalDate.now(ZoneOffset.UTC).getMonthValue() - 1; } - public static int getDayOfMonth() { - return LocalDate.now(ZoneOffset.UTC).getDayOfMonth(); + /** + * Get the current day of the month. + * @deprecated use {@link LocalDate#getDayOfMonth() LocalDate.now(ZoneOffset.UTC).getDayOfMonth()} + */ + @Deprecated + public static int getDayOfMonth() { + return LocalDate.now(ZoneOffset.UTC).getDayOfMonth(); } } From b53b937bf36138ec42ecb09e3d87bd40bf02bc9e Mon Sep 17 00:00:00 2001 From: Bert Massop Date: Sun, 15 Oct 2023 17:26:52 +0200 Subject: [PATCH 184/500] Remove all Fred usages of deprecated CurrentTimeUTC Only get() and getInMillis() were used within Fred. These methods can trivially be replaced by new Date() and System.currentTimeMillis() respectively. --- src/freenet/client/async/ClientRequester.java | 25 ++++++++++--------- .../client/events/SplitfileProgressEvent.java | 3 +-- src/freenet/clients/fcp/ClientGet.java | 3 +-- src/freenet/clients/fcp/ClientPut.java | 3 +-- src/freenet/clients/fcp/ClientPutDir.java | 3 +-- src/freenet/clients/fcp/RequestStatus.java | 5 ++-- src/freenet/clients/http/Cookie.java | 3 +-- src/freenet/clients/http/SessionManager.java | 7 +++--- src/freenet/support/LRUCache.java | 4 +-- test/freenet/clients/http/CookieTest.java | 10 +++----- 10 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/freenet/client/async/ClientRequester.java b/src/freenet/client/async/ClientRequester.java index 901eeece2c3..65f0240cdb5 100644 --- a/src/freenet/client/async/ClientRequester.java +++ b/src/freenet/client/async/ClientRequester.java @@ -16,7 +16,6 @@ import freenet.node.SendableRequest; import freenet.node.useralerts.SimpleUserAlert; import freenet.node.useralerts.UserAlert; -import freenet.support.CurrentTimeUTC; import freenet.support.Logger; import freenet.support.Logger.LogLevel; import freenet.support.io.ResumeFailedException; @@ -125,10 +124,12 @@ public int hashCode() { protected int totalBlocks; /** Number of blocks we have successfully completed a fetch/put for. */ protected int successfulBlocks; - /** - * ATTENTION: This may be null for very old databases. - * @see #getLatestSuccess() Explanation of the content and especially the default value. */ - protected Date latestSuccess = CurrentTimeUTC.get(); + /** + * ATTENTION: This may be null for very old databases. + * + * @see #getLatestSuccess() Explanation of the content and especially the default value. + */ + protected Date latestSuccess = new Date(); /** Number of blocks which have failed. */ protected int failedBlocks; /** Number of blocks which have failed fatally. */ @@ -174,8 +175,8 @@ public Date getLatestFailure() { protected synchronized void resetBlocks() { totalBlocks = 0; successfulBlocks = 0; - // See ClientRequester.getLatestSuccess() for why this defaults to current time. - latestSuccess = CurrentTimeUTC.get(); + // See ClientRequester.getLatestSuccess() for why this defaults to current time. + latestSuccess = new Date(); failedBlocks = 0; fatallyFailedBlocks = 0; latestFailure = null; @@ -242,7 +243,7 @@ public void completedBlock(boolean dontNotify, ClientContext context) { synchronized(this) { if(cancelled) return; successfulBlocks++; - latestSuccess = CurrentTimeUTC.get(); + latestSuccess = new Date(); } if(dontNotify) return; notifyClients(context); @@ -254,7 +255,7 @@ public void completedBlock(boolean dontNotify, ClientContext context) { public void failedBlock(boolean dontNotify, ClientContext context) { synchronized(this) { failedBlocks++; - latestFailure = CurrentTimeUTC.get(); + latestFailure = new Date(); } if(!dontNotify) notifyClients(context); @@ -269,7 +270,7 @@ public void failedBlock(ClientContext context) { public void fatallyFailedBlock(ClientContext context) { synchronized(this) { fatallyFailedBlocks++; - latestFailure = CurrentTimeUTC.get(); + latestFailure = new Date(); } notifyClients(context); } @@ -331,8 +332,8 @@ protected void clearCountersOnRestart() { this.minSuccessBlocks = 0; this.sentToNetwork = false; this.successfulBlocks = 0; - // See ClientRequester.getLatestSuccess() for why this defaults to current time. - this.latestSuccess = CurrentTimeUTC.get(); + // See ClientRequester.getLatestSuccess() for why this defaults to current time. + this.latestSuccess = new Date(); this.totalBlocks = 0; } diff --git a/src/freenet/client/events/SplitfileProgressEvent.java b/src/freenet/client/events/SplitfileProgressEvent.java index 12086627722..5063130e61d 100644 --- a/src/freenet/client/events/SplitfileProgressEvent.java +++ b/src/freenet/client/events/SplitfileProgressEvent.java @@ -6,7 +6,6 @@ import java.util.Date; import freenet.client.async.ClientRequester; -import freenet.support.CurrentTimeUTC; import freenet.support.LogThresholdCallback; import freenet.support.Logger; import freenet.support.Logger.LogLevel; @@ -61,7 +60,7 @@ protected SplitfileProgressEvent() { totalBlocks = 0; succeedBlocks = 0; // See ClientRequester.getLatestSuccess() for why this defaults to current time. - latestSuccess = CurrentTimeUTC.get(); + latestSuccess = new Date(); failedBlocks = 0; fatallyFailedBlocks = 0; latestFailure = null; diff --git a/src/freenet/clients/fcp/ClientGet.java b/src/freenet/clients/fcp/ClientGet.java index a02167d12aa..ab0588b53c0 100644 --- a/src/freenet/clients/fcp/ClientGet.java +++ b/src/freenet/clients/fcp/ClientGet.java @@ -43,7 +43,6 @@ import freenet.crypt.HashResult; import freenet.keys.FreenetURI; import freenet.node.NodeClientCore; -import freenet.support.CurrentTimeUTC; import freenet.support.LogThresholdCallback; import freenet.support.Logger; import freenet.support.Logger.LogLevel; @@ -931,7 +930,7 @@ synchronized RequestStatus getStatus() { boolean totalFinalized = false; int total = 0, min = 0, fetched = 0, fatal = 0, failed = 0; // See ClientRequester.getLatestSuccess() for why this defaults to current time. - Date latestSuccess = CurrentTimeUTC.get(); + Date latestSuccess = new Date(); Date latestFailure = null; if(progressPending != null) { diff --git a/src/freenet/clients/fcp/ClientPut.java b/src/freenet/clients/fcp/ClientPut.java index 0d96f9b3ce5..73f8a379129 100644 --- a/src/freenet/clients/fcp/ClientPut.java +++ b/src/freenet/clients/fcp/ClientPut.java @@ -28,7 +28,6 @@ import freenet.keys.FreenetURI; import freenet.node.NodeClientCore; import freenet.support.Base64; -import freenet.support.CurrentTimeUTC; import freenet.support.IllegalBase64Exception; import freenet.support.LogThresholdCallback; import freenet.support.Logger; @@ -525,7 +524,7 @@ RequestStatus getStatus() { int total=0, min=0, fetched=0, fatal=0, failed=0; // See ClientRequester.getLatestSuccess() for why this defaults to current time. - Date latestSuccess = CurrentTimeUTC.get(); + Date latestSuccess = new Date(); Date latestFailure = null; boolean totalFinalized = false; diff --git a/src/freenet/clients/fcp/ClientPutDir.java b/src/freenet/clients/fcp/ClientPutDir.java index b55162e3c8d..ae35b6bdbcd 100644 --- a/src/freenet/clients/fcp/ClientPutDir.java +++ b/src/freenet/clients/fcp/ClientPutDir.java @@ -26,7 +26,6 @@ import freenet.clients.fcp.RequestIdentifier.RequestType; import freenet.keys.FreenetURI; import freenet.node.NodeClientCore; -import freenet.support.CurrentTimeUTC; import freenet.support.LogThresholdCallback; import freenet.support.Logger; import freenet.support.Logger.LogLevel; @@ -380,7 +379,7 @@ RequestStatus getStatus() { int total=0, min=0, fetched=0, fatal=0, failed=0; // See ClientRequester.getLatestSuccess() for why this defaults to current time. - Date latestSuccess = CurrentTimeUTC.get(); + Date latestSuccess = new Date(); Date latestFailure = null; boolean totalFinalized = false; diff --git a/src/freenet/clients/fcp/RequestStatus.java b/src/freenet/clients/fcp/RequestStatus.java index 68cb114aff4..f78fa4d8dff 100644 --- a/src/freenet/clients/fcp/RequestStatus.java +++ b/src/freenet/clients/fcp/RequestStatus.java @@ -7,7 +7,6 @@ import freenet.clients.fcp.ClientRequest.Persistence; import freenet.keys.FreenetURI; import freenet.l10n.NodeL10n; -import freenet.support.CurrentTimeUTC; /** The status of a request. Cached copy i.e. can be accessed outside the database thread * even for a persistent request. @@ -41,7 +40,7 @@ public abstract class RequestStatus implements Cloneable { /** The download or upload has finished. * @param success Did it succeed? */ synchronized void setFinished(boolean success) { - this.latestSuccess = CurrentTimeUTC.get(); + this.latestSuccess = new Date(); this.hasFinished = true; this.hasSucceeded = success; this.hasStarted = true; @@ -50,7 +49,7 @@ synchronized void setFinished(boolean success) { synchronized void restart(boolean started) { // See ClientRequester.getLatestSuccess() for why this defaults to current time. - this.latestSuccess = CurrentTimeUTC.get(); + this.latestSuccess = new Date(); this.hasFinished = false; this.hasSucceeded = false; this.hasStarted = started; diff --git a/src/freenet/clients/http/Cookie.java b/src/freenet/clients/http/Cookie.java index 02c25d22c85..fd0275e35c9 100644 --- a/src/freenet/clients/http/Cookie.java +++ b/src/freenet/clients/http/Cookie.java @@ -10,7 +10,6 @@ import java.util.Date; import java.util.HashSet; -import freenet.support.CurrentTimeUTC; import freenet.support.TimeUtil; /** @@ -271,7 +270,7 @@ The following grammar uses the notation, and tokens DIGIT (decimal d } public static Date validateExpirationDate(Date expirationDate) { - if(CurrentTimeUTC.get().after(expirationDate)) + if(new Date().after(expirationDate)) throw new IllegalArgumentException("Illegal expiration date, is in past: " + expirationDate); return expirationDate; diff --git a/src/freenet/clients/http/SessionManager.java b/src/freenet/clients/http/SessionManager.java index 78029af6c15..b46da3822e9 100644 --- a/src/freenet/clients/http/SessionManager.java +++ b/src/freenet/clients/http/SessionManager.java @@ -16,7 +16,6 @@ import java.util.Set; import java.util.UUID; -import freenet.support.CurrentTimeUTC; import freenet.support.LRUMap; import freenet.support.Logger; import freenet.support.StringValidityChecker; @@ -252,7 +251,7 @@ public String getCookieNamespace() { public synchronized Session createSession(String userID, ToadletContext context) { // We must synchronize around the fetching of the time and mSessionsByID.push() because mSessionsByID is no sorting data structure: It's a plain // LRUMap so to ensure that it stays sorted the operation "getTime(); push();" must be atomic. - long time = CurrentTimeUTC.getInMillis(); + long time = System.currentTimeMillis(); removeExpiredSessions(time); @@ -279,7 +278,7 @@ public synchronized boolean sessionExists(ToadletContext context) { if(sessionID == null) return false; - removeExpiredSessions(CurrentTimeUTC.getInMillis()); + removeExpiredSessions(System.currentTimeMillis()); return mSessionsByID.containsKey(sessionID); } @@ -299,7 +298,7 @@ public synchronized Session useSession(ToadletContext context) { // We must synchronize around the fetching of the time and mSessionsByID.push() because mSessionsByID is no sorting data structure: It's a plain // LRUMap so to ensure that it stays sorted the operation "getTime(); push();" must be atomic. - long time = CurrentTimeUTC.getInMillis(); + long time = System.currentTimeMillis(); removeExpiredSessions(time); diff --git a/src/freenet/support/LRUCache.java b/src/freenet/support/LRUCache.java index 7900b9d63a7..5f31498132d 100644 --- a/src/freenet/support/LRUCache.java +++ b/src/freenet/support/LRUCache.java @@ -31,7 +31,7 @@ private final class Entry { public Entry(final Value myValue) { mValue = myValue; - mExpirationDate = (mExpirationDelay < Long.MAX_VALUE) ? (CurrentTimeUTC.getInMillis() + mExpirationDelay) : (Long.MAX_VALUE); + mExpirationDate = (mExpirationDelay < Long.MAX_VALUE) ? (System.currentTimeMillis() + mExpirationDelay) : (Long.MAX_VALUE); } public boolean expired(final long time) { @@ -39,7 +39,7 @@ public boolean expired(final long time) { } public boolean expired() { - return expired(CurrentTimeUTC.getInMillis()); + return expired(System.currentTimeMillis()); } public Value getValue() { diff --git a/test/freenet/clients/http/CookieTest.java b/test/freenet/clients/http/CookieTest.java index 636cbd2e680..36f0aff0fe8 100644 --- a/test/freenet/clients/http/CookieTest.java +++ b/test/freenet/clients/http/CookieTest.java @@ -12,8 +12,6 @@ import org.junit.Before; import org.junit.Test; -import freenet.support.CurrentTimeUTC; - public class CookieTest { static final String VALID_PATH = "/Freetalk"; @@ -28,7 +26,7 @@ public class CookieTest { @Before public void setUp() throws Exception { validPath = new URI(VALID_PATH); - validExpiresDate = new Date(CurrentTimeUTC.getInMillis()+60*60*1000); + validExpiresDate = new Date(System.currentTimeMillis() + 60 * 60 * 1000); cookie = new Cookie(validPath, VALID_NAME, VALID_VALUE, validExpiresDate); } @@ -81,7 +79,7 @@ public void testCookieURIStringStringDate() throws URISyntaxException { // TODO: Test for more invalid characters in value; try { - new Cookie(validPath, VALID_NAME, VALID_VALUE, new Date(CurrentTimeUTC.getInMillis()-1)); + new Cookie(validPath, VALID_NAME, VALID_VALUE, new Date(System.currentTimeMillis() - 1)); fail("Constructor allows construction of expired cookies."); } catch(RuntimeException e) {} } @@ -89,10 +87,10 @@ public void testCookieURIStringStringDate() throws URISyntaxException { @Test public void testEqualsObject() throws URISyntaxException { assertEquals(cookie, cookie); - assertEquals(cookie, new Cookie(validPath, VALID_NAME, VALID_VALUE, new Date(CurrentTimeUTC.getInMillis()+60*1000))); + assertEquals(cookie, new Cookie(validPath, VALID_NAME, VALID_VALUE, new Date(System.currentTimeMillis() + 60 * 1000))); // Value is not checked in equals(). - assertEquals(cookie, new Cookie(validPath, VALID_NAME, "", new Date(CurrentTimeUTC.getInMillis()+60*1000))); + assertEquals(cookie, new Cookie(validPath, VALID_NAME, "", new Date(System.currentTimeMillis() + 60 * 1000))); assertFalse(cookie.equals(new Cookie(new URI(VALID_PATH.toLowerCase()), VALID_NAME, VALID_VALUE, validExpiresDate))); assertEquals(cookie, new Cookie(validPath, VALID_NAME.toLowerCase(), VALID_VALUE, validExpiresDate)); From 27eae4d549669ff20d53016aa6c3b9d99443e0e4 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 29 Oct 2023 15:55:31 +0100 Subject: [PATCH 185/500] specialize healing to keys close to the node --- .../client/async/SimpleHealingQueue.java | 63 ++++++++++++++++++- src/freenet/node/NodeClientCore.java | 2 +- .../client/async/SimpleHealingQueueTest.java | 44 +++++++++++++ 3 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 test/freenet/client/async/SimpleHealingQueueTest.java diff --git a/src/freenet/client/async/SimpleHealingQueue.java b/src/freenet/client/async/SimpleHealingQueue.java index d737b7348dd..83c03bf0cec 100644 --- a/src/freenet/client/async/SimpleHealingQueue.java +++ b/src/freenet/client/async/SimpleHealingQueue.java @@ -12,6 +12,8 @@ import freenet.keys.BaseClientKey; import freenet.keys.CHKBlock; import freenet.keys.FreenetURI; +import freenet.node.Location; +import freenet.node.NodeStarter; import freenet.node.RequestClient; import freenet.node.RequestClientBuilder; import freenet.support.LogThresholdCallback; @@ -25,6 +27,8 @@ public class SimpleHealingQueue extends BaseClientPutter implements HealingQueue final int maxRunning; int counter; InsertContext ctx; + private final double nodeLocation; + private final boolean opennetEnabled; final Map runningInserters; private static volatile boolean logMINOR; @@ -39,9 +43,11 @@ public void shouldUpdate(){ static final RequestClient REQUEST_CLIENT = new RequestClientBuilder().build(); - public SimpleHealingQueue(InsertContext context, short prio, int maxRunning) { + public SimpleHealingQueue(InsertContext context, short prio, int maxRunning, double nodeLocation, boolean opennetEnabled) { super(prio, REQUEST_CLIENT); this.ctx = context; + this.nodeLocation = nodeLocation; + this.opennetEnabled = opennetEnabled; this.runningInserters = new HashMap(); this.maxRunning = maxRunning; } @@ -60,7 +66,9 @@ public boolean innerQueue(Bucket data, byte[] cryptoKey, byte cryptoAlgorithm, C Logger.error(this, "Caught trying to insert healing block: "+e, e); return false; } - runningInserters.put(data, sbi); + if (isHealingThisBlockSimilarToForwarding(context, sbi)) { + runningInserters.put(data, sbi); + } } try { sbi.schedule(context); @@ -73,6 +81,57 @@ public boolean innerQueue(Bucket data, byte[] cryptoKey, byte cryptoAlgorithm, C } } + /** + * Specialize Healing to the fraction of the keyspace in which we would receive the inserts + * if we were one of 5 long distance nodes of an actual inserter. + * + * If an opennet node is connected to an attacker, healing traffic could be mistaken for an insert. + * Since opennet cannot be fully secured, this should be avoided. + * As a solution, we specialize healing inserts to the inserts we would send if we were one of 5 + * long distance connections for a node in another part of the keyspace. + * + * As a welcome side effect, specialized healing inserts should take one hop less to reach the + * correct node from which loop detection will stop the insert long before HTL reaches zero. + */ + private boolean isHealingThisBlockSimilarToForwarding( + ClientContext context, + SingleBlockInserter sbi) { + // pure darknet is safer against sybil attacks, so we can heal fully + if (!opennetEnabled) { + return true; + } + // ensure that we have a routing key + sbi.tryEncode(context); + double keyLocation = sbi.getKeyNoEncode().getNodeKey().toNormalizedDouble(); + double randomBetweenZeroAndOne = NodeStarter.getGlobalSecureRandom().nextDouble() / Double.MAX_VALUE; + return shouldHealBlock(nodeLocation, keyLocation, randomBetweenZeroAndOne); + } + + /** + * choose fraction by probabilistic dropping of far away keys. + * only enqueue keys in our 20% of the keyspace: the ones that would reach us if we were one of + * 5 long distance peers of a peer node. + */ + static boolean shouldHealBlock( + double nodeLocation, + double keyLocation, + double randomBetweenZeroAndOne) { + double distanceToNodeLocation = Location.distance(nodeLocation, keyLocation); + // accept half the healings in our 20% of the keyspace. + // If the key is inside "our" 20% of the keyspace, heal it with 50% probability. + if (distanceToNodeLocation < 0.1) { + // accept 50%, specialized to our own location (0.5 ** 4 ~ 0.0625). Accept 70% which are going + // to our short distance peers (0.32 ** 4 ~ 0.01), 78% of those which could be reached via a + // direct short distance FOAF (distance 0.02). + double randomToPower4 = Math.pow(randomBetweenZeroAndOne, 4); + return distanceToNodeLocation < randomToPower4; + } else { + // if the key is a long distance key for us, heal it with 10% probability: it is unlikely that + // this would have reached us. Setting this to 0 could amplify a keyspace takeover attack. + return 0.9 < randomBetweenZeroAndOne; + } + } + @Override public void queue(Bucket data, byte[] cryptoKey, byte cryptoAlgorithm, ClientContext context) { if(!innerQueue(data, cryptoKey, cryptoAlgorithm, context)) diff --git a/src/freenet/node/NodeClientCore.java b/src/freenet/node/NodeClientCore.java index e58e467d041..330dfa411df 100644 --- a/src/freenet/node/NodeClientCore.java +++ b/src/freenet/node/NodeClientCore.java @@ -495,7 +495,7 @@ public void realRun() { false, Node.FORK_ON_CACHEABLE_DEFAULT, false, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, 0, 0, InsertContext.CompatibilityMode.COMPAT_DEFAULT), - RequestStarter.PREFETCH_PRIORITY_CLASS, MAX_RUNNING_HEALING_INSERTS); + RequestStarter.PREFETCH_PRIORITY_CLASS, MAX_RUNNING_HEALING_INSERTS, node.getLocation(), node.isOpennetEnabled()); PooledFileRandomAccessBufferFactory raff = new PooledFileRandomAccessBufferFactory(persistentFilenameGenerator, diff --git a/test/freenet/client/async/SimpleHealingQueueTest.java b/test/freenet/client/async/SimpleHealingQueueTest.java new file mode 100644 index 00000000000..19e880d8229 --- /dev/null +++ b/test/freenet/client/async/SimpleHealingQueueTest.java @@ -0,0 +1,44 @@ +package freenet.client.async; + +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Arrays; + +import org.hamcrest.Matchers; +import org.junit.Test; + +public class SimpleHealingQueueTest { + + @Test + public void healingAlwaysAcceptsAKeyAtTheNodeLocation() { + for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.1, i), Matchers.equalTo(true)); + } + } + + @Test + public void healingAccepts70PercentOfKeysInShortDistance() { + for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)) { + assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.11, i), Matchers.equalTo(true)); + } + } + + @Test + public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistance() { + for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.1999, i), Matchers.equalTo(true)); + } + } + + @Test + public void healingAccepts10PercentOfKeysAtLongDistance() { + for (double i : Arrays.asList(1.0, 0.91)) { + assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(true)); + } + for (double i : Arrays.asList(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + assertThat(String.format("Healing does not trigger at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(false)); + } + } + + +} From 2075df3b7131ad7b6714ae831662cc078694c049 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 29 Oct 2023 15:55:45 +0100 Subject: [PATCH 186/500] remove unused imports --- test/freenet/node/NodeAndClientLayerTestBase.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/freenet/node/NodeAndClientLayerTestBase.java b/test/freenet/node/NodeAndClientLayerTestBase.java index 14554758b2b..87903f5ea79 100644 --- a/test/freenet/node/NodeAndClientLayerTestBase.java +++ b/test/freenet/node/NodeAndClientLayerTestBase.java @@ -7,8 +7,6 @@ import freenet.crypt.DummyRandomSource; import freenet.keys.FreenetURI; import freenet.keys.InsertableClientSSK; -import freenet.keys.InsertableUSK; -import freenet.keys.USK; import freenet.support.SimpleReadOnlyArrayBucket; import freenet.support.api.RandomAccessBucket; From a3f1a5a4b3788b7241dc7e85c6368fe5fb1f9783 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 29 Oct 2023 15:57:02 +0100 Subject: [PATCH 187/500] refactor: extract variable to avoid long long line --- src/freenet/client/async/SplitFileFetcher.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/freenet/client/async/SplitFileFetcher.java b/src/freenet/client/async/SplitFileFetcher.java index d35418b4836..04a99165b45 100644 --- a/src/freenet/client/async/SplitFileFetcher.java +++ b/src/freenet/client/async/SplitFileFetcher.java @@ -22,6 +22,7 @@ import freenet.node.BaseSendableGet; import freenet.support.Logger; import freenet.support.api.LockableRandomAccessBuffer; +import freenet.support.api.RandomAccessBucket; import freenet.support.compress.Compressor.COMPRESSOR_TYPE; import freenet.support.io.BucketTools; import freenet.support.io.FileUtil; @@ -297,7 +298,10 @@ public void onSplitfileCompatibilityMode(CompatibilityMode min, CompatibilityMod @Override public void queueHeal(byte[] data, byte[] cryptoKey, byte cryptoAlgorithm) { try { - context.healingQueue.queue(BucketTools.makeImmutableBucket(context.tempBucketFactory, data), cryptoKey, cryptoAlgorithm, context); + RandomAccessBucket dataBucket = BucketTools.makeImmutableBucket( + context.tempBucketFactory, + data); + context.healingQueue.queue(dataBucket, cryptoKey, cryptoAlgorithm, context); } catch (IOException e) { // Nothing to be done, but need to log the error. Logger.error(this, "I/O error, failed to queue healing block: "+e, e); From de84ac9612d182fabe5436a725143aa6c1e6da72 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 26 Nov 2023 13:19:50 +0100 Subject: [PATCH 188/500] Add high-impact-tasks to bookmarks --- src/freenet/clients/http/staticfiles/defaultbookmarks.dat | 7 ++++++- src/freenet/l10n/freenet.l10n.en.properties | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index f8727655333..baf8f853f5a 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -64,7 +64,7 @@ BookmarkCategory1.Content.Bookmark7.ShortDescription=L10N:GenerateMediaSite BookmarkCategory1.Content.Bookmark7.hasAnActivelink=true BookmarkCategory2.Name=L10N:categoryDocumentation BookmarkCategory2.Content.BookmarkCategory=0 -BookmarkCategory2.Content.Bookmark=11 +BookmarkCategory2.Content.Bookmark=12 BookmarkCategory2.Content.Bookmark0.URI=USK@0iU87PXyodL2nm6kCpmYntsteViIbMwlJE~wlqIVvZ0,nenxGvjXDElX5RIZxMvwSnOtRzUKJYjoXEDgkhY6Ljw,AQACAAE/freenetproject-mirror/515/ BookmarkCategory2.Content.Bookmark0.Name=Freenetproject Website Mirror BookmarkCategory2.Content.Bookmark0.Description=L10N:freenetprojectorg @@ -125,6 +125,11 @@ BookmarkCategory2.Content.Bookmark11.Name=Opennet SeedNodes Uptime Statistics BookmarkCategory2.Content.Bookmark11.Description=L10N:SeedNodesUptimeStats BookmarkCategory2.Content.Bookmark11.ShortDescription=L10N:SeedNodesUptimeStats BookmarkCategory2.Content.Bookmark11.hasAnActivelink=true +BookmarkCategory2.Content.Bookmark12.URI=USK@xPkwhS3czAr5oi6yNgLQ7Ld7RbUZuY6eGniS0n5FZtc,WXVIZrZyLlZugJgJKYvbF9SPfKAUAQX9gAX6g7FGNVE,AQACAAE/high-impact-tasks/21/ +BookmarkCategory2.Content.Bookmark12.Name=High Impact Tasks +BookmarkCategory2.Content.Bookmark12.Description=L10N:HighImpactTasks +BookmarkCategory2.Content.Bookmark12.ShortDescription=L10N:HighImpactTasks +BookmarkCategory2.Content.Bookmark12.hasAnActivelink=true BookmarkCategory3.Name=L10N:categoryBlogs BookmarkCategory3.Content.BookmarkCategory=0 BookmarkCategory3.Content.Bookmark=5 diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 065c3eb3aa2..4eef43a0847 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -123,6 +123,7 @@ Bookmarks.Defaults.Description.jSite=Tool for uploading freesites (Freenet websi Bookmarks.Defaults.Description.Sharesite=Plugin to publish simple Freesites with minimal effort. Bookmarks.Defaults.Description.GenerateMediaSite=Tool to create video- or audio-on-demand sites that start playing right-away Bookmarks.Defaults.Description.SeedNodesUptimeStats=Statistics about the Seednodes needed for the initial connection into Opennet. +Bookmarks.Defaults.Description.HighImpactTasks=Steps to improve Freenet / Hyphanet identified as the most impactful ones Bookmarks.Defaults.Description.Flog.Toad=Toad's flog Bookmarks.Defaults.Description.Flog.Bombe=Bombe's flog Bookmarks.Defaults.Description.Flog.Xor=Flog of the main Freetalk & Web Of Trust developer @@ -152,6 +153,7 @@ Bookmarks.Defaults.ShortDescription.jSite=Essential tool for uploading websites Bookmarks.Defaults.ShortDescription.Sharesite=Plugin that manages a list of sites for which you only need to set title and content, save and click insert. Bookmarks.Defaults.ShortDescription.GenerateMediaSite=Tool to create video- or audio-freesites. Bookmarks.Defaults.ShortDescription.SeedNodesUptimeStats=Uptime statistics for the Opennet Seednodes +Bookmarks.Defaults.ShortDescription.HighImpactTasks=Most important tasks to improve Freenet / Hyphanet Bookmarks.Defaults.ShortDescription.Flog.Toad=Former chief Freenet developer's personal blog Bookmarks.Defaults.ShortDescription.Flog.Bombe=Sone developer's personal blog Bookmarks.Defaults.ShortDescription.Flog.Xor=Freetalk and Web of Trust developer's blog From 18a79cbbf929522a0a66d79d297d5eaa4c6a312e Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 26 Nov 2023 13:21:19 +0100 Subject: [PATCH 189/500] Disable activelink for Index of Indexes (workaround, because it fails) --- src/freenet/clients/http/staticfiles/defaultbookmarks.dat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index f8727655333..5b8e24b146e 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -17,7 +17,7 @@ BookmarkCategory0.Content.Bookmark1.URI=USK@5ijbfKSJ4kPZTRDzq363CHteEUiSZjrO-E36 BookmarkCategory0.Content.Bookmark2.Name=Index of Indexes BookmarkCategory0.Content.Bookmark2.ShortDescription=L10N:JFnikiIndex BookmarkCategory0.Content.Bookmark2.Description=L10N:JFnikiIndex -BookmarkCategory0.Content.Bookmark2.hasAnActivelink=true +BookmarkCategory0.Content.Bookmark2.hasAnActivelink=false BookmarkCategory0.Content.Bookmark2.URI=USK@t-YmshUm43nS16QFieoZMfBdfieb9Opy0a2aMWsoH8o,7NqDX88r1R4SC~elmpW4SuKbnAOka~MKUuBufUWa2xQ,AQACAAE/jFniki.Index/8/Index_of_Indexes.html BookmarkCategory1.Name=L10N:categorySoftware BookmarkCategory1.Content.BookmarkCategory=0 From 79c49edd9f989c5fcd6d7cab79b5d5016ea3b540 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 29 Nov 2023 08:34:20 +0100 Subject: [PATCH 190/500] Update NEWS --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 084766068da..c135d94a455 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,9 @@ next: 1498: +- Support Schema hypha[net] +- Update Sharesite to 0.5.1 +- Deprecated custom datetime handling class CurrentTimeUTC - ⚠ The Windows installer is currently not signed! - Shorten description of sharesite freesite for english - gzip: replace test workaround by fixing the output of the compressor — thanks to Bombe for the SingleOffsetReplacingOutputStream! From 6a55cd5ea073d1dee53145854094ddf7ac577ef5 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Mon, 8 Jan 2024 21:42:34 -0500 Subject: [PATCH 191/500] Add text further describing IPv6 limitations. --- src/freenet/l10n/freenet.l10n.en.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 065c3eb3aa2..4ccf353dc87 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -1223,7 +1223,7 @@ Node.trafficClassLong=The TrafficClass value to pass to Socket.setTrafficClass() Node.nodeName=Nickname for this Freenet node Node.nodeNameLong=Node nickname. This will be visible to your friends only. Node.maxPacketSize=Maximum packet size (aka MTU) -Node.maxPacketSizeLong=Maximum size of the UDP packets Freenet sends, assuming UDP/IP headers are 28 bytes. We will use the MTU of the interface if we can detect it, but mostly obstructions happen elsewhere, and unfortunately we cannot easily detect the path MTU. +Node.maxPacketSizeLong=Maximum size of the UDP packets Freenet sends, assuming UDP/IP headers are 48 bytes (to accommodate IPv6). We will use the MTU of the interface if we can detect it, but mostly obstructions happen elsewhere, and unfortunately we cannot easily detect the path MTU. If you are using IPv6, you are more likely to run into issues if you choose values >1400 because IPv6 will not fragment packets, but drops them instead. 1280 is a safe value. Node.notUsingWrapperTitle=Not using the wrapper! Node.notUsingWrapper=You are running Freenet without the wrapper. This is not recommended. Freenet will not be able to restart itself, so auto-updating won't work, and if Java crashes, it won't get restarted either. Also Freenet can't generate stack dumps in some places so debugging will be marginally harder. Node.notUsingWrapperShort=Freenet is running without the wrapper. This is not recommended. From c63daf5793df883bd75c8456e011152b50bd530e Mon Sep 17 00:00:00 2001 From: Juiceman Date: Mon, 8 Jan 2024 22:23:27 -0500 Subject: [PATCH 192/500] Fix bug limiting MTU to 1280 In UdpSocketHandler.innerCalculateMaxPacketSize() the lesser of the configurable variable node.maxPacketSize and UdpSocketHandler.MAX_ALLOWED_MTU is used, the latter of which was hard coded to 1280. --- src/freenet/io/comm/UdpSocketHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/io/comm/UdpSocketHandler.java b/src/freenet/io/comm/UdpSocketHandler.java index c004613a9d2..040d401bd73 100644 --- a/src/freenet/io/comm/UdpSocketHandler.java +++ b/src/freenet/io/comm/UdpSocketHandler.java @@ -353,7 +353,7 @@ public void sendPacket(byte[] blockToSend, Peer destination, boolean allowLocalA // http://www.studenten-ins-netz.net/inhalt/service_faq.html // officially GRE is 1476 and PPPoE is 1492. // unofficially, PPPoE is often 1472 (seen in the wild). Also PPPoATM is sometimes 1472. - static final int MAX_ALLOWED_MTU = 1280; + static final int MAX_ALLOWED_MTU = 1492; static final int UDPv4_HEADERS_LENGTH = 28; static final int UDPv6_HEADERS_LENGTH = 48; // conservative estimation when AF is not known From eeacc9d9612f88d9844a8a5d4a09fd149b7d3b34 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Mon, 8 Jan 2024 22:48:11 -0500 Subject: [PATCH 193/500] Remove security lowering kludge. As stated in the description of this option, if a large portion of the network disables packet padding it makes the network easier to trace. 15 years later now, if network overhead is a real concern for some users they can tweak this themselves. --- src/freenet/node/NodeCryptoConfig.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/freenet/node/NodeCryptoConfig.java b/src/freenet/node/NodeCryptoConfig.java index 061d6386735..b77f49caf1e 100644 --- a/src/freenet/node/NodeCryptoConfig.java +++ b/src/freenet/node/NodeCryptoConfig.java @@ -240,18 +240,6 @@ public void set(Boolean val) throws InvalidConfigValueException, NodeNeedRestart }); paddDataPackets = config.getBoolean("paddDataPackets"); - securityLevels.addNetworkThreatLevelListener(new SecurityLevelListener() { - - @Override - public void onChange(NETWORK_THREAT_LEVEL oldLevel, NETWORK_THREAT_LEVEL newLevel) { - // Might be useful for nodes which are running with a tight bandwidth quota to minimize the overhead, - // so turn it off for LOW. Otherwise is sensible. - if(newLevel == NETWORK_THREAT_LEVEL.LOW) - paddDataPackets = false; - if(oldLevel == NETWORK_THREAT_LEVEL.LOW) - paddDataPackets = true; - } - }); } /** The number of config options i.e. the amount to increment sortOrder by */ From d369286add999f508fbc09b067b3a12171d9c9e0 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Sun, 14 Jan 2024 22:32:24 -0500 Subject: [PATCH 194/500] Change string comparison into a .isEmpty() check We are actually checking if the string is empty. Using .isEmpty() is clearer. --- src/freenet/client/ClientMetadata.java | 4 +- src/freenet/client/FetchContext.java | 6 +-- src/freenet/client/FetchException.java | 2 +- src/freenet/client/Metadata.java | 2 +- src/freenet/client/async/ClientGetter.java | 4 +- .../client/async/SingleFileFetcher.java | 2 +- .../client/filter/CSSTokenizerFilter.java | 40 +++++++++---------- src/freenet/client/filter/ElementInfo.java | 2 +- src/freenet/client/filter/FilterUtils.java | 2 +- src/freenet/client/filter/HTMLFilter.java | 10 ++--- src/freenet/clients/fcp/AddPeer.java | 4 +- src/freenet/clients/fcp/ClientPut.java | 2 +- src/freenet/clients/fcp/ClientPutBase.java | 2 +- src/freenet/clients/fcp/DirPutFile.java | 2 +- .../fcp/FCPConnectionInputHandler.java | 2 +- src/freenet/clients/fcp/ModifyPeer.java | 10 ++--- .../clients/http/ConnectionsToadlet.java | 4 +- .../clients/http/FProxyFetchInProgress.java | 2 +- src/freenet/clients/http/FProxyToadlet.java | 10 ++--- src/freenet/clients/http/N2NTMToadlet.java | 2 +- src/freenet/clients/http/PproxyToadlet.java | 2 +- src/freenet/clients/http/QueueToadlet.java | 16 ++++---- .../clients/http/SimpleToadletServer.java | 2 +- .../clients/http/ToadletContextImpl.java | 2 +- .../http/wizardsteps/BANDWIDTH_RATE.java | 2 +- src/freenet/io/AllowedHosts.java | 2 +- src/freenet/io/NetworkInterface.java | 2 +- src/freenet/keys/FreenetURI.java | 2 +- src/freenet/l10n/BaseL10n.java | 6 +-- src/freenet/node/MasterKeys.java | 2 +- src/freenet/node/Node.java | 2 +- src/freenet/node/TextModeClientInterface.java | 4 +- .../LongTermManySingleBlocksTest.java | 2 +- 33 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/freenet/client/ClientMetadata.java b/src/freenet/client/ClientMetadata.java index 67c124fba02..53e68a11017 100644 --- a/src/freenet/client/ClientMetadata.java +++ b/src/freenet/client/ClientMetadata.java @@ -64,13 +64,13 @@ public String getMIMEType() { * existing information. */ public void mergeNoOverwrite(ClientMetadata clientMetadata) { - if((mimeType == null) || mimeType.equals("")) + if((mimeType == null) || mimeType.isEmpty()) mimeType = clientMetadata.mimeType; } /** Is there no MIME type? */ public boolean isTrivial() { - return ((mimeType == null) || mimeType.equals("")); + return ((mimeType == null) || mimeType.isEmpty()); } @Override diff --git a/src/freenet/client/FetchContext.java b/src/freenet/client/FetchContext.java index cec1f19bb4d..381624140ee 100644 --- a/src/freenet/client/FetchContext.java +++ b/src/freenet/client/FetchContext.java @@ -406,13 +406,13 @@ public FetchContext(DataInputStream dis) throws StorageFormatException, IOExcept } } String s = dis.readUTF(); - if(s.equals("")) + if(s.isEmpty()) charset = null; else charset = s; canWriteClientCache = dis.readBoolean(); s = dis.readUTF(); - if(s.equals("")) + if(s.isEmpty()) overrideMIME = null; else overrideMIME = s; @@ -425,7 +425,7 @@ public FetchContext(DataInputStream dis) throws StorageFormatException, IOExcept // input stream reached EOF, so it must have been and old version without scehmeHostAndPort. s = ""; } - if (s.equals("")) { + if (s.isEmpty()) { schemeHostAndPort = null; } else { schemeHostAndPort = s; diff --git a/src/freenet/client/FetchException.java b/src/freenet/client/FetchException.java index 5e761085ee7..4fb2d3e0967 100644 --- a/src/freenet/client/FetchException.java +++ b/src/freenet/client/FetchException.java @@ -353,7 +353,7 @@ public static String getShortMessage(FetchExceptionMode mode) { // FIXME change the l10n to use the names rather than codes int code = mode.code; String ret = NodeL10n.getBase().getString("FetchException.shortError."+code); - if(ret == null || ret.equals("")) + if(ret == null || ret.isEmpty()) return "Unknown code "+mode; else return ret; } diff --git a/src/freenet/client/Metadata.java b/src/freenet/client/Metadata.java index bc8c95300d7..c165a4d672f 100644 --- a/src/freenet/client/Metadata.java +++ b/src/freenet/client/Metadata.java @@ -854,7 +854,7 @@ private void addRedirectionManifestWithMetadata(HashMap dir) { Logger.debug(this, "Putting metadata for "+key); manifestEntries.put(key, data); } else if(o instanceof HashMap) { - if(key.equals("")) { + if(key.isEmpty()) { Logger.error(this, "Creating a subdirectory called \"\" - it will not be possible to access this through fproxy!", new Exception("error")); } HashMap hm = Metadata.forceMap(o); diff --git a/src/freenet/client/async/ClientGetter.java b/src/freenet/client/async/ClientGetter.java index dcee4fde0e6..3e54bdbdc45 100644 --- a/src/freenet/client/async/ClientGetter.java +++ b/src/freenet/client/async/ClientGetter.java @@ -529,7 +529,7 @@ public void onFailure(FetchException e, ClientGetState state, ClientContext cont String mime = e.getExpectedMimeType(); if(ctx.overrideMIME != null) mime = ctx.overrideMIME; - if(mime != null && !"".equals(mime)) { + if(mime != null && !mime.isEmpty()) { // Even if it's the default, it is set because we have the final size. UnsafeContentTypeException unsafe = ContentFilter.checkMIMEType(mime); if(unsafe != null) { @@ -784,7 +784,7 @@ public void onExpectedMIME(ClientMetadata clientMetadata, ClientContext context) mime = clientMetadata.getMIMEType(); if(ctx.overrideMIME != null) mime = ctx.overrideMIME; - if(mime == null || mime.equals("")) return; + if(mime == null || mime.isEmpty()) return; synchronized(this) { expectedMIME = mime; } diff --git a/src/freenet/client/async/SingleFileFetcher.java b/src/freenet/client/async/SingleFileFetcher.java index feef22929ea..6a4e6a4561b 100644 --- a/src/freenet/client/async/SingleFileFetcher.java +++ b/src/freenet/client/async/SingleFileFetcher.java @@ -376,7 +376,7 @@ private synchronized void handleMetadata(final ClientContext context) throws Fet } else if(metaStrings.isEmpty()) { FreenetURI u = uri; String last = u.lastMetaString(); - if(last == null || !last.equals("")) + if(last == null || !last.isEmpty()) u = u.addMetaStrings(new String[] { "" }); else u = null; diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index 4158fb8dcff..0286cfcc0e0 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1773,26 +1773,26 @@ else if(HTMLelement.indexOf('#')!=-1) } } - if(isIDSelector && "".equals(id)) return null; // No ID + if(isIDSelector && id.isEmpty()) return null; // No ID boolean elementValid = "*".equals(HTMLelement) || (ElementInfo.isValidHTMLTag(HTMLelement.toLowerCase())) || - ("".equals(HTMLelement.trim()) && - ((!className.equals("")) || (!id.equals("")) || attSelections!=null || - !pseudoClass.equals(""))); + (HTMLelement.trim().isEmpty() && + ((!className.isEmpty()) || (!id.isEmpty()) || attSelections!=null || + !pseudoClass.isEmpty())); if(!elementValid) return null; - if(!className.equals("")) { + if(!className.isEmpty()) { // Note that the definition of isValidName() allows chained classes because it allows . in class names. if(!ElementInfo.isValidName(className)) return null; - } else if(!id.equals("")) { + } else if(!id.isEmpty()) { if(!ElementInfo.isValidName(id)) return null; } - if(!pseudoClass.equals("")) { + if(!pseudoClass.isEmpty()) { if(!ElementInfo.isValidPseudoClass(pseudoClass)) { return null; } else if(ElementInfo.isBannedPseudoClass(pseudoClass)) { @@ -1853,14 +1853,14 @@ else if(HTMLelement.indexOf('#')!=-1) } fBuffer.append(HTMLelement); - if(!className.equals("")) { + if(!className.isEmpty()) { fBuffer.append('.'); fBuffer.append(className); - } else if(!id.equals("")) { + } else if(!id.isEmpty()) { fBuffer.append('#'); fBuffer.append(id); } - if(!pseudoClass.equals("")) { + if(!pseudoClass.isEmpty()) { fBuffer.append(':'); fBuffer.append(pseudoClass); } @@ -2361,7 +2361,7 @@ else if(parts[0] instanceof SimpleParsedWord && "@media".equals(((SimpleParsedWo if(!isState1Present) { String s = buffer.toString().trim(); - if(!(s.equals("") || s.equals("/") || s.equals("<") || s.equals(" propertyVerifierList = new ArrayList(); for (int i = 0; i <= expression.length(); i++) { if(i == expression.length() || expression.charAt(i)=='b') { - if(!firstPart.equals("")) { + if(!firstPart.isEmpty()) { if(ignoredParts.length() == 0) { ignoredParts = firstPart; } else { @@ -4468,7 +4468,7 @@ public boolean recursiveDoubleBarVerifier(String expression,ParsedWord[] words,F { if(i == expression.length() || expression.charAt(i)=='a') { - if(!firstPart.equals("")) { + if(!firstPart.isEmpty()) { if(ignoredParts.length() == 0) ignoredParts = firstPart; else @@ -4502,9 +4502,9 @@ public boolean recursiveDoubleBarVerifier(String expression,ParsedWord[] words,F } // Against the rest of the pattern: the part that we've tried and failed plus the part that we haven't tried yet. // NOT against the verifier we were just considering, because the double-bar operator expects no more than one match from each component of the pattern. - String pattern = ignoredParts+((("".equals(ignoredParts))||("".equals(secondPart)))?"":"a")+secondPart; + String pattern = ignoredParts+(((ignoredParts.isEmpty())||(secondPart.isEmpty()))?"":"a")+secondPart; if(logDEBUG) Logger.debug(this, "14a "+toString(getSubArray(words, 0, j+1))+" can be consumed by "+index+ " passing on expression="+pattern+ " value="+toString(valueToPass)); - if(pattern.equals("")) return false; + if(pattern.isEmpty()) return false; result=recursiveDoubleBarVerifier(pattern,valueToPass, cb); if(result) { diff --git a/src/freenet/client/filter/ElementInfo.java b/src/freenet/client/filter/ElementInfo.java index 1737accfde9..a2d2acb84a8 100644 --- a/src/freenet/client/filter/ElementInfo.java +++ b/src/freenet/client/filter/ElementInfo.java @@ -474,7 +474,7 @@ public static String getPseudoClassArg(String cname, String cname_sans_arg) { int cnameIndex=cname.indexOf(cname_sans_arg); int firstIndex=cname.indexOf('('); int secondIndex=cname.lastIndexOf(')'); - if(cname.substring(cnameIndex+cname_sans_arg.length(),firstIndex).trim().equals("") && cname.substring(0,cnameIndex).trim().equals("") && cname.substring(secondIndex+1,cname.length()).trim().equals("")) + if(cname.substring(cnameIndex + cname_sans_arg.length(), firstIndex).trim().isEmpty() && cname.substring(0, cnameIndex).trim().isEmpty() && cname.substring(secondIndex + 1, cname.length()).trim().isEmpty()) { arg=CSSTokenizerFilter.removeOuterQuotes(cname.substring(firstIndex+1,secondIndex).trim()); } diff --git a/src/freenet/client/filter/FilterUtils.java b/src/freenet/client/filter/FilterUtils.java index c38a6d2f892..677ea2de377 100644 --- a/src/freenet/client/filter/FilterUtils.java +++ b/src/freenet/client/filter/FilterUtils.java @@ -648,7 +648,7 @@ public static String[] removeWhiteSpace(String[] values, boolean stripQuotes) value = value.trim(); if(stripQuotes) value = CSSTokenizerFilter.removeOuterQuotes(value).trim(); - if(value!=null && !("".equals(value.trim()))) + if(value!=null && !(value.trim().isEmpty())) arrayToReturn.add(value); } return arrayToReturn.toArray(new String[0]); diff --git a/src/freenet/client/filter/HTMLFilter.java b/src/freenet/client/filter/HTMLFilter.java index 62d46126488..0dcc6b90625 100644 --- a/src/freenet/client/filter/HTMLFilter.java +++ b/src/freenet/client/filter/HTMLFilter.java @@ -242,7 +242,7 @@ void run() throws IOException, DataFilterException { if(textAllowed) { saveText(b, currentTag, w, this); } else { - if(!b.toString().trim().equals("")) + if(!b.toString().trim().isEmpty()) throwFilterException(l10n("textBeforeHTML")); } break; @@ -294,7 +294,7 @@ void run() throws IOException, DataFilterException { if(textAllowed) { saveText(b, currentTag, w, this); } else { - if(!b.toString().trim().equals("")) + if(!b.toString().trim().isEmpty()) throwFilterException(l10n("textBeforeHTML")); } b.setLength(0); @@ -316,7 +316,7 @@ void run() throws IOException, DataFilterException { if(textAllowed) { saveText(b, currentTag, w, this); } else { - if(!b.toString().trim().equals("")) + if(!b.toString().trim().isEmpty()) throwFilterException(l10n("textBeforeHTML")); } @@ -454,7 +454,7 @@ void run() throws IOException, DataFilterException { if(textAllowed) { saveText(b, currentTag, w, this); } else { - if(!b.toString().trim().equals("")) + if(!b.toString().trim().isEmpty()) throwFilterException(l10n("textBeforeHTML")); } balt.setLength(0); @@ -3066,7 +3066,7 @@ Map sanitizeHash(Map h, throwFilterException(l10n("invalidMetaType")); } else if ( http_equiv.equalsIgnoreCase("Content-Language")) { - if(content.matches("((?>[a-zA-Z0-9]*)(?>-[A-Za-z0-9]*)*(?>,\\s*)?)*") && (!content.trim().equals(""))) { + if(content.matches("((?>[a-zA-Z0-9]*)(?>-[A-Za-z0-9]*)*(?>,\\s*)?)*") && (!content.trim().isEmpty())) { hn.put("http-equiv", "Content-Language"); hn.put("content", content); } diff --git a/src/freenet/clients/fcp/AddPeer.java b/src/freenet/clients/fcp/AddPeer.java index c6f8d00c406..bf130896f34 100644 --- a/src/freenet/clients/fcp/AddPeer.java +++ b/src/freenet/clients/fcp/AddPeer.java @@ -138,7 +138,7 @@ public void run(FCPConnectionHandler handler, Node node) throws MessageInvalidEx throw new MessageInvalidException(ProtocolErrorMessage.URL_PARSE_ERROR, "IO error while retrieving ref URL <"+urlString+">: "+e.getMessage(), identifier, false); } ref = new StringBuilder(ref.toString().trim()); - if("".equals(ref.toString())) { + if(ref.toString().isEmpty()) { throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from URL <"+urlString+ '>', identifier, false); } try { @@ -166,7 +166,7 @@ public void run(FCPConnectionHandler handler, Node node) throws MessageInvalidEx throw new MessageInvalidException(ProtocolErrorMessage.FILE_PARSE_ERROR, "IO error while retrieving ref file <"+fileString+">: "+e.getMessage(), identifier, false); } ref = new StringBuilder(ref.toString().trim()); - if("".equals(ref.toString())) { + if(ref.toString().isEmpty()) { throw new MessageInvalidException(ProtocolErrorMessage.REF_PARSE_ERROR, "Error parsing ref from file <"+fileString+ '>', identifier, false); } try { diff --git a/src/freenet/clients/fcp/ClientPut.java b/src/freenet/clients/fcp/ClientPut.java index 937f3309876..72870d8bfc1 100644 --- a/src/freenet/clients/fcp/ClientPut.java +++ b/src/freenet/clients/fcp/ClientPut.java @@ -196,7 +196,7 @@ public ClientPut(FCPConnectionHandler handler, ClientPutMessage message, FCPServ if ((mimeType == null) && (targetFilename != null)) { mimeType = DefaultMIMETypes.guessMIMEType(targetFilename, true); } - if(mimeType != null && mimeType.equals("")) mimeType = null; + if(mimeType != null && mimeType.isEmpty()) mimeType = null; if(mimeType != null && !DefaultMIMETypes.isPlausibleMIMEType(mimeType)) { throw new MessageInvalidException(ProtocolErrorMessage.BAD_MIME_TYPE, "Bad MIME type in Metadata.ContentType", identifier, global); } diff --git a/src/freenet/clients/fcp/ClientPutBase.java b/src/freenet/clients/fcp/ClientPutBase.java index cce1266ef45..0593ef2eb28 100644 --- a/src/freenet/clients/fcp/ClientPutBase.java +++ b/src/freenet/clients/fcp/ClientPutBase.java @@ -126,7 +126,7 @@ protected ClientPutBase() { static FreenetURI checkEmptySSK(FreenetURI uri, String filename, ClientContext context) { if("SSK".equals(uri.getKeyType()) && uri.getDocName() == null && uri.getRoutingKey() == null) { - if(filename == null || filename.equals("")) filename = "key"; + if(filename == null || filename.isEmpty()) filename = "key"; // SSK@ = use a random SSK. InsertableClientSSK key = InsertableClientSSK.createRandom(context.random, ""); return key.getInsertURI().setDocName(filename); diff --git a/src/freenet/clients/fcp/DirPutFile.java b/src/freenet/clients/fcp/DirPutFile.java index adaaa4eb434..3790aae8563 100644 --- a/src/freenet/clients/fcp/DirPutFile.java +++ b/src/freenet/clients/fcp/DirPutFile.java @@ -50,7 +50,7 @@ public static DirPutFile create(SimpleFieldSet subset, String identifier, boolea if(name == null) throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Missing field Name", identifier, global); String contentTypeOverride = subset.get("Metadata.ContentType"); - if(contentTypeOverride != null && (!contentTypeOverride.equals("")) && !DefaultMIMETypes.isPlausibleMIMEType(contentTypeOverride)) { + if(contentTypeOverride != null && (!contentTypeOverride.isEmpty()) && !DefaultMIMETypes.isPlausibleMIMEType(contentTypeOverride)) { throw new MessageInvalidException(ProtocolErrorMessage.BAD_MIME_TYPE, "Bad MIME type in Metadata.ContentType", identifier, global); } String type = subset.get("UploadFrom"); diff --git a/src/freenet/clients/fcp/FCPConnectionInputHandler.java b/src/freenet/clients/fcp/FCPConnectionInputHandler.java index 3cecb77e766..c470335b2b0 100644 --- a/src/freenet/clients/fcp/FCPConnectionInputHandler.java +++ b/src/freenet/clients/fcp/FCPConnectionInputHandler.java @@ -81,7 +81,7 @@ public void realRun() throws IOException { Closer.close(is); return; } - if(messageType.equals("")) + if(messageType.isEmpty()) continue; fs = new SimpleFieldSet(lis, 4096, 128, true, true, true); diff --git a/src/freenet/clients/fcp/ModifyPeer.java b/src/freenet/clients/fcp/ModifyPeer.java index 86a7406fa69..55dfe593609 100644 --- a/src/freenet/clients/fcp/ModifyPeer.java +++ b/src/freenet/clients/fcp/ModifyPeer.java @@ -53,7 +53,7 @@ public void run(FCPConnectionHandler handler, Node node) throws MessageInvalidEx DarknetPeerNode dpn = (DarknetPeerNode) pn; String isDisabledString = fs.get("IsDisabled"); if(isDisabledString != null) { - if(!isDisabledString.equals("")) { + if(!isDisabledString.isEmpty()) { if(Fields.stringToBool(isDisabledString, false)) { dpn.disablePeer(); } else { @@ -63,25 +63,25 @@ public void run(FCPConnectionHandler handler, Node node) throws MessageInvalidEx } String isListenOnlyString = fs.get("IsListenOnly"); if(isListenOnlyString != null) { - if(!isListenOnlyString.equals("")) { + if(!isListenOnlyString.isEmpty()) { dpn.setListenOnly(Fields.stringToBool(isListenOnlyString, false)); } } String isBurstOnlyString = fs.get("IsBurstOnly"); if(isBurstOnlyString != null) { - if(!isBurstOnlyString.equals("")) { + if(!isBurstOnlyString.isEmpty()) { dpn.setBurstOnly(Fields.stringToBool(isBurstOnlyString, false)); } } String ignoreSourcePortString = fs.get("IgnoreSourcePort"); if(ignoreSourcePortString != null) { - if(!ignoreSourcePortString.equals("")) { + if(!ignoreSourcePortString.isEmpty()) { dpn.setIgnoreSourcePort(Fields.stringToBool(ignoreSourcePortString, false)); } } String allowLocalAddressesString = fs.get("AllowLocalAddresses"); if(allowLocalAddressesString != null) { - if(!allowLocalAddressesString.equals("")) { + if(!allowLocalAddressesString.isEmpty()) { dpn.setAllowLocalAddresses(Fields.stringToBool(allowLocalAddressesString, false)); } } diff --git a/src/freenet/clients/http/ConnectionsToadlet.java b/src/freenet/clients/http/ConnectionsToadlet.java index cbd97810af4..d61d8a6fb1a 100644 --- a/src/freenet/clients/http/ConnectionsToadlet.java +++ b/src/freenet/clients/http/ConnectionsToadlet.java @@ -644,12 +644,12 @@ public void handleMethodPOST(URI uri, final HTTPRequest request, ToadletContext String trustS = request.getPartAsStringFailsafe("trust", 10); FRIEND_TRUST trust = null; - if(trustS != null && !trustS.equals("")) + if(trustS != null && !trustS.isEmpty()) trust = FRIEND_TRUST.valueOf(trustS); String visibilityS = request.getPartAsStringFailsafe("visibility", 10); FRIEND_VISIBILITY visibility = null; - if(visibilityS != null && !visibilityS.equals("")) + if(visibilityS != null && !visibilityS.isEmpty()) visibility = FRIEND_VISIBILITY.valueOf(visibilityS); if(trust == null && !isOpennet()) { diff --git a/src/freenet/clients/http/FProxyFetchInProgress.java b/src/freenet/clients/http/FProxyFetchInProgress.java index 33e91532159..4d6404b4d03 100644 --- a/src/freenet/clients/http/FProxyFetchInProgress.java +++ b/src/freenet/clients/http/FProxyFetchInProgress.java @@ -232,7 +232,7 @@ private boolean checkCache(ClientContext context) { } data = result.asBucket(); mimeType = result.getMimeType(); - if(mimeType == null || mimeType.equals("")) mimeType = DefaultMIMETypes.DEFAULT_MIME_TYPE; + if(mimeType == null || mimeType.isEmpty()) mimeType = DefaultMIMETypes.DEFAULT_MIME_TYPE; if(fctx.overrideMIME != null && !result.alreadyFiltered) mimeType = fctx.overrideMIME; else if(fctx.overrideMIME != null && !mimeType.equals(fctx.overrideMIME)) { diff --git a/src/freenet/clients/http/FProxyToadlet.java b/src/freenet/clients/http/FProxyToadlet.java index f699b4eef78..b6818dee4a7 100644 --- a/src/freenet/clients/http/FProxyToadlet.java +++ b/src/freenet/clients/http/FProxyToadlet.java @@ -310,7 +310,7 @@ private static void addDownloadOptions(ToadletContext ctx, HTMLNode optionList, boolean filterChecked = !(((threatLevel == PHYSICAL_THREAT_LEVEL.LOW && netLevel == NETWORK_THREAT_LEVEL.LOW)) || disableFiltration); if((filterChecked) && mimeType != null && !mimeType.equals("application/octet-stream") && - !mimeType.equals("")) { + !mimeType.isEmpty()) { FilterMIMEType type = ContentFilter.getMIMEType(mimeType); if((type == null || (!(type.safeToRead || type.readFilter != null))) && !(threatLevel == PHYSICAL_THREAT_LEVEL.HIGH || @@ -333,7 +333,7 @@ private static void addDownloadOptions(ToadletContext ctx, HTMLNode optionList, optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "persistence", "forever" }); - if (mimeType != null && !mimeType.equals("")) { + if (mimeType != null && !mimeType.isEmpty()) { optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "type", mimeType }); @@ -392,7 +392,7 @@ private static void addDownloadOptions(ToadletContext ctx, HTMLNode optionList, optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "persistence", "forever" }); - if (mimeType != null && !mimeType.equals("")) { + if (mimeType != null && !mimeType.isEmpty()) { optionForm.addChild("input", new String[] { "type", "name", "value" }, new String[] { "hidden", "type", mimeType }); @@ -655,7 +655,7 @@ public void run() { String override = (requestedMimeType == null) ? "" : "?type="+URLEncoder.encode(requestedMimeType,true); String maybeCharset = httprequest.isParameterSet("maybecharset") ? httprequest.getParam("maybecharset", null) : null; fctx.charset = maybeCharset; - if(override.equals("") && maybeCharset != null) + if(override.isEmpty() && maybeCharset != null) override = "?maybecharset="+URLEncoder.encode(maybeCharset, true); // No point passing ?force= across a redirect, since the key will change. // However, there is every point in passing ?forcedownload. @@ -1074,7 +1074,7 @@ private String sanitizeReferer(ToadletContext ctx) { URI refererURI = new URI(URIPreEncoder.encode(referer)); String path = refererURI.getPath(); while(path.startsWith("/")) path = path.substring(1); - if("".equals(path)) return "/"; + if(path.isEmpty()) return "/"; FreenetURI furi = new FreenetURI(path); HTTPRequest req = new HTTPRequestImpl(refererURI, "GET"); String type = req.getParam("type"); diff --git a/src/freenet/clients/http/N2NTMToadlet.java b/src/freenet/clients/http/N2NTMToadlet.java index a54a72e27d2..2fb6e7a40b0 100644 --- a/src/freenet/clients/http/N2NTMToadlet.java +++ b/src/freenet/clients/http/N2NTMToadlet.java @@ -188,7 +188,7 @@ public void handleMethodPOST(URI uri, HTTPRequest request, ToadletContext ctx) } else if(request.isPartSet("n2nm-upload")) { try{ HTTPUploadedFile file = request.getUploadedFile("n2nm-upload"); - if(!file.getFilename().equals("")) { + if(!file.getFilename().isEmpty()) { long size = request.getUploadedFile("n2nm-upload").getData().size(); if(size > 0) { long limit = maxSize(); diff --git a/src/freenet/clients/http/PproxyToadlet.java b/src/freenet/clients/http/PproxyToadlet.java index 65008f84d8c..2706d8c17c7 100644 --- a/src/freenet/clients/http/PproxyToadlet.java +++ b/src/freenet/clients/http/PproxyToadlet.java @@ -353,7 +353,7 @@ public void handleMethodGET(URI uri, HTTPRequest request, ToadletContext ctx) if(logMINOR) Logger.minor(this, "Pproxy fetching "+path); try { - if (path.equals("")) { + if (path.isEmpty()) { if(!ctx.checkFullAccess(this)) return; diff --git a/src/freenet/clients/http/QueueToadlet.java b/src/freenet/clients/http/QueueToadlet.java index 86f1ff34a26..6f8adcd4155 100644 --- a/src/freenet/clients/http/QueueToadlet.java +++ b/src/freenet/clients/http/QueueToadlet.java @@ -259,7 +259,7 @@ public void handleMethodPOST(URI uri, HTTPRequest request, final ToadletContext line.addChild("#", filename); } } - if(type != null && !type.equals("")) { + if(type != null && !type.isEmpty()) { HTMLNode line = infoList.addChild("li"); boolean finalized = request.isPartSet("finalizedType"); line.addChild("#", NodeL10n.getBase().getString("FProxyToadlet."+(finalized ? "mimeType" : "expectedMimeType"), new String[] { "mime" }, new String[] { type })); @@ -456,7 +456,7 @@ else if(request.isPartSet("restart_request") && (request.getPartAsStringFailsafe } else if(request.isPartSet("bulkDownloads")) { String bulkDownloadsAsString = request.getPartAsStringFailsafe("bulkDownloads", 262144); String[] keys = bulkDownloadsAsString.split("\n"); - if(("".equals(bulkDownloadsAsString)) || (keys.length < 1)) { + if((bulkDownloadsAsString.isEmpty()) || (keys.length < 1)) { writePermanentRedirect(ctx, "Done", path()); return; } @@ -575,13 +575,13 @@ else if(request.isPartSet("restart_request") && (request.getPartAsStringFailsafe final String identifier = file.getFilename() + "-fred-" + System.currentTimeMillis(); final String compatibilityMode = request.getPartAsStringFailsafe("compatibilityMode", 100); final CompatibilityMode cmode; - if(compatibilityMode.equals("")) + if(compatibilityMode.isEmpty()) cmode = CompatibilityMode.COMPAT_DEFAULT.intern(); else cmode = CompatibilityMode.valueOf(compatibilityMode).intern(); String s = request.getPartAsStringFailsafe("overrideSplitfileKey", 65); final byte[] overrideSplitfileKey; - if(s != null && !s.equals("")) + if(s != null && !s.isEmpty()) overrideSplitfileKey = HexUtil.hexToBytes(s); else overrideSplitfileKey = null; @@ -675,13 +675,13 @@ public boolean run(ClientContext context) { final boolean compress = request.isPartSet("compress"); final String compatibilityMode = request.getPartAsStringFailsafe("compatibilityMode", 100); final CompatibilityMode cmode; - if(compatibilityMode.equals("")) + if(compatibilityMode.isEmpty()) cmode = CompatibilityMode.COMPAT_DEFAULT; else cmode = CompatibilityMode.valueOf(compatibilityMode); String s = request.getPartAsStringFailsafe("overrideSplitfileKey", 65); final byte[] overrideSplitfileKey; - if(s != null && !s.equals("")) + if(s != null && !s.isEmpty()) overrideSplitfileKey = HexUtil.hexToBytes(s); else overrideSplitfileKey = null; @@ -781,7 +781,7 @@ public boolean run(ClientContext context) { final boolean compress = request.isPartSet("compress"); String s = request.getPartAsStringFailsafe("overrideSplitfileKey", 65); final byte[] overrideSplitfileKey; - if(s != null && !s.equals("")) + if(s != null && !s.isEmpty()) overrideSplitfileKey = HexUtil.hexToBytes(s); else overrideSplitfileKey = null; @@ -874,7 +874,7 @@ public boolean run(ClientContext context) { for(String part : request.getParts()) { if(!part.startsWith("identifier-")) continue; String key = request.getPartAsStringFailsafe("key-"+part.substring("identifier-".length()), MAX_KEY_LENGTH); - if(key == null || key.equals("")) { + if(key == null || key.isEmpty()) { continue; } form.addChild("#", l10n("key") + ":"); diff --git a/src/freenet/clients/http/SimpleToadletServer.java b/src/freenet/clients/http/SimpleToadletServer.java index 3e294279750..18ccd133e7e 100644 --- a/src/freenet/clients/http/SimpleToadletServer.java +++ b/src/freenet/clients/http/SimpleToadletServer.java @@ -278,7 +278,7 @@ public String get() { public void set(String val) throws InvalidConfigValueException { NodeClientCore core = SimpleToadletServer.this.core; if(core == null) return; - if(val.equals(get()) || val.equals("")) + if(val.equals(get()) || val.isEmpty()) cssOverride = null; else { File tmp = new File(val.trim()); diff --git a/src/freenet/clients/http/ToadletContextImpl.java b/src/freenet/clients/http/ToadletContextImpl.java index 4c93756b699..fafe3e08b6f 100644 --- a/src/freenet/clients/http/ToadletContextImpl.java +++ b/src/freenet/clients/http/ToadletContextImpl.java @@ -519,7 +519,7 @@ public static void handle(Socket sock, ToadletContainer container, PageMaker pag if (firstLine == null) { sock.close(); return; - } else if (firstLine.equals("")) { + } else if (firstLine.isEmpty()) { continue; } diff --git a/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java b/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java index 033217ca544..b37ece875c3 100644 --- a/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java +++ b/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java @@ -129,7 +129,7 @@ public String postStep(HTTPRequest request) { String up = request.getPartAsStringFailsafe("customUp", 20); // Try to parse custom limit first. - if(!down.equals("") && !up.equals("")) { + if(!down.isEmpty() && !up.isEmpty()) { String failedLimits = attemptSet(up, down); if (!failedLimits.isEmpty()) { diff --git a/src/freenet/io/AllowedHosts.java b/src/freenet/io/AllowedHosts.java index 1efec6a67e6..0e332d23208 100644 --- a/src/freenet/io/AllowedHosts.java +++ b/src/freenet/io/AllowedHosts.java @@ -40,7 +40,7 @@ public AllowedHosts(String allowedHosts) { * The new list of allowed hosts s */ public void setAllowedHosts(String allowedHosts) { - if(allowedHosts == null || allowedHosts.equals("")) allowedHosts = NetworkInterface.DEFAULT_BIND_TO; + if(allowedHosts == null || allowedHosts.isEmpty()) allowedHosts = NetworkInterface.DEFAULT_BIND_TO; StringTokenizer allowedHostsTokens = new StringTokenizer(allowedHosts, ","); List newAddressMatchers = new ArrayList(); while (allowedHostsTokens.hasMoreTokens()) { diff --git a/src/freenet/io/NetworkInterface.java b/src/freenet/io/NetworkInterface.java index bb4c8446511..0dc10b87df3 100644 --- a/src/freenet/io/NetworkInterface.java +++ b/src/freenet/io/NetworkInterface.java @@ -137,7 +137,7 @@ protected ServerSocket createServerSocket() throws IOException { * @return List of addresses that we failed to bind to, or null if completely successful. */ public String[] setBindTo(String bindTo, boolean ignoreUnbindableIP6) { - if(bindTo == null || bindTo.equals("")) bindTo = NetworkInterface.DEFAULT_BIND_TO; + if(bindTo == null || bindTo.isEmpty()) bindTo = NetworkInterface.DEFAULT_BIND_TO; StringTokenizer bindToTokens = new StringTokenizer(bindTo, ","); List bindToTokenList = new ArrayList(); List brokenList = null; diff --git a/src/freenet/keys/FreenetURI.java b/src/freenet/keys/FreenetURI.java index b451a8b24ef..0d5b0e65bb7 100644 --- a/src/freenet/keys/FreenetURI.java +++ b/src/freenet/keys/FreenetURI.java @@ -1003,7 +1003,7 @@ public String getPreferredFilename() { } if(metaStr != null) for(String s : metaStr) { - if(s == null || s.equals("")) { + if(s == null || s.isEmpty()) { if(logMINOR) Logger.minor(this, "metaString \"" + s + "\": was null or empty"); continue; diff --git a/src/freenet/l10n/BaseL10n.java b/src/freenet/l10n/BaseL10n.java index b28bb825e47..0cb4836bda6 100644 --- a/src/freenet/l10n/BaseL10n.java +++ b/src/freenet/l10n/BaseL10n.java @@ -402,7 +402,7 @@ public void setOverride(String key, String value) { // If there is no need to keep it in the override, remove it... // unless the original/default is the same as the translation - if ("".equals(value) || (currentTranslation != null && value.equals(this.currentTranslation.get(key)))) { + if (value.isEmpty() || (currentTranslation != null && value.equals(this.currentTranslation.get(key)))) { this.translationOverride.removeValue(key); } else { value = value.replaceAll("(\r|\n|\t)+", ""); @@ -772,7 +772,7 @@ private List performHTMLSubstitutions(String value, String[] patterns, private void addHTMLSubstitutions(HTMLNode node, String value, String[] patterns, HTMLNode[] values) throws L10nParseException { int x; - while(!value.equals("") && (x = value.indexOf("${")) != -1) { + while(!value.isEmpty() && (x = value.indexOf("${")) != -1) { String before = value.substring(0, x); if(before.length() > 0) node.addChild("#", before); @@ -817,7 +817,7 @@ private void addHTMLSubstitutions(HTMLNode node, String value, value = rest; } } - if(!value.equals("")) + if(!value.isEmpty()) node.addChild("#", value); } diff --git a/src/freenet/node/MasterKeys.java b/src/freenet/node/MasterKeys.java index 111f5fe89aa..1f48752cd7d 100644 --- a/src/freenet/node/MasterKeys.java +++ b/src/freenet/node/MasterKeys.java @@ -275,7 +275,7 @@ private void write(File masterKeysFile, String newPassword, Random hardRandom) t md.update(salt); byte[] outerKey = md.digest(); long iterations = 0; - if(!newPassword.equals("")) { + if(!newPassword.isEmpty()) { long startTime = System.currentTimeMillis(); while(System.currentTimeMillis() < startTime + ITERATE_TIME && iterations < MAX_ITERATIONS-20) { for(int i=0;i<10;i++) { diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index 454cbbe863d..b29ef30c61b 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -283,7 +283,7 @@ public void set(String val) throws InvalidConfigValueException { if(get().equals(val)) return; else if(val.length() > 128) throw new InvalidConfigValueException("The given node name is too long ("+val+')'); - else if("".equals(val)) + else if(val.isEmpty()) val = "~none~"; synchronized(this) { myName = val; diff --git a/src/freenet/node/TextModeClientInterface.java b/src/freenet/node/TextModeClientInterface.java index c848c636965..0ca15e711ae 100644 --- a/src/freenet/node/TextModeClientInterface.java +++ b/src/freenet/node/TextModeClientInterface.java @@ -378,7 +378,7 @@ private boolean processLine(BufferedReader reader) throws IOException { if(fnam.length() == 0) { fnam = "freenet-download-"+HexUtil.bytesToHex(BucketTools.hash(data), 0, 10); String ext = DefaultMIMETypes.getExtension(cm.getMIMEType()); - if((ext != null) && !ext.equals("")) + if((ext != null) && !ext.isEmpty()) fnam += '.' + ext; } File f = new File(downloadsDir, fnam); @@ -785,7 +785,7 @@ else if(uline.startsWith("PUTSSKDIR:")) { content = readLines(reader, true); } if(content == null) return false; - if(content.equals("")) return false; + if(content.isEmpty()) return false; addPeer(content); } else if(uline.startsWith("NAME:")) { diff --git a/src/freenet/node/simulator/LongTermManySingleBlocksTest.java b/src/freenet/node/simulator/LongTermManySingleBlocksTest.java index cc25ddf5da2..f83becf430f 100644 --- a/src/freenet/node/simulator/LongTermManySingleBlocksTest.java +++ b/src/freenet/node/simulator/LongTermManySingleBlocksTest.java @@ -385,7 +385,7 @@ public static void main(String[] args) { int totalSuccesses = 0; int totalFetches = 0; for(int i=0;i Date: Fri, 26 Jan 2024 20:34:12 +0100 Subject: [PATCH 195/500] =?UTF-8?q?Re-order=20or=E2=80=99ed=20MessageFilte?= =?UTF-8?q?rs=20so=20the=20most=20likely=20is=20checked=20first?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the profiling with jvisualvm this reduces the total time for MessageFilter::match from 5x the self-time to about 1.2x the self-time In profiling with instrumentation, MessageFilter::match is the most expensive method call, because it is called millions of times in a tight inner loop while handling messages. --- src/freenet/io/comm/MessageFilter.java | 1 + src/freenet/io/xfer/BlockReceiver.java | 2 +- src/freenet/node/AnnounceSender.java | 6 ++---- src/freenet/node/RequestSender.java | 12 ++++-------- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/freenet/io/comm/MessageFilter.java b/src/freenet/io/comm/MessageFilter.java index 84204ca8968..5e0ccf5a76c 100644 --- a/src/freenet/io/comm/MessageFilter.java +++ b/src/freenet/io/comm/MessageFilter.java @@ -177,6 +177,7 @@ public MessageFilter setField(String fieldName, Object fieldValue) { /** * Modifies the filter so that it returns true if either it or the filter in the argument returns true. * Multiple combinations must be nested: such as filter1.or(filter2.or(filter3))). + * filter2 will be checked before filter1, so make sure to add the most common last. * @return reference to this, the modified filter. */ public MessageFilter or(MessageFilter or) { diff --git a/src/freenet/io/xfer/BlockReceiver.java b/src/freenet/io/xfer/BlockReceiver.java index f2f49777eb6..b37ab78845b 100644 --- a/src/freenet/io/xfer/BlockReceiver.java +++ b/src/freenet/io/xfer/BlockReceiver.java @@ -484,7 +484,7 @@ private MessageFilter relevantMessages(long timeout) { MessageFilter mfPacketTransmit = MessageFilter.create().setTimeout(timeout).setType(DMT.packetTransmit).setField(DMT.UID, _uid).setSource(_sender); MessageFilter mfAllSent = MessageFilter.create().setTimeout(timeout).setType(DMT.allSent).setField(DMT.UID, _uid).setSource(_sender); MessageFilter mfSendAborted = MessageFilter.create().setTimeout(timeout).setType(DMT.sendAborted).setField(DMT.UID, _uid).setSource(_sender); - return mfPacketTransmit.or(mfAllSent.or(mfSendAborted)); + return mfSendAborted.or(mfAllSent.or(mfPacketTransmit)); } PartiallyReceivedBlock.PacketReceivedListener myListener; diff --git a/src/freenet/node/AnnounceSender.java b/src/freenet/node/AnnounceSender.java index 2bb260e56c0..7d91e6b292d 100644 --- a/src/freenet/node/AnnounceSender.java +++ b/src/freenet/node/AnnounceSender.java @@ -184,10 +184,8 @@ private void realRun() { MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(ACCEPTED_TIMEOUT).setType(DMT.FNPRejectedOverload); MessageFilter mfOpennetDisabled = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(ACCEPTED_TIMEOUT).setType(DMT.FNPOpennetDisabled); - // mfRejectedOverload must be the last thing in the or - // So its or pointer remains null - // Otherwise we need to recreate it below - MessageFilter mf = mfAccepted.or(mfRejectedLoop.or(mfRejectedOverload.or(mfOpennetDisabled))); + // the order of these filters is performance critical. The last or-filter is checked first. + MessageFilter mf = mfRejectedOverload.or(mfRejectedLoop.or(mfOpennetDisabled.or(mfAccepted))); try { msg = node.usm.waitFor(mf, this); diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index 9f8353deb7a..27231c2a70b 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -939,10 +939,8 @@ protected MessageFilter makeAcceptedRejectedFilter(PeerNode next, MessageFilter mfRejectedLoop = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedLoop); MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedOverload); - // mfRejectedOverload must be the last thing in the or - // So its or pointer remains null - // Otherwise we need to recreate it below - return mfAccepted.or(mfRejectedLoop.or(mfRejectedOverload)); + // the order of these filters is performance critical. The last or-filter is checked first. + return mfRejectedOverload.or(mfRejectedLoop.or(mfAccepted)); } private MessageFilter createMessageFilter(int timeout, PeerNode next) { @@ -951,17 +949,15 @@ private MessageFilter createMessageFilter(int timeout, PeerNode next) { MessageFilter mfRouteNotFound = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPRouteNotFound); MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPRejectedOverload); - MessageFilter mf = mfDNF.or(mfRF.or(mfRouteNotFound.or(mfRejectedOverload))); if(!isSSK) { MessageFilter mfRealDFCHK = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPCHKDataFound); - mf = mfRealDFCHK.or(mf); + return mfDNF.or(mfRF.or(mfRouteNotFound.or(mfRejectedOverload.or(mfRealDFCHK)))); } else { MessageFilter mfPubKey = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKPubKey); MessageFilter mfDFSSKHeaders = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKDataFoundHeaders); MessageFilter mfDFSSKData = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(timeout).setType(DMT.FNPSSKDataFoundData); - mf = mfPubKey.or(mfDFSSKHeaders.or(mfDFSSKData.or(mf))); + return mfDNF.or(mfRF.or(mfRouteNotFound.or(mfRejectedOverload.or(mfPubKey.or(mfDFSSKHeaders.or(mfDFSSKData)))))); } - return mf; } private DO handleMessage(Message msg, boolean wasFork, PeerNode source, MainLoopCallback waiter) { From 6ac82b41d243a59c6fa3e5489f6e26f4284247da Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 20:37:38 +0100 Subject: [PATCH 196/500] Call the match function with all arguments directly. Match is called so often, that the match-method with two arguments took 20% of the self-time of the match-method with three arguments. This may be inflated due to the instrumentation, though, because the method with two arguments does nothing except for running the method with three arguments with the default (false), so I expect less than those 20% in wins. --- src/freenet/io/comm/MessageCore.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freenet/io/comm/MessageCore.java b/src/freenet/io/comm/MessageCore.java index 1db7aad601b..15bcf775aef 100644 --- a/src/freenet/io/comm/MessageCore.java +++ b/src/freenet/io/comm/MessageCore.java @@ -203,7 +203,7 @@ public void checkFilters(Message m, PacketSocketHandler from) { i.remove(); continue; } - MATCHED status = f.match(m, tStart); + MATCHED status = f.match(m, false, tStart); if(status == MATCHED.TIMED_OUT || status == MATCHED.TIMED_OUT_AND_MATCHED) { if(timedOut == null) timedOut = new ArrayList(); @@ -269,7 +269,7 @@ public void checkFilters(Message m, PacketSocketHandler from) { if(logMINOR) Logger.minor(this, "Rechecking filters and adding message"); for (ListIterator i = _filters.listIterator(); i.hasNext();) { MessageFilter f = i.next(); - MATCHED status = f.match(m, tStart); + MATCHED status = f.match(m, false, tStart); if(status == MATCHED.MATCHED) { matched = true; match = f; From e0e5f24d1501e51448d90ac9e4f7479975a4553b Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 20:41:31 +0100 Subject: [PATCH 197/500] Check the HashCode before equals. This saves ~20% method-runtime. --- src/freenet/io/comm/MessageFilter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/freenet/io/comm/MessageFilter.java b/src/freenet/io/comm/MessageFilter.java index 5e0ccf5a76c..8bcde7c4ad9 100644 --- a/src/freenet/io/comm/MessageFilter.java +++ b/src/freenet/io/comm/MessageFilter.java @@ -230,7 +230,10 @@ public MATCHED match(Message m, boolean noTimeout, long now) { return resultNoMatch; } final Object fieldValue = _fields.get(i); - if (!fieldValue.equals(m.getFromPayload(fieldName))) { + final Object messageValue = m.getFromPayload(fieldName); + // check the cheaper hashCode before the full equals, because this is one of the + // most frequently called methods. Reduces the CPU time by about 25%. + if (fieldValue.hashCode() != messageValue.hashCode() || !fieldValue.equals(messageValue)) { return resultNoMatch; } } From eaed0f3af49b5e92c97273b06469d6cf65f9b379 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 20:45:01 +0100 Subject: [PATCH 198/500] Add TODOs with notes for optimization and commented out logging code. To evaluate the logs this produces: grep -Eo or-match.* ~/Freenet/logs/freenet-latest.log | \ sort | uniq -c | sort -h \ > misordered-MessageFilter-or-matches.log cat misordered-MessageFilter-or-matches.log this produces a list of MessageFilters with the frequency for pairs where the first is the one that did not match and the second is the filter that did match. --- src/freenet/io/comm/MessageFilter.java | 12 +++++++++++- src/freenet/node/PeerMessageQueue.java | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/freenet/io/comm/MessageFilter.java b/src/freenet/io/comm/MessageFilter.java index 8bcde7c4ad9..dcff6ea80fa 100644 --- a/src/freenet/io/comm/MessageFilter.java +++ b/src/freenet/io/comm/MessageFilter.java @@ -65,6 +65,9 @@ private MessageFilter() { } public static MessageFilter create() { + // TODO: move to a builder so we can get rid of the synchronized(_fields) in match, + // the most expensive method in all of fred. + // TODO: move source and type into create to get rid of the null-checks in match. return new MessageFilter(); } @@ -178,6 +181,8 @@ public MessageFilter setField(String fieldName, Object fieldValue) { * Modifies the filter so that it returns true if either it or the filter in the argument returns true. * Multiple combinations must be nested: such as filter1.or(filter2.or(filter3))). * filter2 will be checked before filter1, so make sure to add the most common last. + * TODO: change the ordering in match: A.or(B) should first check A, like in A || B. + * TODO: ensure for all usages of or(...) that the most likely package is checked first. * @return reference to this, the modified filter. */ public MessageFilter or(MessageFilter or) { @@ -213,8 +218,9 @@ public MATCHED match(Message m, long now) { public MATCHED match(Message m, boolean noTimeout, long now) { if(_or != null) { MATCHED matched = _or.match(m, noTimeout, now); - if(matched != MATCHED.NONE) + if(matched != MATCHED.NONE) { return matched; // Filter is matched once only. That includes timeouts. + } } final MATCHED resultNoMatch = _timeout < now ? MATCHED.TIMED_OUT : MATCHED.NONE; @@ -242,6 +248,10 @@ public MATCHED match(Message m, boolean noTimeout, long now) { if(logMINOR) Logger.minor(this, "Matched but timed out: "+this); return MATCHED.TIMED_OUT_AND_MATCHED; } + // debugging output to optimize ordering of or-combined MessageFilters + // if (_or != null) { + // Logger.error(this, "Filter or-match failed: or: " + _or._type.getName() + " this: " + this._type.getName()); + // } return MATCHED.MATCHED; } diff --git a/src/freenet/node/PeerMessageQueue.java b/src/freenet/node/PeerMessageQueue.java index cb9f5f5c746..e0d53e257ef 100644 --- a/src/freenet/node/PeerMessageQueue.java +++ b/src/freenet/node/PeerMessageQueue.java @@ -20,6 +20,8 @@ * @author Matthew Toseland (0xE43DA450) */ public class PeerMessageQueue { + // TODO: check whether we can use a standard PriorityBlockingQueue (since Java 8) + // instead of our own DoublyLinkedList implementation. private static volatile boolean logMINOR; private static volatile boolean logDEBUG; From 0283b698940c6d212679c1e2fbf63d1befdf0f14 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 21:03:46 +0100 Subject: [PATCH 199/500] Increase default bandwidth to 160KiB upload, when detection fails --- src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java | 4 +++- src/freenet/l10n/freenet.l10n.en.properties | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java b/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java index 033217ca544..ef5fd2dcd5c 100644 --- a/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java +++ b/src/freenet/clients/http/wizardsteps/BANDWIDTH_RATE.java @@ -40,9 +40,11 @@ public BANDWIDTH_RATE(NodeClientCore core, Config config) { // 6Mbps/256kbps - 6Mbps is common in parts of china, as well as being the real value in lots of DSL areas new BandwidthLimit(384*KiB, 16*KiB, "bandwidthConnection6M", false), // 8Mbps/512kbps - UK DSL1 is either 448k up or 832k up - new BandwidthLimit(512*KiB, 32*KiB, "bandwidthConnection8M", true), + new BandwidthLimit(512*KiB, 32*KiB, "bandwidthConnection8M", false), // 12Mbps/1Mbps - typical DSL2 new BandwidthLimit(768*KiB, 64*KiB, "bandwidthConnection12M", false), + // Typical DSL as of 2024 + new BandwidthLimit(768*KiB, 160*KiB, "bandwidthConnectionHalfVDSL", true), // 20Mbps/5Mbps - Slow end of VDSL new BandwidthLimit(1280*KiB, 320*KiB, "bandwidthConnectionVDSL", false), // 100Mbps fibre etc diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 065c3eb3aa2..68be559cfae 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -543,6 +543,7 @@ FirstTimeWizardToadlet.bandwidthConnection6M=6 megabits (average ADSL1) FirstTimeWizardToadlet.bandwidthConnection8M=8 megabits (fast ADSL1) FirstTimeWizardToadlet.bandwidthConnection12M=12 megabits (slow ADSL2) FirstTimeWizardToadlet.bandwidthConnection20M=20 megabits (fast ADSL2, fast cable) +FirstTimeWizardToadlet.bandwidthConnectionHalfVDSL=Fast DSL (160KiB/s up) FirstTimeWizardToadlet.bandwidthConnectionVDSL=VDSL (20/5) FirstTimeWizardToadlet.bandwidthConnection100M=100 megabits (fibre) FirstTimeWizardToadlet.bandwidthCurrent=Current bandwidth limit From f0c28def11e632343b839c874bf97b1d1183de9c Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 21:35:47 +0100 Subject: [PATCH 200/500] Harmonize New wizard with old wizard --- src/freenet/clients/http/FirstTimeWizardNewToadlet.java | 4 ++-- src/freenet/clients/http/templates/first-time-wizard.html | 8 ++++---- src/freenet/l10n/freenet.l10n.en.properties | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/freenet/clients/http/FirstTimeWizardNewToadlet.java b/src/freenet/clients/http/FirstTimeWizardNewToadlet.java index e9955352be5..4ad010017e7 100644 --- a/src/freenet/clients/http/FirstTimeWizardNewToadlet.java +++ b/src/freenet/clients/http/FirstTimeWizardNewToadlet.java @@ -111,9 +111,9 @@ private class FormModel { private String haveMonthlyLimit = ""; - private String downloadLimit = "900"; + private String downloadLimit = "1024"; - private String uploadLimit = "100"; + private String uploadLimit = "160"; private String bandwidthMonthlyLimit = "500"; diff --git a/src/freenet/clients/http/templates/first-time-wizard.html b/src/freenet/clients/http/templates/first-time-wizard.html index cf516678d33..ca2046ca542 100644 --- a/src/freenet/clients/http/templates/first-time-wizard.html +++ b/src/freenet/clients/http/templates/first-time-wizard.html @@ -68,11 +68,11 @@

{{ l10n("bandwidthCommonInternetConnectionSpeeds") }}

16 {{ l10n("bandwidthCommonInternetConnectionSpeedsKibps") }} - {{ l10n("bandwidthCommonInternetConnectionSpeeds6Mbit") }} - 384 {{ l10n("bandwidthCommonInternetConnectionSpeedsKibps") }} - (3 {{ l10n("bandwidthCommonInternetConnectionSpeedsMibs") }}) + {{ l10n("bandwidthCommonInternetConnectionSpeedsVDSL") }} + 2048 {{ l10n("bandwidthCommonInternetConnectionSpeedsKibps") }} + (16 {{ l10n("bandwidthCommonInternetConnectionSpeedsMibs") }}) - 16 {{ l10n("bandwidthCommonInternetConnectionSpeedsKibps") }} + 160 {{ l10n("bandwidthCommonInternetConnectionSpeedsKibps") }}

diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index 68be559cfae..9a326acce57 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -523,6 +523,7 @@ FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeedsDetected=Detected FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeedsDetectedUnavailable=unavailable FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeeds4Mbit=4 megabits FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeeds6Mbit=6 megabits (average ADSL1) +FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeedsVDSL=VDSL FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeedsKibps=KiB/s FirstTimeWizardToadlet.bandwidthCommonInternetConnectionSpeedsMibs=Mbps FirstTimeWizardToadlet.bandwidthCapPrompt=Does your internet connection have a monthly data limit? From b66fcdc89aa67e45f76078eb27e9e5709aac6a20 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 21:41:30 +0100 Subject: [PATCH 201/500] Remove hash generation to native big integer to reduce dependencies. In the Guix build Hash.java was a blocker that had to be circumvented, because the i2p tools are not packaged. Since the two methods providing NativeBigInteger are unused, this PR removes them completely. --- src/freenet/crypt/Hash.java | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/freenet/crypt/Hash.java b/src/freenet/crypt/Hash.java index c04ee149553..8b6e9eaf46e 100644 --- a/src/freenet/crypt/Hash.java +++ b/src/freenet/crypt/Hash.java @@ -6,7 +6,6 @@ import java.nio.ByteBuffer; import java.security.MessageDigest; -import net.i2p.util.NativeBigInteger; import freenet.support.HexUtil; /** @@ -97,31 +96,6 @@ public final String genHexHash() { return HexUtil.bytesToHex(genHash()); } - /** - * Generates the hash as a NativeBigInteger of all the bytes in the buffer - * added with the addBytes methods. The buffer is then cleared after the hash - * has been generated. - * @return The generated hash as a NativeBigInteger of all the bytes added - * since last reset. - */ - public final NativeBigInteger genNativeBigIntegerHash(){ - return new NativeBigInteger(1, genHash()); - } - - /** - * Generates the hash as a NativeBigInteger string of only the specified - * bytes. The buffer is cleared before processing the input to ensure that - * no extra data is included. Once the hash has been generated, the buffer - * is cleared again. - * @param input The bytes to hash - * @return The generated hash as a NativeBigInteger of the data - */ - public final NativeBigInteger genNativeBigIntegerHash(byte[]... data){ - digest.reset(); - addBytes(data); - return genNativeBigIntegerHash(); - } - /** * Adds the specified byte to the buffer of bytes to be hashed. * @param input Byte to be added to hash From d1c0f708703c6674b50d4b71b1b0ef3522c48925 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 22:22:26 +0100 Subject: [PATCH 202/500] =?UTF-8?q?Do=20not=20divide=200-1=20by=20MAX=5FVA?= =?UTF-8?q?LUE=20=E2=80=94=20thanks=20to=20Bombe=20for=20the=20review!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/freenet/client/async/SimpleHealingQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/client/async/SimpleHealingQueue.java b/src/freenet/client/async/SimpleHealingQueue.java index 83c03bf0cec..e64a722c086 100644 --- a/src/freenet/client/async/SimpleHealingQueue.java +++ b/src/freenet/client/async/SimpleHealingQueue.java @@ -103,7 +103,7 @@ private boolean isHealingThisBlockSimilarToForwarding( // ensure that we have a routing key sbi.tryEncode(context); double keyLocation = sbi.getKeyNoEncode().getNodeKey().toNormalizedDouble(); - double randomBetweenZeroAndOne = NodeStarter.getGlobalSecureRandom().nextDouble() / Double.MAX_VALUE; + double randomBetweenZeroAndOne = NodeStarter.getGlobalSecureRandom().nextDouble(); return shouldHealBlock(nodeLocation, keyLocation, randomBetweenZeroAndOne); } From 45a161102c15ae7aa5a954dccba31d8f116871b6 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 22:23:59 +0100 Subject: [PATCH 203/500] Improve legibility --- src/freenet/client/async/SimpleHealingQueue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/client/async/SimpleHealingQueue.java b/src/freenet/client/async/SimpleHealingQueue.java index e64a722c086..929d0766835 100644 --- a/src/freenet/client/async/SimpleHealingQueue.java +++ b/src/freenet/client/async/SimpleHealingQueue.java @@ -128,7 +128,7 @@ static boolean shouldHealBlock( } else { // if the key is a long distance key for us, heal it with 10% probability: it is unlikely that // this would have reached us. Setting this to 0 could amplify a keyspace takeover attack. - return 0.9 < randomBetweenZeroAndOne; + return randomBetweenZeroAndOne > 0.9; } } From 272da1feecb8edcd47d840e588728db4368da220 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 22:25:52 +0100 Subject: [PATCH 204/500] Pass in Bucket instead of RandomAccessBucket --- src/freenet/client/async/SplitFileFetcher.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/freenet/client/async/SplitFileFetcher.java b/src/freenet/client/async/SplitFileFetcher.java index 04a99165b45..e736f6990c6 100644 --- a/src/freenet/client/async/SplitFileFetcher.java +++ b/src/freenet/client/async/SplitFileFetcher.java @@ -21,6 +21,7 @@ import freenet.keys.FreenetURI; import freenet.node.BaseSendableGet; import freenet.support.Logger; +import freenet.support.api.Bucket; import freenet.support.api.LockableRandomAccessBuffer; import freenet.support.api.RandomAccessBucket; import freenet.support.compress.Compressor.COMPRESSOR_TYPE; @@ -298,7 +299,7 @@ public void onSplitfileCompatibilityMode(CompatibilityMode min, CompatibilityMod @Override public void queueHeal(byte[] data, byte[] cryptoKey, byte cryptoAlgorithm) { try { - RandomAccessBucket dataBucket = BucketTools.makeImmutableBucket( + Bucket dataBucket = BucketTools.makeImmutableBucket( context.tempBucketFactory, data); context.healingQueue.queue(dataBucket, cryptoKey, cryptoAlgorithm, context); From ae520b039890f86c68b8e2bc2baf99be234a58ed Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Fri, 26 Jan 2024 22:51:10 +0100 Subject: [PATCH 205/500] =?UTF-8?q?Extract=20HealingDecisionSupplier=20?= =?UTF-8?q?=E2=80=94=20thanks=20to=20Bombes=20review!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/async/HealingDecisionSupplier.java | 74 +++++++++++++++++++ .../client/async/SimpleHealingQueue.java | 54 +------------- src/freenet/node/NodeClientCore.java | 3 +- ....java => HealingDecisionSupplierTest.java} | 12 +-- 4 files changed, 86 insertions(+), 57 deletions(-) create mode 100644 src/freenet/client/async/HealingDecisionSupplier.java rename test/freenet/client/async/{SimpleHealingQueueTest.java => HealingDecisionSupplierTest.java} (70%) diff --git a/src/freenet/client/async/HealingDecisionSupplier.java b/src/freenet/client/async/HealingDecisionSupplier.java new file mode 100644 index 00000000000..714c09606c1 --- /dev/null +++ b/src/freenet/client/async/HealingDecisionSupplier.java @@ -0,0 +1,74 @@ +package freenet.client.async; + +import freenet.node.Location; +import freenet.node.Node; +import freenet.node.NodeStarter; + + /** + * Specialize Healing to the fraction of the keyspace in which we would receive the inserts + * if we were one of 5 long distance nodes of an actual inserter. + * + * If an opennet node is connected to an attacker, healing traffic could be mistaken for an insert. + * Since opennet cannot be fully secured, this should be avoided. + * As a solution, we specialize healing inserts to the inserts we would send if we were one of 5 + * long distance connections for a node in another part of the keyspace. + * + * As a welcome side effect, specialized healing inserts should take one hop less to reach the + * correct node from which loop detection will stop the insert long before HTL reaches zero. + */ +public class HealingDecisionSupplier { + private final Node node; + + public HealingDecisionSupplier(Node node) { + this.node = node; + } + + public boolean shouldHeal(double keyLocation) { + if (!node.isOpennetEnabled()) { + // darknet is safer against sybil attack, so we can heal fully + return true; + } + double randomBetweenZeroAndOne = NodeStarter.getGlobalSecureRandom().nextDouble(); + return shouldHealBlock(node.getLocation(), keyLocation, randomBetweenZeroAndOne); + } + + /** + * Specialize healing: we want healing traffic to look like regular forwarding. + * + * Far away blocks would be unlikely to reach our node as request, + * so we reduce healing there: only accept 10% of those. + * + * When a key is close to our location, we use a continuous function depending on the distance + * to choose a probability. The closer to our node, the higher the probability of healing. + * As a side effect this reduces the hops healing inserts take, reducing the overall load + * on the network. + * + * The continuous function is gauged to accept 50% of the keys close to our node: a peak at our + * own location for which the area below the curve between 0 and 0.1 sums up to 0.5. + * + * Close keys are those in our 20% of the keyspace: the ones that would reach us if we were one of + * 5 long distance peers of a peer node. These are the keys for which we are most likely to be + * the best next hop when seen from the originator. + */ + static boolean shouldHealBlock( + double nodeLocation, + double keyLocation, + double randomBetweenZeroAndOne) { + double distanceToNodeLocation = Location.distance(nodeLocation, keyLocation); + // If the key is inside "our" 20% of the keyspace, heal it with 50% probability. + if (distanceToNodeLocation < 0.1) { + // accept 50%, specialized to our own location (0.5 ** 4 ~ 0.0625). Accept 70% which are going + // to our short distance peers (0.32 ** 4 ~ 0.01), 78% of those which could be reached via a + // direct short distance FOAF (distance 0.02). + double randomToPower4 = Math.pow(randomBetweenZeroAndOne, 4); + return distanceToNodeLocation < randomToPower4; + } else { + // if the key is a long distance key for us, heal it with 10% probability: it is unlikely that + // this would have reached us. Setting this to 0 could amplify a keyspace takeover attack. + return randomBetweenZeroAndOne > 0.9; + } + } + + + +} diff --git a/src/freenet/client/async/SimpleHealingQueue.java b/src/freenet/client/async/SimpleHealingQueue.java index 929d0766835..63021acb47e 100644 --- a/src/freenet/client/async/SimpleHealingQueue.java +++ b/src/freenet/client/async/SimpleHealingQueue.java @@ -12,8 +12,6 @@ import freenet.keys.BaseClientKey; import freenet.keys.CHKBlock; import freenet.keys.FreenetURI; -import freenet.node.Location; -import freenet.node.NodeStarter; import freenet.node.RequestClient; import freenet.node.RequestClientBuilder; import freenet.support.LogThresholdCallback; @@ -27,8 +25,7 @@ public class SimpleHealingQueue extends BaseClientPutter implements HealingQueue final int maxRunning; int counter; InsertContext ctx; - private final double nodeLocation; - private final boolean opennetEnabled; + private final HealingDecisionSupplier healingDecisionSupplier; final Map runningInserters; private static volatile boolean logMINOR; @@ -43,11 +40,10 @@ public void shouldUpdate(){ static final RequestClient REQUEST_CLIENT = new RequestClientBuilder().build(); - public SimpleHealingQueue(InsertContext context, short prio, int maxRunning, double nodeLocation, boolean opennetEnabled) { + public SimpleHealingQueue(InsertContext context, short prio, int maxRunning, HealingDecisionSupplier healingDecisionSupplier) { super(prio, REQUEST_CLIENT); this.ctx = context; - this.nodeLocation = nodeLocation; - this.opennetEnabled = opennetEnabled; + this.healingDecisionSupplier = healingDecisionSupplier; this.runningInserters = new HashMap(); this.maxRunning = maxRunning; } @@ -81,55 +77,13 @@ public boolean innerQueue(Bucket data, byte[] cryptoKey, byte cryptoAlgorithm, C } } - /** - * Specialize Healing to the fraction of the keyspace in which we would receive the inserts - * if we were one of 5 long distance nodes of an actual inserter. - * - * If an opennet node is connected to an attacker, healing traffic could be mistaken for an insert. - * Since opennet cannot be fully secured, this should be avoided. - * As a solution, we specialize healing inserts to the inserts we would send if we were one of 5 - * long distance connections for a node in another part of the keyspace. - * - * As a welcome side effect, specialized healing inserts should take one hop less to reach the - * correct node from which loop detection will stop the insert long before HTL reaches zero. - */ private boolean isHealingThisBlockSimilarToForwarding( ClientContext context, SingleBlockInserter sbi) { - // pure darknet is safer against sybil attacks, so we can heal fully - if (!opennetEnabled) { - return true; - } // ensure that we have a routing key sbi.tryEncode(context); double keyLocation = sbi.getKeyNoEncode().getNodeKey().toNormalizedDouble(); - double randomBetweenZeroAndOne = NodeStarter.getGlobalSecureRandom().nextDouble(); - return shouldHealBlock(nodeLocation, keyLocation, randomBetweenZeroAndOne); - } - - /** - * choose fraction by probabilistic dropping of far away keys. - * only enqueue keys in our 20% of the keyspace: the ones that would reach us if we were one of - * 5 long distance peers of a peer node. - */ - static boolean shouldHealBlock( - double nodeLocation, - double keyLocation, - double randomBetweenZeroAndOne) { - double distanceToNodeLocation = Location.distance(nodeLocation, keyLocation); - // accept half the healings in our 20% of the keyspace. - // If the key is inside "our" 20% of the keyspace, heal it with 50% probability. - if (distanceToNodeLocation < 0.1) { - // accept 50%, specialized to our own location (0.5 ** 4 ~ 0.0625). Accept 70% which are going - // to our short distance peers (0.32 ** 4 ~ 0.01), 78% of those which could be reached via a - // direct short distance FOAF (distance 0.02). - double randomToPower4 = Math.pow(randomBetweenZeroAndOne, 4); - return distanceToNodeLocation < randomToPower4; - } else { - // if the key is a long distance key for us, heal it with 10% probability: it is unlikely that - // this would have reached us. Setting this to 0 could amplify a keyspace takeover attack. - return randomBetweenZeroAndOne > 0.9; - } + return healingDecisionSupplier.shouldHeal(keyLocation); } @Override diff --git a/src/freenet/node/NodeClientCore.java b/src/freenet/node/NodeClientCore.java index 330dfa411df..85a28df6834 100644 --- a/src/freenet/node/NodeClientCore.java +++ b/src/freenet/node/NodeClientCore.java @@ -16,6 +16,7 @@ import freenet.client.async.ClientLayerPersister; import freenet.client.async.ClientRequestScheduler; import freenet.client.async.DatastoreChecker; +import freenet.client.async.HealingDecisionSupplier; import freenet.client.async.HealingQueue; import freenet.client.async.PersistentStatsPutter; import freenet.client.async.SimpleHealingQueue; @@ -495,7 +496,7 @@ public void realRun() { false, Node.FORK_ON_CACHEABLE_DEFAULT, false, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, 0, 0, InsertContext.CompatibilityMode.COMPAT_DEFAULT), - RequestStarter.PREFETCH_PRIORITY_CLASS, MAX_RUNNING_HEALING_INSERTS, node.getLocation(), node.isOpennetEnabled()); + RequestStarter.PREFETCH_PRIORITY_CLASS, MAX_RUNNING_HEALING_INSERTS, new HealingDecisionSupplier(node)); PooledFileRandomAccessBufferFactory raff = new PooledFileRandomAccessBufferFactory(persistentFilenameGenerator, diff --git a/test/freenet/client/async/SimpleHealingQueueTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java similarity index 70% rename from test/freenet/client/async/SimpleHealingQueueTest.java rename to test/freenet/client/async/HealingDecisionSupplierTest.java index 19e880d8229..31b9416dc3a 100644 --- a/test/freenet/client/async/SimpleHealingQueueTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -7,36 +7,36 @@ import org.hamcrest.Matchers; import org.junit.Test; -public class SimpleHealingQueueTest { +public class HealingDecisionSupplierTest { @Test public void healingAlwaysAcceptsAKeyAtTheNodeLocation() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.1, i), Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.1, i), Matchers.equalTo(true)); } } @Test public void healingAccepts70PercentOfKeysInShortDistance() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)) { - assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.11, i), Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.11, i), Matchers.equalTo(true)); } } @Test public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistance() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { - assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.1999, i), Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.1999, i), Matchers.equalTo(true)); } } @Test public void healingAccepts10PercentOfKeysAtLongDistance() { for (double i : Arrays.asList(1.0, 0.91)) { - assertThat(String.format("Healing triggers at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(true)); } for (double i : Arrays.asList(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - assertThat(String.format("Healing does not trigger at random value %g", i), SimpleHealingQueue.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(false)); + assertThat(String.format("Healing does not trigger at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(false)); } } From a7585e23d7ceac9351c9db7b698ad6e90823ba93 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 28 Jan 2024 20:52:17 +0100 Subject: [PATCH 206/500] Pass precise supplies to the HealingDecision instead of the node. This enables much cleaner testing by actually testing the public API. Thanks to Bombe for the review! --- .../client/async/HealingDecisionSupplier.java | 28 +++++++++---- src/freenet/node/NodeClientCore.java | 3 +- .../async/HealingDecisionSupplierTest.java | 41 ++++++++++++++++--- 3 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/freenet/client/async/HealingDecisionSupplier.java b/src/freenet/client/async/HealingDecisionSupplier.java index 714c09606c1..23b28f22727 100644 --- a/src/freenet/client/async/HealingDecisionSupplier.java +++ b/src/freenet/client/async/HealingDecisionSupplier.java @@ -1,5 +1,7 @@ package freenet.client.async; +import java.util.function.Supplier; + import freenet.node.Location; import freenet.node.Node; import freenet.node.NodeStarter; @@ -17,19 +19,31 @@ * correct node from which loop detection will stop the insert long before HTL reaches zero. */ public class HealingDecisionSupplier { - private final Node node; + private final Supplier currentNodeLocation; + private final Supplier isOpennetEnabled; + private final Supplier randomNumberSupplier; + + public HealingDecisionSupplier(Supplier currentNodeLocation, Supplier isOpennetEnabled) { + + this.currentNodeLocation = currentNodeLocation; + this.isOpennetEnabled = isOpennetEnabled; + randomNumberSupplier = NodeStarter.getGlobalSecureRandom()::nextDouble; + } + + HealingDecisionSupplier(Supplier currentNodeLocation, Supplier isOpennetEnabled, Supplier randomNumberSupplier) { - public HealingDecisionSupplier(Node node) { - this.node = node; + this.currentNodeLocation = currentNodeLocation; + this.isOpennetEnabled = isOpennetEnabled; + this.randomNumberSupplier = randomNumberSupplier; } public boolean shouldHeal(double keyLocation) { - if (!node.isOpennetEnabled()) { + if (!isOpennetEnabled.get()) { // darknet is safer against sybil attack, so we can heal fully return true; } - double randomBetweenZeroAndOne = NodeStarter.getGlobalSecureRandom().nextDouble(); - return shouldHealBlock(node.getLocation(), keyLocation, randomBetweenZeroAndOne); + double randomBetweenZeroAndOne = randomNumberSupplier.get(); + return shouldHealBlock(currentNodeLocation.get(), keyLocation, randomBetweenZeroAndOne); } /** @@ -50,7 +64,7 @@ public boolean shouldHeal(double keyLocation) { * 5 long distance peers of a peer node. These are the keys for which we are most likely to be * the best next hop when seen from the originator. */ - static boolean shouldHealBlock( + private static boolean shouldHealBlock( double nodeLocation, double keyLocation, double randomBetweenZeroAndOne) { diff --git a/src/freenet/node/NodeClientCore.java b/src/freenet/node/NodeClientCore.java index 85a28df6834..2c782749680 100644 --- a/src/freenet/node/NodeClientCore.java +++ b/src/freenet/node/NodeClientCore.java @@ -496,7 +496,8 @@ public void realRun() { false, Node.FORK_ON_CACHEABLE_DEFAULT, false, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, 0, 0, InsertContext.CompatibilityMode.COMPAT_DEFAULT), - RequestStarter.PREFETCH_PRIORITY_CLASS, MAX_RUNNING_HEALING_INSERTS, new HealingDecisionSupplier(node)); + RequestStarter.PREFETCH_PRIORITY_CLASS, MAX_RUNNING_HEALING_INSERTS, + new HealingDecisionSupplier(node::getLocation, node::isOpennetEnabled)); PooledFileRandomAccessBufferFactory raff = new PooledFileRandomAccessBufferFactory(persistentFilenameGenerator, diff --git a/test/freenet/client/async/HealingDecisionSupplierTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java index 31b9416dc3a..09413144616 100644 --- a/test/freenet/client/async/HealingDecisionSupplierTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -12,31 +12,62 @@ public class HealingDecisionSupplierTest { @Test public void healingAlwaysAcceptsAKeyAtTheNodeLocation() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.1, i), Matchers.equalTo(true)); + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat( + String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.1), + Matchers.equalTo(true)); } } @Test public void healingAccepts70PercentOfKeysInShortDistance() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)) { - assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.11, i), Matchers.equalTo(true)); + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.11), + Matchers.equalTo(true)); } } @Test public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistance() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { - assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.1999, i), Matchers.equalTo(true)); + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.1999), + Matchers.equalTo(true)); } } @Test public void healingAccepts10PercentOfKeysAtLongDistance() { for (double i : Arrays.asList(1.0, 0.91)) { - assertThat(String.format("Healing triggers at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(true)); + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.21), + Matchers.equalTo(true)); } for (double i : Arrays.asList(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - assertThat(String.format("Healing does not trigger at random value %g", i), HealingDecisionSupplier.shouldHealBlock(0.1, 0.21, i), Matchers.equalTo(false)); + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat(String.format("Healing does not trigger at random value %g", i), + healingDecisionSupplier.shouldHeal(0.21), + Matchers.equalTo(false)); } } From ac8d5c472f7b6a258e450155046740ff198c3bda Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 28 Jan 2024 20:56:42 +0100 Subject: [PATCH 207/500] Remove no longer needed imports --- src/freenet/client/async/HealingDecisionSupplier.java | 1 - src/freenet/client/async/SplitFileFetcher.java | 1 - 2 files changed, 2 deletions(-) diff --git a/src/freenet/client/async/HealingDecisionSupplier.java b/src/freenet/client/async/HealingDecisionSupplier.java index 23b28f22727..e4152a9f14c 100644 --- a/src/freenet/client/async/HealingDecisionSupplier.java +++ b/src/freenet/client/async/HealingDecisionSupplier.java @@ -3,7 +3,6 @@ import java.util.function.Supplier; import freenet.node.Location; -import freenet.node.Node; import freenet.node.NodeStarter; /** diff --git a/src/freenet/client/async/SplitFileFetcher.java b/src/freenet/client/async/SplitFileFetcher.java index e736f6990c6..c0525178e61 100644 --- a/src/freenet/client/async/SplitFileFetcher.java +++ b/src/freenet/client/async/SplitFileFetcher.java @@ -23,7 +23,6 @@ import freenet.support.Logger; import freenet.support.api.Bucket; import freenet.support.api.LockableRandomAccessBuffer; -import freenet.support.api.RandomAccessBucket; import freenet.support.compress.Compressor.COMPRESSOR_TYPE; import freenet.support.io.BucketTools; import freenet.support.io.FileUtil; From c976386b744dab084253f3025f2221579f2636b7 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 28 Jan 2024 20:56:52 +0100 Subject: [PATCH 208/500] Add test for healing in Darknet mode --- .../client/async/HealingDecisionSupplierTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/freenet/client/async/HealingDecisionSupplierTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java index 09413144616..c015ae1ebf4 100644 --- a/test/freenet/client/async/HealingDecisionSupplierTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -9,6 +9,20 @@ public class HealingDecisionSupplierTest { + @Test + public void healingAlwaysTriggersForDarknet() { + for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> false, + () -> i); + assertThat( + String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.5), + Matchers.equalTo(true)); + } + } + @Test public void healingAlwaysAcceptsAKeyAtTheNodeLocation() { for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { From a29fa9df4895566052f5e81303586a83f716d67a Mon Sep 17 00:00:00 2001 From: Juiceman Date: Sun, 28 Jan 2024 15:30:03 -0500 Subject: [PATCH 209/500] Remove now unnecessary parenthesis --- src/freenet/clients/fcp/DirPutFile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/clients/fcp/DirPutFile.java b/src/freenet/clients/fcp/DirPutFile.java index 3790aae8563..f261745e40b 100644 --- a/src/freenet/clients/fcp/DirPutFile.java +++ b/src/freenet/clients/fcp/DirPutFile.java @@ -50,7 +50,7 @@ public static DirPutFile create(SimpleFieldSet subset, String identifier, boolea if(name == null) throw new MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Missing field Name", identifier, global); String contentTypeOverride = subset.get("Metadata.ContentType"); - if(contentTypeOverride != null && (!contentTypeOverride.isEmpty()) && !DefaultMIMETypes.isPlausibleMIMEType(contentTypeOverride)) { + if(contentTypeOverride != null && !contentTypeOverride.isEmpty() && !DefaultMIMETypes.isPlausibleMIMEType(contentTypeOverride)) { throw new MessageInvalidException(ProtocolErrorMessage.BAD_MIME_TYPE, "Bad MIME type in Metadata.ContentType", identifier, global); } String type = subset.get("UploadFrom"); From 2626bf3080adb6f4e13a0688c60abc3a78784de1 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 29 Jan 2024 11:52:49 +0100 Subject: [PATCH 210/500] Add negative tests for the healing decision supplier --- .../async/HealingDecisionSupplierTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/freenet/client/async/HealingDecisionSupplierTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java index c015ae1ebf4..5033fcbc6dd 100644 --- a/test/freenet/client/async/HealingDecisionSupplierTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -48,6 +48,15 @@ public void healingAccepts70PercentOfKeysInShortDistance() { healingDecisionSupplier.shouldHeal(0.11), Matchers.equalTo(true)); } + for (double i : Arrays.asList(0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat(String.format("Healing does not trigger at random value %g", i), + healingDecisionSupplier.shouldHeal(0.11), + Matchers.equalTo(false)); + } } @Test @@ -61,6 +70,15 @@ public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistance() { healingDecisionSupplier.shouldHeal(0.1999), Matchers.equalTo(true)); } + for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.1, + () -> true, + () -> i); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.1999), + Matchers.equalTo(false)); + } } @Test From 84abbd8f2437539725aa08725d4911b5c68bd783 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 29 Jan 2024 12:02:28 +0100 Subject: [PATCH 211/500] Increase max transparent passthrough to 200MiB links in m3u-lists. At 10 cached files that would be at most 2GiB memory usage in the browser in the extreme case (see m3u-player.js), staying below the 2GiB in Chrome per tab, so it should still work well on most systems. --- src/freenet/client/filter/M3UFilter.java | 2 +- .../client/filter/m3u/safe_madesafe.m3u | 38 +++++++++---------- .../client/filter/m3u/unsafe_madesafe.m3u | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/freenet/client/filter/M3UFilter.java b/src/freenet/client/filter/M3UFilter.java index 31b5f26b7a7..f66c58f4bd4 100644 --- a/src/freenet/client/filter/M3UFilter.java +++ b/src/freenet/client/filter/M3UFilter.java @@ -51,7 +51,7 @@ public class M3UFilter implements ContentDataFilter { { (byte)'\r' }; static final int MAX_URI_LENGTH = 16384; static final String badUriReplacement = "#bad-uri-removed"; - private final long MAX_LENGTH_NO_PROGRESS = (100*1024*1024 * 11) / 10; // 100MiB: playlists are a different usecase, and we want to allow transparent pass-through for most files accessed via a playlist, likely through an external palyer. See FProxyToadlet.MAX_LENGTH_NO_PROGRESS for the default. This value must be synchronized with the test data! + private final long MAX_LENGTH_NO_PROGRESS = (200L*1024*1024 * 11) / 10; // 200MiB: playlists are a different usecase, and we want to allow transparent pass-through for most files accessed via a playlist, likely through an external palyer. See FProxyToadlet.MAX_LENGTH_NO_PROGRESS for the default. This value must be synchronized with the test data! // TODO: Add parsing of ext-comments to allow for gapless playback. // static final int COMMENT_EXT_SIZE = 4; // static final byte[] COMMENT_EXT_START = diff --git a/test/freenet/client/filter/m3u/safe_madesafe.m3u b/test/freenet/client/filter/m3u/safe_madesafe.m3u index 75a63bce912..b36827636c9 100644 --- a/test/freenet/client/filter/m3u/safe_madesafe.m3u +++ b/test/freenet/client/filter/m3u/safe_madesafe.m3u @@ -1,19 +1,19 @@ -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname2.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.m3u?type=audio/mpegurl&max-size=115343360 -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.ogg?type=application/ogg&max-size=115343360 -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.oga?type=audio/ogg&max-size=115343360 -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.ogv?type=video/ogg&max-size=115343360 -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.flac?type=audio/flac&max-size=115343360 -http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/Infinite-Hands-free-software.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/next.m3u?type=audio/mpegurl&max-size=115343360 -http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/Infinite-Hands-free-software.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/next.m3u?type=audio/mpegurl&max-size=115343360 -http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/Infinite-Hands-free-software.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@aYtI6p96mfkDrIXQdnGZWeTxLm~hEjFy8xz~Bw5oZSw,6gcO31K9NqkpyXk4kTfZbwBp0LvvN5NFLIfDnQ8uEXo,AAMC--8/mrtsaman3.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@ONyIPZXETM4dDiObUZkyfQzaOtHxmGIDcB0Eofo9UGA,C85PHfP~LjC~uxntvUi~H9cjXx7poU6wLOu8YEwDKTw,AAMC--8/Home-At-The-Grange.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@q74q2YCWmxGFOivrnLJt3ysXeN3mGJANFQQYt34K3Ag,ISATE9J8ah0V65IZE1H8MENt5U8K9~2DthcPirqh4sk,AAMC--8/cecilos-song-v2.0.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@0FbKGEpOeRN1VEXRlg~o855V9B6OxeV5h4UEHiq3ngw,oEPkK1k0XWvY82ZlmpGF7jGWuIcNbozwiYnhtEnqWzg,AAMC--8/cecilos-songbest-version.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@ZcvI6zgqtQtV65sI9gntyhIJYNEP5X3I2ylmia0FiOg,aDL29QdbwzipSELt~1jsHqgqZ5YA9sZ-34I8~ZFWrwA,AAMC--8/BonnieAlba.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@~A-SETPFf0jekBWw06yNxsfcsoj-v6V1tT8ntd7ns7I,Cy33kB2jkDR7eeqP54DjHLhILOTw253dUVYrTmO3f90,AAMC--8/AlbanAnthem.mp3?type=audio/mpeg&max-size=115343360 -http://localhost:8888/CHK@dq~3Ojv3QItpqNhp7b8W8QrKQo~66duficuXXofHeYY,advGQWcuQbogNX~Kq2to8bWZi7w~YW2aravk1fC4T5M,AAMC--8/BereksBlood.mp3?type=audio/mpeg&max-size=115343360 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname2.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.m3u?type=audio/mpegurl&max-size=230686720 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.ogg?type=application/ogg&max-size=230686720 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.oga?type=audio/ogg&max-size=230686720 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.ogv?type=video/ogg&max-size=230686720 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname3.flac?type=audio/flac&max-size=230686720 +http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/Infinite-Hands-free-software.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/next.m3u?type=audio/mpegurl&max-size=230686720 +http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/Infinite-Hands-free-software.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/next.m3u?type=audio/mpegurl&max-size=230686720 +http://localhost:8888/CHK@qtpnyOzrg~aiAbnw6AoKbX8ZlTCwznjY4G1y-JiiCgg,b0wkEgRPKWMvedueAKLkyv0S83xOrGUT4S7FaN5J3nI,AAMC--8/Infinite-Hands-free-software.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@aYtI6p96mfkDrIXQdnGZWeTxLm~hEjFy8xz~Bw5oZSw,6gcO31K9NqkpyXk4kTfZbwBp0LvvN5NFLIfDnQ8uEXo,AAMC--8/mrtsaman3.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@ONyIPZXETM4dDiObUZkyfQzaOtHxmGIDcB0Eofo9UGA,C85PHfP~LjC~uxntvUi~H9cjXx7poU6wLOu8YEwDKTw,AAMC--8/Home-At-The-Grange.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@q74q2YCWmxGFOivrnLJt3ysXeN3mGJANFQQYt34K3Ag,ISATE9J8ah0V65IZE1H8MENt5U8K9~2DthcPirqh4sk,AAMC--8/cecilos-song-v2.0.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@0FbKGEpOeRN1VEXRlg~o855V9B6OxeV5h4UEHiq3ngw,oEPkK1k0XWvY82ZlmpGF7jGWuIcNbozwiYnhtEnqWzg,AAMC--8/cecilos-songbest-version.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@ZcvI6zgqtQtV65sI9gntyhIJYNEP5X3I2ylmia0FiOg,aDL29QdbwzipSELt~1jsHqgqZ5YA9sZ-34I8~ZFWrwA,AAMC--8/BonnieAlba.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@~A-SETPFf0jekBWw06yNxsfcsoj-v6V1tT8ntd7ns7I,Cy33kB2jkDR7eeqP54DjHLhILOTw253dUVYrTmO3f90,AAMC--8/AlbanAnthem.mp3?type=audio/mpeg&max-size=230686720 +http://localhost:8888/CHK@dq~3Ojv3QItpqNhp7b8W8QrKQo~66duficuXXofHeYY,advGQWcuQbogNX~Kq2to8bWZi7w~YW2aravk1fC4T5M,AAMC--8/BereksBlood.mp3?type=audio/mpeg&max-size=230686720 diff --git a/test/freenet/client/filter/m3u/unsafe_madesafe.m3u b/test/freenet/client/filter/m3u/unsafe_madesafe.m3u index d0f832da98f..04f199c6b7c 100644 --- a/test/freenet/client/filter/m3u/unsafe_madesafe.m3u +++ b/test/freenet/client/filter/m3u/unsafe_madesafe.m3u @@ -1,6 +1,6 @@ #bad-uri-removed #bad-uri-removed #bad-uri-removed -http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname.mp3?type=audio/mpeg&max-size=115343360 +http://localhost:8888/USK@0I8gctpUE32CM0iQhXaYpCMvtPPGfT4pjXm01oid5Zc,3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/FakeM3UHostingFreesite/23/simplepathname.mp3?type=audio/mpeg&max-size=230686720 #bad-uri-removed #bad-uri-removed \ No newline at end of file From 6226889c8d13f93e80403e27b7a0cf302a7a2525 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 01:15:04 +0100 Subject: [PATCH 212/500] Also remove the NativeBigInteger part of HashTest --- test/freenet/crypt/HashTest.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/test/freenet/crypt/HashTest.java b/test/freenet/crypt/HashTest.java index 2fae06d56a1..6e79c4644d1 100644 --- a/test/freenet/crypt/HashTest.java +++ b/test/freenet/crypt/HashTest.java @@ -10,8 +10,6 @@ import java.nio.charset.StandardCharsets; import java.security.MessageDigest; -import net.i2p.util.NativeBigInteger; - import org.bouncycastle.util.encoders.Hex; import org.junit.Test; @@ -133,16 +131,6 @@ public void testGetHashHex(){ } } - @Test - public void testGetNativeBigIntegerHashByteArrayArray(){ - for(int i = 0; i < types.length; i++){ - Hash hash = new Hash(types[i]); - NativeBigInteger abcVector = new NativeBigInteger(1, Hex.decode(trueHashes[i])); - NativeBigInteger result = hash.genNativeBigIntegerHash(helloWorld); - assertEquals("HashType: "+types[i].name(), abcVector, result); - } - } - @Test public void testAddByteByte(){ for(int i = 0; i < types.length; i++){ From 94242b3ef983455e896c11b6bae20df2054521bf Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 01:18:48 +0100 Subject: [PATCH 213/500] Revert "Add TODOs with notes for optimization and commented out logging code." This reverts commit eaed0f3af49b5e92c97273b06469d6cf65f9b379. --- src/freenet/io/comm/MessageFilter.java | 12 +----------- src/freenet/node/PeerMessageQueue.java | 2 -- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/freenet/io/comm/MessageFilter.java b/src/freenet/io/comm/MessageFilter.java index dcff6ea80fa..8bcde7c4ad9 100644 --- a/src/freenet/io/comm/MessageFilter.java +++ b/src/freenet/io/comm/MessageFilter.java @@ -65,9 +65,6 @@ private MessageFilter() { } public static MessageFilter create() { - // TODO: move to a builder so we can get rid of the synchronized(_fields) in match, - // the most expensive method in all of fred. - // TODO: move source and type into create to get rid of the null-checks in match. return new MessageFilter(); } @@ -181,8 +178,6 @@ public MessageFilter setField(String fieldName, Object fieldValue) { * Modifies the filter so that it returns true if either it or the filter in the argument returns true. * Multiple combinations must be nested: such as filter1.or(filter2.or(filter3))). * filter2 will be checked before filter1, so make sure to add the most common last. - * TODO: change the ordering in match: A.or(B) should first check A, like in A || B. - * TODO: ensure for all usages of or(...) that the most likely package is checked first. * @return reference to this, the modified filter. */ public MessageFilter or(MessageFilter or) { @@ -218,9 +213,8 @@ public MATCHED match(Message m, long now) { public MATCHED match(Message m, boolean noTimeout, long now) { if(_or != null) { MATCHED matched = _or.match(m, noTimeout, now); - if(matched != MATCHED.NONE) { + if(matched != MATCHED.NONE) return matched; // Filter is matched once only. That includes timeouts. - } } final MATCHED resultNoMatch = _timeout < now ? MATCHED.TIMED_OUT : MATCHED.NONE; @@ -248,10 +242,6 @@ public MATCHED match(Message m, boolean noTimeout, long now) { if(logMINOR) Logger.minor(this, "Matched but timed out: "+this); return MATCHED.TIMED_OUT_AND_MATCHED; } - // debugging output to optimize ordering of or-combined MessageFilters - // if (_or != null) { - // Logger.error(this, "Filter or-match failed: or: " + _or._type.getName() + " this: " + this._type.getName()); - // } return MATCHED.MATCHED; } diff --git a/src/freenet/node/PeerMessageQueue.java b/src/freenet/node/PeerMessageQueue.java index e0d53e257ef..cb9f5f5c746 100644 --- a/src/freenet/node/PeerMessageQueue.java +++ b/src/freenet/node/PeerMessageQueue.java @@ -20,8 +20,6 @@ * @author Matthew Toseland (0xE43DA450) */ public class PeerMessageQueue { - // TODO: check whether we can use a standard PriorityBlockingQueue (since Java 8) - // instead of our own DoublyLinkedList implementation. private static volatile boolean logMINOR; private static volatile boolean logDEBUG; From 463f65b42655b24dde4ed0d533136ae116cf5d0c Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 19 Oct 2023 13:15:12 +0200 Subject: [PATCH 214/500] FIx indentation (match surrounding code) --- src/freenet/clients/fcp/FCPMessage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freenet/clients/fcp/FCPMessage.java b/src/freenet/clients/fcp/FCPMessage.java index fffbb31af07..c6caf63f0b4 100644 --- a/src/freenet/clients/fcp/FCPMessage.java +++ b/src/freenet/clients/fcp/FCPMessage.java @@ -94,8 +94,8 @@ public static FCPMessage create(String name, SimpleFieldSet fs, BucketFactory bf return new SendTextMessage(fs); if(name.equals(DisconnectMessage.NAME)) return new DisconnectMessage(fs); - if(name.equals(FCPPluginClientMessage.NAME)) - return new FCPPluginClientMessage(fs); + if(name.equals(FCPPluginClientMessage.NAME)) + return new FCPPluginClientMessage(fs); if(name.equals(GenerateSSKMessage.NAME)) return new GenerateSSKMessage(fs); if(name.equals(GetConfig.NAME)) From d06857dbb3043c47ab860610849da6c51d982bfc Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 09:57:32 +0100 Subject: [PATCH 215/500] Extend comment for review: last must match most frequently --- src/freenet/node/AnnounceSender.java | 3 ++- src/freenet/node/RequestSender.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/freenet/node/AnnounceSender.java b/src/freenet/node/AnnounceSender.java index 7d91e6b292d..73b0f98281c 100644 --- a/src/freenet/node/AnnounceSender.java +++ b/src/freenet/node/AnnounceSender.java @@ -184,7 +184,8 @@ private void realRun() { MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(ACCEPTED_TIMEOUT).setType(DMT.FNPRejectedOverload); MessageFilter mfOpennetDisabled = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(ACCEPTED_TIMEOUT).setType(DMT.FNPOpennetDisabled); - // the order of these filters is performance critical. The last or-filter is checked first. + // The order of these filters is performance critical. The last or-filter is checked first. + // So the last filter in the or-"chain" must be the filter which matches most frequently. MessageFilter mf = mfRejectedOverload.or(mfRejectedLoop.or(mfOpennetDisabled.or(mfAccepted))); try { diff --git a/src/freenet/node/RequestSender.java b/src/freenet/node/RequestSender.java index 27231c2a70b..7f763fb9a81 100644 --- a/src/freenet/node/RequestSender.java +++ b/src/freenet/node/RequestSender.java @@ -939,7 +939,8 @@ protected MessageFilter makeAcceptedRejectedFilter(PeerNode next, MessageFilter mfRejectedLoop = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedLoop); MessageFilter mfRejectedOverload = MessageFilter.create().setSource(next).setField(DMT.UID, uid).setTimeout(acceptedTimeout).setType(DMT.FNPRejectedOverload); - // the order of these filters is performance critical. The last or-filter is checked first. + // The order of these filters is performance critical. The last or-filter is checked first. + // So the last filter in the or-"chain" must be the filter which matches most frequently. return mfRejectedOverload.or(mfRejectedLoop.or(mfAccepted)); } From cb837421717060dc3fd490f0deea27c872797e7c Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 10:30:15 +0100 Subject: [PATCH 216/500] Add more tests for review by Bombe --- .../async/HealingDecisionSupplierTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/freenet/client/async/HealingDecisionSupplierTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java index 5033fcbc6dd..21f0ec254ab 100644 --- a/test/freenet/client/async/HealingDecisionSupplierTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -81,6 +81,34 @@ public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistance() { } } + @Test + public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistanceAtADifferentNodeLocationToo() { + for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.6, + () -> true, + () -> i); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.6999), + Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.5001), + Matchers.equalTo(true)); + } + for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.6, + () -> true, + () -> i); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.6999), + Matchers.equalTo(false)); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.5001), + Matchers.equalTo(false)); + } + } + @Test public void healingAccepts10PercentOfKeysAtLongDistance() { for (double i : Arrays.asList(1.0, 0.91)) { From 4b26dbc2760993b96db69efc7549ba4df1a1b065 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 10:42:03 +0100 Subject: [PATCH 217/500] Add test around zero for review by Bombe --- .../async/HealingDecisionSupplierTest.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/test/freenet/client/async/HealingDecisionSupplierTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java index 21f0ec254ab..9ef342344db 100644 --- a/test/freenet/client/async/HealingDecisionSupplierTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -109,6 +109,57 @@ public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistanceAtADifferentNod } } + @Test + public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistanceAroundZero() { + for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.0001, + () -> true, + () -> i); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.1), + Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.9002), + Matchers.equalTo(true)); + } for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.9999, + () -> true, + () -> i); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.0998), + Matchers.equalTo(true)); + assertThat(String.format("Healing triggers at random value %g", i), + healingDecisionSupplier.shouldHeal(0.9000), + Matchers.equalTo(true)); + } + for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.0001, + () -> true, + () -> i); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.1), + Matchers.equalTo(false)); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.9002), + Matchers.equalTo(false)); + } + for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> 0.9999, + () -> true, + () -> i); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.0998), + Matchers.equalTo(false)); + assertThat(String.format("Healing does not trigger random value %g", i), + healingDecisionSupplier.shouldHeal(0.9000), + Matchers.equalTo(false)); + } + } + @Test public void healingAccepts10PercentOfKeysAtLongDistance() { for (double i : Arrays.asList(1.0, 0.91)) { From 90c078c3f4dc3c46d847c705a6aff8563e4c90d8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 20:09:36 +0100 Subject: [PATCH 218/500] Fix IntelliJ indentation (reindent + tabify) --- .../client/async/HealingDecisionSupplier.java | 140 +++++++++--------- 1 file changed, 69 insertions(+), 71 deletions(-) diff --git a/src/freenet/client/async/HealingDecisionSupplier.java b/src/freenet/client/async/HealingDecisionSupplier.java index e4152a9f14c..e985cc976e3 100644 --- a/src/freenet/client/async/HealingDecisionSupplier.java +++ b/src/freenet/client/async/HealingDecisionSupplier.java @@ -5,83 +5,81 @@ import freenet.node.Location; import freenet.node.NodeStarter; - /** - * Specialize Healing to the fraction of the keyspace in which we would receive the inserts - * if we were one of 5 long distance nodes of an actual inserter. - * - * If an opennet node is connected to an attacker, healing traffic could be mistaken for an insert. - * Since opennet cannot be fully secured, this should be avoided. - * As a solution, we specialize healing inserts to the inserts we would send if we were one of 5 - * long distance connections for a node in another part of the keyspace. - * - * As a welcome side effect, specialized healing inserts should take one hop less to reach the - * correct node from which loop detection will stop the insert long before HTL reaches zero. - */ +/** + * Specialize Healing to the fraction of the keyspace in which we would receive the inserts + * if we were one of 5 long distance nodes of an actual inserter. + * + * If an opennet node is connected to an attacker, healing traffic could be mistaken for an insert. + * Since opennet cannot be fully secured, this should be avoided. + * As a solution, we specialize healing inserts to the inserts we would send if we were one of 5 + * long distance connections for a node in another part of the keyspace. + * + * As a welcome side effect, specialized healing inserts should take one hop less to reach the + * correct node from which loop detection will stop the insert long before HTL reaches zero. + */ public class HealingDecisionSupplier { - private final Supplier currentNodeLocation; - private final Supplier isOpennetEnabled; - private final Supplier randomNumberSupplier; + private final Supplier currentNodeLocation; + private final Supplier isOpennetEnabled; + private final Supplier randomNumberSupplier; - public HealingDecisionSupplier(Supplier currentNodeLocation, Supplier isOpennetEnabled) { + public HealingDecisionSupplier(Supplier currentNodeLocation, Supplier isOpennetEnabled) { - this.currentNodeLocation = currentNodeLocation; - this.isOpennetEnabled = isOpennetEnabled; - randomNumberSupplier = NodeStarter.getGlobalSecureRandom()::nextDouble; - } + this.currentNodeLocation = currentNodeLocation; + this.isOpennetEnabled = isOpennetEnabled; + randomNumberSupplier = NodeStarter.getGlobalSecureRandom()::nextDouble; + } - HealingDecisionSupplier(Supplier currentNodeLocation, Supplier isOpennetEnabled, Supplier randomNumberSupplier) { + HealingDecisionSupplier(Supplier currentNodeLocation, Supplier isOpennetEnabled, Supplier randomNumberSupplier) { - this.currentNodeLocation = currentNodeLocation; - this.isOpennetEnabled = isOpennetEnabled; - this.randomNumberSupplier = randomNumberSupplier; - } - - public boolean shouldHeal(double keyLocation) { - if (!isOpennetEnabled.get()) { - // darknet is safer against sybil attack, so we can heal fully - return true; - } - double randomBetweenZeroAndOne = randomNumberSupplier.get(); - return shouldHealBlock(currentNodeLocation.get(), keyLocation, randomBetweenZeroAndOne); - } - - /** - * Specialize healing: we want healing traffic to look like regular forwarding. - * - * Far away blocks would be unlikely to reach our node as request, - * so we reduce healing there: only accept 10% of those. - * - * When a key is close to our location, we use a continuous function depending on the distance - * to choose a probability. The closer to our node, the higher the probability of healing. - * As a side effect this reduces the hops healing inserts take, reducing the overall load - * on the network. - * - * The continuous function is gauged to accept 50% of the keys close to our node: a peak at our - * own location for which the area below the curve between 0 and 0.1 sums up to 0.5. - * - * Close keys are those in our 20% of the keyspace: the ones that would reach us if we were one of - * 5 long distance peers of a peer node. These are the keys for which we are most likely to be - * the best next hop when seen from the originator. - */ - private static boolean shouldHealBlock( - double nodeLocation, - double keyLocation, - double randomBetweenZeroAndOne) { - double distanceToNodeLocation = Location.distance(nodeLocation, keyLocation); - // If the key is inside "our" 20% of the keyspace, heal it with 50% probability. - if (distanceToNodeLocation < 0.1) { - // accept 50%, specialized to our own location (0.5 ** 4 ~ 0.0625). Accept 70% which are going - // to our short distance peers (0.32 ** 4 ~ 0.01), 78% of those which could be reached via a - // direct short distance FOAF (distance 0.02). - double randomToPower4 = Math.pow(randomBetweenZeroAndOne, 4); - return distanceToNodeLocation < randomToPower4; - } else { - // if the key is a long distance key for us, heal it with 10% probability: it is unlikely that - // this would have reached us. Setting this to 0 could amplify a keyspace takeover attack. - return randomBetweenZeroAndOne > 0.9; - } - } + this.currentNodeLocation = currentNodeLocation; + this.isOpennetEnabled = isOpennetEnabled; + this.randomNumberSupplier = randomNumberSupplier; + } + public boolean shouldHeal(double keyLocation) { + if (!isOpennetEnabled.get()) { + // darknet is safer against sybil attack, so we can heal fully + return true; + } + double randomBetweenZeroAndOne = randomNumberSupplier.get(); + return shouldHealBlock(currentNodeLocation.get(), keyLocation, randomBetweenZeroAndOne); + } + /** + * Specialize healing: we want healing traffic to look like regular forwarding. + * + * Far away blocks would be unlikely to reach our node as request, + * so we reduce healing there: only accept 10% of those. + * + * When a key is close to our location, we use a continuous function depending on the distance + * to choose a probability. The closer to our node, the higher the probability of healing. + * As a side effect this reduces the hops healing inserts take, reducing the overall load + * on the network. + * + * The continuous function is gauged to accept 50% of the keys close to our node: a peak at our + * own location for which the area below the curve between 0 and 0.1 sums up to 0.5. + * + * Close keys are those in our 20% of the keyspace: the ones that would reach us if we were one of + * 5 long distance peers of a peer node. These are the keys for which we are most likely to be + * the best next hop when seen from the originator. + */ + private static boolean shouldHealBlock( + double nodeLocation, + double keyLocation, + double randomBetweenZeroAndOne) { + double distanceToNodeLocation = Location.distance(nodeLocation, keyLocation); + // If the key is inside "our" 20% of the keyspace, heal it with 50% probability. + if (distanceToNodeLocation < 0.1) { + // accept 50%, specialized to our own location (0.5 ** 4 ~ 0.0625). Accept 70% which are going + // to our short distance peers (0.32 ** 4 ~ 0.01), 78% of those which could be reached via a + // direct short distance FOAF (distance 0.02). + double randomToPower4 = Math.pow(randomBetweenZeroAndOne, 4); + return distanceToNodeLocation < randomToPower4; + } else { + // if the key is a long distance key for us, heal it with 10% probability: it is unlikely that + // this would have reached us. Setting this to 0 could amplify a keyspace takeover attack. + return randomBetweenZeroAndOne > 0.9; + } + } } From 202a8cdc395c93cb350764b39d8b57b25254752d Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 20:28:44 +0100 Subject: [PATCH 219/500] Extract helper methods for review by Bombe --- .../async/HealingDecisionSupplierTest.java | 302 +++++++++--------- 1 file changed, 157 insertions(+), 145 deletions(-) diff --git a/test/freenet/client/async/HealingDecisionSupplierTest.java b/test/freenet/client/async/HealingDecisionSupplierTest.java index 9ef342344db..1a2483cb291 100644 --- a/test/freenet/client/async/HealingDecisionSupplierTest.java +++ b/test/freenet/client/async/HealingDecisionSupplierTest.java @@ -11,176 +11,188 @@ public class HealingDecisionSupplierTest { @Test public void healingAlwaysTriggersForDarknet() { - for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> false, - () -> i); - assertThat( - String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.5), - Matchers.equalTo(true)); - } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + assertHeals( + getHealingDecisionSupplier(0.1, false, randomValue), + 0.5, + randomValue); + } } @Test public void healingAlwaysAcceptsAKeyAtTheNodeLocation() { - for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat( - String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.1), - Matchers.equalTo(true)); - } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + assertHeals( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.1, + randomValue); + } } @Test public void healingAccepts70PercentOfKeysInShortDistance() { - for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.11), - Matchers.equalTo(true)); - } - for (double i : Arrays.asList(0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat(String.format("Healing does not trigger at random value %g", i), - healingDecisionSupplier.shouldHeal(0.11), - Matchers.equalTo(false)); - } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4)) { + assertHeals( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.11, + randomValue); + } + for (double randomValue : Arrays.asList(0.3, 0.2, 0.1, 0.00000001)) { + assertDoesNotHeal( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.11, + randomValue); + } } @Test public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistance() { - for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.1999), - Matchers.equalTo(true)); - } - for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.1999), - Matchers.equalTo(false)); - } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + assertHeals( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.1999, + randomValue); + } + for (double randomValue : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + assertDoesNotHeal( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.1999, + randomValue); + } } @Test public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistanceAtADifferentNodeLocationToo() { - for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.6, - () -> true, - () -> i); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.6999), - Matchers.equalTo(true)); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.5001), - Matchers.equalTo(true)); - } - for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.6, - () -> true, - () -> i); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.6999), - Matchers.equalTo(false)); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.5001), - Matchers.equalTo(false)); - } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + HealingDecisionSupplier healingDecisionSupplier = getHealingDecisionSupplier( + 0.6, + true, + randomValue); + assertHeals( + healingDecisionSupplier, + 0.6999, + randomValue); + assertHeals( + healingDecisionSupplier, + 0.5001, + randomValue); + } + for (double randomValue : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = getHealingDecisionSupplier( + 0.6, + true, + randomValue); + assertDoesNotHeal( + healingDecisionSupplier, + 0.1999, + randomValue); + assertDoesNotHeal( + healingDecisionSupplier, + 0.5001, + randomValue); + } } @Test public void healingAccepts50PercentOfKeysAtTheLimitOfLongDistanceAroundZero() { - for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.0001, - () -> true, - () -> i); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.1), - Matchers.equalTo(true)); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.9002), - Matchers.equalTo(true)); - } for (double i : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.9999, - () -> true, - () -> i); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.0998), - Matchers.equalTo(true)); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.9000), - Matchers.equalTo(true)); - } - for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.0001, - () -> true, - () -> i); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.1), - Matchers.equalTo(false)); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.9002), - Matchers.equalTo(false)); - } - for (double i : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.9999, - () -> true, - () -> i); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.0998), - Matchers.equalTo(false)); - assertThat(String.format("Healing does not trigger random value %g", i), - healingDecisionSupplier.shouldHeal(0.9000), - Matchers.equalTo(false)); - } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + HealingDecisionSupplier healingDecisionSupplier = getHealingDecisionSupplier( + 0.0001, + true, + randomValue); + assertHeals( + healingDecisionSupplier, + 0.1, + randomValue); + assertHeals( + healingDecisionSupplier, + 0.9002, + randomValue); + } + for (double randomValue : Arrays.asList(1.0, 0.9, 0.8, 0.7, 0.6)) { + HealingDecisionSupplier healingDecisionSupplier = getHealingDecisionSupplier( + 0.9999, + true, + randomValue); + assertHeals( + healingDecisionSupplier, + 0.0998, + randomValue); + assertHeals( + healingDecisionSupplier, + 0.9000, + randomValue); + } + for (double randomValue : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = getHealingDecisionSupplier( + 0.0001, + true, + randomValue); + assertDoesNotHeal( + healingDecisionSupplier, + 0.1, + randomValue); + assertDoesNotHeal( + healingDecisionSupplier, + 0.9002, + randomValue); + } + for (double randomValue : Arrays.asList(0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + HealingDecisionSupplier healingDecisionSupplier = getHealingDecisionSupplier( + 0.9999, + true, + randomValue); + assertDoesNotHeal( + healingDecisionSupplier, + 0.0998, + randomValue); + assertDoesNotHeal( + healingDecisionSupplier, + 0.9000, + randomValue); + } } @Test public void healingAccepts10PercentOfKeysAtLongDistance() { - for (double i : Arrays.asList(1.0, 0.91)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat(String.format("Healing triggers at random value %g", i), - healingDecisionSupplier.shouldHeal(0.21), - Matchers.equalTo(true)); - } - for (double i : Arrays.asList(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { - HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( - () -> 0.1, - () -> true, - () -> i); - assertThat(String.format("Healing does not trigger at random value %g", i), - healingDecisionSupplier.shouldHeal(0.21), - Matchers.equalTo(false)); - } + for (double randomValue : Arrays.asList(1.0, 0.91)) { + assertHeals( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.21, + randomValue); + } + for (double randomValue : Arrays.asList(0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.00000001)) { + assertDoesNotHeal( + getHealingDecisionSupplier(0.1, true, randomValue), + 0.21, + randomValue); + } } + private static HealingDecisionSupplier getHealingDecisionSupplier(double nodeLocation, boolean isOpennet, double randomValue) { + HealingDecisionSupplier healingDecisionSupplier = new HealingDecisionSupplier( + () -> nodeLocation, + () -> isOpennet, + () -> randomValue); + return healingDecisionSupplier; + } + + private static void assertHeals( + HealingDecisionSupplier healingDecisionSupplier, + double keyLocation, double randomValue) { + assertThat( + String.format("Healing triggers at random value %g", randomValue), + healingDecisionSupplier.shouldHeal(keyLocation), + Matchers.equalTo(true)); + } + + private static void assertDoesNotHeal( + HealingDecisionSupplier healingDecisionSupplier, + double keyLocation, double randomValue) { + assertThat( + String.format("Healing does not trigger at random value %g", randomValue), + healingDecisionSupplier.shouldHeal(keyLocation), + Matchers.equalTo(false)); + } } From 327ea0a34b6c883ba0b5a0de380859cb5f501051 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 10 Dec 2022 17:55:20 +0100 Subject: [PATCH 220/500] Support CSS Combinators > + and ~ --- .../client/filter/CSSTokenizerFilter.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index 0286cfcc0e0..e8a55619e20 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -3,9 +3,14 @@ * http://www.gnu.org/ for further details of the GPL. */ package freenet.client.filter; + +import java.io.File; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.Reader; import java.io.Writer; +import java.net.URI; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; @@ -23,11 +28,6 @@ import freenet.support.io.Closer; import freenet.support.io.FileBucket; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; - /** Comprehensive CSS2.1 filter. The old jflex-based filter was very far * from comprehensive. * @author kurmiashish @@ -56,6 +56,8 @@ class CSSTokenizerFilter { Logger.registerClass(CSSTokenizerFilter.class); } + private static final List CSS_COMBINATORS = Arrays.asList(">", "+", "~"); + CSSTokenizerFilter(){ passedCharset = "UTF-8"; stopAtDetectedCharset = false; @@ -1708,7 +1710,7 @@ private int checkImportant(ParsedWord[] words) { } /* - * This function accepts an HTML element(along with class name, ID, pseudo class and attribute selector) and determines whether it is valid or not. + * This function accepts an HTML element(along with class name, ID, pseudo class or attribute selector or a combinator) and determines whether it is valid or not. * Returns null on failure (invalid selector), empty string on banned (but otherwise valid) selector. * @param elementName A selector which may include an HTML element. * @param isIDSelector True if we only allow an ID selector, which must include an ID, may @@ -1775,6 +1777,10 @@ else if(HTMLelement.indexOf('#')!=-1) } if(isIDSelector && id.isEmpty()) return null; // No ID + if (CSS_COMBINATORS.contains(elementString)) { + return elementString; + } + boolean elementValid = "*".equals(HTMLelement) || (ElementInfo.isValidHTMLTag(HTMLelement.toLowerCase())) || From 8db7648cb0f4c2d27bbaa43f3e68eb79ced8fcfd Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 10 Dec 2022 17:55:33 +0100 Subject: [PATCH 221/500] Support CSS the attribute selectors ^= $= *= --- src/freenet/client/filter/CSSTokenizerFilter.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index e8a55619e20..c8d410dae32 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1820,6 +1820,21 @@ else if(HTMLelement.indexOf('#')!=-1) attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("~=")); attSelectionParts[1]=attSelection.substring(attSelection.indexOf("~=")+2, attSelection.length()); + } else if(attSelection.indexOf("^=")!=-1) { + attSelectionParts=new String[2]; + attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("^=")); + attSelectionParts[1]=attSelection.substring(attSelection.indexOf("^=")+2, + attSelection.length()); + } else if(attSelection.indexOf("$=")!=-1) { + attSelectionParts=new String[2]; + attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("$=")); + attSelectionParts[1]=attSelection.substring(attSelection.indexOf("$=")+2, + attSelection.length()); + } else if(attSelection.indexOf("*=")!=-1) { + attSelectionParts=new String[2]; + attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("*=")); + attSelectionParts[1]=attSelection.substring(attSelection.indexOf("*=")+2, + attSelection.length()); } else if(attSelection.indexOf('=') != -1){ attSelectionParts=new String[2]; attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf('=')); From 6748295deb9b692b29fba7b994519d555f3d94a8 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 10 Dec 2022 17:56:03 +0100 Subject: [PATCH 222/500] Support CSS pseudo-element checked --- src/freenet/client/filter/ElementInfo.java | 1 + test/freenet/client/filter/CSSParserTest.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/freenet/client/filter/ElementInfo.java b/src/freenet/client/filter/ElementInfo.java index a2d2acb84a8..7a182325711 100644 --- a/src/freenet/client/filter/ElementInfo.java +++ b/src/freenet/client/filter/ElementInfo.java @@ -210,6 +210,7 @@ public class ElementInfo { "visited", "hover", "active", + "checked", "focus", "focus-within", "lang", diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index f87d6ca7f7c..3293fc118e9 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -49,6 +49,7 @@ public class CSSParserTest { CSS1_SELECTOR.put("h1:focus {}" ,"h1:focus"); CSS1_SELECTOR.put("h1:first-line {}" ,"h1:first-line"); CSS1_SELECTOR.put("h1:first-letter {}" ,"h1:first-letter"); + CSS1_SELECTOR.put("input:checked {}" ,"input:checked"); } // FIXME should specify exact output values From 189687ed6f2c48446ab35776ca3f8cf48120b7b0 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 21:33:15 +0200 Subject: [PATCH 223/500] Add CSS test for ~ and simplify the implementation It changed more than needed. --- src/freenet/client/filter/CSSTokenizerFilter.java | 9 ++------- test/freenet/client/filter/CSSParserTest.java | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index c8d410dae32..da21860e222 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -56,8 +56,6 @@ class CSSTokenizerFilter { Logger.registerClass(CSSTokenizerFilter.class); } - private static final List CSS_COMBINATORS = Arrays.asList(">", "+", "~"); - CSSTokenizerFilter(){ passedCharset = "UTF-8"; stopAtDetectedCharset = false; @@ -1777,12 +1775,9 @@ else if(HTMLelement.indexOf('#')!=-1) } if(isIDSelector && id.isEmpty()) return null; // No ID - if (CSS_COMBINATORS.contains(elementString)) { - return elementString; - } - boolean elementValid = - "*".equals(HTMLelement) || + "*".equals(HTMLelement) || + "~".equals(HTMLelement) || (ElementInfo.isValidHTMLTag(HTMLelement.toLowerCase())) || (HTMLelement.trim().isEmpty() && ((!className.isEmpty()) || (!id.isEmpty()) || attSelections!=null || diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index 3293fc118e9..da8c2f02ac3 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -35,7 +35,7 @@ public class CSSParserTest { // FIXME should specify exact output values - /** CSS1 Selectors */ + /** CSS1 Selectors: key is the input value, value is the expected output. */ private final static HashMap CSS1_SELECTOR= new HashMap<>(); static { CSS1_SELECTOR.put("h1 {}","h1"); @@ -53,7 +53,7 @@ public class CSSParserTest { } // FIXME should specify exact output values - /** CSS2 Selectors */ + /** CSS2 Selectors: key is the input value, value is the expected output. */ private final static HashMap CSS2_SELECTOR= new HashMap<>(); static { CSS2_SELECTOR.put("* {}","*"); @@ -79,6 +79,7 @@ public class CSSParserTest { CSS2_SELECTOR.put("body > P { line-height: 1.3 }", "body>P { line-height: 1.3 }"); CSS2_SELECTOR.put("div ol>li p { color: green;}", "div ol>li p { color: green;}"); CSS2_SELECTOR.put("h1 + h2 { margin-top: -5mm }", "h1+h2 { margin-top: -5mm }"); + CSS2_SELECTOR.put("h1 ~ h2 { margin-top: -5mm }", "h1 ~ h2 { margin-top: -5mm }"); CSS2_SELECTOR.put("h1.opener + h2 { margin-top: -5mm }", "h1.opener+h2 { margin-top: -5mm }"); CSS2_SELECTOR.put("span[class=example] { color: blue; }", "span[class=example] { color: blue; }"); CSS2_SELECTOR.put("span[hello=\"Cleveland\"][goodbye=\"Columbus\"] { color: blue; }", "span[hello=\"Cleveland\"][goodbye=\"Columbus\"] { color: blue; }"); @@ -143,7 +144,7 @@ public class CSSParserTest { } - /** CSS3 Selectors */ + /** CSS3 Selectors: key is the input value, value is the expected output. */ private final static HashMap CSS3_SELECTOR= new HashMap<>(); static { CSS3_SELECTOR.put("tr:nth-child(odd) { background-color: red; }","tr:nth-child(odd) { background-color: red; }"); From 1c5376a0e07222d7acbab4a11ef1aedaeebd42d3 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 21:48:07 +0200 Subject: [PATCH 224/500] Fix: checked only the first char of the key part of CSS selectors --- src/freenet/client/filter/CSSTokenizerFilter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index da21860e222..42c595d8f74 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1851,6 +1851,7 @@ else if(HTMLelement.indexOf('#')!=-1) if(!((c>='a' && c<='z') || (c>='A' && c<='Z'))) return null; for(int i=1;i='a' && c<='z') || (c>='A' && c<='Z') || c=='_' || c=='-')) return null; } From 161159db548953c1b69f5cc3fe6c994166b8662a Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 21:48:39 +0200 Subject: [PATCH 225/500] Add tests for ^= $= and *= --- test/freenet/client/filter/CSSParserTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index da8c2f02ac3..542dd884250 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -62,6 +62,9 @@ public class CSSParserTest { CSS2_SELECTOR.put("h1[foo=bar] {}", "h1[foo=bar] {}"); CSS2_SELECTOR.put("h1[foo~=\"bar\"] {}", "h1[foo~=\"bar\"]"); CSS2_SELECTOR.put("h1[foo|=\"en\"] {}","h1[foo|=\"en\"]"); + CSS2_SELECTOR.put("h1[foo^=\"en\"] {}","h1[foo^=\"en\"]"); + CSS2_SELECTOR.put("h1[foo$=\"en\"] {}","h1[foo$=\"en\"]"); + CSS2_SELECTOR.put("h1[foo*=\"en\"] {}","h1[foo*=\"en\"]"); CSS2_SELECTOR.put("[foo|=\"en\"] {}","[foo|=\"en\"]"); CSS2_SELECTOR.put("h1:first-child {}","h1:first-child"); CSS2_SELECTOR.put("h1:lang(fr) {}","h1:lang(fr)"); From c1ebc316737edb7c604e94fc131e163e161ed703 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 5 Sep 2023 21:48:51 +0200 Subject: [PATCH 226/500] Whitespace --- src/freenet/client/filter/CSSTokenizerFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index 42c595d8f74..d79d3178e33 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1776,7 +1776,7 @@ else if(HTMLelement.indexOf('#')!=-1) if(isIDSelector && id.isEmpty()) return null; // No ID boolean elementValid = - "*".equals(HTMLelement) || + "*".equals(HTMLelement) || "~".equals(HTMLelement) || (ElementInfo.isValidHTMLTag(HTMLelement.toLowerCase())) || (HTMLelement.trim().isEmpty() && From e06eb53c2090551011c72beb8bcbb253e889f9cf Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 7 Sep 2023 10:01:17 +0200 Subject: [PATCH 227/500] Add test that would catch too lax filtering --- test/freenet/client/filter/CSSParserTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/freenet/client/filter/CSSParserTest.java b/test/freenet/client/filter/CSSParserTest.java index 542dd884250..ff9ea15df7e 100644 --- a/test/freenet/client/filter/CSSParserTest.java +++ b/test/freenet/client/filter/CSSParserTest.java @@ -133,6 +133,8 @@ public class CSSParserTest { CSS2_BAD_SELECTOR.add("h1[foo=\"bar\\] {}"); // Unclosed string CSS2_BAD_SELECTOR.add("h1[foo=\"bar] {}"); + // illegal modifier + CSS2_BAD_SELECTOR.add("h1[foo,=bar] {}"); CSS2_BAD_SELECTOR.add("h1:langblahblah(fr) {}"); From 33ea9f440a36fb2375f9290e28d2b0c97c9e9384 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Mon, 4 Sep 2023 23:51:25 +0000 Subject: [PATCH 228/500] remove trailing empty line From 8ccc7e125c11ccd72f105d13b661f8d925aba73d Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sun, 10 Sep 2023 19:04:33 +0200 Subject: [PATCH 229/500] Remove redundancy in CSS Filter --- .../client/filter/CSSTokenizerFilter.java | 53 ++++++------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index d79d3178e33..e29c056a78f 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1802,42 +1802,23 @@ else if(HTMLelement.indexOf('#')!=-1) } if(attSelections!=null) { - String[] attSelectionParts; - - for(String attSelection : attSelections) { - if(attSelection.indexOf("|=")!=-1) { - attSelectionParts=new String[2]; - attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("|=")); - attSelectionParts[1]=attSelection.substring(attSelection.indexOf("|=")+2, - attSelection.length()); - } else if(attSelection.indexOf("~=")!=-1) { - attSelectionParts=new String[2]; - attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("~=")); - attSelectionParts[1]=attSelection.substring(attSelection.indexOf("~=")+2, - attSelection.length()); - } else if(attSelection.indexOf("^=")!=-1) { - attSelectionParts=new String[2]; - attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("^=")); - attSelectionParts[1]=attSelection.substring(attSelection.indexOf("^=")+2, - attSelection.length()); - } else if(attSelection.indexOf("$=")!=-1) { - attSelectionParts=new String[2]; - attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("$=")); - attSelectionParts[1]=attSelection.substring(attSelection.indexOf("$=")+2, - attSelection.length()); - } else if(attSelection.indexOf("*=")!=-1) { - attSelectionParts=new String[2]; - attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf("*=")); - attSelectionParts[1]=attSelection.substring(attSelection.indexOf("*=")+2, - attSelection.length()); - } else if(attSelection.indexOf('=') != -1){ - attSelectionParts=new String[2]; - attSelectionParts[0]=attSelection.substring(0,attSelection.indexOf('=')); - attSelectionParts[1]=attSelection.substring(attSelection.indexOf('=')+1, - attSelection.length()); - } else { - attSelectionParts=new String[] { attSelection }; - } + + for(String attSelection : attSelections) { + + // set the default + String[] attSelectionParts = new String[] { attSelection };; + + List operators = Arrays.asList("|=", "~=", "^=", "$=", "*=", "="); + for (String comparisonOperator : operators) { + if (attSelection.contains(comparisonOperator)) { + attSelectionParts = new String[2]; + attSelectionParts[0] = attSelection + .substring(0, attSelection.indexOf(comparisonOperator)); + attSelectionParts[1] = attSelection + .substring(attSelection.indexOf(comparisonOperator) + comparisonOperator.length()); + break; + } + } //Verifying whether each character is alphanumeric or _ if(logDEBUG) Logger.debug(CSSTokenizerFilter.class, From 9985b57331c4ec395dfb986445be60e154bf5891 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 5 Oct 2023 09:08:15 +0200 Subject: [PATCH 230/500] Remove stray ; --- src/freenet/client/filter/CSSTokenizerFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index e29c056a78f..1c161a00434 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1806,7 +1806,7 @@ else if(HTMLelement.indexOf('#')!=-1) for(String attSelection : attSelections) { // set the default - String[] attSelectionParts = new String[] { attSelection };; + String[] attSelectionParts = new String[] { attSelection }; List operators = Arrays.asList("|=", "~=", "^=", "$=", "*=", "="); for (String comparisonOperator : operators) { From d30fcc0b4a9688b6da85e880bf4e344a3c7951ab Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Thu, 5 Oct 2023 09:11:57 +0200 Subject: [PATCH 231/500] tabify CSSTokenizerFilter --- .../client/filter/CSSTokenizerFilter.java | 296 +++++++++--------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index 1c161a00434..f12ead5124e 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -788,7 +788,7 @@ else if("clip".equalsIgnoreCase(element)) elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("sh"))); allelementVerifiers.remove(element); } - else if("break-after".equalsIgnoreCase(element)) + else if("break-after".equalsIgnoreCase(element)) { elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto","always","avoid","left","right", "page", "column", "avoid-page", "avoid-column" ),ElementInfo.VISUALPAGEDMEDIA)); allelementVerifiers.remove(element); @@ -803,57 +803,57 @@ else if("break-inside".equalsIgnoreCase(element)) elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto","avoid","avoid-page", "avoid-column"),ElementInfo.VISUALPAGEDMEDIA)); allelementVerifiers.remove(element); } - else if("column-count".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("in"))); + else if("column-count".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("in"))); allelementVerifiers.remove(element); - } - else if("column-fill".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto", "balance"),ElementInfo.VISUALMEDIA)); + } + else if("column-fill".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto", "balance"),ElementInfo.VISUALMEDIA)); allelementVerifiers.remove(element); - } - else if("column-gap".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal"),ElementInfo.VISUALMEDIA,Arrays.asList("le"))); + } + else if("column-gap".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("normal"),ElementInfo.VISUALMEDIA,Arrays.asList("le"))); allelementVerifiers.remove(element); - } - else if("column-rule-color".equalsIgnoreCase(element)) - { + } + else if("column-rule-color".equalsIgnoreCase(element)) + { elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,Arrays.asList("co"))); allelementVerifiers.remove(element); - } - else if("column-rule-style".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("13<1,4>"))); + } + else if("column-rule-style".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("13<1,4>"))); allelementVerifiers.remove(element); - } - else if("column-rule-width".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("14<1,4>"))); + } + else if("column-rule-width".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("14<1,4>"))); allelementVerifiers.remove(element); - } + } else if("column-rule".equalsIgnoreCase(element)) - { + { // column-rule-width auxilaryVerifiers[54] = new CSSPropertyVerifier(null,null,null,Arrays.asList("14<1,4>")); // border-style auxilaryVerifiers[55] = new CSSPropertyVerifier(null,null,null,Arrays.asList("13<1,4>")); // color || transparent 13 - elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("54a55a15"))); + elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("54a55a15"))); allelementVerifiers.remove(element); - } - else if("column-span".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("1", "all"),ElementInfo.VISUALMEDIA)); + } + else if("column-span".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("1", "all"),ElementInfo.VISUALMEDIA)); allelementVerifiers.remove(element); - } - else if("column-width".equalsIgnoreCase(element)) - { - elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le"))); + } + else if("column-width".equalsIgnoreCase(element)) + { + elementVerifiers.put(element,new CSSPropertyVerifier(Arrays.asList("auto"),ElementInfo.VISUALMEDIA,Arrays.asList("le"))); allelementVerifiers.remove(element); - } + } else if("columns".equalsIgnoreCase(element)) { // column-width @@ -864,7 +864,7 @@ else if("columns".equalsIgnoreCase(element)) elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,null,Arrays.asList("52a53"))); allelementVerifiers.remove(element); } - else if ("color".equalsIgnoreCase(element)) + else if ("color".equalsIgnoreCase(element)) { elementVerifiers.put(element,new CSSPropertyVerifier(null,ElementInfo.VISUALMEDIA,Arrays.asList("co"))); allelementVerifiers.remove(element); @@ -929,11 +929,11 @@ else if("cursor".equalsIgnoreCase(element)) { // = [ [ [ ]?,]* // [ auto | default | none | - // context-menu | help | pointer | progress | wait | - // cell | crosshair | text | vertical-text | - // alias | copy | move | no-drop | not-allowed | grab | grabbing | - // e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out - // ] ] + // context-menu | help | pointer | progress | wait | + // cell | crosshair | text | vertical-text | + // alias | copy | move | no-drop | not-allowed | grab | grabbing | + // e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize | row-resize | all-scroll | zoom-in | zoom-out + // ] ] auxilaryVerifiers[25]=new CSSPropertyVerifier(null,Arrays.asList("ur"),null,null,true); auxilaryVerifiers[141] = new CSSPropertyVerifier(null, Arrays.asList("in", "re"), null, null, true); auxilaryVerifiers[142] = new CSSPropertyVerifier(null, null, null, Arrays.asList("25 141 141", "25"), true, true); @@ -1722,18 +1722,18 @@ public static String HTMLelementVerifier(String elementString, boolean isIDSelec ArrayList attSelections = null; while(elementString.indexOf('[')!=-1 && elementString.indexOf(']')!=-1 && (elementString.indexOf('[') commaListFromIdentifiers(ParsedWord[] strparts, int of } else if(word instanceof SimpleParsedWord) { String data = ((SimpleParsedWord)word).original; String[] split = FilterUtils.removeWhiteSpace(data.split(","),false); - medias.addAll(Arrays.asList(split)); + medias.addAll(Arrays.asList(split)); } else return null; } } @@ -3025,7 +3025,7 @@ public String encode(boolean unicode) { } } - @Override + @Override public String toString() { return super.toString()+":\""+original+"\""; } @@ -3147,7 +3147,7 @@ else if(c < 32 || (c >= (char)0x0080 && !unicode)) return false; } - @Override + @Override protected void innerEncode(boolean unicode, StringBuilder out) { out.append(stringChar); super.innerEncode(unicode, out); @@ -3162,7 +3162,7 @@ static class ParsedURL extends ParsedString { super(original, decoded, changed || stringChar == 0, stringChar == 0 ? '"' : stringChar); } - @Override + @Override protected void innerEncode(boolean unicode, StringBuilder out) { out.append("url("); super.innerEncode(unicode, out); @@ -3181,7 +3181,7 @@ static class ParsedAttr extends ParsedIdentifier { super(original, decoded, changed); } - @Override + @Override protected void innerEncode(boolean unicode, StringBuilder out) { out.append("attr("); super.innerEncode(unicode, out); @@ -3684,7 +3684,7 @@ static class CSSPropertyVerifier public final boolean isAngle; //an public final boolean isColor; //co public final boolean isURI; //ur - public final boolean isIDSelector; //se + public final boolean isIDSelector; //se public final boolean isShape; //sh public final boolean isString; //st public final boolean isCounter; //co @@ -3701,41 +3701,41 @@ static class CSSPropertyVerifier } CSSPropertyVerifier(Collection allowedValues, - Collection allowedMedia) + Collection allowedMedia) { this(allowedValues, allowedMedia, null, null); } CSSPropertyVerifier(Collection allowedValues, - Collection allowedMedia, - Collection possibleValues) + Collection allowedMedia, + Collection possibleValues) { this(allowedValues, allowedMedia, possibleValues, null); } CSSPropertyVerifier(Collection allowedValues, - Collection possibleValues, - Collection parseExpression, - Collection allowedMedia, - boolean onlyValueVerifier) + Collection possibleValues, + Collection parseExpression, + Collection allowedMedia, + boolean onlyValueVerifier) { this(allowedValues, allowedMedia, possibleValues, parseExpression, onlyValueVerifier, false); } CSSPropertyVerifier(Collection allowedValues, - Collection allowedMedia, - Collection possibleValues, - Collection parseExpression) + Collection allowedMedia, + Collection possibleValues, + Collection parseExpression) { this(allowedValues, allowedMedia, possibleValues, parseExpression, false, false); } CSSPropertyVerifier(Collection allowedValues, - Collection allowedMedia, - Collection possibleValues, - Collection parseExpression, - boolean onlyValueVerifier, - boolean allowCommaDelimiters) + Collection allowedMedia, + Collection possibleValues, + Collection parseExpression, + boolean onlyValueVerifier, + boolean allowCommaDelimiters) { this.onlyValueVerifier = onlyValueVerifier; this.allowCommaDelimiters = allowCommaDelimiters; @@ -3897,7 +3897,7 @@ public boolean checkValidity(String[] media,String[] elements,ParsedWord[] words // FOR EXAMPLE, IN THE SPEC: // 17.6.1.1 empty-cells Applies to: 'table-cell' elements // In 17.2, 'table-cell' is explicitly defined: - // table-cell (In HTML: TD, TH) Specifies that an element represents a table cell. + // table-cell (In HTML: TD, TH) Specifies that an element represents a table cell. // Yet the example for empty-cells is: // The following rule causes borders and backgrounds to be drawn around all cells: // table { empty-cells: show } @@ -4002,13 +4002,13 @@ public boolean checkValidity(String[] media,String[] elements,ParsedWord[] words } if (isIDSelector) { - // In accordance with spec for e.g. nav-*, we only allow ID selectors. - // See http://www.w3.org/TR/css3-ui/ - // REDFLAG If we allow more general selectors (which some browsers may accept) we - // have two new problems: - // 1) They may occupy more than one word, which greatly complicates parsing here, - // 2) We should sanitize the selectors, not just pass them on. Which in turn may - // cause them to take up more than one word! + // In accordance with spec for e.g. nav-*, we only allow ID selectors. + // See http://www.w3.org/TR/css3-ui/ + // REDFLAG If we allow more general selectors (which some browsers may accept) we + // have two new problems: + // 1) They may occupy more than one word, which greatly complicates parsing here, + // 2) We should sanitize the selectors, not just pass them on. Which in turn may + // cause them to take up more than one word! String result = HTMLelementVerifier(words[0].original, true); if (!(result == null || result.isEmpty())) { return true; @@ -4059,7 +4059,7 @@ public boolean checkValidity(String[] media,String[] elements,ParsedWord[] words * 1* => 1<0,65536> * 1? => 1? * 1+ => 1<1,65536> - * 1&&2 => 1b2 (see doubleAmpersandVerifier()) + * 1&&2 => 1b2 (see doubleAmpersandVerifier()) * Additional expressions that can be passed to the function * 1 2 => both 1 and 2 should return true where 1 and 2 are again indices in auxiliaryVerifier array. * [a,b]=> give at least a tokens and at the most b tokens(part of values) to this block of expression. @@ -4101,10 +4101,10 @@ public boolean recursiveParserExpressionVerifier(String expression,ParsedWord[] //Detecting the other end for(int j=0;j= c)) { + char c = expression.charAt(j); + if(c == 'a') { + noOfa++; + } else if(!('0' <= c && '9' >= c)) { endIndex=j; break; } @@ -4138,10 +4138,10 @@ public boolean recursiveParserExpressionVerifier(String expression,ParsedWord[] } else if (expression.charAt(i) == 'b') { // detecting b which is the && operator int endIndex = expression.length(); - // Find the end of a chain of 1b2b3... + // Find the end of a chain of 1b2b3... for (int j = 0; j < expression.length(); j++) { - char c = expression.charAt(j); - if(!(c == 'b' || '0' <= c && '9' >= c)) { + char c = expression.charAt(j); + if(!(c == 'b' || '0' <= c && '9' >= c)) { endIndex=j; break; } @@ -4350,8 +4350,8 @@ public static String getStringFromArray(String[] parts,int lowerIndex,int upperI { for(int i=lowerIndex;i Date: Fri, 26 Jan 2024 22:18:39 +0100 Subject: [PATCH 232/500] Fix: do not tabify in string --- src/freenet/client/filter/CSSTokenizerFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/client/filter/CSSTokenizerFilter.java b/src/freenet/client/filter/CSSTokenizerFilter.java index f12ead5124e..6e5b9258975 100644 --- a/src/freenet/client/filter/CSSTokenizerFilter.java +++ b/src/freenet/client/filter/CSSTokenizerFilter.java @@ -1727,7 +1727,7 @@ public static String HTMLelementVerifier(String elementString, boolean isIDSelec StringBuilder buf=new StringBuilder(elementString); buf.delete(elementString.indexOf('['), elementString.indexOf(']')+1); elementString=buf.toString(); - if(logDEBUG) Logger.debug(CSSTokenizerFilter.class, "attSelection="+attSelection+" elementString="+elementString); + if(logDEBUG) Logger.debug(CSSTokenizerFilter.class, "attSelection="+attSelection+" elementString="+elementString); if(attSelections == null) attSelections = new ArrayList(); attSelections.add(attSelection); } From fda9bdb81d4077747db365a922ee7afe30f10584 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Tue, 30 Jan 2024 23:09:15 +0100 Subject: [PATCH 233/500] Only link indexes via the index of indexes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the decision by OLG Köln from 2023-11 https://www.heise.de/news/Oberlandesgericht-Cloudflare-haftet-als-Taeter-fuer-Urheberrechtsverletzungen-9355760.html caching services must stop access quickly when they get a report. Therefore linking directly to an index becomes too risky: we’ll have link them only via the Index of Indexes so we can remove the link to the index quickly if an index fails to react to a report in time. --- .../http/staticfiles/defaultbookmarks.dat | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat index 9891e4fa5f8..6611489a1c6 100644 --- a/src/freenet/clients/http/staticfiles/defaultbookmarks.dat +++ b/src/freenet/clients/http/staticfiles/defaultbookmarks.dat @@ -3,22 +3,17 @@ Version=1 Bookmark=0 BookmarkCategory0.Name=L10N:categoryStarting BookmarkCategory0.Content.BookmarkCategory=0 -BookmarkCategory0.Content.Bookmark=3 +BookmarkCategory0.Content.Bookmark=2 BookmarkCategory0.Content.Bookmark0.Name=Freenet First Steps BookmarkCategory0.Content.Bookmark0.ShortDescription=L10N:FFS BookmarkCategory0.Content.Bookmark0.Description=L10N:FFS BookmarkCategory0.Content.Bookmark0.hasAnActivelink=true BookmarkCategory0.Content.Bookmark0.URI=USK@62H8KFSZWMyQ2MQgwvNhEYJ2m3SQl696PfsVfWQ-HQo,cJrPvdNz4AnrHJQXNteDV7k3YnAVY-MClt84gwH2qEo,AQACAAE/freenet-first-steps/23/ -BookmarkCategory0.Content.Bookmark1.Name=Clean Spider -BookmarkCategory0.Content.Bookmark1.Description=L10N:CleanSpider -BookmarkCategory0.Content.Bookmark1.ShortDescription=L10N:CleanSpider -BookmarkCategory0.Content.Bookmark1.hasAnActivelink=true -BookmarkCategory0.Content.Bookmark1.URI=USK@5ijbfKSJ4kPZTRDzq363CHteEUiSZjrO-E36vbHvnIU,ZEZqPXeuYiyokY2r0wkhJr5cy7KBH9omkuWDqSC6PLs,AQACAAE/clean-spider/129/ -BookmarkCategory0.Content.Bookmark2.Name=Index of Indexes -BookmarkCategory0.Content.Bookmark2.ShortDescription=L10N:JFnikiIndex -BookmarkCategory0.Content.Bookmark2.Description=L10N:JFnikiIndex -BookmarkCategory0.Content.Bookmark2.hasAnActivelink=false -BookmarkCategory0.Content.Bookmark2.URI=USK@t-YmshUm43nS16QFieoZMfBdfieb9Opy0a2aMWsoH8o,7NqDX88r1R4SC~elmpW4SuKbnAOka~MKUuBufUWa2xQ,AQACAAE/jFniki.Index/8/Index_of_Indexes.html +BookmarkCategory0.Content.Bookmark1.Name=Index of Indexes +BookmarkCategory0.Content.Bookmark1.ShortDescription=L10N:JFnikiIndex +BookmarkCategory0.Content.Bookmark1.Description=L10N:JFnikiIndex +BookmarkCategory0.Content.Bookmark1.hasAnActivelink=false +BookmarkCategory0.Content.Bookmark1.URI=USK@t-YmshUm43nS16QFieoZMfBdfieb9Opy0a2aMWsoH8o,7NqDX88r1R4SC~elmpW4SuKbnAOka~MKUuBufUWa2xQ,AQACAAE/jFniki.Index/8/Index_of_Indexes.html BookmarkCategory1.Name=L10N:categorySoftware BookmarkCategory1.Content.BookmarkCategory=0 BookmarkCategory1.Content.Bookmark=8 From 77cf8cbc032a1f422402ef62ca1c5319c9114b65 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 31 Jan 2024 06:53:32 +0100 Subject: [PATCH 234/500] =?UTF-8?q?Fix=20links=20to=20mailing=20lists=20an?= =?UTF-8?q?d=20IRC=20in=20CONTRIBUTING.md=20=E2=80=94=20thanks=20to=20Juic?= =?UTF-8?q?eman!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONTRIBUTING.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1bec731947a..99dc521444b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,8 +23,7 @@ against the `next` branch. It's usually a good idea to work on a topic / feature branch that starts at `next` and is specific to the pull request. Once you have submitted a pull request, people will start reviewing it and providing feedback. If you don't hear anything for a while feel free to bring it to the attention of -people in [IRC](https://freenetproject.org/irc.html) or the [mailing -list](https://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl) - we may +people in [IRC](https://www.hyphanet.org/pages/help.html#chat-with-us) or the [mailing list](https://www.hyphanet.org/pages/help.html#mailing-lists) - we may have missed it. Code review helps improve code quality, ensures that multiple people know the @@ -37,8 +36,8 @@ producing software that is readable, correct, and sufficiently efficient. Breaking API creates an immense amount of work for developers of other projects, so it is *not* something to be done lightly. If you feel you must make a change that breaks API and cannot maintain backwards compatibility, please first raise -the issue with the community - the [mailing list](https://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl) -and [IRC](https://freenetproject.org/irc.html) are good places to contact us. +the issue with the community - the [mailing list](https://www.hyphanet.org/pages/help.html#mailing-lists) +and [IRC](https://www.hyphanet.org/pages/help.html#chat-with-us) are good places to contact us. Changing dependencies must be accompanied with changes in every installer and updates to `dependencies.properties` and existing From 2fb26b304dacabbec1420fa95d2d30bf2685e488 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 31 Jan 2024 08:48:07 +0100 Subject: [PATCH 235/500] Remove time-dependence of compressor selection --- src/freenet/client/async/InsertCompressor.java | 5 ----- src/freenet/node/Node.java | 18 ++---------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/freenet/client/async/InsertCompressor.java b/src/freenet/client/async/InsertCompressor.java index 9059341a3e1..8abe7d3829e 100644 --- a/src/freenet/client/async/InsertCompressor.java +++ b/src/freenet/client/async/InsertCompressor.java @@ -107,9 +107,7 @@ public void tryCompress(final ClientContext context) throws InsertException { boolean first = true; long amountOfDataToCheckCompressionRatio = config.get("node").getLong("amountOfDataToCheckCompressionRatio"); int minimumCompressionPercentage = config.get("node").getInt("minimumCompressionPercentage"); - int maxTimeForSingleCompressor = config.get("node").getInt("maxTimeForSingleCompressor"); for (final COMPRESSOR_TYPE comp : comps) { - long compressionStartTime = System.currentTimeMillis(); boolean shouldFreeOnFinally = true; RandomAccessBucket result = null; try { @@ -209,9 +207,6 @@ public boolean run(ClientContext context) { result.free(); } - // if one iteration of compression took a lot of time, then we will not try other algorithms - if (System.currentTimeMillis() - compressionStartTime > maxTimeForSingleCompressor) - break; } final CompressionOutput output = new CompressionOutput(bestCompressedData, bestCodec, hashes); diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index b29ef30c61b..18e9d9b41b1 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -655,7 +655,6 @@ public String[] getPossibleValues() { private int inputBandwidthLimit; private long amountOfDataToCheckCompressionRatio; private int minimumCompressionPercentage; - private int maxTimeForSingleCompressor; private boolean connectionSpeedDetection; boolean inputLimitDefault; final boolean enableARKs; @@ -1632,22 +1631,9 @@ public void set(Integer minimumCompressionPercentage) { minimumCompressionPercentage = nodeConfig.getInt("minimumCompressionPercentage"); - nodeConfig.register("maxTimeForSingleCompressor", "20m", sortOrder++, - true, true, "Node.maxTimeForSingleCompressor", - "Node.maxTimeForSingleCompressorLong", new IntCallback() { - @Override - public Integer get() { - return maxTimeForSingleCompressor; - } - @Override - public void set(Integer maxTimeForSingleCompressor) { - synchronized(Node.this) { - Node.this.maxTimeForSingleCompressor = maxTimeForSingleCompressor; - } - } - }, Dimension.DURATION); + // max time for single compressor makes the insert compression CPU dependent, so it should not have been used. + nodeConfig.registerIgnoredOption("maxTimeForSingleCompressor"); - maxTimeForSingleCompressor = nodeConfig.getInt("maxTimeForSingleCompressor"); nodeConfig.register("connectionSpeedDetection", true, sortOrder++, true, true, "Node.connectionSpeedDetection", From ec32c9a03d73ba1ad106f2bde7f2aba79bde1c18 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 31 Jan 2024 12:34:56 +0100 Subject: [PATCH 236/500] Remove translation keys for removed config --- src/freenet/l10n/freenet.l10n.en.properties | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/freenet/l10n/freenet.l10n.en.properties b/src/freenet/l10n/freenet.l10n.en.properties index cead36ac4ac..f02b114b791 100644 --- a/src/freenet/l10n/freenet.l10n.en.properties +++ b/src/freenet/l10n/freenet.l10n.en.properties @@ -1166,8 +1166,6 @@ Node.amountOfDataToCheckCompressionRatio=Amount of data to check compression rat Node.amountOfDataToCheckCompressionRatioLong=The data amount after compression of which we will check whether we have got the desired effect. Node.minimumCompressionPercentage=Minimum compression percentage Node.minimumCompressionPercentageLong=The minimal desired compression effect, %. -Node.maxTimeForSingleCompressor=Maximum desired time for single compressor -Node.maxTimeForSingleCompressorLong=If the operation time of one of the compressors is longer than this setting, the subsequent compressors will not be used. Node.connectionSpeedDetection=Offer upgrade of the connection speed Node.connectionSpeedDetectionLong=Offer upgrade of the connection speed if auto-detected speed is much higher than the set speed Node.invalidStoreSize=Store size must be at least 32MB From 4c625ed772f296ba53b832e5af578054b6a2b217 Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Wed, 31 Jan 2024 12:35:26 +0100 Subject: [PATCH 237/500] Improve Log message for wrong minimum percentage --- src/freenet/node/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index 18e9d9b41b1..07087076954 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -1620,7 +1620,7 @@ public Integer get() { public void set(Integer minimumCompressionPercentage) { synchronized(Node.this) { if (minimumCompressionPercentage < 0 || minimumCompressionPercentage > 100) { - Logger.normal(Node.class, "Wrong minimum compression percentage" + minimumCompressionPercentage); + Logger.normal(Node.class, "Wrong minimum compression percentage: must be between 0 and 100, but is " + minimumCompressionPercentage); return; } From c8c09f4c2e744be5d60aa897b3db0b175c901c9b Mon Sep 17 00:00:00 2001 From: Arne Babenhauserheide Date: Sat, 3 Feb 2024 23:10:32 +0100 Subject: [PATCH 238/500] Add missing Global flag to GetFailed FCP message. Thanks to oishii! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (bug reported by oishii@e-FUmCyxfF9D… on FMS) --- src/freenet/clients/fcp/GetFailedMessage.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/freenet/clients/fcp/GetFailedMessage.java b/src/freenet/clients/fcp/GetFailedMessage.java index 5cd446bc051..f86acb81faf 100644 --- a/src/freenet/clients/fcp/GetFailedMessage.java +++ b/src/freenet/clients/fcp/GetFailedMessage.java @@ -139,6 +139,7 @@ public SimpleFieldSet getFieldSet(boolean verbose) { if(verbose) sfs.putSingle("ShortCodeDescription", getShortFailedMessage()); sfs.putSingle("Identifier", identifier); + sfs.put("Global", global); if(expectedDataLength > -1) { sfs.put("ExpectedDataLength", expectedDataLength); } From 614a70ba320d2cbd846baa0ffd7a8a2f9c227049 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Sat, 3 Feb 2024 19:25:54 -0500 Subject: [PATCH 239/500] Apply sanity check for size There were no restraints on negative values or extremely large values of amountOfDataToCheckCompressionRatio. Add a less than zero and a max of 100 MiB check. --- src/freenet/node/Node.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index b29ef30c61b..db0b84c17fa 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -1603,6 +1603,12 @@ public Long get() { @Override public void set(Long amountOfDataToCheckCompressionRatio) { synchronized(Node.this) { + if (amountOfDataToCheckCompressionRatio < 0 || amountOfDataToCheckCompressionRatio > 100 * 1024 * 1024) { + Logger.normal(Node.class, "Amount of data to check for compression should be 100 MiB max" + + amountOfDataToCheckCompressionRatio); + return; + } + Node.this.amountOfDataToCheckCompressionRatio = amountOfDataToCheckCompressionRatio; } } From 8c222a28c13e17437fb78cb98356f58372140042 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Sun, 4 Feb 2024 22:53:22 -0500 Subject: [PATCH 240/500] Improve text of log message amountOfDataToCheckCompressionRatio log message was hard to read --- src/freenet/node/Node.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index db0b84c17fa..1ace836ffe1 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -1604,8 +1604,8 @@ public Long get() { public void set(Long amountOfDataToCheckCompressionRatio) { synchronized(Node.this) { if (amountOfDataToCheckCompressionRatio < 0 || amountOfDataToCheckCompressionRatio > 100 * 1024 * 1024) { - Logger.normal(Node.class, "Amount of data to check for compression should be 100 MiB max" - + amountOfDataToCheckCompressionRatio); + Logger.normal(Node.class, "Amount of data to check for compression should be 100 MiB max, " + + amountOfDataToCheckCompressionRatio + " bytes selected"); return; } From 4d76d68dab2cda64ec3dab51492f5141d06f929e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 5 Feb 2024 15:09:55 +0100 Subject: [PATCH 241/500] =?UTF-8?q?=E2=9C=85=20Add=20test=20for=20Global?= =?UTF-8?q?=20flag=20in=20GetFailed=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clients/fcp/GetFailedMessageTest.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/freenet/clients/fcp/GetFailedMessageTest.java diff --git a/test/freenet/clients/fcp/GetFailedMessageTest.java b/test/freenet/clients/fcp/GetFailedMessageTest.java new file mode 100644 index 00000000000..ca6211aaca3 --- /dev/null +++ b/test/freenet/clients/fcp/GetFailedMessageTest.java @@ -0,0 +1,28 @@ +package freenet.clients.fcp; + +import freenet.client.FetchException; +import org.junit.Test; + +import static freenet.client.FetchException.FetchExceptionMode.INTERNAL_ERROR; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.anyOf; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.nullValue; + +public class GetFailedMessageTest { + + @Test + public void getFailedMessageWithoutGlobalFlagDoesNotContainGlobalFlagInFieldSet() { + GetFailedMessage message = new GetFailedMessage(fetchException, "TestMessage", false); + assertThat(message.getFieldSet().get("Global"), anyOf(nullValue(), equalTo("false"))); + } + + @Test + public void getFailedMessageWithGlobalFlagContainsGlobalFlagInFieldSet() { + GetFailedMessage message = new GetFailedMessage(fetchException, "TestMessage", true); + assertThat(message.getFieldSet().get("Global"), equalTo("true")); + } + + private final FetchException fetchException = new FetchException(INTERNAL_ERROR); + +} From 760d5d32328aab6dd8d2756035bdbd2583e6bc3e Mon Sep 17 00:00:00 2001 From: Juiceman Date: Fri, 9 Feb 2024 13:38:36 -0500 Subject: [PATCH 242/500] Fix some spelling and typos Fix some spelling and typos, mostly in comments and JavaDocs --- src/freenet/client/async/BaseManifestPutter.java | 4 ++-- src/freenet/client/async/ClientPutter.java | 4 ++-- src/freenet/client/events/ClientEventProducer.java | 2 +- src/freenet/clients/fcp/ClientPutDiskDirMessage.java | 2 +- src/freenet/crypt/ChecksumChecker.java | 2 +- src/freenet/io/AddressIdentifier.java | 4 ++-- src/freenet/io/comm/AsyncMessageCallback.java | 2 +- src/freenet/io/xfer/BlockReceiver.java | 2 +- src/freenet/l10n/BaseL10n.java | 10 +++++----- .../store/caching/CachingFreenetStoreTracker.java | 2 +- src/freenet/support/io/BucketTools.java | 2 +- .../math/BootstrappingDecayingRunningAverage.java | 2 +- .../freenet/store/caching/CachingFreenetStoreTest.java | 2 +- test/freenet/support/Base64Test.java | 2 +- test/freenet/support/BitArrayTest.java | 2 +- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/freenet/client/async/BaseManifestPutter.java b/src/freenet/client/async/BaseManifestPutter.java index 062d5c7eb5d..fc2af9baae1 100644 --- a/src/freenet/client/async/BaseManifestPutter.java +++ b/src/freenet/client/async/BaseManifestPutter.java @@ -71,7 +71,7 @@ public abstract class BaseManifestPutter extends ManifestPutter { * ArchivePutHandler - wrapper for ContainerInserter * * Archives are not part of the site structure, they are used to group files that - * not fit into a container (for example a directory with brazilion files it) + * not fit into a container (for example a directory with a bazillion files in it) * Archives are always inserted as CHK, references to items in it * are normal redirects to CHK@blah,blub,AA/nameinarchive * @@ -326,7 +326,7 @@ public void onSuccess(ClientPutState state, ClientContext context) { } } - /** Placeholder for Matadata, don't run it! */ + /** Placeholder for Metadata, don't run it! */ private final class JokerPutHandler extends PutHandler { private static final long serialVersionUID = 1L; diff --git a/src/freenet/client/async/ClientPutter.java b/src/freenet/client/async/ClientPutter.java index 686a5371805..68fcb2be038 100644 --- a/src/freenet/client/async/ClientPutter.java +++ b/src/freenet/client/async/ClientPutter.java @@ -54,7 +54,7 @@ public class ClientPutter extends BaseClientPutter implements PutCompletionCallb /** The final URI for the data. */ private FreenetURI uri; private final byte[] overrideSplitfileCrypto; - /** Random or overriden splitfile cryptokey. Valid after start(). */ + /** Random or overridden splitfile cryptokey. Valid after start(). */ private byte[] cryptoKey; /** When positive, means we will return metadata rather than a URI, once the * metadata is under this length. If it is too short it is still possible to @@ -84,7 +84,7 @@ public void shouldUpdate(){ * @param isMetadata * @param targetFilename If set, create a one-file manifest containing this filename pointing to this file. * @param binaryBlob - * @param context The client object for purposs of round-robin client balancing. + * @param context The client object for purposes of round-robin client balancing. * @param overrideSplitfileCrypto * @param metadataThreshold */ diff --git a/src/freenet/client/events/ClientEventProducer.java b/src/freenet/client/events/ClientEventProducer.java index 86bfeac3442..d12484829e6 100644 --- a/src/freenet/client/events/ClientEventProducer.java +++ b/src/freenet/client/events/ClientEventProducer.java @@ -27,7 +27,7 @@ public interface ClientEventProducer { void addEventListener(ClientEventListener cel); /** - * Removes an EventListener that will no loger receive events + * Removes an EventListener that will no longer receive events * produced by the implementing object. * @param cel The ClientEventListener to remove. * @return true if a Listener was removed, false otherwise. diff --git a/src/freenet/clients/fcp/ClientPutDiskDirMessage.java b/src/freenet/clients/fcp/ClientPutDiskDirMessage.java index 18ab4c2015c..d303807c389 100644 --- a/src/freenet/clients/fcp/ClientPutDiskDirMessage.java +++ b/src/freenet/clients/fcp/ClientPutDiskDirMessage.java @@ -93,7 +93,7 @@ private HashMap makeBucketsByName(File thisdir, String prefix) t for(int i = 0 ; i < filelist.length ; i++) { if(filelist[i].isHidden() && !includeHiddenFiles) continue; // Skip unreadable files and dirs - // Skip files nonexistant (dangling symlinks) - check last + // Skip files nonexistent (dangling symlinks) - check last if (filelist[i].canRead() && filelist[i].exists()) { if (filelist[i].isFile()) { File f = filelist[i]; diff --git a/src/freenet/crypt/ChecksumChecker.java b/src/freenet/crypt/ChecksumChecker.java index e74595a5385..c93e4a1bbe3 100644 --- a/src/freenet/crypt/ChecksumChecker.java +++ b/src/freenet/crypt/ChecksumChecker.java @@ -65,7 +65,7 @@ public byte[] generateChecksum(byte[] bufToChecksum) { public abstract void copyAndStripChecksum(InputStream is, OutputStream os, long length) throws IOException, ChecksumFailedException; /** Read from disk and verify the checksum that follows the data. If it throws, the buffer will - * be zero'ed out. */ + * be zeroed out. */ public abstract void readAndChecksum(DataInput is, byte[] buf, int offset, int length) throws IOException, ChecksumFailedException; public InputStream checksumReaderWithLength(InputStream dis, BucketFactory bf, long maxLength) diff --git a/src/freenet/io/AddressIdentifier.java b/src/freenet/io/AddressIdentifier.java index 4573772cd2e..56102cabd37 100644 --- a/src/freenet/io/AddressIdentifier.java +++ b/src/freenet/io/AddressIdentifier.java @@ -52,7 +52,7 @@ public enum AddressType { } /** - * Tries to detemine the address type of the given address. + * Tries to determine the address type of the given address. * * REDFLAG: IPv6 percent scope ID's could cause problems with URI's. * Should not be exploitable as we don't do anything important with @@ -71,7 +71,7 @@ public static AddressType getAddressType(String address) { } /** - * Tries to detemine the address type of the given address. + * Tries to determine the address type of the given address. * * @param address * The address to determine the type of diff --git a/src/freenet/io/comm/AsyncMessageCallback.java b/src/freenet/io/comm/AsyncMessageCallback.java index 2af1e75f392..30ae252992f 100644 --- a/src/freenet/io/comm/AsyncMessageCallback.java +++ b/src/freenet/io/comm/AsyncMessageCallback.java @@ -9,7 +9,7 @@ public interface AsyncMessageCallback { /** Called when the packet actually leaves the node. - * This DOES NOT MEAN that it has been successfully recieved + * This DOES NOT MEAN that it has been successfully received * by the partner node (on a lossy transport). */ public void sent(); diff --git a/src/freenet/io/xfer/BlockReceiver.java b/src/freenet/io/xfer/BlockReceiver.java index b37ab78845b..d16c1d9a33a 100644 --- a/src/freenet/io/xfer/BlockReceiver.java +++ b/src/freenet/io/xfer/BlockReceiver.java @@ -550,7 +550,7 @@ private void maybeResetDiscardFilter() { /** * Used to discard leftover messages, usually just packetTransmit and allSent. - * allSent, is quite common, as the receive() routine usually quits immeadiately on receiving all packets. + * allSent, is quite common, as the receive() routine usually quits immediately on receiving all packets. * packetTransmit is less common, when receive() requested what it thought was a missing packet, only reordered. */ @Override diff --git a/src/freenet/l10n/BaseL10n.java b/src/freenet/l10n/BaseL10n.java index 0cb4836bda6..92fcba34889 100644 --- a/src/freenet/l10n/BaseL10n.java +++ b/src/freenet/l10n/BaseL10n.java @@ -31,7 +31,7 @@ * Note : do not use this class *as is*, use NodeL10n.getBase() or * PluginL10n.getBase(). * - * Note : this class also supports using/saving/editing overriden translations. + * Note : this class also supports using/saving/editing overridden translations. * @author Florent Daignière <nextgens@freenetproject.org> * @author Artefact2 */ @@ -246,7 +246,7 @@ public BaseL10n(String l10nFilesBasePath, String l10nFilesMask, String l10nOverr * Note : you shouldn't have to run this yourself. Use PluginL10n or NodeL10n. * @param l10nFilesBasePath Base path of the l10n files, ex. "com/mycorp/myproject/l10n" * @param l10nFilesMask Mask of the l10n files, ex. "messages_${lang}.l10n" - * @param l10nOverrideFilesMask Same as l10nFilesMask, but for overriden messages. + * @param l10nOverrideFilesMask Same as l10nFilesMask, but for overridden messages. * @param lang Language to use. * @param cl ClassLoader to use. */ @@ -376,7 +376,7 @@ public LANGUAGE getSelectedLanguage() { } /** - * Returns true if a key is overriden. + * Returns true if a key is overridden. * @param key Key to check override status * @return boolean */ @@ -417,7 +417,7 @@ public void setOverride(String key, String value) { } /** - * Save the SimpleFieldSet of overriden keys in a file. + * Save the SimpleFieldSet of overridden keys in a file. */ private void saveTranslationFile() { FileOutputStream fos = null; @@ -451,7 +451,7 @@ public SimpleFieldSet getCurrentLanguageTranslation() { } /** - * Get a copy of the currently used SimpleFieldSet (overriden messages). + * Get a copy of the currently used SimpleFieldSet (overridden messages). * @return SimpleFieldSet */ public SimpleFieldSet getOverrideForCurrentLanguageTranslation() { diff --git a/src/freenet/store/caching/CachingFreenetStoreTracker.java b/src/freenet/store/caching/CachingFreenetStoreTracker.java index b40a8035a02..0eac30ad203 100644 --- a/src/freenet/store/caching/CachingFreenetStoreTracker.java +++ b/src/freenet/store/caching/CachingFreenetStoreTracker.java @@ -50,7 +50,7 @@ public CachingFreenetStoreTracker(long maxSize, long period, Ticker ticker) { this.ticker = ticker; } - /** register a CachingFreenetStore to be called when we get full or to flush all after a setted period. */ + /** register a CachingFreenetStore to be called when we get full or to flush all after a set period. */ public void registerCachingFS(CachingFreenetStore fs) { synchronized (cachingStores) { cachingStores.add(fs); diff --git a/src/freenet/support/io/BucketTools.java b/src/freenet/support/io/BucketTools.java index 04af25016ed..8277deacb2f 100644 --- a/src/freenet/support/io/BucketTools.java +++ b/src/freenet/support/io/BucketTools.java @@ -438,7 +438,7 @@ public static Bucket[] split(Bucket origData, int splitSize, BucketFactory bf, b * @param bf * @param length * - * @return the paded bucket + * @return the padded bucket */ public static Bucket pad(Bucket oldBucket, int blockLength, BucketFactory bf, int length) throws IOException { byte[] hash = BucketTools.hash(oldBucket); diff --git a/src/freenet/support/math/BootstrappingDecayingRunningAverage.java b/src/freenet/support/math/BootstrappingDecayingRunningAverage.java index 29aebe0e5b0..8017edf65f0 100644 --- a/src/freenet/support/math/BootstrappingDecayingRunningAverage.java +++ b/src/freenet/support/math/BootstrappingDecayingRunningAverage.java @@ -55,7 +55,7 @@ public void shouldUpdate(){ * @param min * minimum value of input data * @param max - * maxumum value of input data + * maximum value of input data * @param maxReports * number of reports before bootstrapping period ends and decay begins * @param fs diff --git a/test/freenet/store/caching/CachingFreenetStoreTest.java b/test/freenet/store/caching/CachingFreenetStoreTest.java index 9ff75c5d1e7..8a3511bde22 100644 --- a/test/freenet/store/caching/CachingFreenetStoreTest.java +++ b/test/freenet/store/caching/CachingFreenetStoreTest.java @@ -199,7 +199,7 @@ public void waitForZero() throws InterruptedException { /* * Check that if we are going over the maximum size, the caching store will call - * pushAll and all blocks is in the *undelying* store and the size is 0 + * pushAll and all blocks is in the *underlying* store and the size is 0 */ @Test public void testOverMaximumSize() diff --git a/test/freenet/support/Base64Test.java b/test/freenet/support/Base64Test.java index 2fb4c023c43..7dfc9d0516f 100644 --- a/test/freenet/support/Base64Test.java +++ b/test/freenet/support/Base64Test.java @@ -152,7 +152,7 @@ public void testEncodePadding() { */ @Test public void testIllegalBaseCharacter() { -// TODO: check many other possibile cases! +// TODO: check many other possible cases! String illegalCharString = "abcd=fghilmn"; try { Base64.decode(illegalCharString); diff --git a/test/freenet/support/BitArrayTest.java b/test/freenet/support/BitArrayTest.java index 4cb486fbb09..1d864942698 100644 --- a/test/freenet/support/BitArrayTest.java +++ b/test/freenet/support/BitArrayTest.java @@ -60,7 +60,7 @@ private String createAllOneString(int stringSize, String toRepeat) { * Tests BitArray(int) constructor * and verifies if the instance is * well created (all values must be - * readables and false, and the length + * readable and false, and the length * has to be correct) */ @Test From a38a797d6bf7765bf0b9051759239110aa29c36d Mon Sep 17 00:00:00 2001 From: Juiceman Date: Fri, 9 Feb 2024 11:37:21 -0500 Subject: [PATCH 243/500] Capitalize L in literal longs L should be capitalized for to avoid confusion e.g. 5l vs 5L --- src/freenet/clients/http/geoip/IPConverter.java | 10 +++++----- .../clients/http/wizardsteps/DATASTORE_SIZE.java | 16 ++++++++-------- src/freenet/node/NewPacketFormat.java | 10 +++++----- src/freenet/support/Fields.java | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/freenet/clients/http/geoip/IPConverter.java b/src/freenet/clients/http/geoip/IPConverter.java index 91ee8293b9a..84e34cbb5f8 100644 --- a/src/freenet/clients/http/geoip/IPConverter.java +++ b/src/freenet/clients/http/geoip/IPConverter.java @@ -345,10 +345,10 @@ public Country locateIP(byte[] ip) { } if(ip.length != 4) return null; long longip = ( - ((ip[0] << 24) & 0xff000000l) | - ((ip[1] << 16) & 0x00ff0000l) | - ((ip[2] << 8) & 0x0000ff00l) | - ( ip[3] & 0x000000ffl)); + ((ip[0] << 24) & 0xff000000L) | + ((ip[1] << 16) & 0x00ff0000L) | + ((ip[2] << 8) & 0x0000ff00L) | + ( ip[3] & 0x000000ffL)); return locateIP(longip); } @@ -368,7 +368,7 @@ private Country locateIP(long longip) { int mid; while ((mid = (last - start) / 2) > 0) { int midpos = mid + start; - long midip = ips[midpos] & 0xffffffffl; + long midip = ips[midpos] & 0xffffffffL; if (longip >= midip) { last = midpos; } else { diff --git a/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java b/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java index 9e15580a9cf..c75725248c1 100644 --- a/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java +++ b/src/freenet/clients/http/wizardsteps/DATASTORE_SIZE.java @@ -71,7 +71,7 @@ public void getStep(HTTPRequest request, PageHelper helper) { } // We always allow at least 1GB result.addChild("option", "value", "1G", "1 GiB"); - if(maxSize >= 2l*1024*1024*1024) { + if(maxSize >= 2L*1024*1024*1024) { if(autodetectedSize != -1 || !sizeOption.isDefault()) { result.addChild("option", "value", "2G", "2 GiB"); } else { @@ -80,13 +80,13 @@ public void getStep(HTTPRequest request, PageHelper helper) { new String[] { "2G", "on" }, "2GiB"); } } - if(maxSize >= 3l*1024*1024*1024) result.addChild("option", "value", "3G", "3 GiB"); - if(maxSize >= 5l*1024*1024*1024) result.addChild("option", "value", "5G", "5 GiB"); - if(maxSize >= 10l*1024*1024*1024) result.addChild("option", "value", "10G", "10 GiB"); - if(maxSize >= 20l*1024*1024*1024) result.addChild("option", "value", "20G", "20 GiB"); - if(maxSize >= 50l*1024*1024*1024) result.addChild("option", "value", "50G", "50 GiB"); - if(maxSize >= 200l*1024*1024*1024) result.addChild("option", "value", "200G", "200GiB"); - if(maxSize >= 500l*1024*1024*1024) result.addChild("option", "value", "500G", "500GiB"); + if(maxSize >= 3L*1024*1024*1024) result.addChild("option", "value", "3G", "3 GiB"); + if(maxSize >= 5L*1024*1024*1024) result.addChild("option", "value", "5G", "5 GiB"); + if(maxSize >= 10L*1024*1024*1024) result.addChild("option", "value", "10G", "10 GiB"); + if(maxSize >= 20L*1024*1024*1024) result.addChild("option", "value", "20G", "20 GiB"); + if(maxSize >= 50L*1024*1024*1024) result.addChild("option", "value", "50G", "50 GiB"); + if(maxSize >= 200L*1024*1024*1024) result.addChild("option", "value", "200G", "200GiB"); + if(maxSize >= 500L*1024*1024*1024) result.addChild("option", "value", "500G", "500GiB"); //Put buttons below dropdown. HTMLNode below = bandwidthForm.addChild("div"); diff --git a/src/freenet/node/NewPacketFormat.java b/src/freenet/node/NewPacketFormat.java index 5c15940c12f..181653f5a61 100644 --- a/src/freenet/node/NewPacketFormat.java +++ b/src/freenet/node/NewPacketFormat.java @@ -40,7 +40,7 @@ public class NewPacketFormat implements PacketFormat { private static final int MAX_RECEIVE_BUFFER_SIZE = 256 * 1024; private static final int MSG_WINDOW_SIZE = 65536; private static final int NUM_MESSAGE_IDS = 268435456; - static final long NUM_SEQNUMS = 2147483648l; + static final long NUM_SEQNUMS = 2147483648L; private static final long MAX_MSGID_BLOCK_TIME = MINUTES.toMillis(10); private static final int MAX_ACKS = 500; static boolean DO_KEEPALIVES = true; @@ -334,7 +334,7 @@ private NPFPacket tryDecipherPacket(byte[] buf, int offset, int length, SessionK highestReceivedSeqNum = keyContext.highestReceivedSeqNum; } // The entry for the highest received sequence number is kept in the middle of the list - int oldHighestReceived = (int) ((0l + keyContext.watchListOffset + (keyContext.seqNumWatchList.length / 2)) % NUM_SEQNUMS); + int oldHighestReceived = (int) ((0L + keyContext.watchListOffset + (keyContext.seqNumWatchList.length / 2)) % NUM_SEQNUMS); if(seqNumGreaterThan(highestReceivedSeqNum, oldHighestReceived, 31)) { int moveBy; if(highestReceivedSeqNum > oldHighestReceived) { @@ -352,14 +352,14 @@ private NPFPacket tryDecipherPacket(byte[] buf, int offset, int length, SessionK if(logDEBUG) Logger.debug(this, "Moving watchlist pointer by " + moveBy); } - int seqNum = (int) ((0l + keyContext.watchListOffset + keyContext.seqNumWatchList.length) % NUM_SEQNUMS); + int seqNum = (int) ((0L + keyContext.watchListOffset + keyContext.seqNumWatchList.length) % NUM_SEQNUMS); for(int i = keyContext.watchListPointer; i < (keyContext.watchListPointer + moveBy); i++) { keyContext.seqNumWatchList[i % keyContext.seqNumWatchList.length] = encryptSequenceNumber(seqNum++, sessionKey); if(seqNum < 0) seqNum = 0; } keyContext.watchListPointer = (keyContext.watchListPointer + moveBy) % keyContext.seqNumWatchList.length; - keyContext.watchListOffset = (int) ((0l + keyContext.watchListOffset + moveBy) % NUM_SEQNUMS); + keyContext.watchListOffset = (int) ((0L + keyContext.watchListOffset + moveBy) % NUM_SEQNUMS); } for(int i = 0; i < keyContext.seqNumWatchList.length; i++) { @@ -370,7 +370,7 @@ private NPFPacket tryDecipherPacket(byte[] buf, int offset, int length, SessionK keyContext.seqNumWatchList[index].length)) continue; - int sequenceNumber = (int) ((0l + keyContext.watchListOffset + i) % NUM_SEQNUMS); + int sequenceNumber = (int) ((0L + keyContext.watchListOffset + i) % NUM_SEQNUMS); if(logDEBUG) Logger.debug(this, "Received packet matches sequence number " + sequenceNumber); NPFPacket p = decipherFromSeqnum(buf, offset, length, sessionKey, sequenceNumber); if(p != null) { diff --git a/src/freenet/support/Fields.java b/src/freenet/support/Fields.java index 3bfec0afb4f..9486c89e288 100644 --- a/src/freenet/support/Fields.java +++ b/src/freenet/support/Fields.java @@ -76,12 +76,12 @@ public void shouldUpdate(){ 'z' }; private static final long[] MULTIPLES = { - 1000, 1l << 10, - 1000 * 1000, 1l << 20, - 1000l * 1000l * 1000l, 1l << 30, - 1000l * 1000l * 1000l * 1000l, 1l << 40, - 1000l * 1000l * 1000l * 1000l * 1000, 1l << 50, - 1000l * 1000l * 1000l * 1000l * 1000l * 1000l, 1l << 60 + 1000, 1L << 10, + 1000 * 1000, 1L << 20, + 1000L * 1000L * 1000L, 1L << 30, + 1000L * 1000L * 1000L * 1000L, 1L << 40, + 1000L * 1000L * 1000L * 1000L * 1000, 1L << 50, + 1000L * 1000L * 1000L * 1000L * 1000L * 1000L, 1L << 60 }; private static final String[] MULTIPLES_2 = { "k", "K", "m", "M", "g", "G", "t", "T", "p", "P", "e", "E" From 1d99b9da91b8b3ed1becc1a63b2eb9dc25e32ab8 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Fri, 9 Feb 2024 11:52:16 -0500 Subject: [PATCH 244/500] Fix typo and remove extra unary operator Remove extra unary operator --- src/freenet/support/io/NativeThread.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/support/io/NativeThread.java b/src/freenet/support/io/NativeThread.java index 80022f7a38d..f76eb8730d0 100644 --- a/src/freenet/support/io/NativeThread.java +++ b/src/freenet/support/io/NativeThread.java @@ -194,7 +194,7 @@ private boolean setNativePriority(int prio) { throw new IllegalStateException("You're trying to set a thread priority" + " above the current value!! It's not possible if you aren't root" + " and shouldn't ever occur in our code. (asked="+prio+':'+linuxPriority+" currentMax="+ - +currentPriority+':'+NATIVE_PRIORITY_BASE+") SHOUDLN'T HAPPEN, please report!"); + currentPriority+':'+NATIVE_PRIORITY_BASE+") SHOULD NOT HAPPEN, please report!"); Logger.minor(this, "Setting native priority to "+linuxPriority+" (base="+NATIVE_PRIORITY_BASE+") for "+this); return (LinuxNativeThread.setpriority(0, 0, linuxPriority) > -1 ? true : false); } From 91e3b5f146726de01af3a488d3739edc5900e8b3 Mon Sep 17 00:00:00 2001 From: Juiceman Date: Sat, 10 Feb 2024 15:12:50 -0500 Subject: [PATCH 245/500] Replace deprecated tag --- src/freenet/clients/http/staticfiles/freenetjs/hosted.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/freenet/clients/http/staticfiles/freenetjs/hosted.html b/src/freenet/clients/http/staticfiles/freenetjs/hosted.html index f6c5d82329a..824d230e8fa 100644 --- a/src/freenet/clients/http/staticfiles/freenetjs/hosted.html +++ b/src/freenet/clients/http/staticfiles/freenetjs/hosted.html @@ -322,7 +322,7 @@ window.__gwt_module_id = 0; -This html file is for Development Mode support. +This html file is for Development Mode support.