bltavares / colmeia

Attempt to make an interop layer to connect to dat on hyperswarm in Rust
24 stars 4 forks source link
dat hypercore hypercore-protocol p2p

colmeia


Hive (in portuguese). Attempt to make an interop layer to connect to dat on hyperswarm and legacy infra as well. Vaporware and might never be finished. Contributions welcome.

Goals

Write a pure rust network stack compatible with dat, to be able to run it on desktop (Win/Mac/Linux), mobile (and maybe wasm).

Milestones

References

hyperswarm & hypercore-protocol compatibility

Uses NOISE protocol and a different handshake.

Modules

Discovery

Protocol

Reference tools

Versions for reference

CLI binaries

Local dat2: be41e3d43d054982e14dfc60281d9d4425ab5d4b0b280a355b7927869ca08fc5

Find a local peer

colmeia-mdns

RUST_LOG=debug cargo run --bin colmeia-hyperswarm-mdns -- 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5 8000

Connect and troubleshoot a peer

colmeia-nc

RUST_LOG=debug cargo run --bin colmeia-nc -- 7e5998407b3d9dbb94db21ff50ad6f1b1d2c79e476fbaf9856c342eb4382e7f5 127.0.0.1:3282

Clone from a single host

RUST_LOG=debug cargo run --bin colmeia-clone -- 192.168.15.173:3282 dat://6268b99fbacacea49c6bc3d4776b606db2aeadb3fa831342ba9f70d55c98929f

Platforms

:warning: TODO: redo support as part of dat -> hypercore migration

Android Direct compilation

Inside termux, install git and rust:

apk install git
apk install rust
git clone https://github.com/bltavares/colmeia
cd colmeia

cargo run # your desired bin

Cross Compilation

It works!

cross build --target armv7-linux-androideabi
arch target
armv7l armv7-linux-androideabi
aarch64 or arm64 aarch64-linux-android
arm* arm-linux-androideabi
mips-musl mips-unknown-linux-musl

*arm: (seems to be broken)

# Once
adb shell mkdir -p /data/local/tmp/colmeia
adb shell chmod 777 /data/local/tmp/colmeia # Make it readable to let Termux read it as well

adb push ./target/armv7-linux-androideabi/debug/colmeia-mdns /data/local/tmp/colmeia

Android ADB shell

adb shell # open shell in android
chmod +x /data/local/tmp/colmeia/colmeia-server

RUST_LOG=debug  /data/local/tmp/colmeia/colmeia-server 0.0.0.0:8787 dat://460f04cf12c3b9833e5a0d3dd8eea05eab59dd8c1438a7454afe9630b9b4f8bd

Termux from inside Android

Android don't allow execution from outside the app data dir, and you can't push data to other apps dir from adb push. You need to copy the binary to your root folder, which should be executable.

Open the app and copy the content to the home folder:

# Inside termux shell
cp /data/local/tmp/colmeia/colmeia-server ~

RUST_LOG=debug ~/colmeia-server 0.0.0.0:8787 dat://460f04cf12c3b9833e5a0d3dd8eea05eab59dd8c1438a7454afe9630b9b4f8bd

OpenWRT

It compiles with OpenWRT. Tested with 2 different routers on 18.06.1 and 19.07.2.

Run and scp the binaries on target/mips-unknown-linux-musl:

 cross build --target mips-unknown-linux-musl