diff --git a/internal/tutorial/measurex/chapter01/README.md b/internal/tutorial/measurex/chapter01/README.md index 2b5e8b3..2efa2b9 100644 --- a/internal/tutorial/measurex/chapter01/README.md +++ b/internal/tutorial/measurex/chapter01/README.md @@ -190,9 +190,10 @@ Let us run the program with default arguments first. You can do this operation by running: ```bash -go run -race ./internal/tutorial/measurex/chapter01 +go run -race ./internal/tutorial/measurex/chapter01 | jq ``` +Where `jq` is being used to make the output more presentable. If you do that you obtain some logging messages, which are out of the scope of this tutorial, and the following JSON: @@ -257,7 +258,7 @@ Let us now change the domain to resolve to be `antani.ooni.org` (a nonexisting domain), which we can do by running this command: ```bash -go run -race ./internal/tutorial/measurex/chapter01 -domain antani.ooni.org +go run -race ./internal/tutorial/measurex/chapter01 -domain antani.ooni.org | jq ``` This is the output JSON: @@ -318,7 +319,7 @@ top of which `measurex` is written.) Let us now try with an insanely low timeout: ```bash -go run -race ./internal/tutorial/measurex/chapter01 -timeout 250us +go run -race ./internal/tutorial/measurex/chapter01 -timeout 250us | jq ``` To get this JSON: diff --git a/internal/tutorial/measurex/chapter01/main.go b/internal/tutorial/measurex/chapter01/main.go index 1c99f9c..e88c7a7 100644 --- a/internal/tutorial/measurex/chapter01/main.go +++ b/internal/tutorial/measurex/chapter01/main.go @@ -191,9 +191,10 @@ func main() { // this operation by running: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter01 +// go run -race ./internal/tutorial/measurex/chapter01 | jq // ``` // +// Where `jq` is being used to make the output more presentable. // If you do that you obtain some logging messages, which are out of // the scope of this tutorial, and the following JSON: // @@ -258,7 +259,7 @@ func main() { // nonexisting domain), which we can do by running this command: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter01 -domain antani.ooni.org +// go run -race ./internal/tutorial/measurex/chapter01 -domain antani.ooni.org | jq // ``` // // This is the output JSON: @@ -319,7 +320,7 @@ func main() { // Let us now try with an insanely low timeout: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter01 -timeout 250us +// go run -race ./internal/tutorial/measurex/chapter01 -timeout 250us | jq // ``` // // To get this JSON: diff --git a/internal/tutorial/measurex/chapter02/README.md b/internal/tutorial/measurex/chapter02/README.md index ed661bf..cde5ab0 100644 --- a/internal/tutorial/measurex/chapter02/README.md +++ b/internal/tutorial/measurex/chapter02/README.md @@ -85,7 +85,7 @@ Let us run the program with default arguments first. You can do this operation by running: ```bash -go run -race ./internal/tutorial/measurex/chapter02 +go run -race ./internal/tutorial/measurex/chapter02 | jq ``` Here is the JSON we obtain in output: @@ -129,7 +129,7 @@ Let us now see if we can provoke some errors and timeouts. Let us start with an IP address where there's no listening socket: ```bash -go run -race ./internal/tutorial/measurex/chapter02 -address 127.0.0.1:1 +go run -race ./internal/tutorial/measurex/chapter02 -address 127.0.0.1:1 | jq ``` We get this JSON: @@ -161,7 +161,7 @@ the oddity that classifies the error. Let us now try to obtain a timeout: ```bash -go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 +go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 | jq ``` We get this JSON: @@ -192,7 +192,7 @@ precise than just the error alone. Let us now use a very small timeout: ```bash -go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 -timeout 100ms +go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 -timeout 100ms | jq ``` To get this JSON: diff --git a/internal/tutorial/measurex/chapter02/main.go b/internal/tutorial/measurex/chapter02/main.go index 0d19971..b3a4742 100644 --- a/internal/tutorial/measurex/chapter02/main.go +++ b/internal/tutorial/measurex/chapter02/main.go @@ -86,7 +86,7 @@ func main() { // this operation by running: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter02 +// go run -race ./internal/tutorial/measurex/chapter02 | jq // ``` // // Here is the JSON we obtain in output: @@ -130,7 +130,7 @@ func main() { // Let us start with an IP address where there's no listening socket: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter02 -address 127.0.0.1:1 +// go run -race ./internal/tutorial/measurex/chapter02 -address 127.0.0.1:1 | jq // ``` // // We get this JSON: @@ -162,7 +162,7 @@ func main() { // Let us now try to obtain a timeout: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 +// go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 | jq // ``` // // We get this JSON: @@ -193,7 +193,7 @@ func main() { // Let us now use a very small timeout: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 -timeout 100ms +// go run -race ./internal/tutorial/measurex/chapter02 -address 8.8.4.4:1 -timeout 100ms | jq // ``` // // To get this JSON: diff --git a/internal/tutorial/measurex/chapter03/README.md b/internal/tutorial/measurex/chapter03/README.md index fc08816..6063733 100644 --- a/internal/tutorial/measurex/chapter03/README.md +++ b/internal/tutorial/measurex/chapter03/README.md @@ -69,7 +69,7 @@ we print using the usual three-liner. As before, let us start off with a vanilla run: ```bash -go run -race ./internal/tutorial/measurex/chapter03 +go run -race ./internal/tutorial/measurex/chapter03 | jq ``` This time we get a much larger JSON, so I will pretend it is @@ -246,7 +246,7 @@ output JSON changes because of them. Let us try to get a NXDOMAIN error. ```bash -go run -race ./internal/tutorial/measurex/chapter03 -query antani.ooni.org +go run -race ./internal/tutorial/measurex/chapter03 -query antani.ooni.org | jq ``` This produces the following JSON: @@ -443,7 +443,7 @@ Let us now try to get a REFUSED DNS Rcode, again from servers that are, let's say, kind enough to easily help. ```bash -go run -race ./internal/tutorial/measurex/chapter03 -address 180.97.36.63:53 +go run -race ./internal/tutorial/measurex/chapter03 -address 180.97.36.63:53 | jq ``` Here's the answer I get: diff --git a/internal/tutorial/measurex/chapter03/main.go b/internal/tutorial/measurex/chapter03/main.go index 1cce740..645e2b0 100644 --- a/internal/tutorial/measurex/chapter03/main.go +++ b/internal/tutorial/measurex/chapter03/main.go @@ -70,7 +70,7 @@ func main() { // As before, let us start off with a vanilla run: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter03 +// go run -race ./internal/tutorial/measurex/chapter03 | jq // ``` // // This time we get a much larger JSON, so I will pretend it is @@ -247,7 +247,7 @@ func main() { // Let us try to get a NXDOMAIN error. // // ```bash -// go run -race ./internal/tutorial/measurex/chapter03 -query antani.ooni.org +// go run -race ./internal/tutorial/measurex/chapter03 -query antani.ooni.org | jq // ``` // // This produces the following JSON: @@ -444,7 +444,7 @@ func main() { // that are, let's say, kind enough to easily help. // // ```bash -// go run -race ./internal/tutorial/measurex/chapter03 -address 180.97.36.63:53 +// go run -race ./internal/tutorial/measurex/chapter03 -address 180.97.36.63:53 | jq // ``` // // Here's the answer I get: diff --git a/internal/tutorial/measurex/chapter04/README.md b/internal/tutorial/measurex/chapter04/README.md index 25989de..ca1fbc8 100644 --- a/internal/tutorial/measurex/chapter04/README.md +++ b/internal/tutorial/measurex/chapter04/README.md @@ -80,7 +80,7 @@ the measurement itself, which we print below. As before, let us start off with a vanilla run: ```bash -go run -race ./internal/tutorial/measurex/chapter04 +go run -race ./internal/tutorial/measurex/chapter04 | jq ``` Let us comment the JSON in detail: @@ -209,13 +209,13 @@ changes in different error conditions. Here are the commands I used for each proposed exercise: -1. go run -race ./internal/tutorial/measurex/chapter04 -address 8.8.4.4:1 +1. go run -race ./internal/tutorial/measurex/chapter04 -address 8.8.4.4:1 | jq -2. go run -race ./internal/tutorial/measurex/chapter04 -sni example.org +2. go run -race ./internal/tutorial/measurex/chapter04 -sni example.org | jq -3. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni self-signed.badssl.com +3. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni self-signed.badssl.com | jq -4. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni expire.badssl.com +4. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni expire.badssl.com | jq To emulate the last two scenarios, if you're on Linux, a possibility is building Jafar with this command: diff --git a/internal/tutorial/measurex/chapter04/main.go b/internal/tutorial/measurex/chapter04/main.go index 1c7d387..f399a5f 100644 --- a/internal/tutorial/measurex/chapter04/main.go +++ b/internal/tutorial/measurex/chapter04/main.go @@ -81,7 +81,7 @@ func main() { // As before, let us start off with a vanilla run: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter04 +// go run -race ./internal/tutorial/measurex/chapter04 | jq // ``` // // Let us comment the JSON in detail: @@ -193,7 +193,7 @@ func main() { // ### Suggested follow-up experiments // // Try to run experiments in the following scenarios, and -// check the output JSON to familiarize yourself with what +// check the output JSON to familiarize yourself with what // changes in different error conditions. // // 1. measurement that causes timeout @@ -210,13 +210,13 @@ func main() { // // Here are the commands I used for each proposed exercise: // -// 1. go run -race ./internal/tutorial/measurex/chapter04 -address 8.8.4.4:1 +// 1. go run -race ./internal/tutorial/measurex/chapter04 -address 8.8.4.4:1 | jq // -// 2. go run -race ./internal/tutorial/measurex/chapter04 -sni example.org +// 2. go run -race ./internal/tutorial/measurex/chapter04 -sni example.org | jq // -// 3. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni self-signed.badssl.com +// 3. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni self-signed.badssl.com | jq // -// 4. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni expire.badssl.com +// 4. go run -race ./internal/tutorial/measurex/chapter04 -address 104.154.89.105:443 -sni expire.badssl.com | jq // // To emulate the last two scenarios, if you're on Linux, a // possibility is building Jafar with this command: diff --git a/internal/tutorial/measurex/chapter05/README.md b/internal/tutorial/measurex/chapter05/README.md index 6ab8a89..2124b37 100644 --- a/internal/tutorial/measurex/chapter05/README.md +++ b/internal/tutorial/measurex/chapter05/README.md @@ -81,7 +81,7 @@ lines of code for printing the resulting measurement. As before, let us start off with a vanilla run: ```bash -go run -race ./internal/tutorial/measurex/chapter05 +go run -race ./internal/tutorial/measurex/chapter05 | jq ``` Produces this JSON: diff --git a/internal/tutorial/measurex/chapter05/main.go b/internal/tutorial/measurex/chapter05/main.go index 5e6962a..31a2819 100644 --- a/internal/tutorial/measurex/chapter05/main.go +++ b/internal/tutorial/measurex/chapter05/main.go @@ -82,7 +82,7 @@ func main() { // As before, let us start off with a vanilla run: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter05 +// go run -race ./internal/tutorial/measurex/chapter05 | jq // ``` // // Produces this JSON: diff --git a/internal/tutorial/measurex/chapter06/README.md b/internal/tutorial/measurex/chapter06/README.md index ba83f1d..ae4d759 100644 --- a/internal/tutorial/measurex/chapter06/README.md +++ b/internal/tutorial/measurex/chapter06/README.md @@ -458,19 +458,19 @@ Here are some suggestions for follow up measurements: 1. provoke a connect error by using: ``` -go run -race ./internal/tutorial/measurex/chapter06 -address 127.0.0.1:1 +go run -race ./internal/tutorial/measurex/chapter06 -address 127.0.0.1:1 | jq ``` 2. provoke a TLS handshake error by using: ``` -go run -race ./internal/tutorial/measurex/chapter06 -sni example.com +go run -race ./internal/tutorial/measurex/chapter06 -sni example.com | jq ``` 3. provoke an HTTP round trip error by using: ``` -go run -race ./internal/tutorial/measurex/chapter06 -address 8.8.8.8:853 +go run -race ./internal/tutorial/measurex/chapter06 -address 8.8.8.8:853 | jq ``` 4. modify the code to fetch an HTTP endpoint instead (hint: you diff --git a/internal/tutorial/measurex/chapter06/main.go b/internal/tutorial/measurex/chapter06/main.go index 8b19074..a5a2333 100644 --- a/internal/tutorial/measurex/chapter06/main.go +++ b/internal/tutorial/measurex/chapter06/main.go @@ -459,19 +459,19 @@ func main() { // 1. provoke a connect error by using: // // ``` -// go run -race ./internal/tutorial/measurex/chapter06 -address 127.0.0.1:1 +// go run -race ./internal/tutorial/measurex/chapter06 -address 127.0.0.1:1 | jq // ``` // // 2. provoke a TLS handshake error by using: // // ``` -// go run -race ./internal/tutorial/measurex/chapter06 -sni example.com +// go run -race ./internal/tutorial/measurex/chapter06 -sni example.com | jq // ``` // // 3. provoke an HTTP round trip error by using: // // ``` -// go run -race ./internal/tutorial/measurex/chapter06 -address 8.8.8.8:853 +// go run -race ./internal/tutorial/measurex/chapter06 -address 8.8.8.8:853 | jq // ``` // // 4. modify the code to fetch an HTTP endpoint instead (hint: you diff --git a/internal/tutorial/measurex/chapter07/README.md b/internal/tutorial/measurex/chapter07/README.md index 7879009..8392c3a 100644 --- a/internal/tutorial/measurex/chapter07/README.md +++ b/internal/tutorial/measurex/chapter07/README.md @@ -124,7 +124,7 @@ Finally, we print the results. Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter07 +go run -race ./internal/tutorial/measurex/chapter07 | jq ``` Please, check the JSON output. Do you recognize the fields diff --git a/internal/tutorial/measurex/chapter07/main.go b/internal/tutorial/measurex/chapter07/main.go index 851df2d..7cc0ba6 100644 --- a/internal/tutorial/measurex/chapter07/main.go +++ b/internal/tutorial/measurex/chapter07/main.go @@ -125,7 +125,7 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter07 +// go run -race ./internal/tutorial/measurex/chapter07 | jq // ``` // // Please, check the JSON output. Do you recognize the fields diff --git a/internal/tutorial/measurex/chapter08/README.md b/internal/tutorial/measurex/chapter08/README.md index 69dc24a..361db53 100644 --- a/internal/tutorial/measurex/chapter08/README.md +++ b/internal/tutorial/measurex/chapter08/README.md @@ -111,7 +111,7 @@ This is it. The rest of the program is exactly the same. Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter08 +go run -race ./internal/tutorial/measurex/chapter08 | jq ``` Please, check the JSON output. Do you recognize the fields diff --git a/internal/tutorial/measurex/chapter08/main.go b/internal/tutorial/measurex/chapter08/main.go index 8aac27e..7300eae 100644 --- a/internal/tutorial/measurex/chapter08/main.go +++ b/internal/tutorial/measurex/chapter08/main.go @@ -112,7 +112,7 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter08 +// go run -race ./internal/tutorial/measurex/chapter08 | jq // ``` // // Please, check the JSON output. Do you recognize the fields diff --git a/internal/tutorial/measurex/chapter09/README.md b/internal/tutorial/measurex/chapter09/README.md index fe20445..39ef26a 100644 --- a/internal/tutorial/measurex/chapter09/README.md +++ b/internal/tutorial/measurex/chapter09/README.md @@ -112,7 +112,7 @@ our `m` container and we print it. Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter09 +go run -race ./internal/tutorial/measurex/chapter09 | jq ``` Take a look at the JSON output. Can you spot that diff --git a/internal/tutorial/measurex/chapter09/main.go b/internal/tutorial/measurex/chapter09/main.go index f431ff3..67280a7 100644 --- a/internal/tutorial/measurex/chapter09/main.go +++ b/internal/tutorial/measurex/chapter09/main.go @@ -113,7 +113,7 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter09 +// go run -race ./internal/tutorial/measurex/chapter09 | jq // ``` // // Take a look at the JSON output. Can you spot that diff --git a/internal/tutorial/measurex/chapter10/README.md b/internal/tutorial/measurex/chapter10/README.md index d851a06..d2aaaaa 100644 --- a/internal/tutorial/measurex/chapter10/README.md +++ b/internal/tutorial/measurex/chapter10/README.md @@ -115,7 +115,7 @@ The rest of the program is exactly like in chapter09. Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter10 +go run -race ./internal/tutorial/measurex/chapter10 | jq ``` Take a look at the JSON output. Can you spot that diff --git a/internal/tutorial/measurex/chapter10/main.go b/internal/tutorial/measurex/chapter10/main.go index 566100b..712482f 100644 --- a/internal/tutorial/measurex/chapter10/main.go +++ b/internal/tutorial/measurex/chapter10/main.go @@ -116,7 +116,7 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter10 +// go run -race ./internal/tutorial/measurex/chapter10 | jq // ``` // // Take a look at the JSON output. Can you spot that diff --git a/internal/tutorial/measurex/chapter11/README.md b/internal/tutorial/measurex/chapter11/README.md index 700fad7..457e7ee 100644 --- a/internal/tutorial/measurex/chapter11/README.md +++ b/internal/tutorial/measurex/chapter11/README.md @@ -95,13 +95,13 @@ here on `main` using the `PanicOnError` function. Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter11 +go run -race ./internal/tutorial/measurex/chapter11 | jq ``` Take a look at the JSON output and compare it with: ```bash -go run -race ./internal/tutorial/measurex/chapter10 -url https://www.google.com +go run -race ./internal/tutorial/measurex/chapter10 -url https://www.google.com | jq ``` (which is basically forcing chapter10 to run with the @@ -114,7 +114,7 @@ and compare it to the code written in chapter10? Now run: ```bash -go run -race ./internal/tutorial/measurex/chapter11 -url https://google.com +go run -race ./internal/tutorial/measurex/chapter11 -url https://google.com | jq ``` Do you see the opportunity there for following redirections? :^). diff --git a/internal/tutorial/measurex/chapter11/main.go b/internal/tutorial/measurex/chapter11/main.go index 6e36f26..9cdf22d 100644 --- a/internal/tutorial/measurex/chapter11/main.go +++ b/internal/tutorial/measurex/chapter11/main.go @@ -96,13 +96,13 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter11 +// go run -race ./internal/tutorial/measurex/chapter11 | jq // ``` // // Take a look at the JSON output and compare it with: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter10 -url https://www.google.com +// go run -race ./internal/tutorial/measurex/chapter10 -url https://www.google.com | jq // ``` // // (which is basically forcing chapter10 to run with the @@ -115,7 +115,7 @@ func main() { // Now run: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter11 -url https://google.com +// go run -race ./internal/tutorial/measurex/chapter11 -url https://google.com | jq // ``` // // Do you see the opportunity there for following redirections? :^). diff --git a/internal/tutorial/measurex/chapter12/README.md b/internal/tutorial/measurex/chapter12/README.md index c5051ff..d7c428f 100644 --- a/internal/tutorial/measurex/chapter12/README.md +++ b/internal/tutorial/measurex/chapter12/README.md @@ -79,7 +79,7 @@ is closed when done by `MeasureURLAndFollowRedirections`, so we leave the loop. Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter12 +go run -race ./internal/tutorial/measurex/chapter12 | jq ``` Take a look at the JSON. You should see several redirects diff --git a/internal/tutorial/measurex/chapter12/main.go b/internal/tutorial/measurex/chapter12/main.go index 42a3638..fbee259 100644 --- a/internal/tutorial/measurex/chapter12/main.go +++ b/internal/tutorial/measurex/chapter12/main.go @@ -80,7 +80,7 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter12 +// go run -race ./internal/tutorial/measurex/chapter12 | jq // ``` // // Take a look at the JSON. You should see several redirects diff --git a/internal/tutorial/measurex/chapter14/README.md b/internal/tutorial/measurex/chapter14/README.md index b15de3c..fbce4c4 100644 --- a/internal/tutorial/measurex/chapter14/README.md +++ b/internal/tutorial/measurex/chapter14/README.md @@ -250,7 +250,7 @@ func main() { Let us perform a vanilla run first: ```bash -go run -race ./internal/tutorial/measurex/chapter14 +go run -race ./internal/tutorial/measurex/chapter14 | jq ``` Take a look at the JSON. diff --git a/internal/tutorial/measurex/chapter14/main.go b/internal/tutorial/measurex/chapter14/main.go index 4acfc39..c197585 100644 --- a/internal/tutorial/measurex/chapter14/main.go +++ b/internal/tutorial/measurex/chapter14/main.go @@ -251,7 +251,7 @@ func main() { // Let us perform a vanilla run first: // // ```bash -// go run -race ./internal/tutorial/measurex/chapter14 +// go run -race ./internal/tutorial/measurex/chapter14 | jq // ``` // // Take a look at the JSON.