[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r32898 - in gnunet-java: . doc gradle/wrapper src/main/java
From: |
gnunet |
Subject: |
[GNUnet-SVN] r32898 - in gnunet-java: . doc gradle/wrapper src/main/java/org/gnunet/core src/main/java/org/gnunet/dht src/main/java/org/gnunet/gns src/main/java/org/gnunet/identity src/main/java/org/gnunet/mesh src/main/java/org/gnunet/nse src/main/java/org/gnunet/peerinfo src/main/java/org/gnunet/requests src/main/java/org/gnunet/statistics src/main/java/org/gnunet/testbed src/main/java/org/gnunet/util src/main/java/org/gnunet/util/crypto src/main/java/org/gnunet/voting src/test/java/org/gnunet/construct src/test/java/org/gnunet/mesh src/test/java/org/gnunet/secretsharing |
Date: |
Mon, 7 Apr 2014 02:26:06 +0200 |
Author: dold
Date: 2014-04-07 02:26:06 +0200 (Mon, 07 Apr 2014)
New Revision: 32898
Modified:
gnunet-java/build.gradle
gnunet-java/doc/gnunet-java-tutorial.pdf
gnunet-java/doc/gnunet-java-tutorial.tex
gnunet-java/gradle/wrapper/gradle-wrapper.properties
gnunet-java/src/main/java/org/gnunet/core/ConnectHandler.java
gnunet-java/src/main/java/org/gnunet/core/Core.java
gnunet-java/src/main/java/org/gnunet/core/DisconnectHandler.java
gnunet-java/src/main/java/org/gnunet/core/HeaderNotify.java
gnunet-java/src/main/java/org/gnunet/core/InitCallback.java
gnunet-java/src/main/java/org/gnunet/core/MessageNotify.java
gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java
gnunet-java/src/main/java/org/gnunet/core/package-info.java
gnunet-java/src/main/java/org/gnunet/dht/DistributedHashTable.java
gnunet-java/src/main/java/org/gnunet/dht/MonitorGetHandler.java
gnunet-java/src/main/java/org/gnunet/dht/MonitorGetResponseHandler.java
gnunet-java/src/main/java/org/gnunet/dht/MonitorPutHandler.java
gnunet-java/src/main/java/org/gnunet/gns/Gns.java
gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java
gnunet-java/src/main/java/org/gnunet/gns/GnsTool.java
gnunet-java/src/main/java/org/gnunet/gns/RecordFlags.java
gnunet-java/src/main/java/org/gnunet/identity/Identity.java
gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java
gnunet-java/src/main/java/org/gnunet/nse/package-info.java
gnunet-java/src/main/java/org/gnunet/peerinfo/PeerInfo.java
gnunet-java/src/main/java/org/gnunet/peerinfo/PeerProcessor.java
gnunet-java/src/main/java/org/gnunet/requests/Request.java
gnunet-java/src/main/java/org/gnunet/requests/SequentialRequestContainer.java
gnunet-java/src/main/java/org/gnunet/requests/SimpleRequestIdentifier.java
gnunet-java/src/main/java/org/gnunet/requests/TimeoutHandler.java
gnunet-java/src/main/java/org/gnunet/statistics/Statistics.java
gnunet-java/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
gnunet-java/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
gnunet-java/src/main/java/org/gnunet/testbed/ControllerStatusCallback.java
gnunet-java/src/main/java/org/gnunet/testbed/HostRegistrationCompletion.java
gnunet-java/src/main/java/org/gnunet/testbed/OperationCompletionCallback.java
gnunet-java/src/main/java/org/gnunet/util/Connection.java
gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignature.java
gnunet-java/src/main/java/org/gnunet/util/crypto/package-info.java
gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java
gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
gnunet-java/src/test/java/org/gnunet/construct/SendMessageTest.java
gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java
gnunet-java/src/test/java/org/gnunet/secretsharing/SecretsharingTest.java
Log:
docs / fixed fixme in crypto
Modified: gnunet-java/build.gradle
===================================================================
--- gnunet-java/build.gradle 2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/build.gradle 2014-04-07 00:26:06 UTC (rev 32898)
@@ -6,6 +6,8 @@
apply plugin: 'java'
// allow creating files for IntelliJ IDEA
apply plugin: 'idea'
+// ... as well as eclipse
+apply plugin: 'eclipse'
// code coverage reporting
apply plugin: 'jacoco'
// publish repository for other projects to use
@@ -79,14 +81,40 @@
}
-// Print test name, so that we can easily find out
-// which test does not terminate.
test {
+ // Print test name, so that we can easily find out
+ // which test does not terminate.
beforeTest{ descr ->
- logger.warn("Starting Test ${descr.className} : ${descr.name}")
+ logger.warn("Starting test ${descr.className} : ${descr.name}")
}
+ useJUnit {
+ excludeCategories 'org.gnunet.testcat.ExpensiveTests'
+ excludeCategories 'org.gnunet.testcat.ExperimentalTests'
+ }
}
+task testExpensive(type: Test) {
+ // Print test name, so that we can easily find out
+ // which test does not terminate.
+ beforeTest{ descr ->
+ logger.warn("Starting expensive test ${descr.className} :
${descr.name}")
+ }
+ useJUnit {
+ excludeCategories 'org.gnunet.testcat.ExperimentalTests'
+ }
+}
+
+task testExperimental(type: Test) {
+ // Print test name, so that we can easily find out
+ // which test does not terminate.
+ beforeTest{ descr ->
+ logger.warn("Starting experimental test ${descr.className} :
${descr.name}")
+ }
+ useJUnit {
+ includeCategories 'org.gnunet.testcat.ExperimentalTes'
+ }
+}
+
task copyDeps(type: Copy) {
into "$projectDir/lib"
from configurations.runtime
@@ -116,7 +144,7 @@
ivyGnuNetJava (IvyPublication) {
organisation 'org.gnunet'
module 'gnunet-java'
- revision '0.2'
+ revision '0.10.1'
from components.java
}
}
Modified: gnunet-java/doc/gnunet-java-tutorial.pdf
===================================================================
(Binary files differ)
Modified: gnunet-java/doc/gnunet-java-tutorial.tex
===================================================================
--- gnunet-java/doc/gnunet-java-tutorial.tex 2014-04-06 20:08:56 UTC (rev
32897)
+++ gnunet-java/doc/gnunet-java-tutorial.tex 2014-04-07 00:26:06 UTC (rev
32898)
@@ -1,7 +1,9 @@
\documentclass[10pt]{article}
\usepackage[ansinew]{inputenc}
\usepackage{makeidx,amsmath,amssymb,exscale,multicol,epsfig,graphics,verbatim,ulem}
-\usepackage{epsfig,geometry,url,listings,boxedminipage}
+\usepackage{epsfig,geometry,url,listings,subcaption,boxedminipage}
+\usepackage[T1]{fontenc}
+\usepackage{textcomp}
\geometry{headsep=3ex,hscale=0.9}
\usepackage{hyperref}
\hypersetup{
@@ -13,9 +15,18 @@
urlcolor=blue
}
+\lstset{
+basicstyle=\ttfamily,
+upquote=true,
+columns=fullflexible,
+literate={*}{{\char42}}1
+ {-}{{\char45}}1
+ {\\\$}{{\$ }}1
+}
+
\newcommand{\exercise}[1]{\noindent\begin{boxedminipage}{\textwidth}{\bf
Exercise:} #1 \end{boxedminipage}}
-\title{A Tutorial for GNUnet 0.9.x (Java version)}
+\title{A Tutorial for GNUnet 0.10.x (Java version)}
\author{Florian Dold}
@@ -23,10 +34,15 @@
\maketitle
+Although GNUnet is primarily developed in the C programming language, it is
also possible to write components in Java.
+
\section{Getting Started}
\subsection{Installing GNUnet}
-This tutorial assumes that you have GNUnet $\geq$ 0.9.5 installed on your
system. Instructions on how to do this can be found at
\url{https://gnunet.org/installation}, or in the C version of the GNUnet
tutorial.
-Make sure that you run {\tt configure} with the option {\tt
--enable-javaports}, in order to allow
+This tutorial assumes that you have GNUnet $\geq$ 0.10.x installed on your
+machine. Instructions on how to do this can be found at
+\url{https://gnunet.org/installation}, or in the C version of the GNUnet
+tutorial.
+Make sure to run {\tt ./configure} with the option {\tt --enable-javaports},
in order to allow
Java clients to connect to GNUnet services.
Start your GNUnet peer with the command {\tt gnunet-arm -s} and convince
yourself that the default GNUnet services are running by typing {\tt gnunet-arm
-I}.
@@ -36,82 +52,55 @@
}
\subsection{Other Dependencies}
-Make sure that you have OpenJDK 7 or later installed on your system.
-GNUnet-Java uses Gradle for its build system, visit
\url{http://www.gradle.org/} for installation instructions, and install version
1.5 or later.
+Make sure that you have OpenJDK 6 or later installed on your system.
-\exercise{%
- Execute the command {\tt gradle --version} from your shell, and verify that
you correctly installed
- the right version.
-}
+\section{A simple GNUnet-Java extension}
+The simplest way to create a new GNUnet component in Java is to copy
+the template extension project, which already contains a build system
+and sample code.
-\subsection{Installing GNUnet-Java}
-Check out the latest version of GNUnet-Java with subversion
-\begin{lstlisting}[language=bash]
-$ svn checkout https://gnunet.org/svn/gnunet-java/
+Obtain the extension template from the SVN repository:
+\begin{lstlisting}[language=bash,deletekeywords={export}]
+\$ svn export https://gnunet.org/svn/gnunet-java-ext/ my-extension
+\$ cd my-extension
\end{lstlisting}
-% $
-And compile the project with
-\begin{lstlisting}[language=bash]
-$ cd gnunet-java
-$ gradle assemble
-\end{lstlisting}
-To test whether your GNUnet-Java installation is working, run
-\begin{lstlisting}[language=bash]
-$ ./bin/gnunet-nse
-\end{lstlisting}
-% $
-which should display the estimated current size of the network. If the program
keeps running whithout
-producing any output, your GNUnet peer is probably not running.
-Throughout the tutorial it will be useful to consult the Javadoc for
GNUnet-Java,
-either build it yourself with
-\lstset{language=bash}
-\begin{lstlisting}
-$ gradle javadoc # docs will be put in ./build-gradle/docs/
-\end{lstlisting}
-% $
-or use the online version at \url{https://gnunet.org/javadoc/}.
+The template project uses Gradle\footnote{\url{http://gradle.org}} as the
build system. Simply use the \texttt{./gradlew}
+script to run build tasks. The wrapper script will automatically download the
correct version
+of Gradle on the first run. Alternatively, download Gradle$\ge$1.11 yourself,
and use the \texttt{gradle} command
+directly instead of the wrapper.
-\section{A simple GNUnet-Java extension}
-
-Check out the template directory for GNUnet-Java extensions
+Build the template project by running the \emph{assemble} task.
\begin{lstlisting}[language=bash]
-$ svn checkout https://gnunet.org/svn/gnunet-java-ext/
+\$ ./gradlew assemble
\end{lstlisting}
-% $
-The extension template contains a build system and some example code.
-
-Before you can compile the examples in the extension template, make sure you
have the
-following environment variables set, so that the build system can find both
the {\tt gnunet-java.jar}
-and its dependencies
+This will download all required dependencies. Gradle stores all dependencies
in an internal cache. Run
\begin{lstlisting}[language=bash]
-$ export GNJ_HOME=gnunet-java/gradle-build/libs # or wherever gnunet-java.jar
is
-$ export GNJ_DEPS=gnunet-java/lib # or wherever the dependencies of
GNUnet-Java are
+\$ ./gradlew copyDeps
\end{lstlisting}
-Build the example code in the template with
+in order to copy all dependencies into the \texttt{lib/} folder\footnote{This
is not strictly necessary---you can also
+ask Gradle for the classpath pointing to the internal cache. However, having
all dependencies in one folder
+is more convenient, especially when using shell wrappers for Java entry points
later on.}.
+
+Check if if you're on the right track by running the Java client for GNUnet's
network size estimation service:
\begin{lstlisting}[language=bash]
-$ cd gnunet-java-ext
-$ gradle assemble
+\$ java -cp 'lib/*' org.gnunet.nse.NetworkSizeEstimation
\end{lstlisting}
-and run
-\begin{lstlisting}[language=bash]
-$ ./bin/gnunet-ext
-\end{lstlisting}
-which should print ``{\tt hi}'' on your terminal.
+This should print something like \texttt{est: 42.3 dev: 3.14 t: Sun Apr 06
23:40:37 CEST 2014} to
+your terminal. If the program hangs, check if your peer is running and
correctly configured.
\subsection{The Basics}
This is the most basic skeleton for a GNUnet-Java application:
-
\begin{lstlisting}[language=java]
import org.gnunet.util.*;
-public class HelloGNUnet {
+public class HelloGnuNet {
public static void main(String[] args) {
- new Program(args) {
+ new Program() {
public void run() {
System.out.println("Hello, GNUnet");
}
- }.start();
+ }.start(args);
}
\end{lstlisting}
@@ -120,12 +109,9 @@
in the {\tt run} method as initial task.
\exercise{%
- Try to get the code above running. Place your code in the
- {\tt src/} directory of the template and execute {\tt gradle assemble}.
- Copy and modify the example shell-wrapper
- {\tt bin/gnunet-ext} so that you can run your own program with it.
- Remember that the environment variables {\tt GNJ\_HOME} and {\tt GNJ\_DEPS}
- have to be set appropriately.
+ Try to get the code above running by placing it in a \texttt{*.java} file
+ in \texttt{src/main/java/}, running the \texttt{assemble} task from Gradle,
+ and invoking \texttt{java} with the right parameters.
}
\subsection{Adding and using command line arguments}
@@ -134,7 +120,6 @@
{\tt org.gnunet.util.Program} subclass with the address@hidden
Here is a simple example:
-
\begin{lstlisting}[language=java]
new Program(args) {
@Option(
@@ -142,7 +127,7 @@
longname = "name",
action = OptionAction.STORE_STRING,
description = "the name of the person you want to greet")
- String name;
+ String name = "Jane Doe"; // default value if option is missing
[...]
}
\end{lstlisting}
@@ -152,10 +137,10 @@
--name FOO}) or the short name ({\tt -n FOO}) with one dash.
Inside of the {\tt run} method, the field {\tt name} will then be
-initialized with the passed argument, or {\tt null} if the option has
-not been passed.
+initialized with the given argument, or {\tt null} if the option has
+not been specified on the command line.
-The address@hidden annotation can not only be used with Strings, but also
+The address@hidden annotation can not only be used with Strings, but also
with booleans and numbers. These are a few of the available options:
\begin{itemize}
@@ -175,33 +160,45 @@
\end{itemize}
You can change the about text and the version information by
-overriding the {\tt getVersion} or {\tt getAboutText} methods in your
+overriding the {\tt makeHelpText} or {\tt makeVersionDescription} methods in
your
{\tt Program} subclass.
\exercise{Add a few different command line options to your program and print
them with {\tt System.out}!}
+\subsection{Shell Wrappers}
+It is usually more convenient to have a shell wrapper for each entry point than
+it is to pass the main class and classpath to the JVM manually every time.
The shell wrappers
+in the \texttt{bin/} directory of the template use a classpath relative to
their location.
+Thus they only work if in the right location.
+
+\exercise{Copy the wrapper \textt{bin/my-ext} and modify it so that
+calls your \texttt{HelloGnuNet} class.}
+
+\subsection{Documentation}
+The documentation for \emph{gnunet-java} generated by Javadoc is available
+at \url{https://gnunet.org/javadoc/}.
+
\section{The statistics API}
In this section we will use the statistics API of GNUnet-Java. The statistics
-service allows us to store numbers under a subsystem and a name, which
+service allows to store numbers under a subsystem and a name, which
are still available to you and other components of your peer after
your program exits.
-\subsection{Establishing a client with the statistics service}
+\subsection{Connecting to the statistics service}
\begin{lstlisting}[language=java]
Statistics statistics = new Statistics(getConfiguration());
\end{lstlisting}
-The Statistics constructor is called with the default configuration,
+The Statistics constructor is called with the configuration,
provided by the method {\tt getConfiguration} of the {\tt Program}
-class. Calling the constructor establishes a client to the
+class. This establishes a connection to the
statistics service. As with most API calls in GNUnet-Java, this
-operation is asynchronous. This is one of the main reasons why one
-has to wrap your program in the overridden {\tt run} method of {\tt
+operation is asynchronous. This is one of the main reasons why one
+has to wrap teir program in the {\tt run} method of {\tt
Program}: Once all method calls are done, the run method
-returns, and GNUnet-Java keeps the system running until all work has
-been done.
+returns, and GNUnet-Java keeps the system running until all work is done.
Always remember that you always explicitly have to destroy your {\tt
Statistics} instance with the {\tt destroy()}
@@ -219,18 +216,16 @@
\subsection{Retrieving statistics}
Retrieving a value is a little bit more complex. Because of the
-asynchronous nature of the GNUnet-Java APIs, the {\tt startGet} method
+asynchronous nature of the GNUnet-Java APIs, the {\tt get} method
does not directly return values, but a handle (implementing the
interface {\tt Cancelable}) to cancel the get request. The actual
-values are accessed by passing a callback object to the {\tt startGet}
+values are accessed by passing a callback object to the {\tt get}
method.
-Example:
-
+This example retrieves the statistics value ``\# Requests Served'' for the
subsystem ``gnunet-java-hello''
\begin{lstlisting}[language=java]
-// the name parameter is the empty string, this gets all options of the
specified subsystem
-Cancelable getCancel = statistics.get(RelativeTime.SECOND,
"gnunet-java-hello", "",
-new Statistics.StatisticsReceiver {
+Cancelable getCancel = statistics.get(RelativeTime.SECOND, "gnunet-java-hello",
+"# Requests Served", new Statistics.StatisticsReceiver {
public void onDone() {
System.out.println("everything done");
}
@@ -249,7 +244,7 @@
\section{The core API}
-The core API allows sending encrypted messages to connected peers.
+The core API allows sending encrypted messages to directly connected peers.
\subsection{Defining new Messages}
@@ -281,12 +276,11 @@
Every time you add a new type of GNUnet message, you have to run the command
\lstset{language=bash}
\begin{lstlisting}
-$ gradle msgtypes
+\$ gradle msgtypes
\end{lstlisting}
-%$
This generates the file {\tt
- src/org/gnunet/construct/MsgMap.txt}, which allows the system to
-load the right java class when reading a message from the network.
+ src/main/java/org/gnunet/construct/MsgMap.txt}, which allows the system to
+instantiate the right Java class when reading a message from the network.
The above message then contains a value annotated with {\tt @UInt8}:
An {\bf 8}-bit {\bf U}nsigned {\bf int}eger. There are similar
@@ -367,11 +361,7 @@
\exercise{Write an echo program for core: Send a message to the local peer and
receive it!}
-
\section{Other useful APIs}
-
-Many of GNUnet's services are not yet available as a GNUnet-Java API.
-
Some other useful service APIs currently implemented are NSE (in {\tt
org.gnunet.nse.NetworkSizeEstimation}), a service that gives an
estimation of the current size of the network, DHT (in {\tt
@@ -380,6 +370,7 @@
(in {\tt org.gnunet.peerinfo.PeerInfo}), a service for
retrieving information about other known peers.
+Note that some GNUnet services do not yet have Java bindings.
\section{Writing your own client and service}
@@ -456,8 +447,9 @@
another message type.}
\exercise{Write an API for a GNUnet service that has not been implemented yet
in gnunet-java and contribute it back to the project.}
-\section{The state of GNUunet-Java}
+\section{The state of GNUnet-Java}
+
The GNUnet-Java project is still somewhat unstable and under development,
expect
changes that break your stuff! Please report any bugs or feature
requests at \url{https://gnunet.org/bugs/}.
Modified: gnunet-java/gradle/wrapper/gradle-wrapper.properties
===================================================================
--- gnunet-java/gradle/wrapper/gradle-wrapper.properties 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/gradle/wrapper/gradle-wrapper.properties 2014-04-07
00:26:06 UTC (rev 32898)
@@ -1,4 +1,4 @@
-#Mon Mar 10 17:26:40 CET 2014
+#Mon Apr 07 02:02:34 CEST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Modified: gnunet-java/src/main/java/org/gnunet/core/ConnectHandler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/ConnectHandler.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/ConnectHandler.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -26,5 +26,9 @@
* Called when a new peer (with a compatible set of messages) connects to core
*/
public interface ConnectHandler {
+ /**
+ * Called when a new peer (with a compatible set of messages) connects to
core
+ * @param peerIdentity identity of the connecting peer
+ */
void onConnect(PeerIdentity peerIdentity);
}
Modified: gnunet-java/src/main/java/org/gnunet/core/Core.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/Core.java 2014-04-06 20:08:56 UTC
(rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/Core.java 2014-04-07 00:26:06 UTC
(rev 32898)
@@ -23,6 +23,7 @@
import com.google.common.collect.Maps;
import org.gnunet.construct.Construct;
import org.gnunet.construct.MessageLoader;
+import org.gnunet.core.messages.*;
import org.gnunet.mq.Envelope;
import org.gnunet.requests.MatchingRequestContainer;
import org.gnunet.requests.Request;
@@ -36,7 +37,7 @@
/**
- * API for the gnunet core service.
+ * API for the GNUnet core service.
* <p/>
* Sends messages to connected peers.
*/
@@ -246,6 +247,11 @@
}
}
+ /**
+ * Establish a connection to the core service.
+ *
+ * @param cfg configuration to use
+ */
public Core(Configuration cfg) {
client = new Client("core", cfg);
client.installReceiver(new CoreReceiver());
@@ -301,8 +307,8 @@
* Helper function to retrieve the peer identity with the given
configuration via CORE.
* Should <b>not</b> be used unless there is no other means to obtain the
peer identity.
*
- * @param cfg
- * @param cont
+ * @param cfg configuration to use
+ * @param cont continuation, called with the peer identity once available
*/
public static void withPeerIdentity(Configuration cfg, final
PeerIdentityContinuation cont) {
final Core core = new Core(cfg);
@@ -317,28 +323,54 @@
/**
* Observe outgoing message headers from core.
+ *
* @param h callback
*/
public void observeOutboundHeaders(HeaderNotify h) {
this.notifyOutboundHeaders = h;
}
+ /**
+ * Observe inbound headers from core.
+ *
+ * @param h callback
+ */
public void observeInboundHeaders(HeaderNotify h) {
this.notifyInboundHeaders = h;
}
+ /**
+ * Observe inbound messages from core.
+ *
+ * @param h callback
+ */
public void observeInboundMessages(MessageNotify h) {
this.notifyInboundMessages = h;
}
+ /**
+ * Observe outbound messages from core.
+ *
+ * @param h callback
+ */
public void observeOutboundMessages(MessageNotify h) {
this.notifyOutboundMessages = h;
}
+ /**
+ * Observe core connections
+ *
+ * @param connectHandler callback
+ */
public void observeConnect(ConnectHandler connectHandler) {
this.connectHandler = connectHandler;
}
+ /**
+ * Observe core disconnections.
+ *
+ * @param disconnectHandler callback
+ */
public void observeDisconnect(DisconnectHandler disconnectHandler) {
this.disconnectHandler = disconnectHandler;
}
@@ -347,6 +379,8 @@
* Handle all incoming messages with the specified runabout.
* Has to be called before init, as the service has to know which messages
we
* are interested in.
+ *
+ * @param runabout the runabout that will handle received messages
*/
public void setMessageHandler(Runabout runabout) {
if (messageHandler != null) {
Modified: gnunet-java/src/main/java/org/gnunet/core/DisconnectHandler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/DisconnectHandler.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/DisconnectHandler.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -26,5 +26,10 @@
* Called when a peer disconnects from the core.
*/
public interface DisconnectHandler {
+ /**
+ * Called when a peer disconnects from the core.
+ *
+ * @param peerIdentity identity of the peer that disconnected
+ */
void onDisconnect(PeerIdentity peerIdentity);
}
Modified: gnunet-java/src/main/java/org/gnunet/core/HeaderNotify.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/HeaderNotify.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/HeaderNotify.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -23,8 +23,12 @@
import org.gnunet.util.GnunetMessage;
/**
- *
+ * Called to notify the client about a header.
*/
public interface HeaderNotify {
+ /**
+ * Called to notify the client about a header.
+ * @param header the header
+ */
void notify(GnunetMessage.Header header);
}
Modified: gnunet-java/src/main/java/org/gnunet/core/InitCallback.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/InitCallback.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/InitCallback.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -26,5 +26,11 @@
* Called once the handshake with core was successful.
*/
public interface InitCallback {
+ /**
+ * Called once the handshake with core was successful.
+ *
+ * @param myIdentity the identity of the peer that runs
+ * the core service we connected to
+ */
void onInit(PeerIdentity myIdentity);
}
Modified: gnunet-java/src/main/java/org/gnunet/core/MessageNotify.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/MessageNotify.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/MessageNotify.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -23,6 +23,14 @@
import org.gnunet.util.GnunetMessage;
+/**
+ * Notify the client about a message.
+ */
public interface MessageNotify {
+ /**
+ * Notify the client about a message.
+ *
+ * @param messageBody the received message
+ */
void notify(GnunetMessage messageBody);
}
Modified:
gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/PeerIdentityContinuation.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -2,6 +2,14 @@
import org.gnunet.util.PeerIdentity;
+/**
+ * Continuation that receives the peer's identity.
+ */
public interface PeerIdentityContinuation {
+ /**
+ * Called with the peer identity.
+ *
+ * @param peerIdentity the peer identity
+ */
public void cont(PeerIdentity peerIdentity);
}
Modified: gnunet-java/src/main/java/org/gnunet/core/package-info.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/core/package-info.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/core/package-info.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -19,6 +19,6 @@
*/
/**
- * API for the GNUnet CORE service.
+ * Communication with connected peers.
*/
package org.gnunet.core;
Modified: gnunet-java/src/main/java/org/gnunet/dht/DistributedHashTable.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/dht/DistributedHashTable.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/dht/DistributedHashTable.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -21,6 +21,7 @@
package org.gnunet.dht;
import com.google.common.base.Charsets;
+import org.gnunet.dht.messages.*;
import org.gnunet.mq.Envelope;
import org.gnunet.requests.MatchingRequestContainer;
import org.gnunet.requests.Request;
@@ -37,7 +38,7 @@
import java.util.Set;
/**
- * API for the gnunet dht service.
+ * API for the GNUnet dht service.
* <p/>
* Stores data under a key, distributed across the network.
* <p/>
@@ -230,6 +231,7 @@
@Override
public void handleError() {
+ // FIXME
}
}
@@ -256,12 +258,10 @@
* @param routeOptions additional options
* @param type type of the data to store
* @param expiration how long should the value be stored? TODO: what
is the maximum?
- * @param timeout how long after we give up on storing the value?
* @param cont called after the put operation failed or
succeeded
*/
public void put(HashCode key, byte[] data, int replicationLevel,
Set<RouteOption> routeOptions,
- int type, AbsoluteTime expiration,
- RelativeTime timeout, final Continuation cont) {
+ int type, AbsoluteTime expiration, final Continuation
cont) {
PutRequest pr = new PutRequest();
pr.key = key;
pr.data = data;
@@ -296,10 +296,21 @@
getRequest.type = type;
getRequest.replication = type;
getRequest.xquery = xquery;
+ getRequest.replication = replication;
return getRequests.addRequest(getRequest.uid, getRequest);
}
+ /**
+ * Start monitoring certain types of requests.
+ *
+ * @param blockType block type of requests we're interested in
+ * @param key key we're interested in
+ * @param getHandler listener for get requests
+ * @param getResponseHandler listener for get responses
+ * @param putHandler listener for put requests
+ * @return a handle to cancel the monitoring
+ */
public Cancelable startMonitor(int blockType, HashCode key,
MonitorGetHandler getHandler,
MonitorGetResponseHandler
getResponseHandler,
MonitorPutHandler putHandler) {
@@ -389,17 +400,17 @@
dht.put(new HashCode(key), data.getBytes(), replication,
EnumSet.of(RouteOption.NONE),
BlockType.TEST.val,
AbsoluteTime.now().add(RelativeTime.HOUR),
- RelativeTime.SECOND, new Continuation() {
- @Override
- public void cont(boolean success) {
- if (success) {
- System.out.println("put getRequestIdentifier
sent");
- } else {
- System.out.println("error");
- }
- dht.destroy();
- }
- });
+ new Continuation() {
+ @Override
+ public void cont(boolean success) {
+ if (success) {
+ System.out.println("put
getRequestIdentifier sent");
+ } else {
+ System.out.println("error");
+ }
+ dht.destroy();
+ }
+ });
} else if (monitor) {
final DistributedHashTable dht = new
DistributedHashTable(cfg);
dht.startMonitor(BlockType.TEST.val, null,
Modified: gnunet-java/src/main/java/org/gnunet/dht/MonitorGetHandler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/dht/MonitorGetHandler.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/dht/MonitorGetHandler.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -23,8 +23,20 @@
import org.gnunet.util.HashCode;
import org.gnunet.util.PeerIdentity;
-
+/**
+ * Listener for monitoring get requests.
+ */
public interface MonitorGetHandler {
+ /**
+ * Called when a get request happens.
+ *
+ * @param options options of the request
+ * @param type type of the request
+ * @param hopCount hop count of the request
+ * @param desiredReplicationLevel desired replication level for the request
+ * @param getPath path of the get request
+ * @param key key for the request
+ */
void onGet(int options, int type, int hopCount, int
desiredReplicationLevel, PeerIdentity[] getPath,
HashCode key);
}
Modified:
gnunet-java/src/main/java/org/gnunet/dht/MonitorGetResponseHandler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/dht/MonitorGetResponseHandler.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/dht/MonitorGetResponseHandler.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -25,7 +25,20 @@
import org.gnunet.util.PeerIdentity;
+/**
+ * Listener for monitoring get responses.
+ */
public interface MonitorGetResponseHandler {
+ /**
+ * Called when a get response happens.
+ *
+ * @param type
+ * @param getPath
+ * @param putPath
+ * @param expiration
+ * @param key
+ * @param data
+ */
void onGetResponse(int type, PeerIdentity[] getPath, PeerIdentity[]
putPath, AbsoluteTimeMessage expiration,
HashCode key, byte[] data);
}
Modified: gnunet-java/src/main/java/org/gnunet/dht/MonitorPutHandler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/dht/MonitorPutHandler.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/dht/MonitorPutHandler.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -24,7 +24,9 @@
import org.gnunet.util.HashCode;
import org.gnunet.util.PeerIdentity;
-
+/**
+ *
+ */
public interface MonitorPutHandler {
void onPut(int options, int type, int hop_count, AbsoluteTimeMessage
expirationTime, PeerIdentity[] putPath,
HashCode key, byte[] data);
Modified: gnunet-java/src/main/java/org/gnunet/gns/Gns.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/Gns.java 2014-04-06 20:08:56 UTC
(rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/gns/Gns.java 2014-04-07 00:26:06 UTC
(rev 32898)
@@ -130,6 +130,9 @@
}
+ /**
+ * Disconnect from the GNS service.
+ */
public void disconnect() {
client.disconnect();
client = null;
Modified: gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/gns/GnsRecord.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -36,6 +36,9 @@
import java.lang.reflect.Method;
import java.util.Map;
+/**
+ * A GNS record.
+ */
public class GnsRecord implements Message {
private static final Logger logger = LoggerFactory
.getLogger(GnsRecord.class);
Modified: gnunet-java/src/main/java/org/gnunet/gns/GnsTool.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/GnsTool.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/gns/GnsTool.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -7,6 +7,9 @@
import org.gnunet.util.getopt.Argument;
import org.gnunet.util.getopt.ArgumentAction;
+/**
+ * Command line tool for GNS.
+ */
public class GnsTool {
public static void main(String[] args) {
int ret = new Program() {
Modified: gnunet-java/src/main/java/org/gnunet/gns/RecordFlags.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/gns/RecordFlags.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/gns/RecordFlags.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -20,7 +20,9 @@
package org.gnunet.gns;
-
+/**
+ * Flags for GNS records.
+ */
public interface RecordFlags {
/**
* No special options.
Modified: gnunet-java/src/main/java/org/gnunet/identity/Identity.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/identity/Identity.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/identity/Identity.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -35,6 +35,9 @@
import java.util.List;
+/**
+ * Make requests to the identity service.
+ */
public class Identity {
private static final Logger logger = LoggerFactory
.getLogger(Identity.class);
@@ -46,6 +49,15 @@
private static Ego anonymousEgo;
+ /**
+ * Look up the given ego name.
+ *
+ * @param configuration configuration to use for connecting to
+ * the identity service
+ * @param egoName ego name to look up
+ * @param identityCallback handler for lookup result
+ * @return a handle to cancel the lookup
+ */
public static Cancelable lookup(Configuration configuration,
final String egoName, final
IdentityCallback identityCallback) {
final Identity myIdentity = new Identity();
@@ -106,20 +118,47 @@
return cancellationToken;
}
+ /**
+ * An ego.
+ */
public static class Ego {
private String name;
private EcdsaPrivateKey privateKey;
+ /**
+ * Create an ego with the given name and private key.
+ *
+ * @param egoName the ego name
+ * @param privateKey the ego's private key
+ */
public Ego(String egoName, EcdsaPrivateKey privateKey) {
this.name = egoName;
this.privateKey = privateKey;
}
+
+ /**
+ * Get the ego's private key.
+ *
+ * @return the ego's private key
+ */
public EcdsaPrivateKey getPrivateKey() {
return privateKey;
}
+
+ /**
+ * Compute the ego's public key from its private key.
+ *
+ * @return the ego's public key
+ */
public EcdsaPublicKey getPublicKey() {
return privateKey.getPublicKey();
}
+
+ /**
+ * Get the ego's name.
+ *
+ * @return the ego's name
+ */
public String getName() {
return name;
}
@@ -261,6 +300,12 @@
}
}
+ /**
+ * Get the anonymous ego. The anonymous ego has a publicly
+ * known private key.
+ *
+ * @return the anonymous ego
+ */
public static Ego getAnonymousEgo() {
if (anonymousEgo == null) {
anonymousEgo = new Ego(null, EcdsaPrivateKey.getAnonymous());
@@ -269,10 +314,20 @@
}
+ /**
+ * Create a handle that can connect to the identity service.
+ * Nothing will happen until calling connect.
+ */
public Identity() {
// do nothing
}
+ /**
+ * Connect to the identity service.
+ *
+ * @param configuration configuration to use
+ * @param identityListCallback
+ */
public void connect(Configuration configuration, IdentityListCallback
identityListCallback) {
this.configuration = configuration;
this.client = new Client("identity", configuration);
@@ -283,6 +338,13 @@
client.send(m);
}
+ /**
+ * Get the default ego for a service
+ *
+ * @param serviceName name of the service
+ * @param identityCallback callback that receives the default ego
+ * @return a handle to cancel the operation
+ */
public Cancelable get(String serviceName, IdentityCallback
identityCallback) {
return requests.addRequest(new GetDefaultRequest(serviceName,
identityCallback));
}
@@ -298,6 +360,9 @@
return requests.addRequest(new SetDefaultRequest(serviceName, ego));
}
+ /**
+ * Disconnect from the identity service.
+ */
public void disconnect() {
client.disconnect();
client = null;
Modified: gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java 2014-04-06 20:08:56 UTC
(rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/mesh/Mesh.java 2014-04-07 00:26:06 UTC
(rev 32898)
@@ -77,7 +77,7 @@
/**
* Called whenever a tunnel was destroyed.
*/
- private TunnelEndHandler tunnelEndHandler;
+ private ChannelEndHandler channelEndHandler;
/**
* Message handler for messages received through
@@ -108,10 +108,8 @@
/**
* A tunnel to a remote peer.
- * @param <T> type of context data for the tunnel
*/
- public class Channel<T> extends MessageQueue {
- private T context;
+ public class Channel extends MessageQueue {
private final int opt;
final PeerIdentity peer;
final int port;
@@ -129,13 +127,12 @@
* Create a new tunnel (we're initiator and will be allowed to
add/remove peers
* and to broadcast).
*
- * @param context tunnel context
* @param peer peer identity the tunnel should go to
* @param port Port number.
* @param nobuffer Flag for disabling buffering on relay nodes.
* @param reliable Flag for end-to-end reliability.
*/
- public Channel(PeerIdentity peer, int port, boolean nobuffer, boolean
reliable, T context) {
+ public Channel(PeerIdentity peer, int port, boolean nobuffer, boolean
reliable) {
this(peer, 0, port, nobuffer, reliable);
TunnelCreateMessage tcm = new TunnelCreateMessage();
tcm.otherEnd = peer;
@@ -225,14 +222,6 @@
envelopeCanceler = null;
}
- public T getContext() {
- return context;
- }
-
- public void setContext(T newContext) {
- context = newContext;
- }
-
void handleAck() {
ackCount++;
logger.debug("got ack for tunnel id " + tunnelId);
@@ -287,7 +276,7 @@
t.destroyedByService = true;
logger.debug("tunnel destroyed by service");
t.destroy();
- tunnelEndHandler.onChannelEnd(t);
+ channelEndHandler.onChannelEnd(t);
}
public void visit(RejectMessage m) {
@@ -300,15 +289,15 @@
t.destroyedByService = true;
logger.debug("tunnel destroyed by service (nack/reject)");
t.destroy();
- tunnelEndHandler.onChannelEnd(t);
+ channelEndHandler.onChannelEnd(t);
}
@Override
public void handleError() {
logger.warn("lost connection to mesh service, reconnecting");
- if (null != tunnelEndHandler) {
+ if (null != channelEndHandler) {
for (Channel t : tunnelMap.values()) {
- tunnelEndHandler.onChannelEnd(t);
+ channelEndHandler.onChannelEnd(t);
}
}
tunnelMap.clear();
@@ -324,17 +313,17 @@
*
* @param cfg configuration to use
* @param inboundChannelHandler called when an inbound channel is
established
- * @param tunnelEndHandler called when a tunnel is destroyed (either by
the client calling Tunnel.destroy(),
+ * @param channelEndHandler called when a tunnel is destroyed (either by
the client calling Tunnel.destroy(),
* or by the service)
* @param messageReceiver runabout for messages we are interested in
* @param ports ports to listen on
*/
public Mesh(Configuration cfg, InboundChannelHandler inboundChannelHandler,
- TunnelEndHandler tunnelEndHandler, MeshRunabout
messageReceiver, int... ports) {
- if (null == tunnelEndHandler) {
+ ChannelEndHandler channelEndHandler, MeshRunabout
messageReceiver, int... ports) {
+ if (null == channelEndHandler) {
throw new AssertionError("tunnel end handler may not be null");
}
- this.tunnelEndHandler = tunnelEndHandler;
+ this.channelEndHandler = channelEndHandler;
this.messageReceiver = messageReceiver;
this.ports = ports;
this.inboundChannelHandler = inboundChannelHandler;
@@ -352,14 +341,14 @@
}
/**
- * Connect to the mesh service. Use this constructor if you are not
interested in inbound tunnels.
+ * Connect to the mesh service. Use this constructor if you are not
interested in inbound channels.
*
* @param cfg configuration to use
- * @param tunnelEndHandler called when a tunnel is destroyed (either by
the client calling Tunnel.destroy(),
+ * @param channelEndHandler called when a tunnel is destroyed (either by
the client calling Channel.destroy(),
* or by the service)
*/
- public Mesh(Configuration cfg, TunnelEndHandler tunnelEndHandler,
MeshRunabout messageReceiver) {
- this(cfg, null, tunnelEndHandler, messageReceiver);
+ public Mesh(Configuration cfg, ChannelEndHandler channelEndHandler,
MeshRunabout messageReceiver) {
+ this(cfg, null, channelEndHandler, messageReceiver);
}
/**
@@ -367,20 +356,26 @@
* and don't want to receive messages.
*
* @param cfg configuration to use
- * @param tunnelEndHandler called when a tunnel is destroyed (either by
the client calling Tunnel.destroy(),
+ * @param channelEndHandler called when a tunnel is destroyed (either by
the client calling Tunnel.destroy(),
* or by the service)
*/
- public Mesh(Configuration cfg, TunnelEndHandler tunnelEndHandler) {
- this(cfg, null, tunnelEndHandler, null);
+ public Mesh(Configuration cfg, ChannelEndHandler channelEndHandler) {
+ this(cfg, null, channelEndHandler, null);
}
- public <T> Channel<T> createTunnel(PeerIdentity peer, int port, boolean
nobuffer, boolean reliable, T initialContext) {
- return new Channel<T>(peer, port, nobuffer, reliable, initialContext);
- }
- public <T> Channel<T> createTunnel(PeerIdentity peer, int port, boolean
nobuffer, boolean reliable) {
+ /**
+ * Create a channel to a peer over the given port, with the given options.
+ *
+ * @param peer peer to create a channel to
+ * @param port port to use
+ * @param nobuffer true if messages should be buffered
+ * @param reliable true if transmission should be reliable
+ * @return a channel
+ */
+ public Channel createChannel(PeerIdentity peer, int port, boolean
nobuffer, boolean reliable) {
logger.debug("creating tunnel to peer {} over port {}",
peer.toString(), port);
- return new Channel<T>(peer, port, nobuffer, reliable, null);
+ return new Channel(peer, port, nobuffer, reliable);
}
/**
Modified: gnunet-java/src/main/java/org/gnunet/nse/package-info.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/nse/package-info.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/nse/package-info.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -19,6 +19,6 @@
*/
/**
- * API for the gnunet nse service.
+ * Retrieve network size estimates.
*/
package org.gnunet.nse;
Modified: gnunet-java/src/main/java/org/gnunet/peerinfo/PeerInfo.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/peerinfo/PeerInfo.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/peerinfo/PeerInfo.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -22,6 +22,10 @@
import org.gnunet.hello.HelloMessage;
import org.gnunet.mq.Envelope;
+import org.gnunet.peerinfo.messages.InfoEnd;
+import org.gnunet.peerinfo.messages.InfoMessage;
+import org.gnunet.peerinfo.messages.ListAllPeersMessage;
+import org.gnunet.peerinfo.messages.ListPeerMessage;
import org.gnunet.requests.Request;
import org.gnunet.requests.SequentialRequestContainer;
import org.gnunet.util.*;
@@ -97,6 +101,11 @@
}
+ /**
+ * Create a connection to the peerinfo service.
+ *
+ * @param cfg configuration to use
+ */
public PeerInfo(Configuration cfg) {
client = new Client("peerinfo", cfg);
client.installReceiver(new PeerInfoMessageReceiver());
@@ -127,6 +136,9 @@
return iterateRequests.addRequest(r);
}
+ /**
+ * Disconnect from the peerinfo service.
+ */
public void disconnect() {
client.disconnect();
}
Modified: gnunet-java/src/main/java/org/gnunet/peerinfo/PeerProcessor.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/peerinfo/PeerProcessor.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/peerinfo/PeerProcessor.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -7,6 +7,16 @@
* Callback class to receive known peers and their HELLOs.
*/
public interface PeerProcessor {
+ /**
+ * Process a peer and its hello
+ *
+ * @param peerIdentity the peer
+ * @param hello the hello of the peer
+ */
public void onPeer(PeerIdentity peerIdentity, HelloMessage hello);
+
+ /**
+ * Called to indicate the end of a peer list.
+ */
public void onEnd();
}
Modified: gnunet-java/src/main/java/org/gnunet/requests/Request.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/requests/Request.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/requests/Request.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -84,7 +84,7 @@
import org.gnunet.util.Cancelable;
/**
- * A getRequestIdentifier that can be put in a getRequestIdentifier container.
+ * A request that can be put in a request container.
*/
public abstract class Request implements Cancelable {
/**
Modified:
gnunet-java/src/main/java/org/gnunet/requests/SequentialRequestContainer.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/requests/SequentialRequestContainer.java
2014-04-06 20:08:56 UTC (rev 32897)
+++
gnunet-java/src/main/java/org/gnunet/requests/SequentialRequestContainer.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -131,6 +131,12 @@
}
}
+ /**
+ * Add a request to the queue
+ *
+ * @param request the request to add
+ * @return a handle that represents the queued request
+ */
public RequestIdentifier<T> addRequest(final T request) {
final Identifier identifier = new Identifier(request);
requests.addLast(identifier);
@@ -142,6 +148,9 @@
return identifier;
}
+ /**
+ * Re-send all active requests.
+ */
@Override
public void restart() {
LinkedList<Identifier> requestsOld = requests;
Modified:
gnunet-java/src/main/java/org/gnunet/requests/SimpleRequestIdentifier.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/requests/SimpleRequestIdentifier.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/requests/SimpleRequestIdentifier.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -18,10 +18,8 @@
Boston, MA 02111-1307, USA.
*/
-
package org.gnunet.requests;
-
import org.gnunet.mq.Envelope;
import org.gnunet.mq.MessageQueue;
import org.gnunet.mq.NotifySentHandler;
@@ -29,7 +27,6 @@
import org.gnunet.util.RelativeTime;
import org.gnunet.util.Scheduler;
-
abstract class SimpleRequestIdentifier<T extends Request> implements
RequestIdentifier<T> {
private final T request;
/**
Modified: gnunet-java/src/main/java/org/gnunet/requests/TimeoutHandler.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/requests/TimeoutHandler.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/requests/TimeoutHandler.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -21,7 +21,7 @@
package org.gnunet.requests;
/**
- * Callback object for handling getRequestIdentifier timeouts.
+ * Callback object for handling request timeouts.
*/
public interface TimeoutHandler {
void onTimeout();
Modified: gnunet-java/src/main/java/org/gnunet/statistics/Statistics.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/statistics/Statistics.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/statistics/Statistics.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -131,6 +131,11 @@
}
}
+ /**
+ * Create a connection to the statistics service.
+ *
+ * @param cfg configuration to use
+ */
public Statistics(Configuration cfg) {
client = new Client("statistics", cfg);
client.installReceiver(new StatisticsMessageReceiver());
@@ -139,9 +144,7 @@
}
/**
- * Retrieve values from statistics.
- * Only one instance of this getRequestIdentifier may be active
simultaneously.
- * Upon cancellation
+ * Retrieve a statistics value of a subsystem.
*
* @param timeout time after we give up and call receiver.onTimeout
* @param subsystem the subsystem of interest
@@ -164,6 +167,19 @@
}
/**
+ * Retrieve all statistics value of a subsystem.
+ *
+ * @param timeout time after we give up and call receiver.onTimeout
+ * @param subsystem the subsystem of interest
+ * @param receiver callback
+ * @return handle to onCancel the getRequestIdentifier
+ */
+ public Cancelable get(RelativeTime timeout, final String subsystem,
+ final StatisticsReceiver receiver) {
+ return get(timeout, subsystem, "", receiver);
+ }
+
+ /**
* Sets a statistics value asynchronously.
*
* @param name name of the entry
@@ -226,9 +242,10 @@
}
/**
- * Destroy handle to the statistics service. Always finishes writing
pending values.
+ * Destroy handle to the statistics service.
*
- * @param syncFirst Wait until the statistics service has received all our
updates.
+ * @param syncFirst If true, wait until the statistics service has
received all our updates.
+ * If false, pending updates may be lost.
*/
public void destroy(boolean syncFirst) {
if (destroyRequested)
Modified:
gnunet-java/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/statistics/StatisticsReceiver.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -21,9 +21,28 @@
package org.gnunet.statistics;
-
+/**
+ * Handler for statistics results.
+ */
public interface StatisticsReceiver {
+ /**
+ * Called when having received a statistics value from the service.
+ *
+ * @param subsystem subsystem of the value
+ * @param name name of the value
+ * @param value the value
+ */
public void onReceive(String subsystem, String name, long value);
+
+ /**
+ * Called when a statistics request times out. Never called
+ * for watchers.
+ */
public void onTimeout();
+
+ /**
+ * Called when all values for the request have been received.
+ * Never called for watchers.
+ */
public void onDone();
}
Modified: gnunet-java/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/statistics/StatisticsWatcher.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -1,5 +1,15 @@
package org.gnunet.statistics;
+/**
+ * Listener for statistics changes.
+ */
public interface StatisticsWatcher {
+ /**
+ * Called when receiving a change notification for a statistics value.
+ *
+ * @param subsystem subsystem of the value that changed
+ * @param name name of the value that changed
+ * @param value new value
+ */
public void onReceive(String subsystem, String name, long value);
}
Modified:
gnunet-java/src/main/java/org/gnunet/testbed/ControllerStatusCallback.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/testbed/ControllerStatusCallback.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/testbed/ControllerStatusCallback.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -3,7 +3,19 @@
import org.gnunet.util.Configuration;
+/**
+ * Listener for controller status changes.
+ */
public interface ControllerStatusCallback {
+ /**
+ * Called on successful startup.
+ *
+ * @param cfg configuration
+ */
void onStartupSuccess(Configuration cfg);
+
+ /**
+ * Called on failed startup.
+ */
void onStartupFailure();
}
Modified:
gnunet-java/src/main/java/org/gnunet/testbed/HostRegistrationCompletion.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/testbed/HostRegistrationCompletion.java
2014-04-06 20:08:56 UTC (rev 32897)
+++
gnunet-java/src/main/java/org/gnunet/testbed/HostRegistrationCompletion.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -1,4 +1,7 @@
package org.gnunet.testbed;
-public class HostRegistrationCompletion {
+/**
+ * (not yet implemented)
+ */
+public interface HostRegistrationCompletion {
}
Modified:
gnunet-java/src/main/java/org/gnunet/testbed/OperationCompletionCallback.java
===================================================================
---
gnunet-java/src/main/java/org/gnunet/testbed/OperationCompletionCallback.java
2014-04-06 20:08:56 UTC (rev 32897)
+++
gnunet-java/src/main/java/org/gnunet/testbed/OperationCompletionCallback.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -1,7 +1,19 @@
package org.gnunet.testbed;
+/**
+ * Called on completed operation or error.
+ */
public interface OperationCompletionCallback {
+ /**
+ * Called on completed operation.
+ */
void onCompletion();
+
+ /**
+ * Called on error.
+ *
+ * @param emsg error message
+ */
void onError(String emsg);
}
Modified: gnunet-java/src/main/java/org/gnunet/util/Connection.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/Connection.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/util/Connection.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -592,7 +592,7 @@
*
* @param timeout timeout
* @param cont continuation to call
- * @return
+ * @return a handle to cancel the notification
*/
Cancelable notifyConnected(RelativeTime timeout, final Continuation cont) {
if (notifyConnectedTimeout != null) {
Modified: gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EcdsaSignature.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -80,9 +80,16 @@
HashCode h = HashCode.hash(m);
BigInteger z = new BigInteger(1, h.data);
BigInteger sCoeff = Ed25519.decodeScalar(s);
+
+ if (sCoeff.equals(BigInteger.ZERO) || sCoeff.compareTo(Ed25519.l) >=
0) {
+ return false;
+ }
+
BigInteger rCoeff = Ed25519.decodeScalar(r);
+ if (rCoeff.equals(BigInteger.ZERO) || rCoeff.compareTo(Ed25519.l) >=
0) {
+ return false;
+ }
- // FIXME: check range of s and r
BigInteger w = sCoeff.modInverse(Ed25519.l);
BigInteger u1 = z.multiply(w).mod(Ed25519.l);
BigInteger u2 = rCoeff.multiply(w).mod(Ed25519.l);
Modified: gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignature.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignature.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/EddsaSignature.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -61,9 +61,9 @@
/**
* Verify the signature on a message with given purpose.
*
- * @param m
- * @param publicKey
- * @return
+ * @param m the message signed by this signature
+ * @param publicKey public key of the signer
+ * @return true if the signature is valid, false otherwise
*/
public boolean verifyRaw(byte[] m, EddsaPublicKey publicKey) {
Ed25519 R = Ed25519.decode(r);
Modified: gnunet-java/src/main/java/org/gnunet/util/crypto/package-info.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/util/crypto/package-info.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/util/crypto/package-info.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -20,6 +20,6 @@
/**
- * Cryptographic primitives for.
+ * Cryptographic primitives.
*/
package org.gnunet.util.crypto;
Modified: gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/voting/BallotTool.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -28,7 +28,7 @@
import org.gnunet.identity.IdentityCallback;
import org.gnunet.mesh.Mesh;
import org.gnunet.mesh.MeshRunabout;
-import org.gnunet.mesh.TunnelEndHandler;
+import org.gnunet.mesh.ChannelEndHandler;
import org.gnunet.secretsharing.ThresholdPublicKey;
import org.gnunet.testbed.CompressedConfig;
import org.gnunet.util.*;
@@ -161,7 +161,7 @@
private RelativeTime tunnelReconnectBackoff = RelativeTime.STD_BACKOFF;
- public class BallotTunnelEndHandler implements TunnelEndHandler {
+ public class BallotChannelEndHandler implements ChannelEndHandler {
@Override
public void onChannelEnd(final Mesh.Channel channel) {
// FIXME: just re-running 'doCommands' is a bit of a hack
@@ -320,8 +320,8 @@
Random r = new Random();
currentAuthority =
remainingAuthorities.get(r.nextInt(remainingAuthorities.size()));
System.out.println("registering ballot with authority " +
currentAuthority.toString());
- mesh = new Mesh(getConfiguration(), new BallotTunnelEndHandler(),
new BallotRegisterReceiver());
- channel = mesh.createTunnel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true);
+ mesh = new Mesh(getConfiguration(), new BallotChannelEndHandler(),
new BallotRegisterReceiver());
+ channel = mesh.createChannel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true);
BallotRegisterRequestMessage m = new
BallotRegisterRequestMessage();
CompressedConfig ccfg = new
CompressedConfig(ballot.toConfiguration());
m.compressedBallotConfig = ccfg.compressedData;
@@ -365,8 +365,8 @@
PeerIdentity authority =
remainingAuthorities.get(r.nextInt(remainingAuthorities.size()));
System.out.println("submitting to authority " +
authority.toString());
currentAuthority = authority;
- mesh = new Mesh(cfg, new BallotTunnelEndHandler(), new
SubmitReceiver());
- channel = mesh.createTunnel(authority,
TallyAuthorityDaemon.MESH_PORT, true, true, null);
+ mesh = new Mesh(cfg, new BallotChannelEndHandler(), new
SubmitReceiver());
+ channel = mesh.createChannel(authority,
TallyAuthorityDaemon.MESH_PORT, true, true);
SubmitMessage m = new SubmitMessage();
if (ballot.voterPub == null) {
throw new InvalidBallotException("no voter in ballot");
@@ -399,8 +399,8 @@
Random r = new Random();
currentAuthority =
remainingAuthorities.get(r.nextInt(remainingAuthorities.size()));
System.out.println("querying authority " +
currentAuthority.toString());
- mesh = new Mesh(cfg, new BallotTunnelEndHandler(), new
QueryReceiver());
- channel = mesh.createTunnel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true, null);
+ mesh = new Mesh(cfg, new BallotChannelEndHandler(), new
QueryReceiver());
+ channel = mesh.createChannel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true);
ResultQueryMessage m = new ResultQueryMessage();
m.ballotGuid = ballot.getBallotGuid();
channel.send(m);
@@ -415,8 +415,8 @@
Random r = new Random();
currentAuthority =
remainingAuthorities.get(r.nextInt(remainingAuthorities.size()));
System.out.println("asking authority for key " +
currentAuthority.toString());
- mesh = new Mesh(cfg, new BallotTunnelEndHandler(), new
PublicKeyReceiver());
- channel = mesh.createTunnel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true, null);
+ mesh = new Mesh(cfg, new BallotChannelEndHandler(), new
PublicKeyReceiver());
+ channel = mesh.createChannel(currentAuthority,
TallyAuthorityDaemon.MESH_PORT, true, true);
KeyQueryMessage m = new KeyQueryMessage();
m.ballotGuid = ballot.getBallotGuid();
channel.send(m);
Modified: gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
===================================================================
--- gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/main/java/org/gnunet/voting/TallyAuthorityDaemon.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -27,7 +27,7 @@
import org.gnunet.construct.Construct;
import org.gnunet.mesh.Mesh;
import org.gnunet.mesh.MeshRunabout;
-import org.gnunet.mesh.TunnelEndHandler;
+import org.gnunet.mesh.ChannelEndHandler;
import org.gnunet.secretsharing.*;
import org.gnunet.testbed.CompressedConfig;
import org.gnunet.util.*;
@@ -391,7 +391,7 @@
@Override
public void run() {
logger.info("running tally daemon");
- mesh = new Mesh(getConfiguration(), null, new TunnelEndHandler() {
+ mesh = new Mesh(getConfiguration(), null, new ChannelEndHandler() {
@Override
public void onChannelEnd(Mesh.Channel channel) {
logger.warn("on channel end");
Modified: gnunet-java/src/test/java/org/gnunet/construct/SendMessageTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/construct/SendMessageTest.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/test/java/org/gnunet/construct/SendMessageTest.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -1,6 +1,6 @@
package org.gnunet.construct;
-import org.gnunet.core.SendMessage;
+import org.gnunet.core.messages.SendMessage;
import org.gnunet.util.AbsoluteTime;
import org.gnunet.util.GnunetMessage;
import org.gnunet.util.PeerIdentity;
Modified: gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java 2014-04-06
20:08:56 UTC (rev 32897)
+++ gnunet-java/src/test/java/org/gnunet/mesh/MeshTest.java 2014-04-07
00:26:06 UTC (rev 32898)
@@ -23,12 +23,12 @@
}
}
- public static class MyTunnelEndHandler implements TunnelEndHandler {
+ public static class MyChannelEndHandler implements ChannelEndHandler {
Mesh mesh1;
PeerIdentity peerIdentity;
@Override
public void onChannelEnd(Mesh.Channel channel) {
- Mesh.Channel<Void> myChannel = mesh1.createTunnel(peerIdentity,
42, false, true, null);
+ Mesh.Channel<Void> myChannel = mesh1.createChannel(peerIdentity,
42, false, true, null);
myChannel.send(new TestMessage());
}
}
@@ -50,7 +50,7 @@
public void cont(PeerIdentity peerIdentity) {
System.out.println("got peer identity from core");
//
- MyTunnelEndHandler teh = new MyTunnelEndHandler();
+ MyChannelEndHandler teh = new MyChannelEndHandler();
// first mesh handle, used to send the message
final Mesh mesh1 = new Mesh(cfg, teh);
teh.mesh1 = mesh1;
@@ -61,7 +61,7 @@
public void onInboundTunnel(Mesh.Channel tunnel,
PeerIdentity initiator) {
System.out.println("got inbound channel " + initiator);
}
- }, new TunnelEndHandler() {
+ }, new ChannelEndHandler() {
@Override
public void onChannelEnd(Mesh.Channel tunnel) {
System.out.println("channel end handler called");
@@ -69,7 +69,7 @@
}, mh, 42);
mh.m1 = mesh1;
mh.m2 = mesh2;
- Mesh.Channel<Void> channel = mesh1.createTunnel(peerIdentity,
42, false, true, null);
+ Mesh.Channel<Void> channel = mesh1.createChannel(peerIdentity,
42, false, true, null);
channel.send(new TestMessage());
}
});
Modified:
gnunet-java/src/test/java/org/gnunet/secretsharing/SecretsharingTest.java
===================================================================
--- gnunet-java/src/test/java/org/gnunet/secretsharing/SecretsharingTest.java
2014-04-06 20:08:56 UTC (rev 32897)
+++ gnunet-java/src/test/java/org/gnunet/secretsharing/SecretsharingTest.java
2014-04-07 00:26:06 UTC (rev 32898)
@@ -20,16 +20,15 @@
package org.gnunet.secretsharing;
-
import org.gnunet.testing.TestingSubsystem;
import org.gnunet.util.*;
import org.junit.Assert;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import java.math.BigInteger;
public class SecretsharingTest {
-
@Test
public void test_secretsharing_single_generate() {
Program.configureLogging("debug");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r32898 - in gnunet-java: . doc gradle/wrapper src/main/java/org/gnunet/core src/main/java/org/gnunet/dht src/main/java/org/gnunet/gns src/main/java/org/gnunet/identity src/main/java/org/gnunet/mesh src/main/java/org/gnunet/nse src/main/java/org/gnunet/peerinfo src/main/java/org/gnunet/requests src/main/java/org/gnunet/statistics src/main/java/org/gnunet/testbed src/main/java/org/gnunet/util src/main/java/org/gnunet/util/crypto src/main/java/org/gnunet/voting src/test/java/org/gnunet/construct src/test/java/org/gnunet/mesh src/test/java/org/gnunet/secretsharing,
gnunet <=