Skip to content

Commit f2ab216

Browse files
committed
Fix LAN proxy model probing
1 parent 58b1714 commit f2ab216

19 files changed

Lines changed: 136 additions & 59 deletions

core/cmd/cli_smoke_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func smokeIsolatedEnv(t *testing.T) []string {
6969
if runtime.GOOS == "windows" {
7070
env = append(env, "USERPROFILE="+home)
7171
}
72+
t.Cleanup(func() {
73+
cmd := exec.Command(smokeClovapiBinary(t), "proxy", "stop")
74+
cmd.Env = env
75+
_ = cmd.Run()
76+
})
7277
return env
7378
}
7479

core/cmd/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ func cmdProxyLogs() *cobra.Command {
621621
Short: "List recent call log entries",
622622
RunE: func(cmd *cobra.Command, args []string) error {
623623
store := coreproxy.NewCallLogStore()
624+
defer store.Close()
624625
var entries []coreproxy.CallLogEntry
625626
if strings.TrimSpace(sessionID) != "" {
626627
entries = store.ListRecentSessionPage(limit, offset, sessionID)
@@ -666,6 +667,7 @@ func cmdProxyLogs() *cobra.Command {
666667
Short: "List grouped call log sessions",
667668
RunE: func(cmd *cobra.Command, args []string) error {
668669
store := coreproxy.NewCallLogStore()
670+
defer store.Close()
669671
items := store.ListSessions(limit)
670672
if jsonOut {
671673
data, err := json.MarshalIndent(items, "", " ")
@@ -756,7 +758,9 @@ func cmdProxyLogs() *cobra.Command {
756758
return nil
757759
}
758760
}
759-
coreproxy.NewCallLogStore().Clear()
761+
store := coreproxy.NewCallLogStore()
762+
defer store.Close()
763+
store.Clear()
760764
fmt.Println("Call logs cleared.")
761765
return nil
762766
},

core/cmd/proxy_cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func spawnDetachedProxyServe(cfg profile.ProxyConfig) (int, error) {
126126

127127
host := strings.TrimSpace(cfg.Host)
128128
if host == "" {
129-
host = "127.0.0.1"
129+
host = "0.0.0.0"
130130
}
131131
args := []string{"__proxy-daemon", "--host", host, "--port", strconv.Itoa(cfg.Port)}
132132
cmd := exec.Command(exe, args...)

core/cmd/proxy_status_json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func probeProxyHealthBody(cfg profile.ProxyConfig) (bool, map[string]any, int64,
4545
func buildProxyStatusJSON(cfg profile.ProxyConfig, includeLatency bool) proxyStatusJSON {
4646
host := strings.TrimSpace(cfg.Host)
4747
if host == "" {
48-
host = "127.0.0.1"
48+
host = "0.0.0.0"
4949
}
5050
port := cfg.Port
5151
if port <= 0 {

core/internal/buildinfo/buildinfo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "strings"
44

55
// Set at link time via -ldflags (see .goreleaser.yaml).
66
var (
7-
Version = "dev0.1.114"
7+
Version = "dev0.1.116"
88
Commit = "none"
99
Date = "unknown"
1010
)

core/internal/desktop/test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ type TestResult struct {
2525
}
2626

2727
func proxyConfigForTest(s *profile.Store, portOverride int) profile.ProxyConfig {
28-
cfg := profile.ProxyConfig{Enabled: true, Host: "127.0.0.1", Port: 27483}
28+
cfg := profile.ProxyConfig{Enabled: true, Host: "0.0.0.0", Port: 27483}
2929
if s != nil {
3030
cfg = s.Proxy
3131
}
3232
if strings.TrimSpace(cfg.Host) == "" {
33-
cfg.Host = "127.0.0.1"
33+
cfg.Host = "0.0.0.0"
3434
}
3535
if cfg.Port == 0 {
3636
cfg.Port = 27483

core/internal/desktop/test_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ func TestProxyConfigForTestAppliesDefaultsAndOverride(t *testing.T) {
1111
Proxy: profile.ProxyConfig{Host: "", Port: 1234},
1212
}, 5678)
1313

14-
if cfg.Host != "127.0.0.1" {
15-
t.Fatalf("Host = %q, want 127.0.0.1", cfg.Host)
14+
if cfg.Host != "0.0.0.0" {
15+
t.Fatalf("Host = %q, want 0.0.0.0", cfg.Host)
1616
}
1717
if cfg.Port != 5678 {
1818
t.Fatalf("Port = %d, want 5678", cfg.Port)

core/internal/profile/store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ import (
1616
)
1717

1818
func defaultProxyConfig() ProxyConfig {
19-
return ProxyConfig{Enabled: true, Host: "127.0.0.1", Port: 27483}
19+
return ProxyConfig{Enabled: true, Host: "0.0.0.0", Port: 27483}
2020
}
2121

2222
func ensureProxyDefaults(s *Store, oldVersion int) {
2323
if s == nil {
2424
return
2525
}
2626
if strings.TrimSpace(s.Proxy.Host) == "" {
27-
s.Proxy.Host = "127.0.0.1"
27+
s.Proxy.Host = "0.0.0.0"
2828
}
2929
if s.Proxy.Port == 0 {
3030
s.Proxy.Port = 27483

core/internal/proxy/calllog_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ func openTestCallLogStore(t *testing.T) *CallLogStore {
2020

2121
func TestCallLogStorePushAndList(t *testing.T) {
2222
store := openTestCallLogStore(t)
23-
store.Push(CallLogEntry{Request: CallLogRequest{Method: "POST", URL: "/a"}})
24-
store.Push(CallLogEntry{Request: CallLogRequest{Method: "GET", URL: "/b"}})
25-
store.Push(CallLogEntry{Request: CallLogRequest{Method: "DELETE", URL: "/c"}})
23+
store.Push(CallLogEntry{StartedAt: "2026-01-01T00:00:01Z", Request: CallLogRequest{Method: "POST", URL: "/a"}})
24+
store.Push(CallLogEntry{StartedAt: "2026-01-01T00:00:02Z", Request: CallLogRequest{Method: "GET", URL: "/b"}})
25+
store.Push(CallLogEntry{StartedAt: "2026-01-01T00:00:03Z", Request: CallLogRequest{Method: "DELETE", URL: "/c"}})
2626

2727
entries := store.ListRecent(0)
2828
if len(entries) != 3 {

core/internal/proxy/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ type debugTransformResponse struct {
6161

6262
func NewServer(cfg profile.ProxyConfig) *Server {
6363
if strings.TrimSpace(cfg.Host) == "" {
64-
cfg.Host = "127.0.0.1"
64+
cfg.Host = "0.0.0.0"
6565
}
6666
if cfg.Port == 0 {
6767
cfg.Port = 27483

0 commit comments

Comments
 (0)