Compare commits

...
67 Commits
Author SHA1 Message Date
Adam Ierymenko d92da40bff VERSION 0.6.2: Mac users should 'sudo make install-mac-tap' again.
This version fixes a recurrent gremlin in the tap driver for Mac. If you are
having this issue, you should reinstall the tap.

If you're already running ZT1, shut it down (sudo killall zerotier-one) and
then do:

sudo kextunload /Library/Application\ Support/ZeroTier/One/tap.kext

This should unload the old version. Then type 'sudo make install-mac-tap' in
the ZT1 source home directory and the new version will be installed. ZT1 will
load the module again when it next starts.

In addition to a fix, I am now distributing tap binaries and it is no longer
built in the default Makefile. This is because Apple's in the midst of some
changes that have made building it somewhat difficult.

Another note for Mavericks users:

The first time you use ZT1, you will get a popup about unsigned kernel
extensions. This will vanish once we're out of beta and have signing keys
and signed drivers.

Other changes in this version:

 * Minor improvement to Utils::getSecureRandom
 * Bug fixes and a small change to certificates of membership for private
   networks, which now appear to be working very well!
 * Stubbed out messages for auto-update, which will be done in-band via
   the ZT1 protocol. Not implemented yet.
2013-10-28 16:32:17 -04:00
Adam Ierymenko 5750cf6b72 New cthulhu.zerotier.com supernode IP address. 2013-10-28 16:24:55 -04:00
Adam Ierymenko 7015017686 Make Makefile for Mac use clang options instead of old GCC options, and fix a nasty but obvious bug I introduced into Utils::getSecureRandom. 2013-10-28 15:53:40 -04:00
Adam Ierymenko 12b297a712 Put default MTU in tap back to 2800, clean up tun-related files and other things from the original pre-fork tap code base that we will never use. 2013-10-28 15:18:06 -04:00
Adam Ierymenko d290306bb3 Update binary build of tap. 2013-10-28 13:23:56 -04:00
Adam Ierymenko 60ac1b77c5 Fix for GitHub issue #25 2013-10-28 13:22:23 -04:00
Adam Ierymenko e514fe2bff Change install-mac-tap rule. 2013-10-28 09:34:36 -04:00
Adam Ierymenko 148619f0ba Make tap build on OSX 10.9, though not in a way that is easy for users. Instead package binaries. 2013-10-28 09:33:32 -04:00
Adam Ierymenko 17778a36ba Clean up secure random, add packet definitions for update distribution facility. 2013-10-27 07:26:50 -04:00
Adam Ierymenko df28cd88b8 docs: we no longer use MS loopback 2013-10-26 07:39:07 -04:00
Adam Ierymenko 942cc0ca21 Certificate of membership works now... had to fix multicast propagation so COM is pushed with multicast, which makes tremendous sense in retrospect. 2013-10-25 14:51:55 -04:00
Adam Ierymenko 010616e3ae Add some more TRACE output for certs. 2013-10-25 13:43:04 -04:00
Adam Ierymenko 1505e8dd50 Fix netconf init and identity transfer. 2013-10-25 13:04:58 -04:00
Adam Ierymenko 5901972958 More tying up of certificate of membership stuff in the client. 2013-10-24 16:57:26 -04:00
Adam Ierymenko bbcd76ecd0 Netconf updates -- actually issue COM, and log attempts to access networks in NetworkActivity using the new authenticated flag in the new DB schema. 2013-10-24 16:19:53 -04:00
Adam Ierymenko 3de76fcab1 Make network autoconf a little more frequent to tighten up expiration times. 2013-10-21 16:11:29 -04:00
Adam Ierymenko d496304bbf Put back rest of selftest. 2013-10-21 15:59:22 -04:00
Adam Ierymenko 719dd2870d Self-test for certificate of membership. 2013-10-21 15:47:33 -04:00
Adam Ierymenko 2f00ae4fd7 Version 0.6.1: minor bug fix, DBM removal
This version removes the peer DBM present in earlier releases. It is not necessary for
regular clients and has been a source of problems.

There is a long-term identity cache that can be enabled by making a directory called
"iddb.d" in the home folder and restarting ZT1. This is probably something only our
supernodes would need, since regular nodes can easily WHOIS peers they've forgotten
about.

On shutdown, the peer database is dumped to disk. It's then restored on startup.
Peers that have not been used in a while are cleaned out, so this keeps this data
set small.

A DBM may re-appear later if it's needed, but for now it was YAGNI.
2013-10-21 14:22:02 -04:00
Adam Ierymenko 5e71e07f59 Add persistent identity caching for use on supernodes. Activate by just making an iddb.d directory in the ZeroTier home folder. Also clean up some obsolete cruft from makefiles. 2013-10-21 14:12:00 -04:00
Adam Ierymenko 40e4f39181 Peers are now dumped on shutdown in a persistence cache and reloaded on startup, which is good enough for clients right now. Supernodes will get something else for long-term authoritative identity caching. 2013-10-21 11:15:47 -04:00
Adam Ierymenko 6e217dfcb0 Get rid of DBM, which technically is a case of YAGNI. Supernodes will need a way to save identities, but that can be a different feature. Regular clients do not really need a permanent cache (yet). When/if we do need one we can do it then. Until then it only caused problems. 2013-10-21 10:29:44 -04:00
Adam Ierymenko bbfd43e036 VERSION 0.6.0 BETA: please upgrade!
Version 0.6.0 marks the transition of ZeroTier One from ALPHA to BETA.
Major updates to the web site and binary packages for MacOS and Linux
are coming soon, followed by Windows soon thereafter.

This version contains a number of changes including:

 * Speed improvements to encryption
 * A new much-improved identity algorithm, which unfortunately requires an
   identity regeneration. This should happen automatically, and should be
   the last time for a good long while assuming there's nothing wrong with
   what's here.
 * Cleaned up the Network::Config mess in the code, factored out Config
   into its own NetworkConfig class.
 * Lots of work to support private networks, which are still in testing.
   Concurrent with the web site update will be another minor release to
   include any fixes there.
 * Some changes to the protocol for better future-proofing.
 * Netconf support for ARP caching parameters configurable on per-network
   basis.

You must update to stay connected to the network; this version will not
talk to 0.5.0. After this, I'm going to be much more reluctant to make
incompatible changes.
2013-10-20 16:14:27 -04:00
Adam Ierymenko 70655cc3f7 Docs and auto-update of Earth network ID. 2013-10-20 16:00:41 -04:00
Adam Ierymenko c89cdcc3fd Blech... moving on! 2013-10-20 15:54:32 -04:00
Adam Ierymenko 1ed8a22d19 And then it turns out to be too slow on a slower 32-bit machine... we do want to do tablets eventually. 2013-10-20 15:46:36 -04:00
Adam Ierymenko bad043729f Yet another revision of this algo... yeesh... and update to supernode IDs. I think I am gonna go with this one. Seems memory-hard enough to me. I am probably procrastinating by obsessing over it. 2013-10-20 15:31:32 -04:00
Adam Ierymenko 3c5c3280ff Fix an endian-non-neutrality bug in new hashcash identity algo. 2013-10-20 11:04:58 -04:00
Adam Ierymenko 8c9b73f67b Make Salsa20 variable-round, allowing for Salsa20/12 to be used for Packet encrypt and decrypt. Profiling analysis found that Salsa20 encrypt was accounting for a nontrivial percentage of CPU time, so it makes sense to cut this load fundamentally. There are no published attacks against Salsa20/12, and DJB believes 20 rounds to be overkill. This should be more than enough for our needs. Obviously incorporating ASM Salsa20 is among the next steps for performance. 2013-10-18 17:39:48 -04:00
Adam Ierymenko 37e3bc3467 Bump version.h to version 0.6.0... almost there! 2013-10-18 16:59:15 -04:00
Adam Ierymenko 8d3dc3a44b Add commented out gprof makefile options to Linux build. 2013-10-18 16:51:05 -04:00
Adam Ierymenko fbf6ab5d4d Bug fixes: inverted sense bug, printf format bug. 2013-10-18 16:27:07 -04:00
Adam Ierymenko e13d4df9ab Forgot to set defaults if multicast parameters are unset. 2013-10-18 15:50:31 -04:00
Adam Ierymenko fb7d9b1029 Oops we needed _r in there... 2013-10-18 15:00:55 -04:00
Adam Ierymenko 5ef758bbd4 Eliminate unused private field (compiler warning). 2013-10-18 14:27:37 -04:00
Adam Ierymenko ca93b4a1ac Clean up some stuff, including a few spots where exceptions were not being handled correctly. 2013-10-18 14:16:53 -04:00
Adam Ierymenko 03b909603a Clean up the awful Network::Config mess and break that out into NetworkConfig. 2013-10-18 13:20:34 -04:00
Adam Ierymenko 5a8f213c23 Work in progress... 2013-10-18 12:01:48 -04:00
Adam Ierymenko b10871cedc More work in netconf cleanup. 2013-10-18 11:01:41 -04:00
Adam Ierymenko 9f107dbd4e Work in progress on cleaning up netconf mess in node code... 2013-10-18 09:48:02 -04:00
Adam Ierymenko e6eb65be00 Netconf support for ARP and NDP caching TTLs. 2013-10-17 16:49:31 -04:00
Adam Ierymenko dd7758e33e Add multicast trace receiver to attic/. Another run of multicast trace reveals fairly nice behavior. It looks like the traffic jams are the fault of ARP, which results from a gaggle of hosts trying to send ping replies. ARP caching will help with that quite a bit. 2013-10-17 16:27:46 -04:00
Adam Ierymenko d0dbd869c9 Increase verbosity of multicast tracing and fix tap build problem / GitHub Issue #19 2013-10-17 15:20:43 -04:00
Adam Ierymenko 9ece65da23 Fix some old column names in netconf. 2013-10-17 13:52:39 -04:00
Adam Ierymenko 7701e25a45 Merge branch 'adamierymenko-dev' of shub-niggurath.zerotier.com:/git/ZeroTierOne into adamierymenko-dev 2013-10-17 13:08:09 -04:00
Adam Ierymenko 797bba04dd Get rid of not used and maybe never to be used Filter code. 2013-10-17 13:07:53 -04:00
Adam Ierymenko f7bf9da881 Compile fix for netconf. 2013-10-17 11:22:03 -04:00
Adam Ierymenko ce14ba9004 Take the 0.6.0 opportunity to add flags to a few protocol verbs and do a bit more cleanup. Also fix it so certificates wont be accepted unless they are newer than existing ones. 2013-10-17 06:41:52 -04:00
Adam Ierymenko 555471200c Add DISTINCT to queue query. 2013-10-17 05:40:04 -04:00
Adam Ierymenko 7e7e28f5f7 Add support for pushing network config refresh hints from a MEMORY queue table. That ways it will be possible for network changes to take effect almost immediately across all active peers. 2013-10-17 05:37:01 -04:00
Adam Ierymenko 46f868bd4f Lots of cleanup, more work on certificates, some security fixes. 2013-10-16 17:47:26 -04:00
Adam Ierymenko 58fa6cab43 Auto-pushing of membership certs on: MULTICAST_FRAME,FRAME,MULTICAST_LIKE and on receipt of MULTICAST_LIKE. 2013-10-07 17:00:53 -04:00
Adam Ierymenko 4d594b24bc Automagically push netconf certs -- Network support. 2013-10-07 16:13:52 -04:00
Adam Ierymenko b4ae1adfbf Break out certificate of membership into its own class. 2013-10-07 15:29:03 -04:00
Adam Ierymenko dcbc9c8ddd Rename error code for no membership certificate. 2013-10-07 15:21:40 -04:00
Adam Ierymenko 430882327e Couple of small fixes, works again with new ID code. 2013-10-07 15:00:38 -04:00
Adam Ierymenko 2fa2796f2a Another tweak, hopefully final, to reduce variance on identity generation times. 2013-10-07 14:31:13 -04:00
Adam Ierymenko 343b7f44fc Old algo for ID derivation was not in fact memory-hard since Salsa20 is seekable, so take two. 2013-10-07 12:48:27 -04:00
Adam Ierymenko 0c8614b9c6 Add a second arg to idtool generate to make generating both secret and public easier, add new supernode identities after generating them, fix known good and bad IDs in selftest. 2013-10-07 09:36:20 -04:00
Adam Ierymenko 5fa7a92048 Allocate genmem[] since its too big for the stack on some systems. 2013-10-06 05:28:25 -04:00
Adam Ierymenko bc715fbd51 Make new identity hashcash algo memory hard, and tweak generation time a bit. Current hashcash cost should be overkill for what we need but still tolerable to users. 2013-10-05 14:15:59 -04:00
Adam Ierymenko a31c54b44b Remove an obsolete column from Node table in netconf. 2013-10-05 10:45:23 -04:00
Adam Ierymenko 4267e7da93 Remove a whole bunch of now-unnecessary cruft from Topology and PacketDecoder. 2013-10-05 10:19:12 -04:00
Adam Ierymenko 0e43e5e8f2 Rest of work on new hashcash based identity scheme. 2013-10-05 07:00:55 -04:00
Adam Ierymenko b0187f4472 Hashcash-based identity, work in progress... committing to test speed on other boxes. 2013-10-05 06:00:47 -04:00
Adam Ierymenko 588a47be89 Some API improvements to C25519 in preparation for that thing I woke up thinking about at 4am. 2013-10-05 05:26:38 -04:00
Adam Ierymenko ea4e1136dd Flesh out membership certificate with signature, better serialize/deserialize, and rename parameter to qualifier to make better conceptual sense. 2013-10-04 12:24:21 -04:00
129 changed files with 2914 additions and 6173 deletions

No files matched your search

+1 -15
View File
@@ -20,18 +20,4 @@ Edit Makefile.linux if you want to change between debug or release build.
-- Windows
Right now Windows builds using Visual Studio 2012. Technically it should also
build with other tools, but VS2012 is what your author is using.
Load the ZeroTierOne.sln solution. Typically you won't need to worry about
any projects other than ZeroTierOne, Service, and InstallerUpdater. SelfTest
builds the selftest program which can be used to test many aspects of the
core code base. TapDriver builds the Ethernet tap driver, which shouldn't
be something end users need to do and requires a driver signing key to create
a publishable driver that users can load without big red warnings.
To just test ZeroTier One itself, build ZeroTierOne and run the binary in
an administrator-mode command window.
Instructions for doing a full build will be forthcoming once all the details
are worked out. Windows is still a work in progress.
Here be dragons.
+6 -3
View File
@@ -2,18 +2,21 @@ CC=gcc
CXX=g++
INCLUDES=
ARCH=$(shell uname -m)
DEFS=-DZT_ARCH="$(ARCH)" -DZT_OSNAME="linux" -DZT_TRACE
DEFS=
LIBS=
# Uncomment for a release optimized build
CFLAGS=-Wall -O3 -fno-unroll-loops -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
CFLAGS=-Wall -O3 -fno-unroll-loops -fvisibility=hidden -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS)
STRIP=strip --strip-all
# Uncomment for a debug build
#CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS)
#STRIP=echo
# Uncomment for gprof profile build
#CFLAGS=-Wall -g -pg -pthread $(INCLUDES) $(DEFS)
#STRIP=echo
CXXFLAGS=$(CFLAGS) -fno-rtti
include objects.mk
+7 -10
View File
@@ -1,12 +1,12 @@
CC=gcc
CXX=g++
CC=clang
CXX=clang++
INCLUDES=
DEFS=-DZT_ARCH="x86_combined" -DZT_OSNAME="mac" -DZT_TRACE
DEFS=
LIBS=-lm
# Uncomment for a release optimized universal binary build
CFLAGS=-arch i386 -arch x86_64 -Wall -O3 -ftree-vectorize -fstack-protector -pthread -mmacosx-version-min=10.6 -DNDEBUG $(INCLUDES) $(DEFS)
CFLAGS=-arch i386 -arch x86_64 -Wall -O4 -pthread -mmacosx-version-min=10.6 -DNDEBUG $(INCLUDES) $(DEFS)
STRIP=strip
# Uncomment for a debug build
@@ -17,7 +17,7 @@ CXXFLAGS=$(CFLAGS) -fno-rtti
include objects.mk
all: one cli mac-tap
all: one cli
one: $(OBJS)
$(CXX) $(CXXFLAGS) -o zerotier-one main.cpp $(OBJS) $(LIBS)
@@ -35,18 +35,15 @@ idtool: $(OBJS)
$(CXX) $(CXXFLAGS) -o zerotier-idtool idtool.cpp $(OBJS) $(LIBS)
$(STRIP) zerotier-idtool
mac-tap: FORCE
cd mac-tap/tuntap ; make tap.kext
install-mac-tap: FORCE
mkdir -p /Library/Application\ Support/ZeroTier/One
rm -rf /Library/Application\ Support/ZeroTier/One/tap.kext
cp -R mac-tap/tuntap/tap.kext /Library/Application\ Support/ZeroTier/One
cp -R ext/bin/tap-mac//tap.kext /Library/Application\ Support/ZeroTier/One
chown -R root:wheel /Library/Application\ Support/ZeroTier/One/tap.kext
clean:
rm -rf *.dSYM
rm -f $(OBJS) zerotier-*
cd mac-tap/tuntap ; make clean
cd tap-mac/tuntap ; make clean
FORCE:
+3 -5
View File
@@ -3,18 +3,16 @@ ZeroTier One
ZeroTier One creates flat virtual Ethernet networks of almost unlimited size. [Visit ZeroTier Networks on the web](https://www.zerotier.com/) for more information.
This code is presently in **ALPHA** testing. That means that the protocol spec may change in incompatible ways, and it certainly has bugs. Testers should "git pull," rebuild, and restart fairly often. If things mysteriously stop working, do that.
This project is now in beta, which means that major incompatible protocol shifts should now become considerably more rare. You should still update very often if you plan to use it. Binary packages with auto-update are coming very soon.
Follow the [ZeroTier blog](http://blog.zerotier.com/) and the [GitHub project](https://github.com/zerotier/ZeroTierOne) to stay up to date.
See BUILDING.txt and RUNNING.txt for instructions. It currently builds on Mac and Linux. A Windows port is well along the way to completion. If you're brave you can load the Visual Studio 2012 solution and play around.
See BUILDING.txt and RUNNING.txt for instructions. It currently runs on Mac and Linux. A Windows port is well along the way to completion. If you're brave you can load the Visual Studio 2012 solution and play around.
Once you have it running you can join the Earth network -- a LAN for the planet -- by using the 'zerotier-cli' tool: 'sudo zerotier-cli join bc8f9a8ee3000001'. Right now Earth is the only network. Ability to create private networks, as well as some additional special-purpose public ones, will be coming soon. (Note: previous alpha versions auto-joined Earth, but since 0.5.0 it no longer does this.)
Once you have it running you can join the Earth network -- a LAN for the planet -- by using the 'zerotier-cli' tool: 'sudo zerotier-cli join 8056c2e21c000001'. Right now Earth is the only network. Ability to create private networks, as well as some additional special-purpose public ones, will be coming soon. (Note: previous alpha versions auto-joined Earth, but since 0.5.0 it no longer does this.)
Note that this won't work if your firewall does not allow outbound UDP. It must allow two way UDP conversations on port 9993 at a minimum.
ZeroTier One is licensed under the GNU General Public License version 3. You are free to use, modify, or redistribute it under the terms of that license. If you would like to embed ZeroTier One in a closed source product or create a closed source derivative product, contact ZeroTier Networks LLC.
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/59b2cbb9c154bf84bddb4b714402e548 "githalytics.com")](http://githalytics.com/zerotier/ZeroTierOne)
(c)2012-2013 [ZeroTier Networks LLC](https://www.zerotier.com/)
+2 -2
View File
@@ -7,7 +7,7 @@ By convention, ZeroTier One will keep its state here on mac:
/Library/Application Support/ZeroTier/One
ZeroTier ships with a kernel extension for its own tap device, which it
stores in the above directory. To install this from source, type:
stores in the above directory. To install this, type:
sudo make -f Makefile.mac install-mac-tap
@@ -22,7 +22,7 @@ sudo ./zerotier-one &
Finally, join the Earth network (the big public LAN and the only net for now):
sudo zerotier-cli join bc8f9a8ee3000001
sudo zerotier-cli join 8056c2e21c000001
Try pinging earth.zerotier.net and going to http://earth.zerotier.net/ in a
browser to see if you're online.
File renamed without changes.
File renamed without changes.
+2
View File
@@ -0,0 +1,2 @@
This directory is for old code that isn't used but we don't want to lose
track of, and for anything else random like debug scripts.
File renamed without changes.
+27
View File
@@ -0,0 +1,27 @@
#!/usr/bin/ruby
#
# This can be used with the debug build option ZT_TRACE_MULTICAST to trace
# a multicast cascade.
#
# Define ZT_TRACE_MULTICAST to the IP/port where this script will be listening.
# The default port here is 6060, so an example would be to add:
#
# -DZT_TRACE_MULTICAST=\"10.0.0.1/6060\"
#
# ... to DEFS in the Makefile. Then build and run ZeroTier One on a testnet and
# the box defined as the trace endpoint will get spammed with UDP packets
# containing trace information for multicast propagation. This script then dumps
# these trace packets to stdout. Look at the code in PacketDecoder.cpp to see
# what this information entails.
#
require 'socket'
s = UDPSocket.new
s.bind('0.0.0.0',6060)
loop {
m = s.recvfrom(4096)[0].chomp
puts m if m.length > 0
}
+2 -2
View File
@@ -3,5 +3,5 @@ fair game to redistribute. It's packaged with OpenVPN and several
other things and also distributed in source code form as an example
program by Microsoft.
It's used to automatically install the Microsoft Loopback Adapter
or remove it when no longer needed.
It's called by zerotier-one.exe to automagically install and remove
instances of the tap device.
@@ -3,21 +3,21 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>@@CFBUNDLEDEVELOPMENTREGION@@</string>
<string>English</string>
<key>CFBundleExecutable</key>
<string>@@CFBUNDLEEXECUTABLE@@</string>
<string>tap</string>
<key>CFBundleIdentifier</key>
<string>@@CFBUNDLEIDENTIFIER@@</string>
<string>com.zerotier.tap</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>@@CFBUNDLEEXECUTABLE@@</string>
<string>tap</string>
<key>CFBundlePackageType</key>
<string>@@CFBUNDLEPACKAGETYPE@@</string>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>@@CFBUNDLEVERSION@@</string>
<string>20131028</string>
<key>CFBundleSignature</key>
<string>@@CFBUNDLESIGNATURE@@</string>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>OSBundleLibraries</key>
Binary file not shown.
-70
View File
@@ -1,70 +0,0 @@
kissdb
======
(Keep It) Simple Stupid Database
KISSDB is about the simplest key/value store you'll ever see, anywhere.
It's written in plain vanilla C using only the standard string and FILE
I/O functions, and should port to just about anything with a disk or
something that acts like one.
It stores keys and values of fixed length in a stupid-simple file format
based on fixed-size hash tables. If a hash collision occurrs, a new "page"
of hash table is appended to the database. The format is append-only.
There is no delete. Puts that replace an existing value, however, will not
grow the file as they will overwrite the existing entry.
Hash table size is a space/speed trade-off parameter. Larger hash tables
will reduce collisions and speed things up a bit, at the expense of memory
and disk space. A good size is usually about 1/2 the average number of
entries you expect.
Features:
* Tiny, compiles to ~4k on an x86_64 Linux system
* Small memory footprint (only caches hash tables)
* Very space-efficient (on disk) if small hash tables are used
* Makes a decent effort to be robust on power loss
* Pretty respectably fast, especially given its simplicity
* 64-bit, file size limit is 2^64 bytes
* Ports to anything with a C compiler and stdlib/stdio
* Public domain
Limitations:
* Fixed-size keys and values, must recreate and copy to change any init size parameter
* Add/update only, no delete
* Iteration is supported but key order is undefined
* No search for subsets of keys/values
* No indexes
* No transactions
* No special recovery features if a database gets corrupted
* No built-in thread-safety (guard it with a mutex in MT code)
* No built-in caching of data (only hash tables are cached for lookup speed)
* No endian-awareness (currently), so big-endian DBs won't read on little-endian machines
Alternative key/value stores and embedded databases:
* [MDB](http://symas.com/mdb/) uses mmap() and is very fast (not quite as tiny/simple/portable)
* [CDB](http://cr.yp.to/cdb.html) is also minimal and fast, probably the closest thing to this (but has a 4gb size limit)
* [Kyoto Cabinet](http://fallabs.com/kyotocabinet/) is very fast, full-featured, and modern (license required for commercial use)
* [SQLite](http://www.sqlite.org/) gives you a complete embedded SQL server (public domain, very mature, much larger)
* Others include GDBM, NDBM, Berkeley DB, etc. Use your Googles. :)
KISSDB is good if you want space-efficient relatively fast write-once/read-many storage
of keys mapped to values. It's not a good choice if you need searches, indexes, delete,
structured storage, or widely varying key/value sizes. It's also probably not a good
choice if you need a long-lived database for critical data, since it lacks recovery
features and is brittle if its internals are modified. It would be better for a cache
of data that can be restored or "re-learned," such as keys, Bitcoin transactions, nodes
on a peer-to-peer network, log analysis results, rendered web pages, session cookies,
auth tokens, etc.
KISSDB is in the public domain. One reason it was written was the
poverty of simple key/value databases with wide open licensing. Even old
ones like GDBM have GPL, not LGPL, licenses.
See comments in kissdb.h for documentation. Makefile can be used to build
a test program on systems with gcc.
Author: Adam Ierymenko / ZeroTier Networks LLC
-60
View File
@@ -1,60 +0,0 @@
-----
KISSDB file format (version 2)
Author: Adam Ierymenko <adam.ierymenko@zerotier.com>
-----
In keeping with the goal of minimalism the file format is very simple, the
sort of thing that would be given as an example in an introductory course in
data structures. It's a basic hash table that adds additional pages of hash
table entries on collision.
It consists of a 28 byte header followed by a series of hash tables and data.
All integer values are stored in the native word order of the target
architecture (in the future the code might be fixed to make everything
little-endian if anyone cares about that).
The header consists of the following fields:
[0-3] magic numbers: (ASCII) 'K', 'd', 'B', KISSDB_VERSION (currently 2)
[4-11] 64-bit hash table size in entries
[12-19] 64-bit key size in bytes
[20-27] 64-bit value size in bytes
Hash tables are arrays of [hash table size + 1] 64-bit integers. The extra
entry, if nonzero, is the offset in the file of the next hash table, forming
a linked list of hash tables across the file.
Immediately following the header, the first hash table will be written when
the first key/value is added. The algorithm for adding new entries is as
follows:
(1) The key is hashed using a 64-bit variant of the DJB2 hash function, and
this is taken modulo hash table size to get a bucket number.
(2) Hash tables are checked in order, starting with the first hash table,
until a zero (empty) bucket is found. If one is found, skip to step (4).
(3) If no empty buckets are found in any hash table, a new table is appended
to the file and the final pointer in the previous hash table is set to
its offset. (In the code the update of the next hash table pointer in
the previous hash table happens last, after the whole write is complete,
to avoid corruption on power loss.)
(4) The key and value are appended, in order with no additional meta-data,
to the database file. Before appending the offset in the file stream
where they will be stored is saved. After appending, this offset is
written to the empty hash table bucket we chose in steps 2/3. Hash table
updates happen last to avoid corruption if the write does not complete.
Lookup of a key/value pair occurs as follows:
(1) The key is hashed and taken modulo hash table size to get a bucket
number.
(2) If this bucket's entry in the hash table is nonzero, the key at the
offset specified by this bucket is compared to the key being looked up.
If they are equal, the value is read and returned.
(3) If the keys are not equal, the next hash table is checked and step (2)
is repeated. If an empty bucket is encountered or if we run out of hash
tables, the key was not found.
To update an existing value, its location is looked up and the value portion
of the entry is rewritten.
-447
View File
@@ -1,447 +0,0 @@
/* (Keep It) Simple Stupid Database
*
* Written by Adam Ierymenko <adam.ierymenko@zerotier.com>
* KISSDB is in the public domain and is distributed with NO WARRANTY. */
/* Compile with KISSDB_TEST to build as a test program. */
/* Note: big-endian systems will need changes to implement byte swapping
* on hash table file I/O. Or you could just use it as-is if you don't care
* that your database files will be unreadable on little-endian systems. */
#define _FILE_OFFSET_BITS 64
#include "kissdb.h"
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _WIN32
#define fseeko _fseeki64
#define ftello _ftelli64
#endif
#define KISSDB_HEADER_SIZE ((sizeof(uint64_t) * 3) + 4)
/* djb2 hash function */
static uint64_t KISSDB_hash(const void *b,unsigned long len)
{
unsigned long i;
uint64_t hash = 5381;
for(i=0;i<len;++i)
hash = ((hash << 5) + hash) + (uint64_t)(((const uint8_t *)b)[i]);
return hash;
}
int KISSDB_open(
KISSDB *db,
const char *path,
int mode,
unsigned long hash_table_size,
unsigned long key_size,
unsigned long value_size)
{
uint64_t tmp;
uint8_t tmp2[4];
uint64_t *httmp;
uint64_t *hash_tables_rea;
#ifdef _WIN32
db->f = (FILE *)0;
fopen_s(&db->f,path,((mode == KISSDB_OPEN_MODE_RWREPLACE) ? "w+b" : (((mode == KISSDB_OPEN_MODE_RDWR)||(mode == KISSDB_OPEN_MODE_RWCREAT)) ? "r+b" : "rb")));
#else
db->f = fopen(path,((mode == KISSDB_OPEN_MODE_RWREPLACE) ? "w+b" : (((mode == KISSDB_OPEN_MODE_RDWR)||(mode == KISSDB_OPEN_MODE_RWCREAT)) ? "r+b" : "rb")));
#endif
if (!db->f) {
if (mode == KISSDB_OPEN_MODE_RWCREAT) {
#ifdef _WIN32
db->f = (FILE *)0;
fopen_s(&db->f,path,"w+b");
#else
db->f = fopen(path,"w+b");
#endif
}
if (!db->f)
return KISSDB_ERROR_IO;
}
if (fseeko(db->f,0,SEEK_END)) {
fclose(db->f);
return KISSDB_ERROR_IO;
}
if (ftello(db->f) < KISSDB_HEADER_SIZE) {
/* write header if not already present */
if ((hash_table_size)&&(key_size)&&(value_size)) {
if (fseeko(db->f,0,SEEK_SET)) { fclose(db->f); return KISSDB_ERROR_IO; }
tmp2[0] = 'K'; tmp2[1] = 'd'; tmp2[2] = 'B'; tmp2[3] = KISSDB_VERSION;
if (fwrite(tmp2,4,1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
tmp = hash_table_size;
if (fwrite(&tmp,sizeof(uint64_t),1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
tmp = key_size;
if (fwrite(&tmp,sizeof(uint64_t),1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
tmp = value_size;
if (fwrite(&tmp,sizeof(uint64_t),1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
fflush(db->f);
} else {
fclose(db->f);
return KISSDB_ERROR_INVALID_PARAMETERS;
}
} else {
if (fseeko(db->f,0,SEEK_SET)) { fclose(db->f); return KISSDB_ERROR_IO; }
if (fread(tmp2,4,1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
if ((tmp2[0] != 'K')||(tmp2[1] != 'd')||(tmp2[2] != 'B')||(tmp2[3] != KISSDB_VERSION)) {
fclose(db->f);
return KISSDB_ERROR_CORRUPT_DBFILE;
}
if (fread(&tmp,sizeof(uint64_t),1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
if (!tmp) {
fclose(db->f);
return KISSDB_ERROR_CORRUPT_DBFILE;
}
hash_table_size = (unsigned long)tmp;
if (fread(&tmp,sizeof(uint64_t),1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
if (!tmp) {
fclose(db->f);
return KISSDB_ERROR_CORRUPT_DBFILE;
}
key_size = (unsigned long)tmp;
if (fread(&tmp,sizeof(uint64_t),1,db->f) != 1) { fclose(db->f); return KISSDB_ERROR_IO; }
if (!tmp) {
fclose(db->f);
return KISSDB_ERROR_CORRUPT_DBFILE;
}
value_size = (unsigned long)tmp;
}
db->hash_table_size = hash_table_size;
db->key_size = key_size;
db->value_size = value_size;
db->hash_table_size_bytes = sizeof(uint64_t) * (hash_table_size + 1); /* [hash_table_size] == next table */
httmp = malloc(db->hash_table_size_bytes);
if (!httmp) {
fclose(db->f);
return KISSDB_ERROR_MALLOC;
}
db->num_hash_tables = 0;
db->hash_tables = (uint64_t *)0;
while (fread(httmp,db->hash_table_size_bytes,1,db->f) == 1) {
hash_tables_rea = realloc(db->hash_tables,db->hash_table_size_bytes * (db->num_hash_tables + 1));
if (!hash_tables_rea) {
KISSDB_close(db);
free(httmp);
return KISSDB_ERROR_MALLOC;
}
db->hash_tables = hash_tables_rea;
memcpy(((uint8_t *)db->hash_tables) + (db->hash_table_size_bytes * db->num_hash_tables),httmp,db->hash_table_size_bytes);
++db->num_hash_tables;
if (httmp[db->hash_table_size]) {
if (fseeko(db->f,httmp[db->hash_table_size],SEEK_SET)) {
KISSDB_close(db);
free(httmp);
return KISSDB_ERROR_IO;
}
} else break;
}
free(httmp);
return 0;
}
void KISSDB_close(KISSDB *db)
{
if (db->hash_tables)
free(db->hash_tables);
if (db->f)
fclose(db->f);
memset(db,0,sizeof(KISSDB));
}
int KISSDB_get(KISSDB *db,const void *key,void *vbuf)
{
uint8_t tmp[4096];
const uint8_t *kptr;
unsigned long klen,i;
uint64_t hash = KISSDB_hash(key,db->key_size) % (uint64_t)db->hash_table_size;
uint64_t offset;
uint64_t *cur_hash_table;
long n;
cur_hash_table = db->hash_tables;
for(i=0;i<db->num_hash_tables;++i) {
offset = cur_hash_table[hash];
if (offset) {
if (fseeko(db->f,offset,SEEK_SET))
return KISSDB_ERROR_IO;
kptr = (const uint8_t *)key;
klen = db->key_size;
while (klen) {
n = (long)fread(tmp,1,(klen > sizeof(tmp)) ? sizeof(tmp) : klen,db->f);
if (n > 0) {
if (memcmp(kptr,tmp,n))
goto get_no_match_next_hash_table;
kptr += n;
klen -= (unsigned long)n;
} else return 1; /* not found */
}
if (fread(vbuf,db->value_size,1,db->f) == 1)
return 0; /* success */
else return KISSDB_ERROR_IO;
} else return 1; /* not found */
get_no_match_next_hash_table:
cur_hash_table += db->hash_table_size + 1;
}
return 1; /* not found */
}
int KISSDB_put(KISSDB *db,const void *key,const void *value)
{
uint8_t tmp[4096];
const uint8_t *kptr;
unsigned long klen,i;
uint64_t hash = KISSDB_hash(key,db->key_size) % (uint64_t)db->hash_table_size;
uint64_t offset;
uint64_t htoffset,lasthtoffset;
uint64_t endoffset;
uint64_t *cur_hash_table;
uint64_t *hash_tables_rea;
long n;
lasthtoffset = htoffset = KISSDB_HEADER_SIZE;
cur_hash_table = db->hash_tables;
for(i=0;i<db->num_hash_tables;++i) {
offset = cur_hash_table[hash];
if (offset) {
/* rewrite if already exists */
if (fseeko(db->f,offset,SEEK_SET))
return KISSDB_ERROR_IO;
kptr = (const uint8_t *)key;
klen = db->key_size;
while (klen) {
n = (long)fread(tmp,1,(klen > sizeof(tmp)) ? sizeof(tmp) : klen,db->f);
if (n > 0) {
if (memcmp(kptr,tmp,n))
goto put_no_match_next_hash_table;
kptr += n;
klen -= (unsigned long)n;
}
}
if (fwrite(value,db->value_size,1,db->f) == 1) {
fflush(db->f);
return 0; /* success */
} else return KISSDB_ERROR_IO;
} else {
/* add if an empty hash table slot is discovered */
if (fseeko(db->f,0,SEEK_END))
return KISSDB_ERROR_IO;
endoffset = ftello(db->f);
if (fwrite(key,db->key_size,1,db->f) != 1)
return KISSDB_ERROR_IO;
if (fwrite(value,db->value_size,1,db->f) != 1)
return KISSDB_ERROR_IO;
if (fseeko(db->f,htoffset + (sizeof(uint64_t) * hash),SEEK_SET))
return KISSDB_ERROR_IO;
if (fwrite(&endoffset,sizeof(uint64_t),1,db->f) != 1)
return KISSDB_ERROR_IO;
cur_hash_table[hash] = endoffset;
fflush(db->f);
return 0; /* success */
}
put_no_match_next_hash_table:
lasthtoffset = htoffset;
htoffset = cur_hash_table[db->hash_table_size];
cur_hash_table += (db->hash_table_size + 1);
}
/* if no existing slots, add a new page of hash table entries */
if (fseeko(db->f,0,SEEK_END))
return KISSDB_ERROR_IO;
endoffset = ftello(db->f);
hash_tables_rea = realloc(db->hash_tables,db->hash_table_size_bytes * (db->num_hash_tables + 1));
if (!hash_tables_rea)
return KISSDB_ERROR_MALLOC;
db->hash_tables = hash_tables_rea;
cur_hash_table = &(db->hash_tables[(db->hash_table_size + 1) * db->num_hash_tables]);
memset(cur_hash_table,0,db->hash_table_size_bytes);
cur_hash_table[hash] = endoffset + db->hash_table_size_bytes; /* where new entry will go */
if (fwrite(cur_hash_table,db->hash_table_size_bytes,1,db->f) != 1)
return KISSDB_ERROR_IO;
if (fwrite(key,db->key_size,1,db->f) != 1)
return KISSDB_ERROR_IO;
if (fwrite(value,db->value_size,1,db->f) != 1)
return KISSDB_ERROR_IO;
if (db->num_hash_tables) {
if (fseeko(db->f,lasthtoffset + (sizeof(uint64_t) * db->hash_table_size),SEEK_SET))
return KISSDB_ERROR_IO;
if (fwrite(&endoffset,sizeof(uint64_t),1,db->f) != 1)
return KISSDB_ERROR_IO;
db->hash_tables[((db->hash_table_size + 1) * (db->num_hash_tables - 1)) + db->hash_table_size] = endoffset;
}
++db->num_hash_tables;
fflush(db->f);
return 0; /* success */
}
void KISSDB_Iterator_init(KISSDB *db,KISSDB_Iterator *dbi)
{
dbi->db = db;
dbi->h_no = 0;
dbi->h_idx = 0;
}
int KISSDB_Iterator_next(KISSDB_Iterator *dbi,void *kbuf,void *vbuf)
{
uint64_t offset;
if ((dbi->h_no < dbi->db->num_hash_tables)&&(dbi->h_idx < dbi->db->hash_table_size)) {
while (!(offset = dbi->db->hash_tables[((dbi->db->hash_table_size + 1) * dbi->h_no) + dbi->h_idx])) {
if (++dbi->h_idx >= dbi->db->hash_table_size) {
dbi->h_idx = 0;
if (++dbi->h_no >= dbi->db->num_hash_tables)
return 0;
}
}
if (fseeko(dbi->db->f,offset,SEEK_SET))
return KISSDB_ERROR_IO;
if (fread(kbuf,dbi->db->key_size,1,dbi->db->f) != 1)
return KISSDB_ERROR_IO;
if (fread(vbuf,dbi->db->value_size,1,dbi->db->f) != 1)
return KISSDB_ERROR_IO;
if (++dbi->h_idx >= dbi->db->hash_table_size) {
dbi->h_idx = 0;
++dbi->h_no;
}
return 1;
}
return 0;
}
#ifdef KISSDB_TEST
#include <inttypes.h>
int main(int argc,char **argv)
{
uint64_t i,j;
uint64_t v[8];
KISSDB db;
KISSDB_Iterator dbi;
char got_all_values[10000];
int q;
printf("Opening new empty database test.db...\n");
if (KISSDB_open(&db,"test.db",KISSDB_OPEN_MODE_RWREPLACE,1024,8,sizeof(v))) {
printf("KISSDB_open failed\n");
return 1;
}
printf("Adding and then re-getting 10000 64-byte values...\n");
for(i=0;i<10000;++i) {
for(j=0;j<8;++j)
v[j] = i;
if (KISSDB_put(&db,&i,v)) {
printf("KISSDB_put failed (%"PRIu64")\n",i);
return 1;
}
memset(v,0,sizeof(v));
if ((q = KISSDB_get(&db,&i,v))) {
printf("KISSDB_get (1) failed (%"PRIu64") (%d)\n",i,q);
return 1;
}
for(j=0;j<8;++j) {
if (v[j] != i) {
printf("KISSDB_get (1) failed, bad data (%"PRIu64")\n",i);
return 1;
}
}
}
printf("Getting 10000 64-byte values...\n");
for(i=0;i<10000;++i) {
if ((q = KISSDB_get(&db,&i,v))) {
printf("KISSDB_get (2) failed (%"PRIu64") (%d)\n",i,q);
return 1;
}
for(j=0;j<8;++j) {
if (v[j] != i) {
printf("KISSDB_get (2) failed, bad data (%"PRIu64")\n",i);
return 1;
}
}
}
printf("Closing and re-opening database in read-only mode...\n");
KISSDB_close(&db);
if (KISSDB_open(&db,"test.db",KISSDB_OPEN_MODE_RDONLY,1024,8,sizeof(v))) {
printf("KISSDB_open failed\n");
return 1;
}
printf("Getting 10000 64-byte values...\n");
for(i=0;i<10000;++i) {
if ((q = KISSDB_get(&db,&i,v))) {
printf("KISSDB_get (3) failed (%"PRIu64") (%d)\n",i,q);
return 1;
}
for(j=0;j<8;++j) {
if (v[j] != i) {
printf("KISSDB_get (3) failed, bad data (%"PRIu64")\n",i);
return 1;
}
}
}
printf("Iterator test...\n");
KISSDB_Iterator_init(&db,&dbi);
i = 0xdeadbeef;
memset(got_all_values,0,sizeof(got_all_values));
while (KISSDB_Iterator_next(&dbi,&i,&v) > 0) {
if (i < 10000)
got_all_values[i] = 1;
else {
printf("KISSDB_Iterator_next failed, bad data (%"PRIu64")\n",i);
return 1;
}
}
for(i=0;i<10000;++i) {
if (!got_all_values[i]) {
printf("KISSDB_Iterator failed, missing value index %"PRIu64"\n",i);
return 1;
}
}
KISSDB_close(&db);
printf("All tests OK!\n");
return 0;
}
#endif
-171
View File
@@ -1,171 +0,0 @@
/* (Keep It) Simple Stupid Database
*
* Written by Adam Ierymenko <adam.ierymenko@zerotier.com>
* KISSDB is in the public domain and is distributed with NO WARRANTY. */
#ifndef ___KISSDB_H
#define ___KISSDB_H
#include <stdio.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Version: 2
*
* This is the file format identifier, and changes any time the file
* format changes. The code version will be this dot something, and can
* be seen in tags in the git repository.
*/
#define KISSDB_VERSION 2
/**
* KISSDB database state
*
* These fields can be read by a user, e.g. to look up key_size and
* value_size, but should never be changed.
*/
typedef struct {
unsigned long hash_table_size;
unsigned long key_size;
unsigned long value_size;
unsigned long hash_table_size_bytes;
unsigned long num_hash_tables;
uint64_t *hash_tables;
FILE *f;
} KISSDB;
/**
* I/O error or file not found
*/
#define KISSDB_ERROR_IO -1
/**
* Out of memory
*/
#define KISSDB_ERROR_MALLOC -2
/**
* Invalid paramters (e.g. missing _size paramters on init to create database)
*/
#define KISSDB_ERROR_INVALID_PARAMETERS -3
/**
* Database file appears corrupt
*/
#define KISSDB_ERROR_CORRUPT_DBFILE -4
/**
* Open mode: read only
*/
#define KISSDB_OPEN_MODE_RDONLY 1
/**
* Open mode: read/write
*/
#define KISSDB_OPEN_MODE_RDWR 2
/**
* Open mode: read/write, create if doesn't exist
*/
#define KISSDB_OPEN_MODE_RWCREAT 3
/**
* Open mode: truncate database, open for reading and writing
*/
#define KISSDB_OPEN_MODE_RWREPLACE 4
/**
* Open database
*
* The three _size parameters must be specified if the database could
* be created or re-created. Otherwise an error will occur. If the
* database already exists, these parameters are ignored and are read
* from the database. You can check the struture afterwords to see what
* they were.
*
* @param db Database struct
* @param path Path to file
* @param mode One of the KISSDB_OPEN_MODE constants
* @param hash_table_size Size of hash table in 64-bit entries (must be >0)
* @param key_size Size of keys in bytes
* @param value_size Size of values in bytes
* @return 0 on success, nonzero on error
*/
extern int KISSDB_open(
KISSDB *db,
const char *path,
int mode,
unsigned long hash_table_size,
unsigned long key_size,
unsigned long value_size);
/**
* Close database
*
* @param db Database struct
*/
extern void KISSDB_close(KISSDB *db);
/**
* Get an entry
*
* @param db Database struct
* @param key Key (key_size bytes)
* @param vbuf Value buffer (value_size bytes capacity)
* @return -1 on I/O error, 0 on success, 1 on not found
*/
extern int KISSDB_get(KISSDB *db,const void *key,void *vbuf);
/**
* Put an entry (overwriting it if it already exists)
*
* In the already-exists case the size of the database file does not
* change.
*
* @param db Database struct
* @param key Key (key_size bytes)
* @param value Value (value_size bytes)
* @return -1 on I/O error, 0 on success
*/
extern int KISSDB_put(KISSDB *db,const void *key,const void *value);
/**
* Cursor used for iterating over all entries in database
*/
typedef struct {
KISSDB *db;
unsigned long h_no;
unsigned long h_idx;
} KISSDB_Iterator;
/**
* Initialize an iterator
*
* @param db Database struct
* @param i Iterator to initialize
*/
extern void KISSDB_Iterator_init(KISSDB *db,KISSDB_Iterator *dbi);
/**
* Get the next entry
*
* The order of entries returned by iterator is undefined. It depends on
* how keys hash.
*
* @param Database iterator
* @param kbuf Buffer to fill with next key (key_size bytes)
* @param vbuf Buffer to fill with next value (value_size bytes)
* @return 0 if there are no more entries, negative on error, positive if an kbuf/vbuf have been filled
*/
extern int KISSDB_Iterator_next(KISSDB_Iterator *dbi,void *kbuf,void *vbuf);
#ifdef __cplusplus
}
#endif
#endif
+9 -2
View File
@@ -41,7 +41,7 @@ static void printHelp(char *pn)
{
std::cout << "Usage: " << pn << " <command> [<args>]" << std::endl << std::endl;
std::cout << "Commands:" << std::endl;
std::cout << "\tgenerate [<identity.secret>]" << std::endl;
std::cout << "\tgenerate [<identity.secret>] [<identity.public>]" << std::endl;
std::cout << "\tvalidate <identity.secret/public>" << std::endl;
std::cout << "\tgetpublic <identity.secret>" << std::endl;
std::cout << "\tsign <identity.secret> <file>" << std::endl;
@@ -80,6 +80,13 @@ int main(int argc,char **argv)
std::cerr << "Error writing to " << argv[2] << std::endl;
return -1;
} else std::cout << argv[2] << " written" << std::endl;
if (argc >= 4) {
idser = id.toString(false);
if (!Utils::writeFile(argv[3],idser)) {
std::cerr << "Error writing to " << argv[3] << std::endl;
return -1;
} else std::cout << argv[3] << " written" << std::endl;
}
} else std::cout << idser;
} else if (!strcmp(argv[1],"validate")) {
if (argc < 3) {
@@ -93,7 +100,7 @@ int main(int argc,char **argv)
return -1;
}
if (!id.locallyValidate(true)) {
if (!id.locallyValidate()) {
std::cerr << argv[2] << " FAILED validation." << std::endl;
return -1;
} else std::cout << argv[2] << " is a valid identity (full check performed)" << std::endl;
-37
View File
@@ -1,37 +0,0 @@
Building
========
If you want to build the tun/tap drivers, make sure you have Apple's Developer
Tools installed. Then from the top of the tun/tap source tree issue
# make
This will build the driver kexts and place them as tap.kext and tun.kext in the
top tun/tap directory. You can install these two kexts directly in
/Library/Extensions. As root, you can simply say
# make install_kext
Otherwise OS X will refuse to load the extensions. After that, they can be
loaded using kextload:
# kextload /Library/Extensions/tap.kext/
kextload: /Library/Extensions/tap.kext/ loaded successfully
# kextload /Library/Extensions/tun.kext/
kextload: /Library/Extensions/tun.kext/ loaded successfully
If you want to have the extensions loaded at boot time, use the startup items
provided in the directory startup_items. This can be done using the Makefile (as
root):
# make install_scripts
I have also included the files used to build the installer packages in the
directory pkg. They can be made by
# make pkg
This is all I have to say at the moment, feel free to mail me any bug reports,
problems and suggestions you have at <mattias.nissler@gmx.de>.
-66
View File
@@ -1,66 +0,0 @@
# Lets have a version, at last!
TUNTAP_VERSION = 20111101
# BASE install directory
BASE=
all: tap.kext tun.kext
pkg: all
/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker \
-d pkg/tuntap.pmdoc -o tuntap_$(TUNTAP_VERSION).pkg -v
tar czf tuntap_$(TUNTAP_VERSION).tar.gz \
README.installer README tuntap_$(TUNTAP_VERSION).pkg
# Install targets
# They are provided for the gentoo ebuild, but should work just fine for other people as well.
install_kext: tap.kext tun.kext
mkdir -p ${BASE}/Library/Extensions
cp -pR tap.kext ${BASE}/Library/Extensions/
chown -R root:wheel ${BASE}/Library/Extensions/tap.kext
cp -pR tun.kext ${BASE}/Library/Extensions/
chown -R root:wheel ${BASE}/Library/Extensions/tun.kext
install_scripts:
mkdir -p ${BASE}/Library/StartupItems
cp -pR startup_item/tap ${BASE}/Library/StartupItems/
chown -R root:wheel ${BASE}/Library/StartupItems/tap
cp -pR startup_item/tun ${BASE}/Library/StartupItems/
chown -R root:wheel ${BASE}/Library/StartupItems/tun
install: install_kext install_scripts
tarball: clean
touch tuntap_$(TUNTAP_VERSION)_src.tar.gz
tar czf tuntap_$(TUNTAP_VERSION)_src.tar.gz \
-C .. \
--exclude "tuntap/tuntap_$(TUNTAP_VERSION)_src.tar.gz" \
--exclude "tuntap/tuntap_$(TUNTAP_VERSION).tar.gz" \
--exclude "tuntap/tuntap_$(TUNTAP_VERSION).pkg" \
--exclude "*/.*" \
tuntap
clean:
cd src/tap && make -f Makefile clean
cd src/tun && make -f Makefile clean
-rm -rf tuntap_$(TUNTAP_VERSION).pkg
-rm -f tuntap_$(TUNTAP_VERSION).tar.gz
-rm -f tuntap_$(TUNTAP_VERSION)_src.tar.gz
tap.kext:
cd src/tap && make TUNTAP_VERSION=$(TUNTAP_VERSION) -f Makefile all
tun.kext:
cd src/tun && make TUNTAP_VERSION=$(TUNTAP_VERSION) -f Makefile all
test:
# configd messes with interface flags, issuing SIOCSIFFLAGS ioctls upon receiving kernel
# events indicating protocols have been attached and detached. Unfortunately, configd does
# this asynchronously, making the SIOCSIFFLAGS changes totally unpredictable when we bring
# our interfaces up and down in rapid succession during our tests. I haven't found a good
# way to suppress or handle this mess other than disabling configd temporarily.
killall -STOP configd
-PYTHONPATH=test python test/tuntap/tuntap_tests.py --tests='$(TESTS)'
killall -CONT configd
.PHONY: test
Loaded 20 of 129 files, more files were not shown because too many files have changed in this diff. Show more