660fe4a
diff -up ./contrib/doc/cjdnslog.md.man ./contrib/doc/cjdnslog.md
d7184b7
--- ./contrib/doc/cjdnslog.md.man	2016-05-10 18:55:17.289488599 -0400
d7184b7
+++ ./contrib/doc/cjdnslog.md	2016-05-10 18:55:17.289488599 -0400
660fe4a
@@ -0,0 +1,43 @@
660fe4a
+cjdnslog(1) -- display cjdroute log messages
660fe4a
+=============================================
660fe4a
+
660fe4a
+## SYNOPSIS
660fe4a
+
660fe4a
+`/usr/bin/cjdnslog` [<options>...]
660fe4a
+
660fe4a
+## DESCRIPTION
660fe4a
+
660fe4a
+Cjdroute sends continuous log messages to the bit bucket.  Cjdnslog
660fe4a
+captures that information in real time and sends it to stdout.
660fe4a
+
660fe4a
+##OPTIONS
660fe4a
+
660fe4a
+With no options, cjdnslog logs everything.
660fe4a
+
2183a3c
+  * `--help`
660fe4a
+    Print usage summary.
660fe4a
+
2183a3c
+  * `-f source_file.c`
660fe4a
+    Restrict output to log messages generated in source_file.c.
660fe4a
+
2183a3c
+  * `-v log_level`
660fe4a
+    Restrict output to messages at log_level or higher.  Log levels 
660fe4a
+    include DEBUG, INFO, WARN, ERROR.
660fe4a
+
2183a3c
+  * `-l lineno`
660fe4a
+    Restrict output to message generated on source line lineno.  Normally
660fe4a
+    used in conjunction with `-f`.
660fe4a
+
660fe4a
+##USAGE
660fe4a
+
660fe4a
+Running cjdnslog requires admin privilege.  The cjdnsadmin lib will 
660fe4a
+try to read `/etc/cjdroute.conf` for the admin password.  This will 
660fe4a
+normally succeed only for root.  Otherwise, it tries `~/.cjdnsadmin`
660fe4a
+
660fe4a
+##FILES
660fe4a
+
660fe4a
+`~/.cjdnsadmin`
660fe4a
+
660fe4a
+## SEE ALSO
660fe4a
+
660fe4a
+cjdroute(1)
2f8dfd1
diff -up ./contrib/doc/cjdns-online.md.man ./contrib/doc/cjdns-online.md
d7184b7
--- ./contrib/doc/cjdns-online.md.man	2016-05-10 18:55:17.289488599 -0400
d7184b7
+++ ./contrib/doc/cjdns-online.md	2016-05-10 18:55:17.289488599 -0400
2f8dfd1
@@ -0,0 +1,33 @@
2f8dfd1
+cjdns-online(1) -- check whether cjdns tunnel devices are available
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`cjdns-online` [<options>...]
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+
2f8dfd1
+Cjdns-online waits for cjdns to make its tunnel device available so 
2f8dfd1
+that services that listen on the cjdns IP can start.  If you have
2f8dfd1
+configured services to listen on the cjdns IP, then you can use:
2f8dfd1
+
2f8dfd1
+    systemctl enable cjdns-wait-online
2f8dfd1
+
2f8dfd1
+to wait until this IP is available before starting network services.
2f8dfd1
+This will increase your boot time somewhat, but is needed to launch
2f8dfd1
+thttpd at boot, for example.
2f8dfd1
+
2f8dfd1
+##OPTIONS
2f8dfd1
+
2f8dfd1
+  * `-t`, `--timeout` <timeout_value>:	
2f8dfd1
+    time to wait in seconds, default 30
2f8dfd1
+
2f8dfd1
+  * `-x`, `--exit`:		
2f8dfd1
+    Exit immediately if cjdns is not online
2f8dfd1
+
2f8dfd1
+  * `-q`, `--quiet`:
2f8dfd1
+    Don't print anything
2f8dfd1
+
2f8dfd1
+  * `-s`, `--wait-for-startup`:
2f8dfd1
+    Wait for full startup instead of just tun dev.  This is not implemented.
2f8dfd1
+
2f8dfd1
diff -up ./contrib/doc/cjdroute.md.man ./contrib/doc/cjdroute.md
d7184b7
--- ./contrib/doc/cjdroute.md.man	2016-05-10 18:55:17.289488599 -0400
d7184b7
+++ ./contrib/doc/cjdroute.md	2016-05-10 18:55:17.289488599 -0400
2f8dfd1
@@ -0,0 +1,76 @@
2f8dfd1
+cjdroute(1) -- Cjdns packet switch
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`/usr/sbin/cjdroute` [<options>...]
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+
2f8dfd1
+Cjdns implements an encrypted IPv6 network using public-key cryptography for
2f8dfd1
+address allocation and a distributed hash table for routing. This provides
2f8dfd1
+near-zero-configuration networking, and prevents many of the security and
2f8dfd1
+scalability issues that plague existing networks.
2f8dfd1
+
2f8dfd1
+cjdroute runs in the background and either decrypts packets addressed to
2f8dfd1
+this node, or sends them on to the next node in the route.
2f8dfd1
+
2f8dfd1
+##OPTIONS
2f8dfd1
+
2f8dfd1
+  * `--help`:
2f8dfd1
+    Print usage summary.
2f8dfd1
+
2f8dfd1
+  * `--genconf` [--no-eth]:
2f8dfd1
+    Generate a configuration file, write it to stdout.
2f8dfd1
+    If --no-eth is specified then ethernet beaconing will be disabled.
2f8dfd1
+
2f8dfd1
+  * `--bench`:
2f8dfd1
+    Run some cryptography performance benchmarks.
2f8dfd1
+
2f8dfd1
+  * `--version`:             
2f8dfd1
+    Print cjdroute version and the protocol version which this node speaks.
2f8dfd1
+
2f8dfd1
+  * `--cleanconf` < conf:
2f8dfd1
+    Print a clean (valid json) version of the config.
2f8dfd1
+
2f8dfd1
+  * `--nobg`                
2f8dfd1
+    Never fork to the background no matter the config.
2f8dfd1
+
2f8dfd1
+##USAGE
2f8dfd1
+
2f8dfd1
+To get the router up and running:
2f8dfd1
+
2f8dfd1
+  * Step 1:
2f8dfd1
+    Generate a new configuration file if one doesn't already exist.
2f8dfd1
+
2f8dfd1
+      cjdroute --genconf > /etc/cjdroute.conf
2f8dfd1
+
2f8dfd1
+    You can also simply:
2f8dfd1
+
2f8dfd1
+      systemctl start cjdns
2f8dfd1
+
2f8dfd1
+    which will tell cjdroute to generate a new config if needed.
2f8dfd1
+
2f8dfd1
+  * Step 2:
2f8dfd1
+    Find somebody to connect to.
2f8dfd1
+    Check out the IRC channel or http://hyperboria.net/
2f8dfd1
+    for information about how to meet new people and make connect to them.
2f8dfd1
+    Read more here: https://github.com/cjdelisle/cjdns/#2-find-a-friend
2f8dfd1
+
2f8dfd1
+    By default, cjdroute will find any cjdns nodes on your local LAN
2f8dfd1
+    without any configuration.
2f8dfd1
+
2f8dfd1
+  * Step 3:
2f8dfd1
+    Add that somebody's node to your cjdroute.conf file.
2f8dfd1
+    https://github.com/cjdelisle/cjdns/#3-connect-your-node-to-your-friends-node
2f8dfd1
+
2f8dfd1
+  * Step 4:
2f8dfd1
+    Fire it up!
2f8dfd1
+
2f8dfd1
+      systemctl start cjdns
2f8dfd1
+
2f8dfd1
+    Or if you had already started cjdns:
2f8dfd1
+
2f8dfd1
+      systemctl restart cjdns
2f8dfd1
+
2f8dfd1
+For more information about other functions and non-standard setups, see README.md
2f8dfd1
diff -up ./contrib/doc/makekeys.md.man ./contrib/doc/makekeys.md
d7184b7
--- ./contrib/doc/makekeys.md.man	2016-05-10 18:55:17.289488599 -0400
d7184b7
+++ ./contrib/doc/makekeys.md	2016-05-10 18:58:51.521907178 -0400
d7184b7
@@ -0,0 +1,24 @@
2f8dfd1
+makekeys(1) -- write cjdns keys generated via libnacl to stdout
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`makekeys`
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+
2f8dfd1
+Generates cjdns private keys and writes them to stdout forever with
2f8dfd1
+corresponding IP6 address and public key.  Sample:
2f8dfd1
+
2f8dfd1
+    9b5520e11b4e1aac4e54cf8382ca219b6942f75519dbe7cc71fc6c4bb636a2db fca1:43dc:9e20:68dc:df3f:6bf1:fbf9:37ab x70u0x6sfh0yuushlq7wvcdxj8rgb8lvss9t6f42zp60ftq71cm0.k
2f8dfd1
+    579db68cfdeaeda1ff7f365c73e620bedb0f68cb443a0cd7ef6bae16d0e1e12e fc68:b272:3aa3:cb4a:a686:dab0:7df5:2fb5 fmurp2qrb0yqmcjmbjtuhuxuf6v3rgmdn9hgsfh47k20h68y2lz0.k
2f8dfd1
+
d7184b7
+##USAGE
d7184b7
+
d7184b7
+Example use:
d7184b7
+
d7184b7
+    makekeys | head -20 >keys.txt
d7184b7
+
2f8dfd1
+## SEE ALSO
2f8dfd1
+
2f8dfd1
+publictoip6(1)
1271acc
diff -up ./contrib/doc/peerStats.md.man ./contrib/doc/peerStats.md
d7184b7
--- ./contrib/doc/peerStats.md.man	2016-05-10 18:55:17.289488599 -0400
d7184b7
+++ ./contrib/doc/peerStats.md	2016-05-10 18:55:17.289488599 -0400
1271acc
@@ -0,0 +1,25 @@
1271acc
+peerStats(1) -- show cjdns peers
1271acc
+=============================================
1271acc
+
1271acc
+## SYNOPSIS
1271acc
+
1271acc
+`peerStats`
1271acc
+
1271acc
+## DESCRIPTION
1271acc
+
1271acc
+Cjdroute talks to a number of immediate peers configured in
1271acc
+`/etc/cjdroute.conf`.  These can be discovered dynamically on local
1271acc
+networks if "beacon" is enabled.  Peers are enabled to connect
1271acc
+to cjdroute by adding a login in "authorizedPasswords".  Connecting
1271acc
+out to peers is configured in "connectTo" in either the IPv4 or IPv6 section.
1271acc
+
1271acc
+No admin privilege is needed to run peerStats, but it looks in `~/.cjdnsadmin`
1271acc
+for the IP and admin port of cjdroute.
1271acc
+
1271acc
+##FILES
1271acc
+
1271acc
+`~/.cjdnsadmin`
1271acc
+
1271acc
+## SEE ALSO
1271acc
+
1271acc
+cjdroute(1), sessionStats(1)
2f8dfd1
diff -up ./contrib/doc/privatetopublic.md.man ./contrib/doc/privatetopublic.md
d7184b7
--- ./contrib/doc/privatetopublic.md.man	2016-05-10 18:55:17.290488610 -0400
d7184b7
+++ ./contrib/doc/privatetopublic.md	2016-05-10 18:55:17.290488610 -0400
2f8dfd1
@@ -0,0 +1,25 @@
2f8dfd1
+privatetopublic(8) -- convert cjdns private keys to public keys and IP6
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`/usr/libexec/cjdns/privatetopublic`
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+
2f8dfd1
+As private keys are very sensitive, /usr/libexec/cjdns/privatetopublic reads
2f8dfd1
+them from stdin.  If your shell, terminal, or other program keeps history,
2f8dfd1
+please avoid `echo 'key' | /usr/libexec/cjdns/privatetopublic`, or similar
2f8dfd1
+constructs.  A heredoc is suitable for use in scripts, and will avoid
2f8dfd1
+unwanted revealing of the key in process lists, like so:
2f8dfd1
+
2f8dfd1
+    /usr/libexec/cjdns/privatetopublic <
2f8dfd1
+    key
2f8dfd1
+    EOF
2f8dfd1
+
2f8dfd1
+Key should be in hex form, maximum 64 characters.  Extra characters will be
2f8dfd1
+silently ignored.
2f8dfd1
+
2f8dfd1
+## SEE ALSO
2f8dfd1
+
2f8dfd1
+publictoip6(1)
2f8dfd1
diff -up ./contrib/doc/publictoip6.md.man ./contrib/doc/publictoip6.md
d7184b7
--- ./contrib/doc/publictoip6.md.man	2016-05-10 18:55:17.290488610 -0400
d7184b7
+++ ./contrib/doc/publictoip6.md	2016-05-10 18:59:01.906033221 -0400
2f8dfd1
@@ -0,0 +1,14 @@
d7184b7
+publictoip6(1) -- Derive cjdns IP6 address from a public key
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`publictoip6` <public key>
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+Get a cjdns IPv6 address from a public key and write to stdout.
2f8dfd1
+The key should be in Base32 and end in '.k'.
2f8dfd1
+
2f8dfd1
+## SEE ALSO
2f8dfd1
+
2f8dfd1
+randombytes(1)
2f8dfd1
diff -up ./contrib/doc/randombytes.md.man ./contrib/doc/randombytes.md
d7184b7
--- ./contrib/doc/randombytes.md.man	2016-05-10 18:55:17.290488610 -0400
d7184b7
+++ ./contrib/doc/randombytes.md	2016-05-10 18:55:17.290488610 -0400
2f8dfd1
@@ -0,0 +1,16 @@
2f8dfd1
+randombytes(1) -- write random bytes generated via libnacl to stdout
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`randombytes`
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+
2f8dfd1
+Writes random bytes to stdout forever using the cryptographically secure
2f8dfd1
+random generator in libnacl.  In practice, the output is piped
2f8dfd1
+to a program like dd(1) or base64(1).
2f8dfd1
+
2f8dfd1
+## SEE ALSO
2f8dfd1
+
2f8dfd1
+makekeys(1)
4b865ac
diff -up ./contrib/doc/sessionStats.md.man ./contrib/doc/sessionStats.md
d7184b7
--- ./contrib/doc/sessionStats.md.man	2016-05-10 18:55:17.290488610 -0400
d7184b7
+++ ./contrib/doc/sessionStats.md	2016-05-10 18:55:17.290488610 -0400
4b865ac
@@ -0,0 +1,39 @@
4b865ac
+sessionStats(1) -- show cjdns crypto sessions
4b865ac
+=============================================
4b865ac
+
4b865ac
+## SYNOPSIS
4b865ac
+
4b865ac
+`sessionStats`
4b865ac
+
4b865ac
+## DESCRIPTION
4b865ac
+
4b865ac
+Cjdroute always talks to other nodes over a "session" similar to
4b865ac
+a TLS session.  A session is required not only to talk to each peer,
4b865ac
+but also when talking to intermediate nodes to ask them about their peers
4b865ac
+when planning a route.  
4b865ac
+
1257fc8
+The cjdns protocol offers Perfect Forward Secrecy.  Each session has a random
4b865ac
+symmetric key that encrypts that session.  If a node is compromised, 
4b865ac
+the attacker can get the session keys and read current and future sessions.
4b865ac
+However, the session keys are securely erased when a session is destroyed,
4b865ac
+so that past sessions (before the compromise) cannot be read.  The lifetime
4b865ac
+of a session is somewhat random.  Cjdroute caches recently active sessions,
4b865ac
+and destroys sessions that have not been used for a while.
4b865ac
+
4b865ac
+##USAGE
4b865ac
+
4b865ac
+Running sessionStats requires admin privilege.  The cjdnsadmin lib will 
4b865ac
+try to read `/etc/cjdroute.conf` for the admin password.  This will 
4b865ac
+normally succeed only for root.  Otherwise, it tries `~/.cjdnsadmin`
4b865ac
+
4b865ac
+##FILES
4b865ac
+
4b865ac
+`~/.cjdnsadmin`
4b865ac
+`/etc/cjdroute.conf`
4b865ac
+
4b865ac
+##BUGS
4b865ac
+If you get a TypeError, you probably have the wrong admin password.
4b865ac
+
4b865ac
+## SEE ALSO
4b865ac
+
4b865ac
+cjdroute(1), peerStats(1)
2f8dfd1
diff -up ./contrib/doc/sybilsim.md.man ./contrib/doc/sybilsim.md
d7184b7
--- ./contrib/doc/sybilsim.md.man	2016-05-10 18:55:17.290488610 -0400
d7184b7
+++ ./contrib/doc/sybilsim.md	2016-05-10 18:55:17.290488610 -0400
2f8dfd1
@@ -0,0 +1,43 @@
2f8dfd1
+sybilsim(8) -- Cjdns packet switch
2f8dfd1
+=============================================
2f8dfd1
+
2f8dfd1
+## SYNOPSIS
2f8dfd1
+
2f8dfd1
+`/usr/libexec/cjdns/sybilsim < config.json`
2f8dfd1
+
2f8dfd1
+## DESCRIPTION
2f8dfd1
+
2f8dfd1
+Sybilsim reads a list of nodes and peers from stdin and simulates the
2f8dfd1
+corresponding mesh without any actual networking using the same code
2f8dfd1
+as cjdroute.  This is useful for testing and optimizing cjdroute.
2f8dfd1
+Every node must have a valid cjdns private key. The makekeys(1) utility can be
2f8dfd1
+useful for scripts that generate the config.  
2f8dfd1
+
2f8dfd1
+##USAGE
2f8dfd1
+
2f8dfd1
+Example config:
2f8dfd1
+
2f8dfd1
+    {
2f8dfd1
+      "nodes": {
2f8dfd1
+	"alice": {
2f8dfd1
+	  "privateKey":
2f8dfd1
+	    "5e2295679394e5e1db67c238abbc10292ad9b127904394c52cc5fff39383e920",
2f8dfd1
+	  "peers": []
2f8dfd1
+	},
2f8dfd1
+	"bob": {
2f8dfd1
+	  "privateKey":
2f8dfd1
+	    "6569bf3f0d168faa6dfb2912f8ee5ee9b938319e97618fdf06caed73b1aad1cc",
2f8dfd1
+	  "peers": [ "alice" ]
2f8dfd1
+	}
2f8dfd1
+      }
2f8dfd1
+    }
2f8dfd1
+
2f8dfd1
+Example use:
2f8dfd1
+
2f8dfd1
+    makekeys | head -20 >keys.txt
2f8dfd1
+    node /usr/libexec/cjdns/tools/lib/makesim.js keys.txt |
2f8dfd1
+    /usr/libexec/cjdns/sybilsim
2f8dfd1
+
2f8dfd1
+## SEE ALSO
2f8dfd1
+
2f8dfd1
+makekeys(1), cjdroute(1)
4b865ac
diff -up ./contrib/doc/traceroute.md.man ./contrib/doc/traceroute.md
d7184b7
--- ./contrib/doc/traceroute.md.man	2016-05-10 18:55:17.290488610 -0400
d7184b7
+++ ./contrib/doc/traceroute.md	2016-05-10 18:55:17.290488610 -0400
4b865ac
@@ -0,0 +1,33 @@
1257fc8
+cjdns-traceroute(1) -- trace cjdns packet routing
4b865ac
+=============================================
4b865ac
+
4b865ac
+## SYNOPSIS
4b865ac
+
4b865ac
+`cjdns-traceroute` <host_or_ip>
4b865ac
+
4b865ac
+## DESCRIPTION
4b865ac
+
1257fc8
+Because cjdns is end to end encrypted, the standard traceroute always
4b865ac
+shows a direct connection.  Cjdns-traceroute queries cjdroute to discover
4b865ac
+what route would be used to send a packet to the destination IP.
4b865ac
+Note that just as with the standard traceroute, there is no guarantee
4b865ac
+that that precise route will actually be used with the next packet.
4b865ac
+
4b865ac
+Cjdns-traceroute requires admin privilege.  The cjdnsadmin lib will 
4b865ac
+try to read `/etc/cjdroute.conf` for the admin password.  This will 
4b865ac
+normally succeed only for root.  Otherwise, it tries `~/.cjdnsadmin`
4b865ac
+
4b865ac
+##USAGE
4b865ac
+
4b865ac
+##FILES
4b865ac
+
4b865ac
+`~/.cjdnsadmin`
4b865ac
+`/etc/cjdroute.conf`
4b865ac
+
4b865ac
+##BUGS
4b865ac
+Cjdns-traceroute throws an ugly exception if you forget
4b865ac
+to pass an IP or have the wrong admin password.
4b865ac
+
4b865ac
+## SEE ALSO
4b865ac
+
4b865ac
+cjdroute(1)