Skip to content

Instantly share code, notes, and snippets.

@hkwi
hkwi / Vagrantfile
Created December 28, 2016 05:58
Linux vxlan unicast example
Vagrant.configure(2) do |config|
config.vm.box = "minimal/xenial64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.define :node2 do |node|
node.vm.network :private_network, ip: "192.168.30.2"
node.vm.provision :shell, inline: <<-SHELL
ip link add vxlan5 type vxlan id 5 dstport 4789
ip addr add 192.168.5.2/24 dev vxlan5
ip link set up vxlan5
@hkwi
hkwi / README.md
Last active November 27, 2024 15:47
Linux vxlan nat traversal example

This example shows vxlan nat traversal, using UDP hole punching.

         +---------------+
         | (node5) vxlan |
         +---------------+
                  | uplink
       +--------------------+
       | (node4) masquerade |
 +--------------------+
@hkwi
hkwi / wifi_atheros9170.md
Last active January 13, 2017 02:27
Linux wifi information
$ sudo iw phy
Wiphy phy2
        max # scan SSIDs: 4
        max scan IEs length: 2257 bytes
        Retry short limit: 7
        Retry long limit: 4
        Coverage class: 0 (up to 0m)
        Device supports RSN-IBSS.
        Device supports T-DLS.
@hkwi
hkwi / Vagrantfile
Last active January 24, 2017 07:15
Simple routing
Vagrant.configure(2) do |config|
config.vm.box = "minimal/xenial64"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.define :nodeL do |node|
node.vm.network :private_network, ip: "192.168.30.2", virtualbox__intnet: "L"
node.vm.provision :shell, inline: <<-SHELL
ip route replace default via 192.168.30.3
SHELL
end
@hkwi
hkwi / Vagrantfile
Last active February 3, 2017 09:13
dnsmasq dhcp lease watch by dbus signals
Vagrant.configure("2") do |config|
config.vm.box = "minimal/xenial64"
config.vm.provision "file", source: "listener.py", destination: "listener.py"
config.vm.provision "file", source: "hook.py", destination: "hook.py"
config.vm.provision "shell", inline: <<-SHELL
apt-get update -y
apt-get install -y python-dbus dnsmasq libglib2.0-bin
echo "enable-dbus" >> /etc/dnsmasq.d/dbus.conf
echo "dhcp-range=192.168.0.2,192.168.0.31" >> /etc/dnsmasq.d/dbus.conf
systemctl restart dnsmasq
@hkwi
hkwi / README.md
Last active February 3, 2017 08:31
inotify eventlet integration

Finally, I found eventlet-inotifyx.

@hkwi
hkwi / Vagrantfile
Created February 3, 2017 09:13
dnsmasq dhcp lease watch by inotify
Vagrant.configure("2") do |config|
config.vm.box = "minimal/xenial64"
config.vm.provision "file", source: "listener.py", destination: "listener.py"
config.vm.provision "file", source: "hook.py", destination: "hook.py"
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y python-pip python-dbus dnsmasq
pip install eventlet-inotifyx
echo "enable-dbus" >> /etc/dnsmasq.d/ix.conf
echo "dhcp-range=192.168.0.2,192.168.0.31" >> /etc/dnsmasq.d/ix.conf
@hkwi
hkwi / h2_memo.md
Last active February 20, 2017 04:55

h2, h2c という方法がある。

http を使う h2c は破壊されやすい(firewallとか)ので、使用上注意が必要。

openssl genrsa -out server.key
openssl req -new -x509 -sha256 -key server.key -out server.crt
@hkwi
hkwi / recv_push_async_await.py
Last active November 6, 2022 15:37
h2c server-push client example
import re
import struct
import curio
import curio.socket as socket
import h11
import h2.connection
from urllib.parse import urlparse
async def push_test(url, callback):
@hkwi
hkwi / send_push_eventlet.py
Created March 11, 2017 17:06
h2c server-push server example
import h11
import h2.events
import h2.connection
import eventlet
def handle(sock, addr):
con = h11.Connection(our_role=h11.SERVER)
con2 = h2.connection.H2Connection(client_side=False)
while True:
data = sock.recv(8192)