cmd/buildlet: advertise a hostname of "buildlet" if nothing else is set

Change-Id: I255e8feb105cee93ed65a268cd7ae0aa338ca142
Reviewed-on: https://go-review.googlesource.com/c/build/+/207557
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/cmd/buildlet/reverse.go b/cmd/buildlet/reverse.go
index f849366..3c3194d 100644
--- a/cmd/buildlet/reverse.go
+++ b/cmd/buildlet/reverse.go
@@ -68,6 +68,9 @@
 		if *hostname == "" {
 			*hostname, _ = os.Hostname()
 		}
+		if *hostname == "" {
+			*hostname = "buildlet"
+		}
 	}
 
 	key, err := keyForMode(*reverseType)
diff --git a/cmd/coordinator/reverse.go b/cmd/coordinator/reverse.go
index 734633d..d1fefcc 100644
--- a/cmd/coordinator/reverse.go
+++ b/cmd/coordinator/reverse.go
@@ -517,6 +517,11 @@
 		return
 	}
 
+	if hostname == "" {
+		http.Error(w, "missing X-Go-Builder-Hostname header", http.StatusBadRequest)
+		return
+	}
+
 	// Check build keys.
 	if hostType == "" {
 		http.Error(w, "missing X-Go-Host-Type; old buildlet binary?", http.StatusBadRequest)