Skip to content

Commit

Permalink
Add a hash of the query to POST requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jedisct1 committed Nov 22, 2018
1 parent fd9e97a commit 70bdd46
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dnscrypt-proxy/xtransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package main
import (
"bytes"
"context"
"crypto/sha512"
"crypto/tls"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -177,6 +179,14 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
if padding != nil {
header["X-Pad"] = []string{*padding}
}
if body != nil {
h := sha512.Sum512(*body)
qs := url.Query()
qs.Add("body_hash", hex.EncodeToString(h[:32]))
url2 := *url
url2.RawQuery = qs.Encode()
url = &url2
}
req := &http.Request{
Method: method,
URL: url,
Expand All @@ -188,6 +198,7 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
bc := ioutil.NopCloser(bytes.NewReader(*body))
req.Body = bc
}
fmt.Println(req)
var err error
host := url.Host
xTransport.cachedIPs.RLock()
Expand Down

0 comments on commit 70bdd46

Please sign in to comment.