Skip to content

Instantly share code, notes, and snippets.

View losnir's full-sized avatar

losnir

  • Israel
View GitHub Profile
@losnir
losnir / README.md
Created December 28, 2021 01:05
recursive DNS resolver using unbound in K8S

This gist is how I personally deploy an arm64 version of unbound (for running on Raspberry Pi) configured as a recursive DNS resolver.

Use case is setting this up as the upstream resolver in PiHole (also running in K8S) in order to eliminate the need of a 3rd-party resolver (i.e. Cloudflare, Quad9), potentially avoiding DNS spoofing / poisoning / etc.

Service is exposed with a ClusterIP under 10.43.0.53 listening to both TCP/UDP on port 53.

TODO / Considerations:

  • This still does not hide your DNS traffic from your ISP since root nameservers do not use DoH/DoT. Ultimately, this should run somewhere in the cloud (for example AWS EC2/ECS) and configured in DoH/DoT mode. This is also a fantastic opportunity to use ZeroTier for tying it all together to your local LAN without exposing your cloud resources to the public, while increasing security (ZT is encrypted).
@losnir
losnir / awesome_regex.md
Created August 12, 2019 08:57
Awesome regex

Awesome regex

AWS ARN:

/^arn:aws\w*:\w+:\w*:(?:\d{12})?:(?:\w+\/(?:\w+|\*)|\w+:(?:\w+|\*)|\w+|\*)/
job "dummy-batch-job" {
datacenters = ["us-east-1"]
type = "batch"
periodic {
cron = "*/1 * * * * *"
prohibit_overlap = true
}
group "monitor" {
@losnir
losnir / motor_power_constants.asm
Last active September 8, 2021 15:01
Xiaomi M365 Custom Firmware
0x00004e1e movw r2, #0xc977
0x00004e26 movw r1, #0xc977
0x00004e3e movw r2, #0xc977
0x00004e46 movw r1, #0xc977
0x00004e5c movw r3, #0xc977
@losnir
losnir / formatter.js
Created July 16, 2017 13:16
ES15 String Formatting using Tagged Template Literal
function interpolateStringLiteral (template, tokens, input) {
const dict = input[input.length - 1] || {};
return template.reduce((accumulator, part, i) => {
const key = tokens[i];
const value = Number.isInteger(key) ? input[key] : dict[key];
accumulator.push(part);
accumulator.push(value);
return accumulator;
}, []);
}
@losnir
losnir / .eslintrc
Created December 8, 2016 19:15
My code style for eslint
{
"rules": {
"keyword-spacing": ["error", { before: true, after: false }],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true, "align": "value" }],
"object-curly-spacing": ["error", "always"],
"one-var": ["error", "always"],
"padded-blocks": ["off"],
"max-len": ["error", 100],
"indent": ["error", 3, { "VariableDeclarator": 2 }]
}
@losnir
losnir / gist:4ef2dfc818fe8a824994
Created February 22, 2015 11:14
Knockout Utilities
/**
* A recursive deep-cloning utility, specifically for KO ViewModels.
* @author Nir Azuelos
* @param {object} input
* @returns {object} output
*/
ko.utils.clone = function(input) {
var mapped = ko.mapping.fromJS(input, {
create: function (options) {
return ko.mapping.visitModel(options.data, function (value, parent) {