Commit Graph

600 Commits

Author SHA1 Message Date
Brian Cunnie
ec76a6cdcf License: GNU Affero → Apache 2.0
Now that I've worked on the other side of LGPL licensing, and the pain
of providing build instructions for a binary we download from Maven, I'm
a big fan of Apache 2.0 licensing.
2020-12-01 12:09:50 -08:00
Brian Cunnie
0c09717a1b BOSH release: 1.1.2: make website great again
Now we have A & AAAA records for sslip.io.
1.1.2
2020-12-01 12:03:10 -08:00
Brian Cunnie
4d05abd1b0 🐞 make sslip.io's website accessible again
The new webserver didn't have A and AAAA records for `sslip.io`, which
meant there was no website. We need a website. This commit fixes that.

The code is somewhat inflexible in that it assumes that there's exactly
oneA record and exactly one AAAA record.

I took the opportunity to bump SOA's serial and set the Hostmaster email
address to my primary email (brian.cunnie@gmail.com).

fixes:
```
curl: (6) Could not resolve host: sslip.io
```
2020-12-01 11:55:17 -08:00
Brian Cunnie
a37bbc150c CI: check sslip.io's A & AAAA records, and website
- The impetus? I deployed a custom webserver but forgot to add the
  A & AAAA records for sslip.io, so the website disappeared.
- I now check for the A & AAAA records (to be present, but not of any
  particular value because that gives me the latitude to migrate to
  other machines).
- I also check that the website is responsive.
- drive by: removed hard-coding of `sslip.io` in many tests; instead we
  now query the domain that the env var `DOMAIN` is set to.
2020-12-01 10:01:08 -08:00
Brian Cunnie
09249be0a0 CI: don't double-count the nameservers
On macOS, `whois` returns _two_ results for the domain `sslip.io` from
two different whois servers:

- whois.nic.io
- whois.namecheap.com

This means that every nameservers is double-counted. To fix, we remove
the duplicates.

fixes:
```
     Failure/Error: expect(dig_nameservers.sort).to eq(whois_nameservers.sort)

       expected: ["ns-aws.nono.io.", "ns-aws.nono.io.", "ns-azure.nono.io.", "ns-azure.nono.io.", "ns-gce.nono.io.", "ns-gce.nono.io."]
            got: ["ns-aws.nono.io.", "ns-azure.nono.io.", "ns-gce.nono.io."]

       (compared using ==)
     # ./spec/check-dns_spec.rb:44:in `block (3 levels) in <top (required)>'
```
2020-12-01 09:22:24 -08:00
Brian Cunnie
06f1556699 Revert "dig shouldn't bomb-out if forbidden hyphen is used"
DiG 9.10.6 no longer has the `+noidn` option, and `dig` will error if we
try to use it.

fixes:
```
dig +short +noidnin ns sslip.io @ns-azure.nono.io.
Invalid option: +noidnin
```

And this previously-invalid dig query now works, so we don't need the
option anyway:
```
dig +short AAAA api.--.sslip.io
::
```

This reverts commit a2564c12d3.
2020-12-01 09:17:08 -08:00
Brian Cunnie
0ac9e1895d HTML: tidy 5.6.0 the HTML assets
It makes it easier for editing.
2020-12-01 08:40:00 -08:00
Brian Cunnie
459a86dab3 🐞 sslip.io SOA conforms to the Golang server's
- Modified SOA:
  - We're setting the SOA serial _backwards_; yes, even though there's no
    impact, it feels gross. But the alternative, modifying the Golang code
    and re-releasing, was too much work.
  - I changed the SOA's refresh/retry/expire to match google.com's.
  - I changed the mname (primary master) from `ns-he.nono.io` to
    `sslip.io`. The change is cosmetic; those are the same machine.
- We emptied out the `pdns_named_conf`; we're not using the bind backend
  anymore, so the bind configuration can be empty.

fixes <https://ci.nono.io/teams/main/pipelines/sslip.io/jobs/check-dns/builds/3813>:
```
       expected: "ns-he.nono.io. briancunnie.gmail.com. 2020112800 300 300 300 300\n"
            got: "sslip.io. yoyo.nono.io. 2020090400 900 900 1800 300\n"
```
2020-11-30 17:24:06 -08:00
Brian Cunnie
3c36f85b6d BOSH release: 1.1.1: compilation bugfix 1.1.1 2020-11-30 14:06:50 -08:00
Brian Cunnie
d072448c2f 🐞 BOSH Release compiles properly
fixes:
```
+ go build -o /var/vcap/packages/sslip.io-dns-server/bin/sslip.io-dns-server
main.go:7:2: package xip/xip is not in GOROOT (/var/vcap/data/packages/golang-1-linux/da1e0a99a1246edab92d9ffd0c4a2e7c3d5df83a/src/xip/xip)
```
2020-11-30 14:03:04 -08:00
Brian Cunnie
c1e7908f57 BOSH release: 1.1.0: A records for nameservers 1.1.0 2020-11-30 13:37:31 -08:00
Brian Cunnie
8571723582 Golang-based DNS server: return A records for nameservers
Some clients query us for the A records of our nameservers even though
our nameservers aren't in our domain; the nameservers are in the
`nono.io` domain, not in the `sslip.io` domain.

Our new code returns the A records of our nameservers:

previously:
```
2020/11/28 21:57:38 190.113.222.130.55236 TypeA ns-aws.nono.io. ? nil, SOA
2020/11/28 21:57:38 190.113.222.130.49919 TypeA ns-azure.nono.io. ? nil, SOA
2020/11/28 21:57:38 190.113.222.130.8090 TypeA ns-gce.nono.io. ? nil, SOA
```
now:
```
2020/11/30 13:20:10 127.0.0.1.58410 TypeA ns-aws.nono.io. ? 52.0.56.137
2020/11/30 13:20:20 127.0.0.1.54717 TypeA ns-azure.nono.io. ? 52.187.42.158
2020/11/30 13:20:28 127.0.0.1.62487 TypeA ns-gce.nono.io. ? 104.155.144.4
```

I learned about Golang maps while implementing this feature.
2020-11-30 13:12:28 -08:00
Brian Cunnie
e7674992c6 .gitignore: ignore JetBrains's ./idea 2020-11-30 10:37:02 -08:00
Brian Cunnie
d9c8291f51 🐞 Import module xip correctly
Don't use the GitHub path; use the local directory.

See
<https://github.com/golang/go/wiki/Modules#do-modules-work-with-relative-imports-like-import-subdir>
for more information. tldr:

```golang
import "xip/xip"
```

The first `xip` is the module name, and the second `xip` is the
subdirectory. They happen to be the same in this case.
2020-11-28 15:11:55 -08:00
Brian Cunnie
f3d4f70ecf sslip.io nameservers no longer use bind backend
The nameservers only use the pipe backend because they are no longer
acting as secondaries for the "regular" domains.

They are now exclusively serving sslip.io domain (and whitelabels).
2020-11-28 13:38:52 -08:00
Brian Cunnie
ef3a0bfd13 🐞 SOA and hostmaster are no longer swapped
I had accidentally swapped the SOA & hostmaster. This didn't break
anything, but it's very embarrassing.

fixes <http://www.webdnstools.com/dnstools/domain_check>:

> Checking DNS contact email address is valid. ns-he@nono.io is not valid. Mail server returned 'no such user'.

> Your SOA record lists briancunnie.gmail.com as the Primary nameserver. This server is not listed as a valid nameserver at the parent servers.
2020-11-28 12:33:24 -08:00
Brian Cunnie
206069be7d BOSH Release README is now 1.0.1
...instead of pointing to the old, broken-logging 1.0.0
2020-11-27 18:07:46 -08:00
Brian Cunnie
b4a58b982e BOSH release: 1.0.1 fixes logging 1.0.1 2020-11-27 17:42:59 -08:00
Brian Cunnie
c452cbb71a BOSH Release has a README
To describe how to deploy, etc.
2020-11-27 17:40:41 -08:00
Brian Cunnie
1040783f64 🐞 BOSH Release: job generates logs
Previously logs weren't being generated because I wasn't redirecting the
output because I accidentally deleted a trailing backslash.
2020-11-27 17:26:24 -08:00
Brian Cunnie
3e8d3d263a splash page: deprecate ns-vultr
It isn't reliable; It's off the last week of the month.
2020-11-27 16:01:37 -08:00
Brian Cunnie
5269ed5ecb BOSH release: 1.0.0 includes sslip.io package 1.0.0 2020-11-26 16:37:21 -08:00
Brian Cunnie
4714e9f2ba BOSH Release: vendored-Golang is in the final builds
Not worthy of its own commit; it should have been part of the commit
where I vendored Golang.
2020-11-26 16:35:13 -08:00
Brian Cunnie
bfa7221973 BOSH release: package sslip.io-dns-server
The packaging script is a bit of a hack: we create the `src/` directory
and move our source into it. 🤮

The source should have been in the proper directory to begin with, but
I'm too tired to fight with directory structures right now.
2020-11-26 16:31:36 -08:00
Brian Cunnie
8c256c773c 🐞 Golang modules: use proper module name
fixes:
```
main.go:7:2: module github.com/cunnie/sslip.io@latest found (v0.0.0-20201126193932-8400f99e37d2), but does not contain package github.com/cunnie/sslip.io/src/xip
```
2020-11-26 15:12:29 -08:00
Brian Cunnie
f2e8c6246f src/bosh-release/src
...so that the packaging script will work.

I made a symbolic link for convenience.
2020-11-26 15:11:25 -08:00
Brian Cunnie
8400f99e37 BOSH release: .gitignore eliminates unhappy commits
I especially don't want to commit the `config/private.yml`, which has my
GCS credentials.
2020-11-26 11:39:32 -08:00
Brian Cunnie
b640f0b89e BOSH release: vendor the Golang package
I'll need Golang to compile the DNS server during the compilation phase.

<https://github.com/bosh-packages/golang-release>
2020-11-26 11:38:22 -08:00
Brian Cunnie
2d30e75f7e BOSH release: use GCS to store the BOSH blobs
...and the bucket's name is <drumroll> ... sslip-io-release! How's that
for the principle of least surprise?
2020-11-26 11:37:35 -08:00
Brian Cunnie
47adbd1706 BOSH Release for DNS server: job sslip.io-dns-server
This is a bittersweet moment—it's likely the last BOSH release I'll ever
write, and in some ways is closing a chapter of my life that I found
incredibly fun, exciting, and educational.

Why write a BOSH Release? Because the sslip.io infrastructure, or at
least three of the four nameservers, are BOSH-deployed.

Why write a DNS server? Why not continue with the existing PowerDNS
server + BASH backend? Because I'm stuck at the 4.2.2 PowerDNS release,
and I was unable to get 4.3+ to compile in the BOSH way. Let's be
honest: converting an application to a BOSH package is like doing a
port, a difficult port, and it was easier to write my own DNS server
than port PowerDNS 4.3+ to BOSH.

There's only one job in this commit (`sslip.io-dns-server`), which is
clearly named to avoid confusing with the at least 3 other DNS servers
(BOSH's DNS, BIND, and PowerDNS) that have BOSH releases. The BOSH
package will be in an upcoming commit.
2020-11-25 15:05:07 -08:00
Brian Cunnie
d728bb2a0e Experimental server uses Golang modules
...because I want to learn how to use Go modules.

(also I now ignore macOS dingleberries, `.DS_Store`)
2020-11-22 03:52:15 -08:00
Brian Cunnie
4ce0fa323c Document the experimental Golang DNS server
This is mostly for me because I forget how I wrote it (e.g. what happens
when you query a `TXT` record).
2020-11-22 03:47:40 -08:00
Brian Cunnie
15a9cd41e5 Logging is finished
I used a shorthand logging which extracts the info I'm interested in:
- IP of the asker (e.g. 10.0.9.30)
- Port of the asker (e.g. 59036)
- Type of the question (e.g. TypeA)
- Name of the question (e.g. 127.0.0.1.nono.io)
- Question mark (a delimiter)
- one of the following
  - answer (e.g. 127.0.0.1, MX, NS, SOA)
  - or no answer, but an authority section (e.g. nil, SOA)
2020-10-04 13:33:44 -04:00
Brian Cunnie
558a71d0c0 processQuestion() uses name result parameters, too
<https://golang.org/doc/effective_go.html#named-results>
2020-10-04 12:23:50 -04:00
Brian Cunnie
31a0723fd5 QueryResponse() uses named return values
It's more of an experiment than anything else, but I like how it
documents the purpose of the return value.
2020-10-04 12:23:18 -04:00
Brian Cunnie
dc341d1ef7 Scaffolding for log messages
We want to log queries (mostly because I'd like some metric of how many
queries people are making, what those queries are, and what my answers
are).

I also put a guard against one of the error conditions (I had assumed
only one type of error would ever be returned; I believe that assumption
is naïve)
2020-10-04 10:48:49 -04:00
Brian Cunnie
5b1e9986c0 Return remaining records (answers: 0, authorities: 1)
- We return the remaining records (e.g. SRV, HINFO). The behavior is the
  same for an A/AAAA record that is not found, i.e. no answers, 1
  authority.
2020-10-02 11:48:11 -04:00
Brian Cunnie
c3f96b8890 DNS "ANY" Type returns "Not implemented"
Blog post for rationale: https://blog.cloudflare.com/rfc8482-saying-goodbye-to-any/

I am following the behavior of 1.1.1.1, but I may switch to the behavior
of 8.8.8.8 (Google), which returns all records.
2020-10-01 15:02:44 -04:00
Brian Cunnie
4194986d77 NS records are properly returned
- Unlike MX and SOA records, NS records are an array.
- Moved the variables into a block `var ( ... )`, reads more easily.
- `processQuestion()` answers MX & SOA records (and of course NS
records)
2020-09-30 10:35:20 -07:00
Brian Cunnie
15900f4c51 Tidy up: no panic()s
- user better variable naming
- sort functions somewhat alphabetically
2020-09-27 17:44:57 -07:00
Brian Cunnie
41b171fe8d Extracted method processQuestion()
...because `QueryResponse()` was becoming much too big.
2020-09-27 14:47:15 -07:00
Brian Cunnie
2ad70a028a SOAResource(), MXResource() have unit tests
Sure, they have unit tests, but the methods are so simple I'm not sure
they're worth testing.

I changed the hostmaster to `yoyo@nono.io` because I felt more
comfortable having the email on ProtonMail in lieu of Gmail.
2020-09-27 14:27:02 -07:00
Brian Cunnie
93748f8be2 xip: lookup IPv6 (AAAA) records, too
- Refactored the tests, but they're still hard to follow

Todo:

- break out the case statement to a separate method in `QueryResponse()`
- add NS, MX records
2020-09-23 15:35:35 -07:00
Brian Cunnie
c4e5dfb0ca Use dnsmessage's Parser() and Builder()`
- Change Ginkgo's `To(Not(` to use the shorter `ToNot(`
- did fewer initializations in the `vars` block and moved them to the
  `BeforeEach()` blocks.

The `QueryResponse()` test is too long & convoluted; even I have a hard
time understanding them, and I wrote them! The tests & code should be
re-written, but that's for another day.
2020-09-20 16:39:04 -07:00
Brian Cunnie
67acbb7f47 Golang: use dnsmessage.Builder
- It automatically populates the header for us, which would have been a
  big headache to do manually.
- Switched `ENOTFOUND` to `ErrNotFound`, and updated the error message
  as well. As sad as it was to make this switch, I must acknowledge that
  I'm coding in Go, not C, and I should follow its conventions.
- TWO OF THE TESTS ARE BROKEN. I know, I'll fix them soon. I should have
  fixed the tests first, then the code, but I was overeager.
2020-09-16 20:04:25 -07:00
Brian Cunnie
7b3fdd9c04 🏆 Success! It resolves 1 query
- it resolves `127.0.0.1.sslip.io`
- it ranges through all the questions in query, even though, IIRC, only
  the first one is ever populated.
- ran both `gofmt` and `goimports`
2020-09-06 16:03:33 -07:00
Brian Cunnie
e9ef1536cf SOAResource() provides SOA information
- currently hard-coded. And I didn't think too hard about how I could
  make it more flexible in the future.
- various times stolen from the domain `google.com`, with the exception
  of `minTTL`, which I bumped from 60 to 300.
- I called variable names that are arrays "...Array" because they're so
  rare--slices are much more common.
- fixed a bug in main.go where the error-logic was inverted.
2020-09-04 14:53:41 -07:00
Brian Cunnie
6cb1a1902e 🐞 can't have break when not in a loop 2020-09-04 12:50:22 -07:00
Brian Cunnie
c189897bed Document xip package, functions
Because I love documenting, and the act of documenting clarifies my
thinking.
2020-09-04 12:23:40 -07:00
Brian Cunnie
293cc3c7f2 Handle DNS query's processing in a separate thread
...because I can. And because it gives me a reason to use `go func()`
2020-09-04 12:20:10 -07:00