Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

Versions follow `v*.*.*` with dots. Dates are US Eastern.

## 0.7.0 · 2026-11-22

No setup by hand, and any request can be sent again.

- On macOS and Windows FormNET can point the computer's proxy at itself while it runs (Preferences > Capture > System Proxy, off by default), so browsers and most apps show up in Flows with nothing to configure. Your previous proxy settings come back when FormNET quits, and at the next start if it ever crashed; `formnet sysproxy restore` puts them back by hand.
- Resend any captured request, or edit its method, address, headers and body first. The new request is recorded as its own flow and links back to the original.
- Setup shows ready-to-copy lines that send curl, Node.js, Python, Java, Go and git through FormNET, for sh and PowerShell, with this run's real address and certificate.
- The new labels read in English in the other languages until a later version translates them.

## 0.6.0 · 2026-11-22

Agents can use FormNET, and FormNET has the family's terminal panel.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := v0.6.0
VERSION := v0.7.0
LDFLAGS := -s -w -X github.com/nodemode-dev/formnet/internal/app.Version=$(VERSION)
GO_BUILD := CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)"
TARGETS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</p>

<p align="center">
<img alt="version v0.6.0" src="https://img.shields.io/badge/version-v0.6.0-eef0f4?style=flat-square">
<img alt="version v0.7.0" src="https://img.shields.io/badge/version-v0.7.0-eef0f4?style=flat-square">
<img alt="Go 1.26" src="https://img.shields.io/badge/Go-1.26-00ADD8?style=flat-square&logo=go&logoColor=white">
<img alt="TypeScript and Vite" src="https://img.shields.io/badge/TypeScript-Vite-3178c6?style=flat-square">
<img alt="macOS, Windows, Linux" src="https://img.shields.io/badge/macOS%20%C2%B7%20Windows%20%C2%B7%20Linux-native-2f7bf5?style=flat-square">
Expand Down
37 changes: 33 additions & 4 deletions cmd/formnet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/nodemode-dev/formnet/internal/proxy"
"github.com/nodemode-dev/formnet/internal/server"
"github.com/nodemode-dev/formnet/internal/settings"
"github.com/nodemode-dev/formnet/internal/sysproxy"
"github.com/nodemode-dev/formnet/internal/terminal"
"github.com/nodemode-dev/formnet/internal/userfile"
)
Expand All @@ -54,6 +55,8 @@ func run(args []string, stdout, stderr io.Writer) int {
return caCommand(args[1:], stdout, stderr)
case "snapshot":
return snapshot(stdout, stderr)
case "sysproxy":
return sysproxy.Command(args[1:], stdout, stderr)
case "url":
return printURL(stdout, stderr)
case "open":
Expand Down Expand Up @@ -83,6 +86,9 @@ func usage(w io.Writer) {
ca export PATH write the root certificate (PEM) to PATH
ca trust print the command that makes this computer trust the root
snapshot print the machine's connection table once, as JSON
sysproxy print whether the system proxy points at formnet (macOS, Windows)
sysproxy on|off ask the running formnet to set the system proxy, or put the previous one back
sysproxy restore put back the system proxy a formnet that did not stop cleanly left (no server needed)
mcp serve MCP on stdio for agents; reads the running formnet, starts nothing
agents sync write agents/, the skill pack's tool table and .agents/skills (in the repository)
agents check fail when those files are stale or a skill breaks the format contract
Expand All @@ -100,10 +106,14 @@ Settings (environment):
FORMNET_MACHINE_INTERVAL seconds between machine snapshots; default 2
FORMNET_REVERSE_DNS 1 to name remote addresses in the machine view (sends PTR queries); default off
FORMNET_TOKEN this run's session token; default a new one, kept in <data>/token
FORMNET_SYSTEM_PROXY 1 to point the system proxy at formnet while it runs, 0 not to (macOS, Windows); default off

Interception and the passthrough list chosen in the web client are kept in
<data>/settings.json; FORMNET_INTERCEPT or FORMNET_PASSTHROUGH, when set, wins
for that run and is not written there.
Interception, the passthrough list and the system proxy chosen in the web
client are kept in <data>/settings.json; FORMNET_INTERCEPT,
FORMNET_PASSTHROUGH or FORMNET_SYSTEM_PROXY, when set, wins for that run and
is not written there. While the system proxy points at formnet, the settings
it replaced are kept in <data>/sysproxy.json and put back when formnet stops,
or at the next start after a crash.

The web client answers only to a page opened with the session token: use the
address "formnet serve" prints, or run "formnet open". Scripts send the token
Expand All @@ -130,6 +140,11 @@ func serve(stdout, stderr io.Writer) int {
log.Error("data folder", "path", cfg.Data, "err", err)
return 1
}
if msg, err := sysproxy.Recover(cfg.Data); err != nil {
log.Warn("system proxy left by the last run", "err", err, "run", "formnet sysproxy restore")
} else if msg != "" {
log.Info(msg)
}
authority, err := ca.Load(cfg.Data)
if err != nil {
log.Error("certificate authority", "err", err)
Expand Down Expand Up @@ -195,10 +210,11 @@ func serve(stdout, stderr io.Writer) int {
go func() { proxyErr <- px.Serve(ctx, bound.proxy) }()

remember := func(u server.ProxySettings) error { return saved.Update(u.Intercept, u.Passthrough) }
systemProxy := sysproxy.New(sysproxy.Options{Data: cfg.Data, Address: proxyAddr, API: apiAddr, Enabled: kept.SystemProxy, Remember: saved.SetSystemProxy, Log: log})
terminals := terminal.New(terminal.Options{APIAddr: apiAddr, ProxyAddr: proxyAddr, CAPath: info.Path, Log: log})
defer terminals.Close()
api := &http.Server{
Handler: server.Handler(server.Deps{Addr: apiAddr, Token: token, Store: store, Proxy: px, CA: authority, Machine: monitor, Dist: formnet.Dist(), Log: log, Notices: bound.notices, Quit: stop, Remember: remember, Terminals: terminals}),
Handler: server.Handler(server.Deps{Addr: apiAddr, Token: token, Store: store, Proxy: px, CA: authority, Machine: monitor, Dist: formnet.Dist(), Log: log, Notices: bound.notices, Quit: stop, Remember: remember, SystemProxy: systemProxy, BodyLimit: cfg.BodyLimit, Terminals: terminals}),
ReadHeaderTimeout: 10 * time.Second,
IdleTimeout: 90 * time.Second,
}
Expand All @@ -223,6 +239,16 @@ func serve(stdout, stderr io.Writer) int {
// The desktop app waits for this line before it opens its window.
fmt.Fprintf(stdout, "formnet desktop ready http://%s/\n", apiAddr)

wantSystemProxy := kept.SystemProxy
if cfg.SystemProxySet {
wantSystemProxy = cfg.SystemProxy
}
if ok, _ := sysproxy.Supported(); ok && wantSystemProxy && ctx.Err() == nil {
if err := systemProxy.Enable(); err != nil {
log.Warn("system proxy not set", "err", err)
}
}

code := 0
select {
case <-ctx.Done():
Expand All @@ -237,6 +263,9 @@ func serve(stdout, stderr io.Writer) int {
code = 1
}
}
if err := systemProxy.Close(); err != nil {
log.Warn("system proxy not put back", "err", err, "run", "formnet sysproxy restore")
}
terminals.Close()
removeEndpoints(cfg.Data)
stop()
Expand Down
13 changes: 13 additions & 0 deletions internal/HASHOUT_LOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ The export folder is made with mode 0700 and refused when it is a link or a file

`formnet agents sync` writes `agents/manifest.json` (tool names by class, protocol, skills), `agents/tools.json` (the full definitions as `tools/list` returns them), the skill pack's `references/mcp-tools.md`, and `.agents/skills` as a byte-identical copy of `.claude/skills`; `formnet agents check` fails when any of them is stale and when a skill breaks the format contract (name rule and folder match, description length and a use clause, no tags, em dash, emoji or README). Tool counts in documents come from that output.

## 2026-11-22 · System proxy, resend and recipes

`internal/sysproxy` points the system proxy at this run's real proxy address (the moved one when the preferred port was held) while the choice is on, off by default. The choice is `system_proxy` in `<data>/settings.json` (a version 1 file without it reads as false; the version stays 1); `FORMNET_SYSTEM_PROXY=1|0` wins for that run and is never written. `POST /api/sysproxy` keeps `true` only when setting it worked and keeps `false` always; on a system that is not supported it changes and keeps nothing. `enabled` in the status is the kept choice, `active` is read from the system (at most every 2 seconds) and is true when any setting points at this run's address.

macOS: `/usr/sbin/networksetup` on every enabled service from `-listallnetworkservices` (lines starting with `*` are disabled, the first line explains that). For each, `-getwebproxy`, `-getsecurewebproxy`, `-getproxybypassdomains` and `-getautoproxyurl` are read and saved; then `-setwebproxy`, `-setsecurewebproxy` (host, port) and `-setwebproxystate`, `-setsecurewebproxystate on`. SOCKS, the bypass list and automatic configuration are never written. A failure is read from the exit status and from an `** Error` line; one that names admin rights, privileges or authorization becomes a plain sentence saying an administrator account is needed, and every service already changed is put back first. A service whose proxy uses a password is refused before anything changes, because networksetup could not put the password back. Restoring writes the saved host and port and the saved on or off state, for each setting that still points at FormNET; a setting that had no server is only turned off, since networksetup cannot clear a server field. FormNET never runs sudo and never asks for a password.

Windows: `HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings` through advapi32 (`RegOpenKeyExW`, `RegQueryValueExW`, `RegSetValueExW`, `RegDeleteValueW`). `ProxyEnable`, `ProxyServer`, `ProxyOverride` are saved (absent stays absent on restore) and `AutoConfigURL` recorded; FormNET writes `ProxyServer=http=ADDR;https=ADDR`, keeps the person's `ProxyOverride` and adds `<local>` when it is missing, sets `ProxyEnable=1`, then calls `InternetSetOptionW` with 39 (settings changed) and 37 (refresh) from wininet.dll, loaded by its System32 path. The "Automatically detect settings" switch lives in the binary `Connections\DefaultConnectionSettings` value and is neither read nor changed. When `AutoConfigURL` is set (Windows) or an auto-proxy URL is on (macOS), `auto_config` is true and `reason` says the system prefers its automatic configuration. Other systems answer `supported: false` with the reason from the task.

Crash safety: `<data>/sysproxy.json` (`userfile`, atomic) holds the saved settings, the address set, this run's API address and pid, and is written before anything changes. A clean stop (SIGTERM, Ctrl-C, the desktop pipe closing, `POST /api/quit`, or either listener failing) puts back each setting that still points at FormNET's address and deletes the file, before the API shuts down. At start, before the certificate and the listeners, a file whose run no longer answers `/healthz` is handled: if the system still points at the recorded address the saved settings go back, otherwise the system is left alone; the file is deleted either way. A file whose run still answers is left to that run, so a FormNET being replaced restores its own settings; a new run turning the proxy on waits up to 5 seconds for such a file to go, refuses while its owner still answers, and inherits the saved settings of a dead owner whose address the system still points at. `formnet sysproxy restore` does the same without a server and refuses while the run that set it still answers.

Resend: `POST /api/flows/{id}/resend` goes through `Proxy.Resend`, which builds the request, checks the destination with the proxy's guard (a refusal is a 403 before any flow exists), and runs it through the same exchange code as a proxied request (`forward` now calls `exchange`, which panics only for a real client), with the proxy's transport and guarded dialer, normal certificate checks for https, a 10 minute bound and the proxy's lifetime. A hook marks the new flow (`resent_from`, `edited`, `client_process: "FormNET resend"`, `client_pid` FormNET's own) before the Store sees it and the id is answered once it is stored. `edited` is true when a field given differs from the capture. Headers lose hop-by-hop and `Proxy-*` names; `Content-Length` is recomputed from the body; a `Host` header becomes the request's host. A body captured decoded (`decoded: true` in the detail) is encoded again with the request's `Content-Encoding` (gzip, deflate as zlib, br, zstd) when that header is still the captured one; otherwise the body goes as given. Errors: not an http flow, or a truncated body sent unedited, 409; bad edits 400; a refused destination 403; the route body is read up to twice the body limit plus 64 KiB (413 past it) and an edited body may hold at most the body limit (413).

Recipes: `GET /api/recipes` answers `{proxy_addr, ca_path, platform, recipes:[{id, title, shell, lines, note}]}` for curl, Node.js, Python requests and pip, Java, Go programs and git, with sh and PowerShell on macOS and Linux and PowerShell only on Windows (no sh there by default; PowerShell's `curl` is another command, so the line calls `curl.exe`). Every value is single-quoted for its shell, Java `-D` arguments included, since PowerShell splits an unquoted `-Dname.part=value`. git uses `http.proxy`, the documented key that covers https URLs; there is no `https.proxy` key in git-config. Go's line sets `SSL_CERT_FILE` only on Linux and other Unix, because crypto/x509 reads it only there; on macOS and Windows the note says to trust the root. Notes say where a CA option replaces the default roots rather than adding to them.

## 2026-11-22 · The terminal dock's engine and the agent finder

Expand Down
15 changes: 15 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// FORMNET_REVERSE_DNS 1 to look up names for remote addresses in the machine view; default off
// FORMNET_INTERCEPT auto (open HTTPS only while the root is trusted), on, or off; when set, wins over <data>/settings.json; default auto
// FORMNET_TOKEN this run's session token; default a new random one, written to <data>/token
// FORMNET_SYSTEM_PROXY 1 or 0: point the system proxy at formnet for this run (macOS, Windows); when set, wins over <data>/settings.json
// FORMNET_DESKTOP set by the desktop app; the server stops when its stdin closes
package config

Expand Down Expand Up @@ -49,6 +50,8 @@ type Config struct {
PassthroughSet bool // FORMNET_PASSTHROUGH was set: it wins over <data>/settings.json for this run
Token string // empty means make one
Desktop bool
SystemProxy bool // FORMNET_SYSTEM_PROXY's value
SystemProxySet bool // FORMNET_SYSTEM_PROXY was set: it wins over <data>/settings.json for this run
}

// Load resolves the configuration from the environment and the home folder.
Expand Down Expand Up @@ -97,7 +100,19 @@ func load(getenv func(string) string, home func() (string, error)) (Config, erro
if token != "" && len(token) < 16 {
return Config{}, errors.New("FORMNET_TOKEN: must be at least 16 characters")
}
systemProxy, systemProxySet := false, false
switch strings.ToLower(strings.TrimSpace(getenv("FORMNET_SYSTEM_PROXY"))) {
case "":
case "1", "true", "yes", "on":
systemProxy, systemProxySet = true, true
case "0", "false", "no", "off":
systemProxySet = true
default:
return Config{}, errors.New("FORMNET_SYSTEM_PROXY: must be 1 or 0")
}
return Config{
SystemProxy: systemProxy,
SystemProxySet: systemProxySet,
Data: data,
ReverseDNS: truthy(getenv("FORMNET_REVERSE_DNS")),
Intercept: intercept,
Expand Down
3 changes: 3 additions & 0 deletions internal/flow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type Flow struct {
DurationMS float64 `json:"duration_ms"` // start to end

Error string `json:"error,omitempty"`

ResentFrom string `json:"resent_from,omitempty"` // the flow this one sent again, when FormNET resent it
Edited bool `json:"edited,omitempty"` // the resent request was changed before it went out
}

// Summary is the Flow without bodies, as the list and the stream carry it.
Expand Down
32 changes: 25 additions & 7 deletions internal/proxy/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,53 @@ func (t *timing) ttfbMS() float64 {

// forward relays one plain exchange and records it.
func (p *Proxy) forward(w http.ResponseWriter, r *http.Request, o origin) {
if copyErr := p.exchange(w, r, o, nil); copyErr != nil {
// The upstream stopped mid-body. Resetting the client connection is the
// only honest signal that the body is not complete.
panic(http.ErrAbortHandler)
}
}

// flowHook marks a flow the proxy itself starts and says when it is stored.
type flowHook struct {
mark func(flow.Flow) flow.Flow
added chan<- string
}

// exchange relays one plain exchange and records it. A non-nil error means
// the upstream body was cut short after the response headers went out.
func (p *Proxy) exchange(w http.ResponseWriter, r *http.Request, o origin, hook *flowHook) error {
rawURL := o.url(r)
f := p.newFlow(flow.KindHTTP, o, r.Method, rawURL)
reqCapture := newCapture(r.Body, p.opts.BodyLimit)
requestLine := fmt.Sprintf("%s %s %s", r.Method, r.URL.RequestURI(), r.Proto)
f.Request = reqCapture.message(r.Header, requestLine, p.opts.BodyLimit)
f.ClientProtocol = r.Proto
f.Protocol = r.Proto
if hook != nil && hook.mark != nil {
f = hook.mark(f)
}
f = p.opts.Store.Add(f)
if hook != nil && hook.added != nil {
hook.added <- f.ID
}

out, err := p.outgoing(r, rawURL, reqCapture)
if err != nil {
p.fail(w, f, http.StatusBadRequest, "formnet could not build the upstream request: "+err.Error())
return
return nil
}
tm := &timing{}
out = out.WithContext(httptrace.WithClientTrace(out.Context(), tm.trace()))
resp, err := p.transport.RoundTrip(out)
if err != nil {
p.fail(w, f, statusFor(err), "formnet could not reach "+f.Host+": "+err.Error())
return
return nil
}
defer resp.Body.Close()
f, copyErr := p.relayResponse(w, resp, f, tm, reqCapture, requestLine, r.Header)
p.finish(f)
if copyErr != nil {
// The upstream stopped mid-body. Resetting the client connection is the
// only honest signal that the body is not complete.
panic(http.ErrAbortHandler)
}
return copyErr
}

// outgoing builds the upstream request from the client's.
Expand Down
4 changes: 4 additions & 0 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type Proxy struct {
mode string
passthrough []string
hijacked map[net.Conn]struct{}
serveCtx context.Context // ends when Serve stops; resends run under it

refusedMu sync.Mutex
refused map[string]time.Time // last refused handshake per program and host
Expand Down Expand Up @@ -171,6 +172,9 @@ func (p *Proxy) Serve(ctx context.Context, ln net.Listener) error {
return err
}
p.setRunning(addr, true)
p.mu.Lock()
p.serveCtx = ctx
p.mu.Unlock()
p.log.Info("proxy listening", "addr", ln.Addr().String())
go p.followTrust(ctx)
srv := &http.Server{Handler: p, ReadHeaderTimeout: 30 * time.Second, IdleTimeout: 90 * time.Second}
Expand Down
Loading
Loading