Acknowledgments |
|
xvii | |
Introduction |
|
xix | |
Who This Book Is For |
|
xx | |
Installing Go |
|
xx | |
Recommended Development Environments |
|
xxi | |
What's in This Book |
|
xxi | |
|
PART I NETWORK ARCHITECTURE |
|
|
1 | (42) |
|
1 An Overview Of Networked Systems |
|
|
3 | (14) |
|
Choosing a Network Topology |
|
|
3 | (3) |
|
|
6 | (1) |
|
The Open Systems Interconnection Reference Model |
|
|
7 | (5) |
|
The Hierarchal Layers of the OSI Reference Model |
|
|
8 | (2) |
|
Sending Traffic by Using Data Encapsulation |
|
|
10 | (2) |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
14 | (1) |
|
|
14 | (1) |
|
|
15 | (1) |
|
|
15 | (2) |
|
2 Resource Location And Traffic Routing |
|
|
17 | (26) |
|
|
18 | (1) |
|
|
18 | (8) |
|
|
19 | (1) |
|
Subdividing IPv4 Addresses into Subnets |
|
|
20 | (3) |
|
Ports and Socket Addresses |
|
|
23 | (1) |
|
Network Address Translation |
|
|
24 | (1) |
|
Unicasting, Multicasting, and Broadcasting |
|
|
25 | (1) |
|
Resolving the MAC Address to a Physical Network Connection |
|
|
26 | (1) |
|
|
26 | (5) |
|
|
26 | (2) |
|
|
28 | (2) |
|
Advantages of IPv6 over IPv4 |
|
|
30 | (1) |
|
The Internet Control Message Protocol |
|
|
31 | (1) |
|
|
32 | (1) |
|
|
33 | (1) |
|
The Border Gateway Protocol |
|
|
34 | (1) |
|
Name and Address Resolution |
|
|
34 | (7) |
|
Domain Name Resource Records |
|
|
35 | (5) |
|
|
40 | (1) |
|
Privacy and Security Considerations of DNS Queries |
|
|
40 | (1) |
|
|
41 | (2) |
|
PART II SOCKET-LEVEL PROGRAMMING |
|
|
43 | (120) |
|
3 Reliable Tcp Data Streams |
|
|
45 | (28) |
|
|
46 | (1) |
|
Working with TCP Sessions |
|
|
46 | (5) |
|
Establishing a Session with the TCP Handshake |
|
|
47 | (1) |
|
Acknowledging Receipt of Packets by Using Their Sequence Numbers |
|
|
47 | (1) |
|
Receive Buffers and Window Sizes |
|
|
48 | (2) |
|
Gracefully Terminating TCP Sessions |
|
|
50 | (1) |
|
Handling Less Graceful Terminations |
|
|
51 | (1) |
|
Establishing a TCP Connection by Using Go's Standard Library |
|
|
51 | (20) |
|
Binding, Listening for, and Accepting Connections |
|
|
51 | (2) |
|
Establishing a Connection with a Server |
|
|
53 | (9) |
|
|
62 | (9) |
|
|
71 | (2) |
|
|
73 | (32) |
|
Using the net.Conn Interface |
|
|
74 | (1) |
|
Sending and Receiving Data |
|
|
74 | (13) |
|
Reading Data into a Fixed Buffer |
|
|
74 | (2) |
|
Delimited Reading by Using a Scanner |
|
|
76 | (3) |
|
Dynamically Allocating the Buffer Size |
|
|
79 | (7) |
|
Handling Errors While Reading and Writing Data |
|
|
86 | (1) |
|
Creating Robust Network Applications by Using the io Package |
|
|
87 | (11) |
|
Proxying Data Between Connections |
|
|
87 | (6) |
|
Monitoring a Network Connection |
|
|
93 | (3) |
|
Pinging a Host in ICMP-Filtered Environments |
|
|
96 | (2) |
|
Exploring Go's TCPConn Object |
|
|
98 | (3) |
|
Controlling Keepalive Messages |
|
|
99 | (1) |
|
Handling Pending Data on Close |
|
|
99 | (1) |
|
Overriding Default Receive and Send Buffers |
|
|
100 | (1) |
|
Solving Common Go TCP Network Problems |
|
|
101 | (1) |
|
|
101 | (1) |
|
Sockets Stuck in the CLOSE WAIT State |
|
|
102 | (1) |
|
|
102 | (3) |
|
5 Unreliable Udp Communication |
|
|
105 | (14) |
|
Using UDP: Simple and Unreliable |
|
|
106 | (1) |
|
Sending and Receiving UDP Data |
|
|
107 | (8) |
|
|
107 | (2) |
|
Receiving Data from the Echo Server |
|
|
109 | (1) |
|
Every UDP Connection Is a Listener |
|
|
110 | (3) |
|
|
113 | (2) |
|
|
115 | (2) |
|
|
117 | (2) |
|
6 Ensuring Udp Reliability |
|
|
119 | (22) |
|
Reliable File Transfers Using TFTP |
|
|
119 | (1) |
|
|
120 | (11) |
|
|
121 | (3) |
|
|
124 | (4) |
|
|
128 | (1) |
|
|
129 | (2) |
|
|
131 | (4) |
|
|
131 | (1) |
|
|
132 | (3) |
|
|
135 | (1) |
|
Downloading Files over UDP |
|
|
135 | (4) |
|
|
139 | (2) |
|
|
141 | (22) |
|
What Are Unix Domain Sockets? |
|
|
142 | (1) |
|
Binding to Unix Domain Socket Files |
|
|
143 | (11) |
|
Changing a Socket File's Ownership and Permissions |
|
|
143 | (1) |
|
Understanding Unix Domain Socket Types |
|
|
144 | (10) |
|
Writing a Service That Authenticates Clients |
|
|
154 | (6) |
|
Requesting Peer Credentials |
|
|
154 | (2) |
|
|
156 | (3) |
|
Testing the Service with Netcat |
|
|
159 | (1) |
|
|
160 | (3) |
|
PART III APPLICATION-LEVEL PROGRAMMING |
|
|
163 | (104) |
|
|
165 | (22) |
|
Understanding the Basics of HTTP |
|
|
166 | (7) |
|
Uniform Resource Locators |
|
|
166 | (1) |
|
|
167 | (3) |
|
|
170 | (2) |
|
From Request to Rendered Page |
|
|
172 | (1) |
|
Retrieving Web Resources in Go |
|
|
173 | (6) |
|
Using Go's Default HTTP Client |
|
|
173 | (1) |
|
Closing the Response Body |
|
|
174 | (2) |
|
Implementing Time-outs and Cancellations |
|
|
176 | (2) |
|
Disabling Persistent TCP Connections |
|
|
178 | (1) |
|
|
179 | (5) |
|
Posting JSON to a Web Server |
|
|
179 | (2) |
|
Posting a Multipart Form with Attached Files |
|
|
181 | (3) |
|
|
184 | (3) |
|
|
187 | (30) |
|
The Anatomy of a Go HTTP Server |
|
|
188 | (5) |
|
Clients Don't Respect Your Time |
|
|
191 | (1) |
|
|
192 | (1) |
|
|
193 | (9) |
|
Test Your Handlers with httptest |
|
|
195 | (1) |
|
How You Write the Response Matters |
|
|
196 | (2) |
|
Any Type Can Be a Handler |
|
|
198 | (2) |
|
Injecting Dependencies into Handlers |
|
|
200 | (2) |
|
|
202 | (5) |
|
|
203 | (1) |
|
Protecting Sensitive Files |
|
|
204 | (3) |
|
|
207 | (2) |
|
|
209 | (6) |
|
Pushing Resources to the Client |
|
|
210 | (4) |
|
|
214 | (1) |
|
|
215 | (2) |
|
10 Caddy: A Contemporary Web Server |
|
|
217 | (24) |
|
|
218 | (1) |
|
Let's Encrypt Integration |
|
|
218 | (1) |
|
How Does Caddy Fit into the Equation? |
|
|
219 | (1) |
|
|
219 | (1) |
|
|
219 | (1) |
|
Building Caddy from Source Code |
|
|
220 | (1) |
|
Running and Configuring Caddy |
|
|
220 | (4) |
|
Modifying Caddy's Configuration in Real Time |
|
|
222 | (2) |
|
Storing the Configuration in a File |
|
|
224 | (1) |
|
Extending Caddy with Modules and Adapters |
|
|
224 | (8) |
|
Writing a Configuration Adapter |
|
|
225 | (1) |
|
Writing a Restrict Prefix Middleware Module |
|
|
226 | (5) |
|
Injecting Your Module into Caddy |
|
|
231 | (1) |
|
Reverse-Proxying Requests to a Backend Web Service |
|
|
232 | (6) |
|
Creating a Simple Backend Web Service |
|
|
232 | (2) |
|
Setting Up Caddy's Configuration |
|
|
234 | (1) |
|
Adding a Reverse-Proxy to Your Service |
|
|
235 | (1) |
|
|
236 | (1) |
|
|
236 | (1) |
|
|
237 | (1) |
|
|
238 | (3) |
|
11 Securing Communications With TLS |
|
|
241 | (26) |
|
A Closer Look at Transport Layer Security |
|
|
242 | (3) |
|
|
243 | (1) |
|
In Certificate Authorities We Trust |
|
|
243 | (1) |
|
|
244 | (1) |
|
Protecting Data in Transit |
|
|
245 | (10) |
|
|
245 | (2) |
|
|
247 | (2) |
|
|
249 | (3) |
|
|
252 | (3) |
|
Mutual TLS Authentication |
|
|
255 | (10) |
|
Generating Certificates for Authentication |
|
|
256 | (3) |
|
|
259 | (6) |
|
|
265 | (2) |
|
PART IV SERVICE ARCHITECTURE |
|
|
267 | (88) |
|
|
269 | (26) |
|
|
270 | (14) |
|
|
276 | (2) |
|
|
278 | (2) |
|
|
280 | (4) |
|
Transmitting Serialized Objects |
|
|
284 | (10) |
|
Connecting Services with gRPC |
|
|
284 | (2) |
|
Creating a TLS-Enabled gRPC Server |
|
|
286 | (3) |
|
Creating a gRPC Client to Test the Server |
|
|
289 | (5) |
|
|
294 | (1) |
|
|
295 | (34) |
|
|
296 | (20) |
|
|
297 | (3) |
|
|
300 | (1) |
|
|
301 | (11) |
|
Scaling Up with Wide Event Logging |
|
|
312 | (3) |
|
Log Rotation with Lumberjack |
|
|
315 | (1) |
|
|
316 | (4) |
|
|
317 | (1) |
|
|
317 | (1) |
|
|
318 | (1) |
|
|
319 | (1) |
|
Instrumenting a Basic HTTP Server |
|
|
320 | (6) |
|
|
326 | (3) |
|
|
329 | (26) |
|
|
330 | (3) |
|
|
333 | (8) |
|
Installing the AWS Command Line Interface |
|
|
333 | (1) |
|
|
333 | (2) |
|
|
335 | (1) |
|
Defining an AWS Lambda Function |
|
|
336 | (3) |
|
Compiling, Packaging, and Deploying Your Function |
|
|
339 | (1) |
|
Testing Your AWS Lambda Function |
|
|
340 | (1) |
|
|
341 | (5) |
|
Installing the Google Cloud Software Development Kit |
|
|
341 | (1) |
|
Initializing the Google Cloud SDK |
|
|
341 | (1) |
|
Enable Billing and Cloud Functions |
|
|
342 | (1) |
|
Defining a Cloud Function |
|
|
342 | (2) |
|
Deploying Your Cloud Function |
|
|
344 | (1) |
|
Testing Your Google Cloud Function |
|
|
345 | (1) |
|
|
346 | (7) |
|
Installing the Azure Command Line Interface |
|
|
346 | (1) |
|
Configuring the Azure CLI |
|
|
347 | (1) |
|
Installing Azure Functions Core Tools |
|
|
347 | (1) |
|
Creating a Custom Handler |
|
|
348 | (1) |
|
Defining a Custom Handler |
|
|
349 | (1) |
|
Locally Testing the Custom Handler |
|
|
350 | (1) |
|
Deploying the Custom Handler |
|
|
351 | (2) |
|
Testing the Custom Handler |
|
|
353 | (1) |
|
|
353 | (2) |
Index |
|
355 | |