Files
magpie/internal/provider/unredacted.go
T
yetone 0549e5301a masking: Send requests unmasked is found from Settings › Privacy and holds on every route (CrazyMouse_TT on X)
CrazyMouse_TT runs a model of their own and wanted masking off for it.
The switch already existed (the provider editor's Advanced › Send requests
unmasked, provider.Unredacted), but nothing near masking pointed to it,
and it held only on chat-shaped routes.

- Settings › Privacy has a "Sent unmasked" row: each provider set so is a
  button that opens its editor with Advanced open; with none, the row says
  where the switch is (settingsJSON.UnmaskedProviders, redact plugin's
  unmaskedRow).
- Images (draw.go), videos (video.go) and Ark's own API (native.go) go as
  written when every model they may go to is such a provider
  (unmaskedMembers); a group with one member left on stays masked, as a
  chat's route does (unredactedRoute).
- A Remote magpie may be set so too (SkipsRedaction no longer refuses
  it): it is sent the request as written with no X-Magpie-Masked-As, so
  it masks by its own Settings and switches, once, before any vendor
  (1d6d263ee's hop). Left off, it is masked here, as before. The editor
  says so for a remote magpie.
- Default stays off for every provider: nothing changes for anyone who
  hasn't ticked it.

app.js stays under TestCoreScriptBudget by a shorter unmaskRow call and
three trimmed comments (app.js -51 bytes vs base).

Run (mote, at this tree): gofmt -l clean; go vet darwin, GOOS=linux
-tags nogui, GOOS=windows clean; go test -count=1 ./internal/gateway
./internal/provider ./internal/cli ./internal/masking ./internal/gui ok.
GUI (chromium + webkit, 5 languages, 1100/440px):
provider-unmasked, unmasked-providers, i18n-keys, i18n-en-no-cjk,
redact-route: 126 pass, 0 fail. masking-records.test.cjs is red the same
on origin/main 9430c5309 (#5830).

Broken by hand: SkipsRedaction refusing a remote magpie again made
TestUnredactedRemoteMagpieMasksOnItsOwnSide red; images/videos/Ark
ignoring the switch made TestUnredactedProviderDrawsWhole,
...MakesVideosWhole and ...ArkNativeWhole red; dropping
unmaskedProviders made unmasked-providers.test.cjs red.

Not tried: Windows (win-run), and a real two-machine magpie hop; the hop
is tested with two in-process gateways and a tap between them.
2026-11-10 10:03:49 +08:00

50 lines
1.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package provider
import (
"net"
"github.com/yetone/magpie/internal/netproxy"
)
// SkipsRedaction says requests to p go unmasked: the user set Unredacted
// ("Send requests unmasked") and p has somewhere they go. It is the user's
// word for each provider whatever the address (AcMilan on Discord), a
// subscription's and a plugin's too (isee1_1 on Discord: a plugin's
// provider never had the switch): the editor cautions while it is on for
// one not on this computer or the local network, which a signed-in
// account's or a plugin's vendor never is, and nothing here looks one up.
// Another magpie (a Remote magpie) set so is sent the request as written,
// with no X-Magpie-Masked-As, so it masks by its own Settings › Privacy
// and its own providers' switches before anything reaches a vendor
// (CrazyMouse_TT on X: a model of the user's own behind that magpie);
// left off, it is sent the request masked here, as before.
func (p Provider) SkipsRedaction() bool {
if !p.Unredacted {
return false
}
if p.Account != nil {
return true // the agent's sign-in or a plugin's: its vendor is where it goes
}
for _, b := range []string{p.Chat, p.Responses, p.Anthropic, p.Gemini, p.Decide} {
if b != "" {
return true
}
}
return false
}
// LocalHost says host is on this machine or the local network: localhost,
// a .local name, a loopback, private or link-local IP, or a name every
// address of which is one (netproxy.LocalName, looked up now and kept a
// minute; one that doesn't resolve isn't). Only the editor's caution asks
// it (/api/local-hosts), never a request.
func LocalHost(host string) bool {
if local(host) {
return true
}
if ip := net.ParseIP(host); ip != nil {
return netproxy.LocalIP(ip)
}
return netproxy.LocalName(host)
}