Skip to content

Instantly share code, notes, and snippets.

@russelldavies
russelldavies / daemon.json
Created February 6, 2024 15:46
Docker IPv6
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8::/64",
"experimental": true,
"ip6tables": true,
"default-address-pools":[
{"base": "172.17.0.0/16", "size": 24 },
{"base": "2001:db8:1::/64", "size": 80 }
],
"dns": [
@russelldavies
russelldavies / permutations.rs
Created November 8, 2023 20:38
Permutations
fn main() {
let mut items: Vec<&str> = vec!["a", "b", "c"];
let mut c = vec![0; items.len()];
println!("{:?}", items);
let mut i = 0;
while i < items.len() {
if c[i] < i {
if i % 2 == 0 {
@russelldavies
russelldavies / satshunter.py
Created October 19, 2023 19:37
Sats Hunter
import argparse
import multiprocessing
import itertools
from bip_utils import Bip39SeedGenerator, Bip44Changes, Bip84, Bip84Coins
from bip_utils.utils.mnemonic import MnemonicChecksumError
def validate_mnemonic(perm):
mnemonic = " ".join(perm)
return False
@russelldavies
russelldavies / init.sh
Last active March 11, 2024 18:44
IPv6 bootstrap EC2 instance
#!/bin/sh
# nat64.net NAT64 DNS resolvers
# This can be removed once AWS adds IPv6 DNS records for various services, e.g. SSM
echo 'DNS=2a00:1098:2c::1 2a01:4f9:c010:3f02::1 2a01:4f8:c2c:123f::1\nDomains=~.' >> /etc/systemd/resolved.conf
systemctl restart systemd-resolved.service
snap switch --channel=candidate amazon-ssm-agent
snap refresh amazon-ssm-agent
@russelldavies
russelldavies / intercept.js
Created August 5, 2023 11:26
Intercept unauthorized requests for Elm
XMLHttpRequest = class extends XMLHttpRequest {
send() {
const onreadystatechange = this.onreadystatechange;
this.onreadystatechange = () => {
console.log(this.readyState);
if (typeof onreadystatechange === 'function') {
this._onreadystatechange();
}
};
super.send();
#!/bin/sh
snap switch --channel=candidate amazon-ssm-agent
snap refresh amazon-ssm-agent
@russelldavies
russelldavies / mount.sh
Created June 4, 2023 14:51
Mount disk image in MacOS
#!/bin/sh
hdiutil attach -readonly -imagekey diskimage-class=CRawDiskImage disk.img
@russelldavies
russelldavies / git.md
Created November 2, 2022 23:15
Git message imperatives

Git message imperatives:

  • Add = Create a capability e.g. feature, test, dependency.
  • Cut = Remove a capability e.g. feature, test, dependency.
  • Fix = Fix an issue e.g. bug, typo, accident, misstatement.
  • Bump = Increase the version of something e.g. dependency.
  • Make = Change the build process, or tooling, or infra.
  • Start = Begin doing something; e.g. create a feature flag.
  • Stop = End doing something; e.g. remove a feature flag.
  • Refactor = A code change that MUST be just a refactoring.
  • Reformat = Refactor of formatting, e.g. omit whitespace.
@russelldavies
russelldavies / README.md
Created October 7, 2022 14:16
Accessing a Modem through a Ubiquiti USG

The configuration here assumes that the USG is configured at 192.168.1.1/24 and the modem at 192.168.0.1/24.

IP Masquerading

For this method we need to create a virtual interface on the USG's WAN port configured to the same subnet as the modem. As the USG will be configured with both its own subnet and the modem's, it knows how to route traffic between them. Heowever, without a static route, the modem doesn't know how to route traffic back to the USG's LAN. The solution is make the USG do some NAT so that the USG's LAN packets have their IP address masqueraded so the packets appear to come from the USG's virtual interface rather than the LAN.

On the USG create a virtual network interface (psuedo interface) with an IP address on the same subnet as the modem (192.168.0.100 is chosen here) and add a masquerading rule:

configure
@russelldavies
russelldavies / README.md
Created May 29, 2022 17:50
AWS VPC IPv6-only subnets with IPv4 connectivity using DNS64 and NAT64

This is mainly applicable if you want to have IPv6-only subnets rather than dual-stack. You might do this because you don't want to have to worry about IPv4 address conflicts or whatever.

IPv4 enabled subnet

You must either have or create a separate IPv4 public subnet from the IPv6-only subnet. Configure a NAT gateway (which must have an IPv4 address) in this subnet.

Routing Table

| Destination | Target |