Skip to content

Instantly share code, notes, and snippets.

package main
import (
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"fmt"
"net/http"
"net/url"
@arpitkh96
arpitkh96 / aes.go
Created August 8, 2020 08:58
AES Implementation in golang
// Handler is AES Handler
type Handler struct {
aesgcm cipher.AEAD
salt []byte
}
func New(aesPwd string) (*Handler, error) {
if len(aesPwd) != 72 {
return nil, fmt.Errorf("AESSecret: Invalid length: %d, should be 72", len(aesPwd))
}
@arpitkh96
arpitkh96 / two_containers.sh
Created July 25, 2019 04:04
two containers with bridge
#/bin/bash
set -x
# Add a namespace named con1
ip netns add con1
# Add a veth pair
ip link add veth11 type veth peer name veth10
# Assign one of the pair to con1
ip link set veth10 netns con1
# Add an ip address (notice the /24 subnet)
ip netns exec con1 ip addr add 10.0.0.2/24 dev veth10
CON=containerns1
IP=10.0.0.3
echo "Creating the namespace"
sudo ip netns add $CON
echo "Creating the veth pair"
sudo ip link add veth10 type veth peer name veth11
echo "Adding one end of the veth pair to the namespace"
sudo ip link set veth10 netns $CON
CON="containerns"
IP="10.0.0.2"
echo "Configuring the interface in the network namespace with an IP address"
sudo ip netns exec $CON ip addr add $IP dev veth0
echo "Enabling the interface inside the network namespace"
sudo ip netns exec $CON ip link set dev veth0 up
echo "Enabling the interface on the node"
sudo ip link set dev veth1 up
@arpitkh96
arpitkh96 / single-container-1.sh
Last active July 20, 2019 18:33
Single container
CON="containerns"
echo "Creating the namespace"
sudo ip netns add $CON
echo "Creating the veth pair"
sudo ip link add veth0 type veth peer name veth1
echo "Adding one end of the veth pair to the namespace"
sudo ip link set veth0 netns $CON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.