llbl

package module
v0.0.0-...-e41c2fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 5 Imported by: 0

README

llbl

"Let Localhost be Localhost" DNS server which resolves *.localhost to 127.0.0.1.

It relies on /etc/resolver.

Installation

go get github.com/ichiban/llbl/cmd/llbl

Usage

By default, foo.localhost doesn't resolve to anything.

$ ping -c 1 foo.localhost
ping: cannot resolve foo.localhost: Unknown host

Run llbl with sudo. While it's running, any domains that end with .localhost will be resolved as 127.0.0.1.

$ sudo llbl
Password:
INFO[0000] listen                                        addr="0.0.0.0:62631"
$ ping -c 1 foo.localhost
PING foo.localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.048 ms

--- foo.localhost ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.048/0.048/0.048/0.000 ms

Back story

I wanted to test a web app which can be accessed as *.example.com where * can be any strings. So I looked it up how to configure /etc/hosts to resolve any *.example.com to localhost.

I stumbled upon a stackoverflow answer that says there's no way to configure /etc/hosts that way. So, instead I needed to run a local DNS server. For that purpose, the domain has to be *.test but there's a proposal to use *.localhost. I checked if foo.localhost works on my laptop. It didn't. So I made this.

License

Distributed under the MIT license. See LICENSE for more information.

Contributing

  1. Fork it (https://github.com/ichiban/llbl/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(port int) (func() error, error)

Configure configures /etc/resolver/localhost to lookup llbl.

func Handle

func Handle(w dns.ResponseWriter, r *dns.Msg)

Handle handles DNS query for *.localhost.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL