refactor: move more commands to internal/cmd (#207)

* refactor: move more commands to internal/cmd

Part of https://github.com/ooni/probe/issues/1335.

We would like all commands to be at the same level of engine
rather than inside engine (now that we can do it).

* fix: update .gitignore

* refactor: also move jafar outside engine

* We should be good now?
This commit is contained in:
Simone Basso 2021-02-03 12:23:15 +01:00 committed by GitHub
parent 6351d898d6
commit 4eeadd06a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
85 changed files with 72 additions and 65 deletions

6
.gitignore vendored
View File

@ -2,9 +2,15 @@
/*.jsonl
/*.tar.gz
/*.zip
/apitool
/apitool.exe
/coverage.cov
/miniooni
/miniooni.exe
/oohelper
/oohelper.exe
/oohelperd
/oohelperd.exe
/ooniprobe
/ooniprobe.exe
/ooniprobe_checksums.txt

View File

@ -13,7 +13,7 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/cmd/ooniprobe/internal/utils"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/engine/shellx"
"golang.org/x/sys/unix"
)

4
internal/cmd/README.md Normal file
View File

@ -0,0 +1,4 @@
# 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.

View File

@ -17,8 +17,8 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices"
"github.com/ooni/probe-cli/v3/internal/engine/version"

1
internal/cmd/jafar/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/badproxy.pem

View File

@ -9,7 +9,7 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/flagx"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/flagx"
)
func TestStringArray(t *testing.T) {

View File

@ -8,7 +8,7 @@ import (
"net/http"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
)
func TestPass(t *testing.T) {

View File

@ -14,9 +14,9 @@ import (
"time"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/resolver"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/resolver"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/engine/shellx"
)
func init() {

View File

@ -3,8 +3,8 @@
package iptables
import (
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/shellx"
)
type linuxShell struct{}

View File

@ -18,15 +18,15 @@ import (
"github.com/apex/log"
"github.com/apex/log/handlers/cli"
"github.com/miekg/dns"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/badproxy"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/flagx"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/httpproxy"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/iptables"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/resolver"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/tlsproxy"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/badproxy"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/flagx"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/httpproxy"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/iptables"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/resolver"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/tlsproxy"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/shellx"
)
var (

View File

@ -6,8 +6,8 @@ import (
"runtime"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/iptables"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/iptables"
"github.com/ooni/probe-cli/v3/internal/engine/shellx"
)
func ensureWeStartOverWithIPTables() {

View File

@ -5,7 +5,7 @@ import (
"testing"
"github.com/miekg/dns"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
)
func TestPass(t *testing.T) {

View File

@ -7,7 +7,7 @@ import (
"sync"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/cmd/jafar/uncensored"
)
func TestPass(t *testing.T) {

View File

@ -13,7 +13,7 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/version"

View File

@ -8,7 +8,7 @@ import (
"reflect"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelper/internal"
"github.com/ooni/probe-cli/v3/internal/cmd/oohelper/internal"
)
func TestMakeTCPEndpoints(t *testing.T) {

View File

@ -10,7 +10,7 @@ import (
"net/http"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelper/internal"
"github.com/ooni/probe-cli/v3/internal/cmd/oohelper/internal"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
)

View File

@ -8,7 +8,7 @@ import (
"sync"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelperd/internal"
"github.com/ooni/probe-cli/v3/internal/cmd/oohelperd/internal"
)
func TestHTTPDoWithInvalidURL(t *testing.T) {

View File

@ -10,7 +10,7 @@ import (
"strings"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelperd/internal"
"github.com/ooni/probe-cli/v3/internal/cmd/oohelperd/internal"
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
)

View File

@ -9,7 +9,7 @@ import (
"time"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelperd/internal"
"github.com/ooni/probe-cli/v3/internal/cmd/oohelperd/internal"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
)

View File

@ -2,9 +2,7 @@
/.vscode
/apitool
/asn.mmdb
/badproxy.pem
/ca-bundle.pem
/cmd/jafar/badproxy.pem
/country.mmdb
/example.org
/jafar

View File

@ -1,3 +0,0 @@
# Directory github.com/ooni/probe-engine/cmd
This directory contains the source code for the CLI tools we build.

View File

@ -16,7 +16,7 @@ import (
"time"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/internal/randx"
"github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/netx"

View File

@ -13,7 +13,7 @@ import (
"time"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netxlogger"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonidatamodel"

View File

@ -10,7 +10,7 @@ import (
"net/http/cookiejar"
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"

View File

@ -11,7 +11,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
)
func TestRunnerWithInvalidURLScheme(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"context"
"github.com/ooni/probe-cli/v3/internal/engine/geolocate"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
)

View File

@ -12,7 +12,7 @@ import (
"time"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity/internal"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
)

View File

@ -4,7 +4,7 @@ import (
"context"
"net/http"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
type avastResponse struct {

View File

@ -7,7 +7,7 @@ import (
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
)
func TestIPLookupWorksUsingAvast(t *testing.T) {

View File

@ -5,8 +5,8 @@ import (
"net/http"
"strings"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
func ipConfigIPLookup(

View File

@ -7,7 +7,7 @@ import (
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
)
func TestIPLookupWorksUsingIPConfig(t *testing.T) {

View File

@ -4,8 +4,8 @@ import (
"context"
"net/http"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
type ipInfoResponse struct {

View File

@ -7,7 +7,7 @@ import (
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
)
func TestIPLookupWorksUsingIPInfo(t *testing.T) {

View File

@ -9,7 +9,7 @@ import (
"time"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/pion/stun"
)

View File

@ -5,7 +5,7 @@ import (
"encoding/xml"
"net/http"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
type ubuntuResponse struct {

View File

@ -9,7 +9,7 @@ import (
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
)
func TestUbuntuParseError(t *testing.T) {

View File

@ -9,7 +9,7 @@ import (
"testing"
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
func TestFetchResourceIntegration(t *testing.T) {

View File

@ -11,7 +11,7 @@ import (
"github.com/apex/log"
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
)

View File

@ -9,7 +9,7 @@ import (
"github.com/apex/log"
"github.com/google/go-cmp/cmp"
engine "github.com/ooni/probe-cli/v3/internal/engine"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/model"
)

View File

@ -6,7 +6,7 @@ import (
"net/http"
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/internal/psiphonx"
"github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/internal/torx"

View File

@ -8,7 +8,7 @@ import (
"net/http"
"time"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
)
// DNSOverHTTPS is a DNS over HTTPS RoundTripper. Requests are submitted over

View File

@ -9,7 +9,7 @@ import (
"strings"
"testing"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/netx/resolver"
)

View File

@ -4,7 +4,7 @@ import (
"context"
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
type checkReportIDResponse struct {

View File

@ -8,8 +8,8 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices"
)

View File

@ -5,7 +5,7 @@ import (
"net/url"
"time"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
)
// MeasurementMetaConfig contains configuration for GetMeasurementMeta.

View File

@ -9,8 +9,8 @@ import (
"github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices"
)

View File

@ -29,7 +29,7 @@ import (
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/model"
)

View File

@ -7,7 +7,7 @@ import (
"time"
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices"
)

View File

@ -13,7 +13,7 @@ import (
"os"
"path/filepath"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/httpx"
"github.com/ooni/probe-cli/v3/internal/engine/model"
)

View File

@ -13,7 +13,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/geolocate"
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/internal/platform"
"github.com/ooni/probe-cli/v3/internal/engine/internal/sessionresolver"
"github.com/ooni/probe-cli/v3/internal/engine/internal/tunnel"

1
pkg/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/testdata