mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-25 13:39:34 +01:00
Add some validation for incoming connections
This commit is contained in:
parent
523f6ffb80
commit
25d72a7e31
@ -71,6 +71,11 @@ func (c *Client) StartServer() {
|
|||||||
|
|
||||||
// ServeHTTP implementation.
|
// ServeHTTP implementation.
|
||||||
func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if r.Method != "POST" {
|
||||||
|
log.Println("invalid " + r.Method + " connection from " + r.RemoteAddr)
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
msg := IMessage{}
|
msg := IMessage{}
|
||||||
err := r.ParseForm()
|
err := r.ParseForm()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -86,6 +91,11 @@ func (c *Client) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.NotFound(w, r)
|
http.NotFound(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if msg.Token == "" {
|
||||||
|
log.Println("no token from " + r.RemoteAddr)
|
||||||
|
http.NotFound(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
c.In <- msg
|
c.In <- msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user