aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2014-02-24 15:42:55 +0100
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2014-02-24 15:42:55 +0100
commit1aa13877f1fb8f2fe80bddaa4f8265c1dc1811d1 (patch)
tree1e10c31ac107fea2aad6c3049c17abacd84b0693
parentb32e2bf6dfe370d85828e2f0a959b91552dd6589 (diff)
downloadDns-1aa13877f1fb8f2fe80bddaa4f8265c1dc1811d1.zip
Dns-1aa13877f1fb8f2fe80bddaa4f8265c1dc1811d1.tar.gz
Dns-1aa13877f1fb8f2fe80bddaa4f8265c1dc1811d1.tar.bz2
Add syntax highlighting.
-rw-r--r--README.md82
1 files changed, 47 insertions, 35 deletions
diff --git a/README.md b/README.md
index abdfac5..b498135 100644
--- a/README.md
+++ b/README.md
@@ -18,18 +18,24 @@ new resolution host: ours.
On Mac OS X, the simplest way is to write in `/etc/resolver/hoa` the following
declarations:
- nameserver 127.0.0.1
- port 57005
+```
+nameserver 127.0.0.1
+port 57005
+```
On Linux, we will use [DNSMasq](http://thekelleys.org.uk/dnsmasq/doc.html)
(often already installed). Then, we edit the file `/etc/dnsmasq.conf` by adding:
- server=/hoa/127.0.0.1#57005
+```
+server=/hoa/127.0.0.1#57005
+```
And do not forget to restart:
- $ sudo /etc/init.d/dnsmasq restart
- * Restarting DNS forwarder and DHCP server dnsmasq [OK]
+```sh
+$ sudo /etc/init.d/dnsmasq restart
+ * Restarting DNS forwarder and DHCP server dnsmasq [OK]
+```
For Windows, it is more complicated. You should read the documentation.
@@ -39,18 +45,20 @@ Well, now, we will create our resolution server that will listen
`127.0.0.1:57005` (`57005` = `0xDEAD`) in UDP. Thus, in the `Resolution.php`
file:
- $dns = new Hoa\Dns\Dns(
- new Hoa\Socket\Server('udp://127.0.0.1:57005')
- );
- $dns->on('query', function ( Hoa\Core\Event\Bucket $bucket ) {
+```php
+$dns = new Hoa\Dns\Dns(
+ new Hoa\Socket\Server('udp://127.0.0.1:57005')
+);
+$dns->on('query', function ( Hoa\Core\Event\Bucket $bucket ) {
- $data = $bucket->getData();
- echo 'Resolving domain ', $data['domain'],
- ' of type ', $data['type'], "\n";
+ $data = $bucket->getData();
+ echo 'Resolving domain ', $data['domain'],
+ ' of type ', $data['type'], "\n";
- return '127.0.0.1';
- });
- $dns->run();
+ return '127.0.0.1';
+});
+$dns->run();
+```
All query for the top level domain `.hoa` will be resolved to `127.0.0.1` (note:
we do not look at the type, which should be `A` or `AAAA` respectively for IPv4
@@ -59,29 +67,33 @@ and IPv6).
Finally, let say we have a HTTP server that runs on `127.0.0.1:8888` and the
index responds `yeah \o/`, then we start our resolver:
- $ php Resolver.php
+```sh
+$ php Resolver.php
+```
And we make a HTTP request on `foo.hoa` (that will be resolve to `127.0.0.1`):
- $ curl foo.hoa --verbose
- * About to connect() to foo.hoa port 8888 (#0)
- * Trying 127.0.0.1... connected
- * Connected to foo.hoa (127.0.0.1) port 8888 (#0)
- > GET / HTTP/1.1
- > User-Agent: curl/a.b.c (…) libcurl/d.e.f
- > OpenSSL/g.h.i zlib/j.k.l
- > Host: foo.hoa:8888
- > Accept: */*
- >
- < HTTP/1.1 200 OK
- < Date: …
- < Server: …
- < Content-Type: text/html
- < Content-Length: 8
- <
- yeah \o/
- * Connection #0 to host foo.hoa left intact
- * Closing connection #0
+```sh
+$ curl foo.hoa --verbose
+* About to connect() to foo.hoa port 8888 (#0)
+* Trying 127.0.0.1... connected
+* Connected to foo.hoa (127.0.0.1) port 8888 (#0)
+> GET / HTTP/1.1
+> User-Agent: curl/a.b.c (…) libcurl/d.e.f
+> OpenSSL/g.h.i zlib/j.k.l
+> Host: foo.hoa:8888
+> Accept: */*
+>
+< HTTP/1.1 200 OK
+< Date: …
+< Server: …
+< Content-Type: text/html
+< Content-Length: 8
+<
+yeah \o/
+* Connection #0 to host foo.hoa left intact
+* Closing connection #0
+```
We see that `foo.hoa` is resolved to `127.0.0.1`!