This wiki is now locked - both user registration and edits (except by admins) are disabled. We're currently migrating all the content to our new wiki. If you have time, please register and help us out!

You can still view the source code of every page. Once a page has been copied over to the new wiki, please add a link to it to MigratedPages (the only page which is still editable), to notify the admins to go and blank it.


Guide to the Freenet Source Code


Freenet is written in Java.

There are instructions for downloading and building/compiling the source code.

The basic directory structure


If you look in the freenet/src directory, you can see a freenet directory. This is where the main code is stored. There are also directories called net and org for some outside code, plugins for optional plugins to the main Freenet, and test, which is for some test programs.

If we look in the freenet/src/freenet directory, we can see several subdirectories:

The client directory has code for enabling client applications to talk to the Freenet node.
The clients directory is for the web front end to Freenet, also know as FProxy.
The config directory sorts out the various configuration options of Freenet.
The crypt directory is all the encryption and hashing code used in Freenet.
The io directory is for fairly low-level code related to how Freenet talks to other nodes.
The keys directory has code for manipulating the various Freenet identification keys: CHK, SSK, USK, KSK.
The node directory is for the higher-level communication between Freenet nodes.
The plugin directory is the beginnings of a new plugin system, which will be much cleaner.
The pluginmanager directory is the implementation and interfaces for the old plugin system, which is very low-level, requiring plugin authors to access node classes etc directly.
The store directory is for the datastore, the only implementation at the moment uses Berkeley DB Java Edition for its index.
The support directory contains miscellaneous helper classes, most of which could be reused in other code.
The tools directory contains tools classes i.e. classes that can be called from outside through the jar

Where the code starts from


You might be thinking: which class kicks it all off, where do we start? Have a look in the build.xml file in the root directory. You can see somewhere in there it says:

<attribute name="Main-Class" value="freenet/node/Node"/>


This means that when you run Freenet, it start by running the code in the main() method of src/node/Node.class.
This in turn calls the main() method of src/node/NodeStarter.class.

The Freenet Keys


To understand how Freenet works, you need to understand how data inserted to Freenet is encrypted, identified, stored and retrieved.

Freenet stores data in chunks of 32KB. If you insert a file larger than 32KB, it breaks it up into pieces, and creates a kind of index to these pieces, called a manifest. This level of detail is hidden to the end user: as far as they are concerned they just insert the whole file, and retrieve the whole file.

Each of these 32KB chunks is hashed and encrypted. To retrieve the file chunk, you need to know its hash, which is used as an index to the file. To decrypt the file chunk, you need to know its decryption key. The node storing the chunk only knows the hash, not the decryption key. So when you publicly advertise the file, you need to tell people both the hash (where to find it) and the decryption key (how to decipher the file chunk once you have retrieved it).
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki