mirror of
https://github.com/golang/go
synced 2024-11-18 21:54:49 -07:00
go.tools/playground/socket: log connections and code snippet run requests
This logs all successful handshakes and all requests to run code snippets; it is not immediately obvious how to limit this to non-localhost hosts, or to instances where publicly available playgrounds are allowed without resorting to addition of a new global. The level of noise on the log should not be too great. LGTM=adg R=adg CC=golang-codereviews https://golang.org/cl/112850043
This commit is contained in:
parent
32c9809768
commit
063db5971c
@ -95,6 +95,7 @@ func handshake(c *websocket.Config, req *http.Request) error {
|
|||||||
log.Println("bad websocket origin:", o)
|
log.Println("bad websocket origin:", o)
|
||||||
return websocket.ErrBadWebSocketOrigin
|
return websocket.ErrBadWebSocketOrigin
|
||||||
}
|
}
|
||||||
|
log.Println("accepting connection from:", req.RemoteAddr)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +137,7 @@ func socketHandler(c *websocket.Conn) {
|
|||||||
case m := <-in:
|
case m := <-in:
|
||||||
switch m.Kind {
|
switch m.Kind {
|
||||||
case "run":
|
case "run":
|
||||||
|
log.Println("running snippet from:", c.Request().RemoteAddr)
|
||||||
proc[m.Id].Kill()
|
proc[m.Id].Kill()
|
||||||
lOut := limiter(in, out)
|
lOut := limiter(in, out)
|
||||||
proc[m.Id] = startProcess(m.Id, m.Body, lOut, m.Options)
|
proc[m.Id] = startProcess(m.Id, m.Body, lOut, m.Options)
|
||||||
|
Loading…
Reference in New Issue
Block a user