]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - systems/eldiron/websites/games/codenames/greenapid.patch
Squash changes containing private information
[perso/Immae/Config/Nix.git] / systems / eldiron / websites / games / codenames / greenapid.patch
CommitLineData
de6002a1
IB
1diff --git a/cmd/greenapid/main.go b/cmd/greenapid/main.go
2index 86499e9..1589323 100644
3--- a/cmd/greenapid/main.go
4+++ b/cmd/greenapid/main.go
5@@ -1,6 +1,7 @@
6 package main
7
8 import (
9+ "net"
10 "net/http"
11
12 "github.com/jbowens/codenamesgreen/gameapi"
13@@ -13,6 +14,12 @@ func main() {
14 }
15
16 h := gameapi.Handler(wordLists)
17- err = http.ListenAndServe(":8080", h)
18+ server := &http.Server{Handler: h}
19+ ln, err := net.Listen("unix", "/run/codenamesgreen/socket.sock")
20+ if err != nil {
21+ panic(err)
22+ }
23+
24+ err = server.Serve(ln)
25 panic(err)
26 }
615293e4
IB
27diff --git a/gameapi/handler.go b/gameapi/handler.go
28index d67cf94..108e7e1 100644
29--- a/gameapi/handler.go
30+++ b/gameapi/handler.go
31@@ -101,7 +101,7 @@ func (h *handler) handleIndex(rw http.ResponseWriter, req *http.Request) {
32 for {
33 w1 := strings.ToLower(h.allWords[h.rand.Int63n(int64(len(h.allWords)))])
34 w2 := strings.ToLower(h.allWords[h.rand.Int63n(int64(len(h.allWords)))])
35- id := fmt.Sprintf("%s-%s", w1, w2)
36+ id = fmt.Sprintf("%s-%s", w1, w2)
37 if _, ok := h.games[id]; !ok {
38 break
39 }