4 Commits

Author SHA1 Message Date
b472f63f17 Fix mistake in BUILD.txt 2020-10-15 01:01:30 +00:00
ad42cbe99b Add detailed instructions to build the plugin in BUILD.txt, known to build with from both the mtn and git mirrors 2020-10-14 22:57:18 +00:00
zzz
0c33a94f14 drop JSON license, no longer bundled 2020-08-23 14:31:41 +00:00
zzz
5b04a9cf40 0.6
Disable pack200
Update makeplugin.sh script
2020-06-08 12:50:11 +00:00
6 changed files with 112 additions and 197 deletions

65
BUILD.txt Normal file
View File

@ -0,0 +1,65 @@
Setting up a build environment for I2PSnark-RPC
===============================================
These build instructions seem to work with both git and mtn.
1. You can build I2PSnark-RPC using either the packages that come with
an I2P installation or with packages from the I2P code.
If you have an existing I2P installation and want to use it, you should set
the I2P environment variable to point to your I2P Installation. If you
installed I2P via the .jar, this will be $HOME/i2p. On Apple, the I2P
libraries are found at `/Applications/i2p`. If you have installed I2P using
a Debian package(i.e. `sudo apt-get install i2p i2p-router`) then you have
libraries available at /usr/lib/i2p.
If you have the I2P source code in ../i2p relative to the parent directory,
and have run `ant pkg`, then the libraries will automatically be detected.
./i2p/pkg-tmp
./i2p.plugins.i2psnark-rpc
2. Copy plugin.config from the scripts directory into the plugin directory.
cp scripts/plugin.config plugin/plugin.config
3. If you don't have plugin signing keys yet, the build script will generate them.
However, if you prefer to do this in advance, you can.
To do this with I2P installed in the $HOME directory, you can run the following
script:
java -cp "~/i2p/lib/i2p.jar:/usr/share/java/gnu-getopt.jar" \
net.i2p.crypto.SU3File keygen -t RSA_SHA512_4096 \
"~/.i2p-plugin-keys/user-su3-public-signing.crt" \
"~/.i2p-plugin-keys/user-su3-keystore.ks" \
"user@mail.i2p"
There is a helper script to make this process easier at
[i2pgit.org](https://i2pgit.org/idk/generate-plugin-signing-keys)
[git.idk.i2p](https://i2pgit.org/idk/generate-plugin-signing-keys). If you
have never generated plugin signing keys before, you can run the command:
./i2pk -p $HOME/.i2p-plugin-keys -n 'user' -s 'user@mail.i2p' generate_keys
4. Edit the plugin/plugin.config file. You will need to change the signer field to
match your keys, and add a version line to the file.
name=i2psnark-rpc
-signer=zzz-plugin@mail.i2p
+signer=user@mail.i2p
consoleLinkName=I2PSnark-Remote
consoleLinkURL=/transmission/web/
description=RPC and Web UI for i2psnark
min-java-version=1.7
min-jetty-version=9
min-i2p-version=0.9.47
+version=0.1.2-test
5. You should be ready to build the plugin. Run the script scripts/makeplugin.sh
from the project root.
./scripts/makeplugin.sh
You will be prompted to generate your keystore password. Once entered, the
i2psnark-rpc plugin packages will be generated.

View File

@ -1,3 +1,6 @@
* 2020-06-08 0.6
- Disable pack200
* 2020-05-31 0.5 * 2020-05-31 0.5
- Remove bundled libjson-simple which conflicts with i2p.jar - Remove bundled libjson-simple which conflicts with i2p.jar
- Switch to use libjson-simple 2.x API in i2p.jar - Switch to use libjson-simple 2.x API in i2p.jar

View File

@ -11,7 +11,7 @@
<target name="plugin" depends="war"> <target name="plugin" depends="war">
<!-- get version number --> <!-- get version number -->
<buildnumber file="scripts/build.number" /> <buildnumber file="scripts/build.number" />
<property name="release.number" value="0.5" /> <property name="release.number" value="0.6" />
<!-- we don't bother with an update plugin, everything is in a single war --> <!-- we don't bother with an update plugin, everything is in a single war -->
<copy file="LICENSE.txt" todir="plugin/" overwrite="true" /> <copy file="LICENSE.txt" todir="plugin/" overwrite="true" />
@ -21,8 +21,8 @@
<arg value="version=${release.number}-b${build.number}" /> <arg value="version=${release.number}-b${build.number}" />
</exec> </exec>
<exec executable="pack200" failonerror="true"> <exec executable="pack200" failonerror="true">
<arg value="-g" /> <arg value="-r" />
<arg value="plugin/console/webapps/transmission.war.pack" /> <arg value="plugin/console/webapps/transmission.war" />
<arg value="src/build/transmission.war.jar" /> <arg value="src/build/transmission.war.jar" />
</exec> </exec>
<input message="Enter su3 signing key password:" addproperty="release.password.su3" /> <input message="Enter su3 signing key password:" addproperty="release.password.su3" />
@ -47,7 +47,7 @@
<target name="clean" > <target name="clean" >
<ant dir="src" target="clean" /> <ant dir="src" target="clean" />
<delete file="plugin/plugin.config" /> <delete file="plugin/plugin.config" />
<delete file="plugin/console/webapps/transmission.war.pack" /> <delete file="plugin/console/webapps/transmission.war" />
<delete file="plugin/LICENSE.txt" /> <delete file="plugin/LICENSE.txt" />
<delete file="plugin/README.txt" /> <delete file="plugin/README.txt" />
<delete file="plugin.zip" /> <delete file="plugin.zip" />

View File

@ -1,157 +0,0 @@
**** LICENSING NOTE FROM PARG ****
The version included within Vuze in LGPL version 2.1 and is an old version of the software available here:
https://code.google.com/p/json-simple/downloads/detail?name=json_simple.zip&can=2&q=
(archived here: https://web.archive.org/web/20140328054522/https://json-simple.googlecode.com/files/json_simple.zip )
The license was subsequently updated to Apache but the Vuze copy remains LGPL.
***********************************
Simple Java toolkit for JSON (JSON.simple)
==========================================
1.Why the Simple Java toolkit (also named as JSON.simple) for JSON?
When I use JSON as the data exchange format between the AJAX client and JSP
for the first time, what worry me mostly is how to encode Java strings and
numbers correctly in the server side so the AJAX client will receive a well
formed JSON data. When I looked into the 'JSON in Java' directory in JSON
website,I found that wrappers to JSONObject and JSONArray can be simpler,
due to the simplicity of JSON itself. So I wrote the JSON.simple package.
2.Is it simple,really?
I think so. Take an example:
import org.json.simple.JSONObject;
JSONObject obj=new JSONObject();
obj.put("name","foo");
obj.put("num",new Integer(100));
obj.put("balance",new Double(1000.21));
obj.put("is_vip",new Boolean(true));
obj.put("nickname",null);
System.out.print(obj);
Result:
{"nickname":null,"num":100,"balance":1000.21,"is_vip":true,"name":"foo"}
The JSONObject.toString() will escape controls and specials correctly.
3.How to use JSON.simple in JSP?
Take an example in JSP:
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="org.json.simple.JSONObject"%>
<%
JSONObject obj=new JSONObject();
obj.put("name","foo");
obj.put("num",new Integer(100));
obj.put("balance",new Double(1000.21));
obj.put("is_vip",new Boolean(true));
obj.put("nickname",null);
out.print(obj);
out.flush();
%>
So the AJAX client will get the responseText.
4.Some details about JSONObject?
JSONObject inherits java.util.HashMap,so it don't have to worry about the
mapping things between keys and values. Feel free to use the Map methods
like get(), put(), and remove() and others. JSONObject.toString() will
combine key value pairs to get the JSON data string. Values will be escaped
into JSON quote string format if it's an instance of java.lang.String. Other
type of instance like java.lang.Number,java.lang.Boolean,null,JSONObject and
JSONArray will NOT escape, just take their java.lang.String.valueOf() result.
null value will be the JSON 'null' in the result.
It's still correct if you put an instance of JSONObject or JSONArray into an
instance of JSONObject or JSONArray. Take the example about:
JSONObject obj2=new JSONObject();
obj2.put("phone","123456");
obj2.put("zip","7890");
obj.put("contact",obj2);
System.out.print(obj);
Result:
{"nickname":null,"num":100,"contact":{"phone":"123456","zip":"7890"},"balance":1000.21,"is_vip":true,"name":"foo"}
The method JSONObject.escape() is used to escape Java string into JSON quote
string. Controls and specials will be escaped correctly into \b,\f,\r,\n,\t,
\",\\,\/,\uhhhh.
5.Some detail about JSONArray?
org.json.simple.JSONArray inherits java.util.ArrayList. Feel free to use the
List methods like get(),add(),remove(),iterator() and so on. The rules of
JSONArray.toString() is similar to JSONObject.toString(). Here's the example:
import org.json.simple.JSONArray;
JSONArray array=new JSONArray();
array.add("hello");
array.add(new Integer(123));
array.add(new Boolean(false));
array.add(null);
array.add(new Double(123.45));
array.add(obj2);//see above
System.out.print(array);
Result:
["hello",123,false,null,123.45,{"phone":"123456","zip":"7890"}]
6.What is JSONValue for?
org.json.simple.JSONValue is use to parse JSON data into Java Object.
In JSON, the topmost entity is JSON value, not the JSON object. But
it's not necessary to wrap JSON string,boolean,number and null again,
for the Java has already had the according classes: java.lang.String,
java.lang.Boolean,java.lang.Number and null. The mapping is:
JSON Java
------------------------------------------------
string <=> java.lang.String
number <=> java.lang.Number
true|false <=> java.lang.Boolean
null <=> null
array <=> org.json.simple.JSONArray
object <=> org.json.simple.JSONObject
------------------------------------------------
JSONValue has only one kind of method, JSONValue.parse(), which receives
a java.io.Reader or java.lang.String. Return type of JSONValue.parse()
is according to the mapping above. If the input is incorrect in syntax or
there's exceptions during the parsing, I choose to return null, ignoring
the exception: I have no idea if it's a serious implementaion, but I think
it's convenient to the user.
Here's the example:
String s="[0,{\"1\":{\"2\":{\"3\":{\"4\":[5,{\"6\":7}]}}}}]";
Object obj=JSONValue.parse(s);
JSONArray array=(JSONArray)obj;
System.out.println(array.get(1));
JSONObject obj2=(JSONObject)array.get(1);
System.out.println(obj2.get("1"));
Result:
{"1":{"2":{"3":{"4":[5,{"6":7}]}}}}
{"2":{"3":{"4":[5,{"6":7}]}}}
7.About the author.
I'm a Java EE developer on Linux.
I'm working on web systems and information retrieval systems.
I also develop 3D games and Flash games.
You can contact me through:
Fang Yidong<fangyidong@yahoo.com.cn>
Fang Yidong<fangyidng@gmail.com>

View File

@ -7,6 +7,17 @@
# zzz 2010-02 # zzz 2010-02
# zzz 2014-08 added support for su3 files # zzz 2014-08 added support for su3 files
# #
if [ -z "$I2P" -a -d "$PWD/../i2p/pkg-temp" ]; then
export I2P=$PWD/../i2p/pkg-temp
fi
if [ ! -d "$I2P" ]; then
echo "Can't locate your I2P installation. Please add a environment variable named I2P with the path to the folder as value"
echo "On OSX this solved with running: export I2P=/Applications/i2p if default install directory is used."
exit 1
fi
CPATH=$I2P/lib/i2p.jar:/usr/share/java/gnu-getopt.jar CPATH=$I2P/lib/i2p.jar:/usr/share/java/gnu-getopt.jar
PUBKEYDIR=$HOME/.i2p-plugin-keys PUBKEYDIR=$HOME/.i2p-plugin-keys
PUBKEYFILE=$PUBKEYDIR/plugin-public-signing.key PUBKEYFILE=$PUBKEYDIR/plugin-public-signing.key
@ -22,53 +33,53 @@ PLUGINDIR=${1:-plugin}
PC=plugin.config PC=plugin.config
PCT=${PC}.tmp PCT=${PC}.tmp
if [ ! -d $PLUGINDIR ] if [ ! -d "$PLUGINDIR" ]
then then
echo "You must have a $PLUGINDIR directory" echo "You must have a $PLUGINDIR directory"
exit 1 exit 1
fi fi
if [ ! -f $PLUGINDIR/$PC ] if [ ! -f "$PLUGINDIR/$PC" ]
then then
echo "You must have a $PLUGINDIR/$PC file" echo "You must have a $PLUGINDIR/$PC file"
exit 1 exit 1
fi fi
SIGNER=`grep '^signer=' $PLUGINDIR/$PC` SIGNER=`grep '^signer=' "$PLUGINDIR/$PC"`
if [ "$?" -ne "0" ] if [ "$?" -ne "0" ]
then then
echo "You must have a signer name in $PC" echo "You must have a signer name in $PC"
echo 'For example name=foo' echo 'For example signer=foo'
exit 1 exit 1
fi fi
SIGNER=`echo $SIGNER | cut -f 2 -d '='` SIGNER=`echo $SIGNER | cut -f 2 -d '='`
if [ ! -f $PRIVKEYFILE ] if [ ! -f "$PRIVKEYFILE" ]
then then
echo "Creating new XPI2P DSA keys" echo "Creating new XPI2P DSA keys"
mkdir -p $PUBKEYDIR || exit 1 mkdir -p "$PUBKEYDIR" || exit 1
java -cp $CPATH net.i2p.crypto.TrustedUpdate keygen $PUBKEYFILE $PRIVKEYFILE || exit 1 java -cp "$CPATH" net.i2p.crypto.TrustedUpdate keygen "$PUBKEYFILE" "$PRIVKEYFILE" || exit 1
java -cp $CPATH net.i2p.data.Base64 encode $PUBKEYFILE $B64KEYFILE || exit 1 java -cp "$CPATH" net.i2p.data.Base64 encode "$PUBKEYFILE" "$B64KEYFILE" || exit 1
rm -rf logs/ rm -rf logs/
chmod 444 $PUBKEYFILE $B64KEYFILE chmod 444 "$PUBKEYFILE" "$B64KEYFILE"
chmod 400 $PRIVKEYFILE chmod 400 "$PRIVKEYFILE"
echo "Created new XPI2P keys: $PUBKEYFILE $PRIVKEYFILE" echo "Created new XPI2P keys: $PUBKEYFILE $PRIVKEYFILE"
fi fi
if [ ! -f $PRIVKEYSTORE ] if [ ! -f "$PRIVKEYSTORE" ]
then then
echo "Creating new SU3 $KEYTYPE keys for $SIGNER" echo "Creating new SU3 $KEYTYPE keys for $SIGNER"
java -cp $CPATH net.i2p.crypto.SU3File keygen -t $KEYTYPE $PUBKEYSTORE $PRIVKEYSTORE $SIGNER || exit 1 java -cp "$CPATH" net.i2p.crypto.SU3File keygen -t $KEYTYPE "$PUBKEYSTORE" "$PRIVKEYSTORE" $SIGNER || exit 1
echo '*** Save your password in a safe place!!! ***' echo '*** Save your password in a safe place!!! ***'
rm -rf logs/ rm -rf logs/
# copy to the router dir so verify will work # copy to the router dir so verify will work
CDIR=$I2P/certificates/plugin CDIR=$I2P/certificates/plugin
mkdir -p $CDIR || exit 1 mkdir -p "$CDIR" || exit 1
CFILE=$CDIR/`echo $SIGNER | sed s/@/_at_/`.crt CFILE=$CDIR/`echo $SIGNER | sed s/@/_at_/`.crt
cp $PUBKEYSTORE $CFILE cp "$PUBKEYSTORE" "$CFILE"
chmod 444 $PUBKEYSTORE chmod 444 "$PUBKEYSTORE"
chmod 400 $PRIVKEYSTORE chmod 400 "$PRIVKEYSTORE"
chmod 644 $CFILE chmod 644 "$CFILE"
echo "Created new SU3 keys: $PUBKEYSTORE $PRIVKEYSTORE" echo "Created new SU3 keys: $PUBKEYSTORE $PRIVKEYSTORE"
echo "Copied public key to $CFILE for testing" echo "Copied public key to $CFILE for testing"
fi fi
@ -76,7 +87,7 @@ fi
rm -f plugin.zip rm -f plugin.zip
OPWD=$PWD OPWD=$PWD
cd $PLUGINDIR cd "$PLUGINDIR"
grep -q '^name=' $PC grep -q '^name=' $PC
if [ "$?" -ne "0" ] if [ "$?" -ne "0" ]
@ -102,12 +113,12 @@ mv $PCT $PC || exit 1
# add our Base64 key # add our Base64 key
grep -v '^key=' $PC > $PCT grep -v '^key=' $PC > $PCT
B64KEY=`cat $B64KEYFILE` B64KEY=`cat "$B64KEYFILE"`
echo "key=$B64KEY" >> $PCT || exit 1 echo "key=$B64KEY" >> $PCT || exit 1
mv $PCT $PC || exit 1 mv $PCT $PC || exit 1
# zip it # zip it
zip -r $OPWD/plugin.zip * || exit 1 zip -r "$OPWD/plugin.zip" * || exit 1
# get the version and use it for the sud header # get the version and use it for the sud header
VERSION=`grep '^version=' $PC | cut -f 2 -d '='` VERSION=`grep '^version=' $PC | cut -f 2 -d '='`
@ -115,24 +126,24 @@ VERSION=`grep '^version=' $PC | cut -f 2 -d '='`
NAME=`grep '^name=' $PC | cut -f 2 -d '='` NAME=`grep '^name=' $PC | cut -f 2 -d '='`
XPI2P=${NAME}.xpi2p XPI2P=${NAME}.xpi2p
SU3=${NAME}.su3 SU3=${NAME}.su3
cd $OPWD cd "$OPWD"
# sign it # sign it
echo 'Signing. ...' echo 'Signing. ...'
java -cp $CPATH net.i2p.crypto.TrustedUpdate sign plugin.zip $XPI2P $PRIVKEYFILE $VERSION || exit 1 java -cp "$CPATH" net.i2p.crypto.TrustedUpdate sign plugin.zip "$XPI2P" "$PRIVKEYFILE" "$VERSION" || exit 1
java -cp $CPATH net.i2p.crypto.SU3File sign -c PLUGIN -t $KEYTYPE plugin.zip $SU3 $PRIVKEYSTORE $VERSION $SIGNER || exit 1 java -cp "$CPATH" net.i2p.crypto.SU3File sign -c PLUGIN -t $KEYTYPE plugin.zip "$SU3" "$PRIVKEYSTORE" "$VERSION" "$SIGNER" || exit 1
rm -f plugin.zip rm -f plugin.zip
# verify # verify
echo 'Verifying. ...' echo 'Verifying. ...'
java -cp $CPATH net.i2p.crypto.TrustedUpdate showversion $XPI2P || exit 1 java -cp "$CPATH" net.i2p.crypto.TrustedUpdate showversion "$XPI2P" || exit 1
java -cp $CPATH -Drouter.trustedUpdateKeys=$B64KEY net.i2p.crypto.TrustedUpdate verifysig $XPI2P || exit 1 java -cp "$CPATH" -Drouter.trustedUpdateKeys=$B64KEY net.i2p.crypto.TrustedUpdate verifysig "$XPI2P" || exit 1
java -cp $CPATH net.i2p.crypto.SU3File showversion $SU3 || exit 1 java -cp "$CPATH" net.i2p.crypto.SU3File showversion "$SU3" || exit 1
java -cp $CPATH net.i2p.crypto.SU3File verifysig -k $PUBKEYSTORE $SU3 || exit 1 java -cp "$CPATH" net.i2p.crypto.SU3File verifysig -k "$PUBKEYSTORE" "$SU3" || exit 1
rm -rf logs/ rm -rf logs/
echo 'Plugin files created: ' echo 'Plugin files created: '
wc -c $XPI2P wc -c "$XPI2P"
wc -c $SU3 wc -c "$SU3"
exit 0 exit 0

View File

@ -35,13 +35,6 @@ Copyright (c) Transmission authors and contributors
<br> <br>
See <a href="licenses/Transmission.txt">Transmission.txt</a> See <a href="licenses/Transmission.txt">Transmission.txt</a>
<p>
JSON:
<br>
LGPLv2.1
<br>
See <a href="licenses/JSON.txt">JSON.txt</a>
<p> <p>
Transmission/Vuze web UI: Transmission/Vuze web UI:
<br> <br>