forked from SatoriNetwork/Neuron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcjdns
87 lines (68 loc) · 2.32 KB
/
cjdns
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
## attempting to install cjdns test-run:
# RUN docker with ipv6 support before
# (must add "ipv6": true, to docker configuration file)
docker run --rm -it --name satorineuron -p 24601:24601 -p 24603:24603 -p 11234:11234 --sysctl net.ipv6.conf.all.disable_ipv6=0 --env ENV=test satorinet/satorineuron:latest bash
# attempting to install cjdns to /tmp as a test-run
cd /tmp
# need curl
apt-get update
apt-get install build-essential git
apt-get install curl -y
# need node
apt-get install -y nodejs
node -v
# need rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
# need cjdns
git clone https://github.com/cjdelisle/cjdns.git
# install cjdns
cd /tmp/cjdns
./do
# link
ln -s $(pwd)/cjdroute /usr/local/bin/cjdroute
./cjdroute --genconf > /etc/cjdroute.conf
# edit config manually:
# set binding port to 24603
# paste peer connect_to entry
vi /etc/cjdroute.conf
# manually get data:
# copy self ipv6
# copy self entry
# get external ip (satorinet.io/ip) and paste as your id key
cat /etc/cjdroute.conf
#"fc54:08ab:ba2d:61dd:8297:6192:6e62:8810"
#"129.227.46.147:24603": {
# "login": "default-login",
# "password": "4u1x42ktq3b7nvrcj8gzkg6nm0kubdz",
# "publicKey": "ysf8rg5x3u9l9n91xmqs668bj3v2zrgwqyhnb3bwdwbwr5yqcsz0.k",
# "peerName": "black"
# },
# start cjdroute
nohup cjdroute < /etc/cjdroute.conf > /var/log/cjdns.log 2>&1 &
# look at logs to make sure its running
/var/log/cjdns.log
# now that it's running start python and try to connect with socket script
# paste peer ipv6 address
python
```
import socket
import json
from cryptography.fernet import Fernet
key = Fernet.generate_key()
cipher = Fernet(key)
def send_message(ipv6_address, port, message):
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
encrypted_message = cipher.encrypt(message.encode())
sock.sendto(encrypted_message, (ipv6_address, port))
def receive_message(port):
sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
sock.bind(('::', port))
while True:
data, addr = sock.recvfrom(1024)
decrypted_message = cipher.decrypt(data).decode()
print(f"Received message from {addr}: {decrypted_message}")
ipv6 = "fc54:08ab:ba2d:61dd:8297:6192:6e62:8810"
send_message(ipv6, 24603, "Hello, Peer!")
receive_message(24603)
```