Skip to content

Instantly share code, notes, and snippets.

View cmol's full-sized avatar

Claus Lensbøl cmol

View GitHub Profile
@cmol
cmol / keybase.md
Created May 16, 2015 13:41
keybase.md

Keybase proof

I hereby claim:

  • I am cmol on github.
  • I am cmol (https://keybase.io/cmol) on keybase.
  • I have a public key whose fingerprint is 54C4 F886 5479 CCDB F367 DC13 720E 785B F86A EAD3

To claim this, I am signing this object:

@cmol
cmol / natPMP.py
Last active December 16, 2015 13:29
Script for requesting a port redirection via natPMP. Uses python3
"""
Script for requesting a port redirection via natPMP.
Follows the standart of:
http://tools.ietf.org/html/draft-cheshire-nat-pmp-07#section-3.3
with the exception of hold times. We are not going to wait a little
above 3 minutes to test for natPMP.
"""
import socket
import random
2620:0000:0862:ed1a:0000:0000:0000:0001
cmol@qui-gon:~$ ruby src/multicast.rb
Using local interface wlp4s0 with address fe80::71c0:aa40:6d16:7c59%wlp4s0
========= Sending echo REQUEST from fe80::71c0:aa40:6d16:7c59%wlp4s0
[REQUEST] Hello from fe80::ade4:80af:c170:6340%enp0s31f6
========= Sending echo REPLY to fe80::ade4:80af:c170:6340%wlp4s0
[REQUEST] Hello from fe80::a00:27ff:fe07:dea6%enp0s3
========= Sending echo REPLY to fe80::a00:27ff:fe07:dea6%wlp4s0
[REPLY] Hello from fe80::ade4:80af:c170:6340%enp0s31f6
def send_request(socket, linklocal_addr, multicast_addr, multicast_port,
flags)
puts "========= Sending echo REQUEST from #{linklocal_addr}"
socket.send("[REQUEST] Hello from #{linklocal_addr}",
flags, multicast_addr, multicast_port)
end
cmol@second-host:~$ ruby src/multicast.rb
Using local interface enp0s31f6 with address fe80::ade4:80af:c170:6340%enp0s31f6
[REPLY] Hello from fe80::71c0:aa40:6d16:7c59%wlp4s0
cmol@qui-gon:~$ ruby src/multicast.rb
Using local interface wlp4s0 with address fe80::71c0:aa40:6d16:7c59%wlp4s0
========= Sending echo REQUEST from fe80::71c0:aa40:6d16:7c59%wlp4s0
cmol@third-host:~$ ruby src/multicast.rb
Using local interface enp0s3 with address fe80::a00:27ff:fe07:dea6%enp0s3
========= Sending echo REQUEST from fe80::a00:27ff:fe07:dea6%enp0s3
[REPLY] Hello from fe80::71c0:aa40:6d16:7c59%wlp4s0
[REPLY] Hello from fe80::ade4:80af:c170:6340%enp0s31f6
[["if_name", index, "ip_address"],[...]]
require "socket"
CONNECT_ADDR = "localhost"
CONNECT_PORT = 12345
MSG_LENGTH = 256
FLAGS = 0
Addrinfo.udp(CONNECT_ADDR, CONNECT_PORT).connect do |socket|
socket.send("Connected via unspecified address family socket", FLAGS)
message, server = socket.recvfrom(MSG_LENGTH)