mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-16 02:40:37 +01:00
Add a hash of the query to POST requests
This commit is contained in:
parent
fd9e97a570
commit
70bdd46425
@ -3,8 +3,10 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"crypto/sha512"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -177,6 +179,14 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
|||||||
if padding != nil {
|
if padding != nil {
|
||||||
header["X-Pad"] = []string{*padding}
|
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{
|
req := &http.Request{
|
||||||
Method: method,
|
Method: method,
|
||||||
URL: url,
|
URL: url,
|
||||||
@ -188,6 +198,7 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
|||||||
bc := ioutil.NopCloser(bytes.NewReader(*body))
|
bc := ioutil.NopCloser(bytes.NewReader(*body))
|
||||||
req.Body = bc
|
req.Body = bc
|
||||||
}
|
}
|
||||||
|
fmt.Println(req)
|
||||||
var err error
|
var err error
|
||||||
host := url.Host
|
host := url.Host
|
||||||
xTransport.cachedIPs.RLock()
|
xTransport.cachedIPs.RLock()
|
||||||
|
Loading…
Reference in New Issue
Block a user