306d18e466
Here's the squash of the following patches that enable support
for go1.18 and update our dependencies.
This diff WILL need to be backported to the release/3.14 branch.
* chore: use go1.17.8
See https://github.com/ooni/probe/issues/2067
* chore: upgrade to probe-assets@v0.8.0
See https://github.com/ooni/probe/issues/2067.
* chore: update dependencies and enable go1.18
As mentioned in 7a0d17ea91
,
the tree won't build with `go1.18` unless we say it does.
So, not only here we need to update dependencies but also we
need to explicitly say `go1.18` in the `go.mod`.
This work is part of https://github.com/ooni/probe/issues/2067.
* chore(coverage.yml): run with go1.18
This change will give us a bare minimum confidence that we're
going to build our tree using version 1.18 of golang.
See https://github.com/ooni/probe/issues/2067.
* chore: update user agent used for measuring
See https://github.com/ooni/probe/issues/2067
* chore: run `go generate ./...`
See https://github.com/ooni/probe/issues/2067
* fix(dialer_test.go): make test work with go1.17 and go1.18
1. the original test wanted the dial to fail, so ensure we're not
passing any domain name to exercise dialing not resolving;
2. match the end of the error rather than the whole error string.
Tested locally with both go1.17 and go1.18.
See https://github.com/ooni/probe-cli/pull/708#issuecomment-1096447186
193 lines
5.3 KiB
Go
193 lines
5.3 KiB
Go
// Code generated by go generate; DO NOT EDIT.
|
|
// 2022-04-12 11:16:02.453796 +0200 CEST m=+0.000316501
|
|
|
|
package ooapi
|
|
|
|
//go:generate go run ./internal/generator -file requests.go
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"github.com/ooni/probe-cli/v3/internal/ooapi/apimodel"
|
|
)
|
|
|
|
func (api *simpleCheckReportIDAPI) newRequest(ctx context.Context, req *apimodel.CheckReportIDRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/_/check_report_id"
|
|
q := url.Values{}
|
|
if req.ReportID == "" {
|
|
return nil, newErrEmptyField("ReportID")
|
|
}
|
|
q.Add("report_id", req.ReportID)
|
|
URL.RawQuery = q.Encode()
|
|
return api.requestMaker().NewRequest(ctx, "GET", URL.String(), nil)
|
|
}
|
|
|
|
func (api *simpleCheckInAPI) newRequest(ctx context.Context, req *apimodel.CheckInRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/check-in"
|
|
body, err := api.jsonCodec().Encode(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out, err := api.requestMaker().NewRequest(ctx, "POST", URL.String(), bytes.NewReader(body))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out.Header.Set("Content-Type", "application/json")
|
|
return out, nil
|
|
}
|
|
|
|
func (api *simpleLoginAPI) newRequest(ctx context.Context, req *apimodel.LoginRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/login"
|
|
body, err := api.jsonCodec().Encode(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out, err := api.requestMaker().NewRequest(ctx, "POST", URL.String(), bytes.NewReader(body))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out.Header.Set("Content-Type", "application/json")
|
|
return out, nil
|
|
}
|
|
|
|
func (api *simpleMeasurementMetaAPI) newRequest(ctx context.Context, req *apimodel.MeasurementMetaRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/measurement_meta"
|
|
q := url.Values{}
|
|
if req.ReportID == "" {
|
|
return nil, newErrEmptyField("ReportID")
|
|
}
|
|
q.Add("report_id", req.ReportID)
|
|
if req.Full {
|
|
q.Add("full", "true")
|
|
}
|
|
if req.Input != "" {
|
|
q.Add("input", req.Input)
|
|
}
|
|
URL.RawQuery = q.Encode()
|
|
return api.requestMaker().NewRequest(ctx, "GET", URL.String(), nil)
|
|
}
|
|
|
|
func (api *simpleRegisterAPI) newRequest(ctx context.Context, req *apimodel.RegisterRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/register"
|
|
body, err := api.jsonCodec().Encode(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out, err := api.requestMaker().NewRequest(ctx, "POST", URL.String(), bytes.NewReader(body))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out.Header.Set("Content-Type", "application/json")
|
|
return out, nil
|
|
}
|
|
|
|
func (api *simpleTestHelpersAPI) newRequest(ctx context.Context, req *apimodel.TestHelpersRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/test-helpers"
|
|
return api.requestMaker().NewRequest(ctx, "GET", URL.String(), nil)
|
|
}
|
|
|
|
func (api *simplePsiphonConfigAPI) newRequest(ctx context.Context, req *apimodel.PsiphonConfigRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/test-list/psiphon-config"
|
|
return api.requestMaker().NewRequest(ctx, "GET", URL.String(), nil)
|
|
}
|
|
|
|
func (api *simpleTorTargetsAPI) newRequest(ctx context.Context, req *apimodel.TorTargetsRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/test-list/tor-targets"
|
|
return api.requestMaker().NewRequest(ctx, "GET", URL.String(), nil)
|
|
}
|
|
|
|
func (api *simpleURLsAPI) newRequest(ctx context.Context, req *apimodel.URLsRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/api/v1/test-list/urls"
|
|
q := url.Values{}
|
|
if req.CategoryCodes != "" {
|
|
q.Add("category_codes", req.CategoryCodes)
|
|
}
|
|
if req.CountryCode != "" {
|
|
q.Add("country_code", req.CountryCode)
|
|
}
|
|
if req.Limit != 0 {
|
|
q.Add("limit", newQueryFieldInt64(req.Limit))
|
|
}
|
|
URL.RawQuery = q.Encode()
|
|
return api.requestMaker().NewRequest(ctx, "GET", URL.String(), nil)
|
|
}
|
|
|
|
func (api *simpleOpenReportAPI) newRequest(ctx context.Context, req *apimodel.OpenReportRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = "/report"
|
|
body, err := api.jsonCodec().Encode(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out, err := api.requestMaker().NewRequest(ctx, "POST", URL.String(), bytes.NewReader(body))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out.Header.Set("Content-Type", "application/json")
|
|
return out, nil
|
|
}
|
|
|
|
func (api *simpleSubmitMeasurementAPI) newRequest(ctx context.Context, req *apimodel.SubmitMeasurementRequest) (*http.Request, error) {
|
|
URL, err := url.Parse(api.baseURL())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
up, err := api.templateExecutor().Execute("/report/{{ .ReportID }}", req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
URL.Path = up
|
|
body, err := api.jsonCodec().Encode(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out, err := api.requestMaker().NewRequest(ctx, "POST", URL.String(), bytes.NewReader(body))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out.Header.Set("Content-Type", "application/json")
|
|
return out, nil
|
|
}
|