cleanup: doh.powerdns.org is not working anymore (#924)

While there, `.../internal/sessionresolver` => `.../sessionresolver`

See https://github.com/ooni/probe/issues/2255
This commit is contained in:
Simone Basso 2022-09-02 14:44:23 +02:00 committed by GitHub
commit 1153850aca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 3 additions and 23 deletions

View file

@ -0,0 +1,37 @@
package sessionresolver
//
// JSON codec
//
import "encoding/json"
// jsonCodec encodes to/decodes from JSON.
type jsonCodec interface {
// Encode encodes v as a JSON stream of bytes.
Encode(v interface{}) ([]byte, error)
// Decode decodes b from a JSON stream of bytes.
Decode(b []byte, v interface{}) error
}
// codec always returns a valid jsonCodec.
func (r *Resolver) codec() jsonCodec {
if r.jsonCodec != nil {
return r.jsonCodec
}
return &jsonCodecStdlib{}
}
// jsonCodecStdlib is the default codec.
type jsonCodecStdlib struct{}
// Decode implements jsonCodec.Decode.
func (*jsonCodecStdlib) Decode(b []byte, v interface{}) error {
return json.Unmarshal(b, v)
}
// Encode implements jsonCodec.Encode.
func (*jsonCodecStdlib) Encode(v interface{}) ([]byte, error) {
return json.Marshal(v)
}