Skip to content

Commit

Permalink
Merge branch 'master' into docker-multiarch
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanluc162 authored Jan 28, 2023
2 parents ac4daeb + 9fd31d0 commit aac8f21
Show file tree
Hide file tree
Showing 66 changed files with 978 additions and 265 deletions.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test:ant:
- echo junit.home=/usr/share/java >> override.properties
- echo hamcrest.home=/usr/share/java >> override.properties
- echo mockito.home=/usr/share/java >> override.properties
- echo build.built-by=GitHub Actions >> override.properties
script:
- ant test
only:
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ WORKDIR /tmp/build
COPY . .

RUN apk add --virtual build-base gettext tar bzip2 apache-ant openjdk17 \
&& echo "build.built-by=Docker" >> override.properties \

&& ant preppkg-linux-only \
&& rm -rf pkg-temp/osid pkg-temp/lib/wrapper pkg-temp/lib/wrapper.* \
&& apk del build-base gettext tar bzip2 apache-ant openjdk17

FROM alpine:latest
ENV APP_HOME="/i2p"

RUN apk add openjdk17-jre
RUN apk add openjdk17-jre ttf-dejavu

WORKDIR ${APP_HOME}
COPY --from=builder /tmp/build/pkg-temp .

Expand Down
26 changes: 17 additions & 9 deletions apps/addressbook/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,36 @@
</jar>
</target>

<!-- actually the jar -->
<target name="warUpToDate">
<uptodate property="war.uptodate" targetfile="${dist}/${war}">
<srcfiles dir= "." includes="${build}/**/*.class, web.xml"/>
<uptodate property="war.uptodate" targetfile="${dist}/${jar}">
<srcfiles dir= "." includes="${build}/**/*.class"/>
</uptodate>
<condition property="shouldListChanges" >
<and>
<not>
<isset property="war.uptodate" />
</not>
<isset property="mtn.available" />
<isset property="git.available" />
</and>
</condition>
</target>

<target name="changes" depends="warUpToDate" if="shouldListChanges" >
<exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="list" />
<arg value="changed" />
<arg value="." />
</exec>
<exec executable="git" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="status" />
<arg value="-s" />
<arg value="--porcelain" />
<arg value="-uno" />
<arg value="." />
</exec>
<!-- trim flags -->
<exec executable="sed" inputstring="${workspace.changes}" outputproperty="workspace.changes.sed" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-e" />
<arg value="s/^[MTADRCU ]*//" />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<exec executable="tr" inputstring="${workspace.changes.sed}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
Expand Down
31 changes: 19 additions & 12 deletions apps/desktopgui/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,24 @@
</target>

<target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
<exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="list" />
<arg value="changed" />
<arg value="." />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
</exec>
<exec executable="git" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="status" />
<arg value="-s" />
<arg value="--porcelain" />
<arg value="-uno" />
<arg value="." />
</exec>
<!-- trim flags -->
<exec executable="sed" inputstring="${workspace.changes}" outputproperty="workspace.changes.sed" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-e" />
<arg value="s/^[MTADRCU ]*//" />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes.sed}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
</exec>
</target>

<target name="jar" depends="compile, bundle, listChangedFiles" unless="jar.uptodate" >
Expand Down Expand Up @@ -108,7 +115,7 @@
<not>
<isset property="jar.uptodate" />
</not>
<isset property="mtn.available" />
<isset property="git.available" />
</and>
</condition>
</target>
Expand Down
28 changes: 25 additions & 3 deletions apps/i2pcontrol/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,29 @@
</javac>
</target>

<target name="jar" depends="compile">
<target name="listChangedFiles" if="git.available" >
<exec executable="git" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="status" />
<arg value="-s" />
<arg value="--porcelain" />
<arg value="-uno" />
<arg value="." />
<arg value="../resources" />
</exec>
<!-- trim flags -->
<exec executable="sed" inputstring="${workspace.changes}" outputproperty="workspace.changes.sed" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-e" />
<arg value="s/^[MTADRCU ]*//" />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes.sed}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
</exec>
</target>

<target name="jar" depends="compile, listChangedFiles">
<!-- set if unset -->
<property name="workspace.changes.tr" value="" />
<jar destfile="build/i2pcontrol.jar" basedir="./build/obj" includes="**/*.class" >
Expand All @@ -108,7 +130,7 @@
</jar>
</target>

<target name="socketJar" depends="compileSocketJar">
<target name="socketJar" depends="compileSocketJar, listChangedFiles">
<!-- set if unset -->
<property name="workspace.changes.tr" value="" />
<jar destfile="build/i2pcontrol.jar" basedir="./build/obj" includes="**/*.class" >
Expand All @@ -124,7 +146,7 @@
</jar>
</target>

<target name="war" depends="compile" >
<target name="war" depends="compile, listChangedFiles" >
<!-- set if unset -->
<property name="workspace.changes.tr" value="" />
<war destfile="build/jsonrpc.war" webxml="web.xml" >
Expand Down
17 changes: 12 additions & 5 deletions apps/i2psnark/java/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,20 @@
</target>

<target name="listChangedFiles" depends="jarUpToDate" if="shouldListChanges" >
<exec executable="mtn" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="list" />
<arg value="changed" />
<exec executable="git" outputproperty="workspace.changes" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="status" />
<arg value="-s" />
<arg value="--porcelain" />
<arg value="-uno" />
<arg value=".." />
</exec>
<!-- trim flags -->
<exec executable="sed" inputstring="${workspace.changes}" outputproperty="workspace.changes.sed" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-e" />
<arg value="s/^[MTADRCU ]*//" />
</exec>
<!-- \n in an attribute value generates an invalid manifest -->
<exec executable="tr" inputstring="${workspace.changes}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<exec executable="tr" inputstring="${workspace.changes.sed}" outputproperty="workspace.changes.tr" errorproperty="mtn.error2" failifexecutionfails="false" >
<arg value="-s" />
<arg value="[:space:]" />
<arg value="," />
Expand Down Expand Up @@ -111,7 +118,7 @@
<not>
<isset property="war.uptodate" />
</not>
<isset property="mtn.available" />
<isset property="git.available" />
</and>
</condition>
</target>
Expand Down
6 changes: 6 additions & 0 deletions apps/i2psnark/java/src/org/klomp/snark/I2PSnarkUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class I2PSnarkUtil implements DisconnectListener {
private DHT _dht;
private long _startedTime;
private final DisconnectListener _discon;
private int _maxFilesPerTorrent = SnarkManager.DEFAULT_MAX_FILES_PER_TORRENT;

private static final int EEPGET_CONNECT_TIMEOUT = 45*1000;
private static final int EEPGET_CONNECT_TIMEOUT_SHORT = 5*1000;
Expand Down Expand Up @@ -242,6 +243,11 @@ public Map<String, String> getI2CPOptions() {
/** @since 0.9.1 */
public File getTempDir() { return _tmpDir; }

/** @since 0.9.58 */
public int getMaxFilesPerTorrent() { return _maxFilesPerTorrent; }
/** @since 0.9.58 */
public void setMaxFilesPerTorrent(int max) { _maxFilesPerTorrent = Math.max(max, 1); }

/**
* Connect to the router, if we aren't already
*/
Expand Down
16 changes: 10 additions & 6 deletions apps/i2psnark/java/src/org/klomp/snark/SnarkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public class SnarkManager implements CompleteListener, ClientApp, DisconnectList
private static final String PROP_META_ACTIVITY = "activity";

private static final String CONFIG_FILE_SUFFIX = ".config";
private static final String CONFIG_FILE = "i2psnark" + CONFIG_FILE_SUFFIX;
public static final String CONFIG_FILE = "i2psnark" + CONFIG_FILE_SUFFIX;
private static final String COMMENT_FILE_SUFFIX = ".comments.txt.gz";
public static final String PROP_FILES_PUBLIC = "i2psnark.filesPublic";
public static final String PROP_OLD_AUTO_START = "i2snark.autoStart"; // oops
Expand Down Expand Up @@ -164,13 +164,16 @@ public class SnarkManager implements CompleteListener, ClientApp, DisconnectList
private static final String PROP_COMMENTS = "i2psnark.comments";
/** @since 0.9.31 */
private static final String PROP_COMMENTS_NAME = "i2psnark.commentsName";
/** @since 0.9.58 */
public static final String PROP_MAX_FILES_PER_TORRENT = "i2psnark.maxFilesPerTorrent";

public static final int MIN_UP_BW = 10;
public static final int DEFAULT_MAX_UP_BW = 25;
public static final int DEFAULT_STARTUP_DELAY = 3;
public static final int DEFAULT_REFRESH_DELAY_SECS = 15;
private static final int DEFAULT_PAGE_SIZE = 50;
public static final int DEFAULT_TUNNEL_QUANTITY = 3;
public static final int DEFAULT_MAX_FILES_PER_TORRENT = 2000;
public static final String CONFIG_DIR_SUFFIX = ".d";
private static final String SUBDIR_PREFIX = "s";
private static final String B64 = Base64.ALPHABET_I2P;
Expand Down Expand Up @@ -1000,6 +1003,7 @@ private void updateConfig() {
// _util.setProxy(eepHost, eepPort);
_util.setMaxUploaders(getInt(PROP_UPLOADERS_TOTAL, Snark.MAX_TOTAL_UPLOADERS));
_util.setMaxUpBW(getInt(PROP_UPBW_MAX, DEFAULT_MAX_UP_BW));
_util.setMaxFilesPerTorrent(getInt(PROP_MAX_FILES_PER_TORRENT, DEFAULT_MAX_FILES_PER_TORRENT));
_util.setStartupDelay(getInt(PROP_STARTUP_DELAY, DEFAULT_STARTUP_DELAY));
_util.setFilesPublic(areFilesPublic());
_util.setOpenTrackers(getListConfig(PROP_OPENTRACKERS, DEFAULT_OPENTRACKERS));
Expand Down Expand Up @@ -1479,9 +1483,6 @@ public void saveConfig() {
}
}

/** hardcoded for sanity. perhaps this should be customizable, for people who increase their ulimit, etc. */
public static final int MAX_FILES_PER_TORRENT = 2000;

/**
* Set of canonical .torrent filenames that we are dealing with.
* An unsynchronized copy.
Expand Down Expand Up @@ -2450,8 +2451,11 @@ public void removeMagnetStatus(byte[] ih) {
*/
private String validateTorrent(MetaInfo info) {
List<List<String>> files = info.getFiles();
if ( (files != null) && (files.size() > MAX_FILES_PER_TORRENT) ) {
return _t("Too many files in \"{0}\" ({1})!", info.getName(), files.size());
if (files != null && files.size() > _util.getMaxFilesPerTorrent()) {
return _t("Too many files in \"{0}\" ({1})!", info.getName(), files.size()) +
" - limit is " + _util.getMaxFilesPerTorrent() + ", zip them or set " +
PROP_MAX_FILES_PER_TORRENT + '=' + files.size() + " in " +
_configFile.getAbsolutePath() + " and restart";
} else if ( (files == null) && (info.getName().endsWith(".torrent")) ) {
return _t("Torrent file \"{0}\" cannot end in \".torrent\"!", info.getName());
} else if (info.getPieces() <= 0) {
Expand Down
8 changes: 6 additions & 2 deletions apps/i2psnark/java/src/org/klomp/snark/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,13 @@ private List<TorrentFile> getFiles(File base) throws IOException
* @throws IOException if too many total files
*/
private void addFiles(List<File> l, File f) throws IOException {
int max = _util.getMaxFilesPerTorrent();
if (!f.isDirectory()) {
if (l.size() >= SnarkManager.MAX_FILES_PER_TORRENT)
throw new IOException("Too many files, limit is " + SnarkManager.MAX_FILES_PER_TORRENT + ", zip them?");
if (l.size() >= max)
throw new IOException(_util.getString("Too many files in \"{0}\" ({1})!", metainfo.getName(), l.size()) +
" - limit is " + max + ", zip them or set " +
SnarkManager.PROP_MAX_FILES_PER_TORRENT + '=' + l.size() + " in " +
SnarkManager.CONFIG_FILE + " and restart");
l.add(f);
} else {
File[] files = f.listFiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ else if (method.equals("POST"))
out.write("<script src=\".resources/js/configui.js?" + CoreVersion.VERSION + "\" type=\"text/javascript\"></script>\n");
} else {
delay = _manager.getRefreshDelaySeconds();
if (delay > 0) {
// init for search even if refresh disabled
//if (delay > 0) {
String jsPfx = _context.isRouterContext() ? "" : ".resources";
String downMsg = _context.isRouterContext() ? _t("Router is down") : _t("I2PSnark has stopped");
// fallback to metarefresh when javascript is disabled
Expand All @@ -337,7 +338,7 @@ else if (method.equals("POST"))
"var ajaxDelay = " + (delay * 1000) + ";\n" +
"</script>\n" +
"<script src=\".resources/js/initajax.js?" + CoreVersion.VERSION + "\" type=\"text/javascript\"></script>\n");
}
//}
out.write("<script nonce=\"" + cspNonce + "\" type=\"text/javascript\">\n" +
"var deleteMessage1 = \"" + _t("Are you sure you want to delete the file \\''{0}\\'' (downloaded data will not be deleted) ?") + "\";\n" +
"var deleteMessage2 = \"" + _t("Are you sure you want to delete the torrent \\''{0}\\'' and all downloaded data?") + "\";\n" +
Expand Down Expand Up @@ -394,7 +395,7 @@ else if (method.equals("POST"))
if (search != null)
out.write(" value=\"" + DataHelper.escapeHTML(search) + '"');
out.write(">" +
"<input type=\"reset\" class=\"cancel\" id=\"searchcancel\" value=\"\">" +
"<a class=\"cancel\" id=\"searchcancel\" href=\"" + _contextPath + "/\"></a>" +
"</form>\n");
}
}
Expand Down
5 changes: 3 additions & 2 deletions apps/i2psnark/launch-i2psnark
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ raiseopenfilesulimit() {

raiseopenfilesulimit

I2P="."
java $JAVA_OPTS -jar "$I2P/i2psnark.jar"
I2P="`dirname $0`"
cd "$I2P"
java $JAVA_OPTS -jar i2psnark.jar
4 changes: 3 additions & 1 deletion apps/i2psnark/resources/js/initajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ function requestAjax2(refreshtime) {
}

function initAjax() {
setTimeout(requestAjax1, ajaxDelay);
if (ajaxDelay > 0) {
setTimeout(requestAjax1, ajaxDelay);
}
}

document.addEventListener("DOMContentLoaded", function() {
Expand Down
17 changes: 16 additions & 1 deletion apps/i2psnark/resources/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,32 @@ function initSearch()
var sch = document.getElementById("search");
if (sch != null) {
var box = document.getElementById("searchbox");
sch.addEventListener("reset", function(event) {
var cxl = document.getElementById("searchcancel");
cxl.addEventListener("click", function(event) {
if (box.value !== "") {
box.value = "";
requestAjax2(-1);
}
cxl.classList.add("disabled");
event.preventDefault();
});

box.addEventListener("input", function(event) {
if (box.value !== "") {
cxl.classList.remove("disabled");
} else {
cxl.classList.add("disabled");
}
requestAjax2(-1);
});

if (box.value !== "") {
cxl.classList.remove("disabled");
} else {
cxl.classList.add("disabled");
}
// so we don't get the link popup
cxl.removeAttribute("href");
}
}

Expand Down
Loading

0 comments on commit aac8f21

Please sign in to comment.