Skip to content

Instantly share code, notes, and snippets.

@asergeyev
asergeyev / digfuncs.sh
Created February 15, 2016 17:35
Bunch of dig command line examples
# All authority gluerecs by name:
dig +noall +authority $NAME @b.gtld-servers.net | sed -e 's/.*\s//' | xargs -n1 -I % bash -c 'dig +short $NAME @% | sed -e s/^/%\\t/'
# All authority gluerecs with glue IPs:
dig +noall +additional $NAME @b.gtld-servers.net | sed -e 's/.*\s//' | xargs -n1 -I % bash -c 'dig +short $NAME @% | sed -e s/^/%\\t/'
# All recs found with resolving every name to all known IPs
dig +noall +authority $NAME @b.gtld-servers.net | sed -e 's/.*\s//' | xargs -n1 -I % dig +short NS $ZONE @% | sort -u | xargs -n1 -I % bash -c 'dig +short A %; dig +short AAAA %' | sort -u | grep -v : |xargs -n1 -I % bash -c 'dig +short $NAME @% | sed -e s/^/%\\t/'
# For one above, find zone by name (not 100% good but works ok for basic things):
@asergeyev
asergeyev / cryptosigner.diff
Created October 19, 2015 13:19
Crypto signer backporting for DNS lib
diff --git a/dnssec.go b/dnssec.go
index 84cb214..9198d6d 100644
--- a/dnssec.go
+++ b/dnssec.go
@@ -18,8 +18,26 @@ import (
"sort"
"strings"
"time"
+ "io"
)
@asergeyev
asergeyev / greeter.html
Created March 4, 2015 13:00
Websocketd Greeter HTML
<!DOCTYPE html>
<html>
<head>
<title>websocketd greeter example</title>
<style>
#messages {
font: bold 2em arial;
margin: auto;
padding: 10px;
text-align: center;
diff --git a/server_test.go b/server_test.go
index 4041468..bf60984 100644
--- a/server_test.go
+++ b/server_test.go
@@ -40,10 +40,6 @@ func RunLocalUDPServer(laddr string) (*Server, string, error) {
server.ActivateAndServe()
pc.Close()
}()
- // in order to let all Server internals to finish before test will touch
- // server's internal fields, we need to cycle thru other goroutinges for
@asergeyev
asergeyev / gist:16db89fc6af9654422be
Last active August 29, 2015 14:05
Diff for NSEC and NSEC3 and DNSSEC algorithms to be mixcase
diff --git a/zscan.go b/zscan.go
index e051d8e..ed0114f 100644
@@ -671,9 +671,11 @@ func zlexer(s *scan, c chan lex) {
if stri != 0 {
l.value = _STRING
l.token = string(str[:stri])
+ l.tokenUpper = strings.ToUpper(l.token)
+
l.length = stri
if !rrtype {
#!/bin/sh
# this will fire even when sleep is working (when assuming bash)
ok(){
echo "TRAP"
exit 2
}
trap "ok" SIGINT
diff --git a/client.go b/client.go
index 7842cfc..a12f4ba 100644
--- a/client.go
+++ b/client.go
@@ -47,6 +47,7 @@ func (c *Client) Exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err erro
if err = w.dial(); err != nil {
return nil, 0, err
}
+ defer w.close()
if err = w.send(m); err != nil {
@asergeyev
asergeyev / jsonf
Created March 7, 2012 13:58
Prettifying JSON
#!/usr/bin/env node
var fs = require('fs');
fs.readFile( process.argv[2], function(e, b) {console.log(JSON.stringify(JSON.parse(b), null, 2))} )
@asergeyev
asergeyev / anyevent.html
Created January 9, 2012 16:58
Anyevent example for websockets to support old websocket proto from some agents (Safari, Chrome on Google TV)
<!DOCTYPE html>
<!-- mostly borrowed from Mojo -->
<html>
<head>
<title>WebSocket</title>
</head>
<body>
Testing WebSockets, please make sure you have JavaScript enabled.
Fedora 14:
/lib/libuuid.so.1
linux-gate.so.1 => (0x00a80000)
libc.so.6 => /lib/libc.so.6 (0x0028c000)
/lib/ld-linux.so.2 (0x0026b000)
FreeBSD:
/usr/local/lib/libuuid.so:
libc.so.7 => /lib/libc.so.7 (0x800633000)