Skip to content

Instantly share code, notes, and snippets.

View gubatron's full-sized avatar

Angel Leon gubatron

View GitHub Profile
@gubatron
gubatron / Types of Nat.md
Last active August 29, 2015 14:09
Strategies for Defeating NAT configuration issues: STUN/TURN/ICE

Strategies for Defeating NAT configuration issues: STUN/TURN/ICE.

(decided to write this down to have all this in one place, in a way at least I can understand, I hope it helps others which had the same questions as me when they came across STUN/TURN/ICE acronyms and found it all confusing, not knowing what was needed first and what problems each solved)

NAT devices, basically keep tables that map external IP:PORT to internal IP:PORTs and when IP packets come in and out, they rewrite these packets so that they IP:PORTs are changed (initially with the goal of reusing a limited number of public addresses, but lately to restrict direct communication between machines inside restricted networked environments).

This works fine for certain protocol standards, but it's not so good when you have a custom protocol that carries inside IP:PORT information as the NAT device won't look inside the packet, and in many cases, we don't want anybody looking inside the packet, for instance when the data is encrypted, there

Verifying that +gubatron is my openname (Bitcoin username). https://onename.io/gubatron
@gubatron
gubatron / gubatron.gpg.pub
Created November 15, 2014 15:59
gpg public key gubatron@gmail.com
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQGiBErdpzYRBAD/RYL/4qrpBVkh60O0WT99evLRW+bCc61/rGwYNMFv/8HZFd+Z
ApKQeFVtI5Qmrdrhk6sNtntRO8C1Trchkezeg6pm3W7N9BO/Xxwq4gw3IfKIj2O4
TcE8ZUt24KOmeRBItD4G0VOujVNr/vBmtW+qeFDqm/o1LcK2rGtfMjpgVwCg7xbH
ceu5fmGV1hZ0qlnmAZz0er0D/jHdviQo0SEMlqYSGe1I5E0r/VuvovmDH2Qmly4m
1z3k+REFqGkuIqwMEhCKLT3rqAyfVrD8+xxBnW8TpRQDfJ7Sz76QyGfk9/R5tn0i
3j9z5cLzKwzGPiMffyIktZSrgdZ0DyuqL7I/GpYWCs6qEEsGw0czSTENUakevZjZ
ggsnBADVqcKPrZ51L7wIl5H/SNZ1db69BNKrq2ii1d6t5Vuf+y/AP0umtik5h+EQ
@gubatron
gubatron / building-libtorrent-and-python-libtorrent-for-macosx.md
Last active August 29, 2015 14:09
OpenBazaar: Building libtorrent and python-libtorrent on MacOSX.

OpenBazaar: Building libtorrent and python-libtorrent on MacOSX.

Nov. 15th 2014 - By Angel Leon. Tips are welcome.

Express route

  1. Install a binary boost distribution (it must contain the Boost.Python module) and make sure to setup the BOOST_ROOT environment variable.
  2. Download the libtorrent.tar.gz, and uncompress it.
  3. If you have the 1.0.2 version, you will have to go to bindings\python and remove the compile_flags and link_flags files which got packaged by mistake.
@gubatron
gubatron / boost bootstrap.md
Created November 15, 2014 17:51
boost bootstrap output
gubatrons-macbook-pro-3:boost_1_57_0 gubatron$ ./bootstrap.sh --with-python=/Users/gubatron/workspace.frostwire/OpenBazaar/env/bin/python
-n Building Boost.Build engine with toolset darwin... 
tools/build/src/engine/bin.macosxx86_64/b2
-n Detecting Python version... 
2.7
-n Detecting Python root... 
/Users/gubatron/workspace.frostwire/OpenBazaar/env/bin/..
-n Unicode/ICU support for Boost.Regex?... 
not found.
@gubatron
gubatron / boost b2 output.md
Created November 15, 2014 18:05
boost b2 output
gubatrons-macbook-pro-3:boost_1_57_0 gubatron$ ./b2

Building the Boost C++ Libraries.


Performing configuration checks

    - 32-bit                   : no  (cached)
    - 64-bit                   : yes (cached)
@gubatron
gubatron / b2 install output.md
Created November 15, 2014 18:18
boost b2 install output
gubatrons-macbook-pro-3:boost_1_57_0 gubatron$ ./b2 install
Performing configuration checks

    - 32-bit                   : no  (cached)
    - 64-bit                   : yes (cached)
    - arm                      : no  (cached)
    - mips1                    : no  (cached)
    - power                    : no  (cached)
    - sparc                    : no  (cached)
@gubatron
gubatron / libtorrent bjam build output.md
Last active August 29, 2015 14:09
libtorrent bjam build output.md
gubatrons-macbook-pro:libtorrent-rasterbar-1.0.2 gubatron$ $BOOST_ROOT/bjam toolset=darwin boost=source boost-link=shared link=shared variant=release deprecated-functions=off dht=on
BOOST_ROOT = /Users/gubatron/src/boost_1_57_0
CXXFLAGS = -I/Users/gubatron/src/boost_1_57_0 -stdlib=libc++ -std=c++11 -O3
LDFLAGS = -L/Users/gubatron/src/boost_1_57_0/stage/lib
OS = MACOSX
...patience...
...patience...
...found 2462 targets...
...updating 117 targets...
@gubatron
gubatron / python setup.py build output.md
Last active August 29, 2015 14:09
python setup.py build output
gubatrons-macbook-pro:python gubatron$ python setup.py bdist
/Users/gubatron/src/libtorrent-rasterbar-1.0.2/bin/darwin-4.2.1/release/boost-link-shared/boost-source/deprecated-functions-off/threading-multi/libtorrent.dylib.1.0.2
Copied library
gubatrons-macbook-pro:python gubatron$ python setup.py bdist
running bdist
running bdist_dumb
running build
running build_ext
building 'libtorrent' extension
@gubatron
gubatron / testing_dht_alerts.py
Created November 17, 2014 03:44
testing_dht_alert.py
import libtorrent
from threading import Thread
import time
ERROR_NOTIFICATION_ALERT_MASK = 1
PORT_MAPPING_NOTIFICATION_ALERT_MASK = 4
DEBUG_NOTIFICATION_ALERT_MASK = 32
DHT_NOTIFICATION_ALERT_MASK = 1024