Create a folder to store the databases :
mkdir -p /usr/share/GeoIP
Download Country IP database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
| sudo apt update && sudo apt upgrade | |
| sudo apt install golang | |
| sudo apt-get install libmnl-dev libelf-dev build-essential pkg-config | |
| git clone https://git.zx2c4.com/wireguard-go | |
| cd wireguard-go/ | |
| git checkout 0.0.20181001 # Get the desired release tag from `git tag` | |
| make | |
| sudo make install |
Create a folder to store the databases :
mkdir -p /usr/share/GeoIP
Download Country IP database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
| wget -qO- https://check.torproject.org/exit-addresses | grep ExitAddress | cut -d ' ' -f 2 | sed "s/^/deny /g; s/$/;/g" > /etc/nginx/conf.d/tor-block.conf; systemctl reload nginx |
| // Implementation of a UDP proxy | |
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "log" | |
| "net" | |
| "os" |
| package main | |
| import ( | |
| "fmt" | |
| "io" | |
| "net" | |
| "time" | |
| ) | |
| func main() { |
| // fileResponseWriter wraps an http.ResponseWriter and a File | |
| // passing it to an http.Handler's ServeHTTP | |
| // will write to both the file and the response. | |
| type fileResponseWriter struct { | |
| file io.Writer | |
| resp http.ResponseWriter | |
| multi io.Writer | |
| } |
| package main | |
| import ( | |
| "bytes" | |
| "log" | |
| "sort" | |
| ) | |
| // implement `Interface` in sort package. | |
| type sortByteArrays [][]byte |
I've put together these notes as I read about DHT's in depth and then learned how the libtorrent implementation based on the Kademlia paper actually works.
400,000,000,000 (400 billion stars), that's a 4 followed by 11 zeros.
The number of atoms in the universe is estimated to be around 10^82.
A DHT with keys of 160 bits, can have 2^160 possible numbers, which is around 10^48
| // Copyright (c) 2017 Ismael Celis | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is | |
| // furnished to do so, subject to the following conditions: | |
| // The above copyright notice and this permission notice shall be included in all |
| func handleUpload(u io.Reader) (err error) { | |
| // capture all bytes from upload | |
| b, err := ioutil.ReadAll(u) | |
| if err != nil { | |
| return | |
| } | |
| // wrap the bytes in a ReadSeeker | |
| r := bytes.NewReader(b) |