feat: fix proxy compatibility and establish TUI foundation
This commit is contained in:
@@ -256,8 +256,8 @@ func compatible(input profile.Profile) (profile.Profile, error) {
|
||||
if err != nil {
|
||||
return profile.Profile{}, err
|
||||
}
|
||||
if p.Mode == profile.AdvancedMode && p.AllURL != "" {
|
||||
return profile.Profile{}, errors.New("Docker daemon Target does not support an ALL/SOCKS proxy; remove it before applying")
|
||||
if p.Mode == profile.AdvancedMode && p.AllURL != "" && (p.HTTPURL == "" || p.HTTPSURL == "") {
|
||||
return profile.Profile{}, errors.New("Docker daemon Target cannot use an ALL/SOCKS proxy as a fallback; provide both HTTP and HTTPS proxy URLs before applying")
|
||||
}
|
||||
for name, raw := range map[string]string{"HTTP": p.HTTPURL, "HTTPS": p.HTTPSURL} {
|
||||
if raw == "" {
|
||||
|
||||
@@ -562,6 +562,25 @@ func TestDockerDaemonRestartFailureIsRedactedTruthfulAndRetryable(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDockerDaemonAcceptsCompleteHTTPProfileWithAdditionalSOCKSProxy(t *testing.T) {
|
||||
a, record, daemonPath, _, _ := fixture(t)
|
||||
p := &profile.Profile{
|
||||
Name: "dual", Mode: profile.AdvancedMode,
|
||||
HTTPURL: "http://localhost:7890", HTTPSURL: "http://localhost:7890", AllURL: "socks5://localhost:7890",
|
||||
}
|
||||
result := a.SetDesired(context.Background(), true, p)
|
||||
if result.Err != nil || result.Inspection.State != target.Enabled {
|
||||
t.Fatalf("dual-protocol result = %#v events=%v", result, record.events)
|
||||
}
|
||||
data, err := os.ReadFile(daemonPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(data), `"http-proxy": "http://localhost:7890"`) || !strings.Contains(string(data), `"https-proxy": "http://localhost:7890"`) {
|
||||
t.Fatalf("daemon config = %s", data)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDockerDaemonRejectsIncompatibleProfileBeforeMutation(t *testing.T) {
|
||||
for _, p := range []*profile.Profile{
|
||||
{Name: "socks", Mode: profile.SingleMode, SingleURL: "socks5://proxy.example:1080"},
|
||||
|
||||
Reference in New Issue
Block a user