Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 9a292d7

Browse files
committed
Initial commit
0 parents  commit 9a292d7

35 files changed

+9891
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
_build
2+
*.native
3+
*.byte
4+
setup.log

.ocp-indent

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
align_ops=false
2+
strict_with=auto
3+
syntax=bitstring
4+
syntax=lwt

LICENCE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(* The MIT License (MIT)
2+
3+
Copyright (c) 2014 Nicolas Ojeda Bar <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *)

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# OASIS_START
2+
# DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954)
3+
4+
SETUP = ocaml setup.ml
5+
6+
build: setup.data
7+
$(SETUP) -build $(BUILDFLAGS)
8+
9+
doc: setup.data build
10+
$(SETUP) -doc $(DOCFLAGS)
11+
12+
test: setup.data build
13+
$(SETUP) -test $(TESTFLAGS)
14+
15+
all:
16+
$(SETUP) -all $(ALLFLAGS)
17+
18+
install: setup.data
19+
$(SETUP) -install $(INSTALLFLAGS)
20+
21+
uninstall: setup.data
22+
$(SETUP) -uninstall $(UNINSTALLFLAGS)
23+
24+
reinstall: setup.data
25+
$(SETUP) -reinstall $(REINSTALLFLAGS)
26+
27+
clean:
28+
$(SETUP) -clean $(CLEANFLAGS)
29+
30+
distclean:
31+
$(SETUP) -distclean $(DISTCLEANFLAGS)
32+
33+
setup.data:
34+
$(SETUP) -configure $(CONFIGUREFLAGS)
35+
36+
configure:
37+
$(SETUP) -configure $(CONFIGUREFLAGS)
38+
39+
.PHONY: build doc test all install uninstall reinstall clean distclean configure
40+
41+
# OASIS_STOP

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# ocaml-dht
2+
3+
OCaml-DHT is a small BitTorrent DHT implementation. It is shamelessly based in the one found in [MLdonkey](http://mldonkey.sourceforge.net), but adapated to work with [Lwt](http://ocsigen.org/lwt/).
4+
5+
This is a preliminary release.
6+
7+
## Installation
8+
9+
The easiest way is to use [OPAM](http://opam.ocaml.org).
10+
```sh
11+
opam install dht
12+
```
13+
14+
Alternatively, clone from git and install manually:
15+
```sh
16+
cd ~/tmp
17+
git clone https://github.com/nojb/ocaml-dht
18+
cd ocaml-dht
19+
make
20+
make install
21+
```
22+
23+
Either way the end-result will be a OCaml library (findlib name: `dht`) and a executable `find_ih`.
24+
25+
### Documentation
26+
27+
Look in `DHT.mli`, `Kademlia.mli`, and `KRPC.mli`.
28+
29+
### Usage
30+
31+
First, one needs to bootstrap using `DHT.auto_bootstrap`. Then one can query for peers using
32+
`DHT.query_peers`. To see how it works, get a nice info hash
33+
you are interested in (e.g., 4D753474429D817B80FF9E0C441CA660EC5D2450 for Ubuntu 14.04) and execute:
34+
35+
```sh
36+
$ find_ih 4D753474429D817B80FF9E0C441CA660EC5D2450
37+
```
38+
39+
You will see a lot of debug output which explains (if you know what it means) what is going on.
40+
41+
## Comments
42+
43+
Comments, bug reports and feature requests are very welcome: [email protected].

_oasis

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
OASISFormat: 0.4
2+
Name: bt
3+
Version: 0.1.0
4+
Synopsis: BitTorrent DHT library for Lwt
5+
Authors: Nicolas Ojeda Bar <[email protected]>
6+
License: MIT
7+
Plugins: META (0.4), DevFiles (0.4)
8+
BuildTools: ocamlbuild
9+
10+
Library dht
11+
Path: lib
12+
Pack: false
13+
Install: true
14+
FindlibName: dht
15+
Modules: Bcode, SHA1, KRPC, Addr, UDP, DHT, Kademlia, Log, Util
16+
BuildDepends: lwt, lwt.unix, cryptokit, zarith, qcheck, bitstring, bitstring.syntax
17+
18+
Executable find_ih
19+
Path: lib_test
20+
MainIs: find_ih.ml
21+
Build$: true
22+
Custom: true
23+
CompiledObject: best
24+
Install: false
25+
BuildDepends: dht

_tags

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# OASIS_START
2+
# DO NOT EDIT (digest: 224e0ec4e529dd26b219b55fb1278f1b)
3+
# Ignore VCS directories, you can use the same kind of rule outside
4+
# OASIS_START/STOP if you want to exclude directories that contains
5+
# useless stuff for the build process
6+
<**/.svn>: -traverse
7+
<**/.svn>: not_hygienic
8+
".bzr": -traverse
9+
".bzr": not_hygienic
10+
".hg": -traverse
11+
".hg": not_hygienic
12+
".git": -traverse
13+
".git": not_hygienic
14+
"_darcs": -traverse
15+
"_darcs": not_hygienic
16+
# Library dht
17+
"lib/dht.cmxs": use_dht
18+
<lib/*.ml{,i}>: pkg_bitstring
19+
<lib/*.ml{,i}>: pkg_bitstring.syntax
20+
<lib/*.ml{,i}>: pkg_cryptokit
21+
<lib/*.ml{,i}>: pkg_lwt
22+
<lib/*.ml{,i}>: pkg_lwt.unix
23+
<lib/*.ml{,i}>: pkg_qcheck
24+
<lib/*.ml{,i}>: pkg_zarith
25+
# Executable find_ih
26+
<lib_test/find_ih.{native,byte}>: pkg_bitstring
27+
<lib_test/find_ih.{native,byte}>: pkg_bitstring.syntax
28+
<lib_test/find_ih.{native,byte}>: pkg_cryptokit
29+
<lib_test/find_ih.{native,byte}>: pkg_lwt
30+
<lib_test/find_ih.{native,byte}>: pkg_lwt.unix
31+
<lib_test/find_ih.{native,byte}>: pkg_qcheck
32+
<lib_test/find_ih.{native,byte}>: pkg_zarith
33+
<lib_test/find_ih.{native,byte}>: use_dht
34+
<lib_test/*.ml{,i}>: pkg_bitstring
35+
<lib_test/*.ml{,i}>: pkg_bitstring.syntax
36+
<lib_test/*.ml{,i}>: pkg_cryptokit
37+
<lib_test/*.ml{,i}>: pkg_lwt
38+
<lib_test/*.ml{,i}>: pkg_lwt.unix
39+
<lib_test/*.ml{,i}>: pkg_qcheck
40+
<lib_test/*.ml{,i}>: pkg_zarith
41+
<lib_test/*.ml{,i}>: use_dht
42+
<lib_test/find_ih.{native,byte}>: custom
43+
# OASIS_STOP

configure

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
# OASIS_START
4+
# DO NOT EDIT (digest: dc86c2ad450f91ca10c931b6045d0499)
5+
set -e
6+
7+
FST=true
8+
for i in "$@"; do
9+
if $FST; then
10+
set --
11+
FST=false
12+
fi
13+
14+
case $i in
15+
--*=*)
16+
ARG=${i%%=*}
17+
VAL=${i##*=}
18+
set -- "$@" "$ARG" "$VAL"
19+
;;
20+
*)
21+
set -- "$@" "$i"
22+
;;
23+
esac
24+
done
25+
26+
ocaml setup.ml -configure "$@"
27+
# OASIS_STOP

descr

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DHT library for Lwt

0 commit comments

Comments
 (0)