ooni-probe-cli/internal/cmd
Simone Basso eed51978ca
refactor(httpx): hide the real APIClient (#648)
As mentioned in https://github.com/ooni/probe/issues/1951, one of
the main issues I did see with httpx.APIClient is that in some cases
it's used in a very fragile way by probeservices.Client.

This happens in psiphon.go and tor.go, where we create a copy of
the APIClient and then modify it's Authorization field.

If we ever refactor probeservices.Client to take a pointer to
httpx.Client, we are now mutating the httpx.Client.

Of course, we don't want that to happen.

This diff attempts to address such a problem as follows:

1. we create a new APIClientTemplate type that holds the same
fields of an APIClient and allows to build an APIClient

2. we modify every user of APIClient to use APIClientTemplate

3. when we need an APIClient, we build it from the corresponding
template and, when we need to use a specific Authorization, we
use a build factory that sets APIClient.Authorization

4. we hide APIClient by renaming it apiClient and by defining
an interface called APIClient that allows to use it

So, now the codebase always uses the opaque APIClient interface to
issue API calls and always uses the APIClientTemplate to build an
opaque APIClient.

Boom! We have separated construction from usage and we are not
mutating in weird ways the APIClient anymore.
2022-01-05 14:15:42 +01:00
..
apitool refactor(httpx): hide the real APIClient (#648) 2022-01-05 14:15:42 +01:00
e2epostprocess cleanup(all): stop using deprecated ioutil functions (#381) 2021-06-15 14:01:45 +02:00
getresources refactor: redesign how we import assets (#260) 2021-04-01 16:57:31 +02:00
jafar [forwardport] release 3.11: update all the dependencies (#636) (#637) 2021-12-06 17:46:13 +01:00
miniooni refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
oohelper feat(webstepsx): websteps using measurex (#530) 2021-09-30 02:06:27 +02:00
oohelperd refactor: interfaces and data types into the model package (#642) 2022-01-03 13:53:23 +01:00
printversion fix: ensure we bind oohelperd with the repo's version number (#558) 2021-10-22 17:21:38 +02:00
ptxclient feat: introduce ptx package for pluggable transports dialers (#373) 2021-06-14 10:20:54 +02:00
README.md doc: ensure all top dirs have an explanatory README (#214) 2021-02-03 16:54:00 +01:00

Directory github.com/ooni/probe-cli/internal/cmd

This directory contains the source code for the CLI tools we build but we don't want to expose to the outside world. That is, you can only build these tools if you have cloned this repo.