Skip to content

Instantly share code, notes, and snippets.

@cbluth
cbluth / wireguard_userspace.sh
Created July 30, 2020 09:04 — forked from svet-b/wireguard_userspace.sh
Install WireGuard userspace on Linux
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
@cbluth
cbluth / nginx-geoip-module.md
Created July 28, 2020 16:22 — forked from VirtuBox/nginx-geoip-module.md
How to configure GeoIP module for Nginx

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
@cbluth
cbluth / block-tor.sh
Created April 16, 2020 11:15 — forked from tiagoad/block-tor.sh
Cronjob to block tor exit nodes with nginx on debian 8 jessie
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
@cbluth
cbluth / udpProxy.go
Created March 26, 2020 14:22 — forked from mike-zhang/udpProxy.go
Implementation of a UDP proxy in Golang
// Implementation of a UDP proxy
package main
import (
"flag"
"fmt"
"log"
"net"
"os"
@cbluth
cbluth / client.go
Created March 25, 2020 09:00 — forked from elico/client.go
golang tcp client connection alive check
package main
import (
"fmt"
"io"
"net"
"time"
)
func main() {
@cbluth
cbluth / file_response_writer.go
Created March 22, 2020 08:52 — forked from ismasan/file_response_writer.go
Write backend HTTP response to http.ResponseWriter and File
// 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
}
@cbluth
cbluth / sortByteSlice.go
Created March 9, 2020 10:49 — forked from schmohlio/sortByteSlice.go
sort byte slices in Golang without needing to fmt as string. useful for Set hashes
package main
import (
"bytes"
"log"
"sort"
)
// implement `Interface` in sort package.
type sortByteArrays [][]byte
@cbluth
cbluth / dht-walkthrough.md
Created March 8, 2020 11:44 — forked from gubatron/dht-walkthrough.md
DHT walkthrough notes

DHT Walkthrough Notes

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.

What problem does this solve?

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

#!/usr/bin/env bash
apt remove --purge wazuh-agent -y ; curl -so /tmp/wazuh-agent.deb \
'https://packages.wazuh.com/3.x/apt/pool/main/w/wazuh-agent/wazuh-agent_3.11.3-1_amd64.deb'
sudo WAZUH_MANAGER_IP='wazuh.example.org' dpkg -i /tmp/wazuh-agent.deb
sed -i \
's#<protocol>udp</protocol>#<protocol>tcp</protocol>#' \
/var/ossec/etc/ossec.conf
systemctl restart wazuh-agent.service
@cbluth
cbluth / sse.go
Created February 14, 2020 10:41 — forked from ismasan/sse.go
Example SSE server in Golang
// 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