Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

feat(core): add opt-in official gateway relay support

baiyuze2ea523afa414
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 74a5026..81db5cd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -8,6 +8,20 @@ on:
workflow_dispatch:
jobs:
+ security:
+ name: Go dependency security
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: client-core/go.mod
+ - run: go install golang.org/x/vuln/cmd/[email protected]
+ - run: govulncheck ./...
+ working-directory: client-core
+ - run: govulncheck ./...
+ working-directory: server
+
server:
name: 服务器
runs-on: ubuntu-latest
diff --git a/PRIVACY.md b/PRIVACY.md
new file mode 100644
index 0000000..98028f4
--- /dev/null
+++ b/PRIVACY.md
@@ -0,0 +1,69 @@
+# Privacy and official service data
+
+## Local and self-hosted use
+
+New installations start with official public service disabled. Clipboard
+history and cached files are stored locally. LAN discovery and synchronization
+use the local network. Custom servers are user-selected; their operators have
+their own retention practices. Neither mode uploads official usage telemetry.
+Optional public STUN probing reveals the source network address to selected
+STUN providers; the setting to use only the chosen server disables extra probes.
+
+## Official access
+
+Enabling the official service is a deliberate setting with an explanation.
+The client first uses signaling and STUN to try a direct connection. A failed
+direct attempt with an online compatible peer is required before requesting
+official relay access. No machine fingerprint is needed for direct service.
+
+| Data | Purpose / retention |
+| --- | --- |
+| Device public key and signature | Prove possession of the existing identity; gateway authentication state is transient |
+| Server-derived pseudonymous device number | Access counts, first/last seen, bans and cumulative totals |
+| Application-specific machine digest | Relay quota grouping only; raw system identifier never leaves the client |
+| Daily upload/download and access totals | Per-device detail retained for 90 days; essential aggregate totals retained longer |
+| Current peer/session and routing metadata | Transient forwarding and abuse protection; not historical relationship tracking |
+| IP addresses | Necessarily visible for transport; not persisted in official statistics or ordinary proxy logs |
+
+Real computer names and OS details are not included in new official client
+handshakes/pairing requests. Paired devices exchange display names inside the
+encrypted data channel. Clipboard content, file names, paths, local usernames,
+MAC addresses, browser UA, installed software and behavior analytics are not
+fields of the gateway protocol. No third-party client analytics SDK is added.
+
+The machine digest is generated only when relay authorization is requested.
+Windows uses MachineGuid; macOS uses IOPlatformUUID; Linux uses a stable
+machine-id, never reboot-specific boot_id. A bounded, cached read is wrapped
+by a versioned PasteFerry-specific HMAC; the service hashes again with its own
+secret. These are pseudonymous identifiers, not guaranteed anonymity. Ordinary
+application reinstall generally preserves the quota group; OS reinstall,
+cloning or a modified client can change or forge it.
+
+The dashboard counts **official service devices**, not people, total installs,
+or users who choose LAN/custom servers. Recreated device keys may count again.
+
+## Usage and controls
+
+The default relay allowance is 100 MB/day, decimal bytes, upload plus download,
+reset at midnight Beijing time. Direct transfers do not consume this quota.
+Encrypted transport overhead contributes to measured relay data. The gateway
+may conservatively hold a small unresolved reservation after a crash until the
+daily reset. Unknown/stale usage is labeled unavailable, not displayed as zero.
+
+Turning off official service cancels official requests, polling and tunnels.
+There is no separate background analytics channel. Quota exhaustion affects
+official relay only; it does not turn off LAN or direct synchronization.
+No anonymous-account system can guarantee a unique natural person without
+collecting additional identity information; PasteFerry does not attempt that.
+
+## Website and audit
+
+The website has an existing Cloudflare Web Analytics beacon, separate from
+the desktop client. Website visits reach Cloudflare and the hosting endpoint;
+they are not software installation or active-device counts. Consult the
+website provider's privacy policy for its network processing.
+
+The published client, network field list and [gateway protocol](design/official-gateway.md)
+can be audited. A private gateway's production data handling requires operator
+and deployment audit; open client source alone cannot prove it. See
+[SECURITY.md](SECURITY.md) for the trust model and reporting channel.
diff --git a/README.md b/README.md
index 9577120..5462ef2 100644
--- a/README.md
+++ b/README.md
@@ -102,6 +102,15 @@ Open TCP 8787, UDP 3478 and UDP 32768–60999, then enter `ws://<server address>
| **Server** | Optional, only to sync across networks: Linux (x86_64, ARM64; systemd or Docker), macOS, or Windows 10/11 x64 |
| **iPhone / iPad** | Not supported: iOS doesn't let apps watch the clipboard in the background |
+## Optional official access (2.1)
+
+New installations keep official public service off. Enable **Settings → Use
+official service** to try direct connections first and request official relay
+only after direct failure. A separate sidebar shows the daily allowance and
+usage. Both peers need a compatible client for official relay; LAN and custom
+servers continue to work without the gateway. See [privacy](PRIVACY.md),
+[security](SECURITY.md) and the [public protocol](design/official-gateway.md).
+
## Documentation
- [How it works](guide/how-it-works.md): architecture, NAT traversal, security model, fallbacks, lessons learned
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 7cf7e9e..f195603 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -115,3 +115,7 @@ sudo ./install.sh <服务器公网IP>
## 许可
隔空贴以 [GNU AGPL-3.0](LICENSE) 免费开源:任何人(包括公司)都可以使用和修改,但分发它、或通过网络提供修改过的版本时,必须以同样的许可公开你的源码。详见 [LICENSING.md](LICENSING.md)。1.2.0 及更早的版本仍适用 MIT 许可。
+
+## 可选官方服务(2.1)
+
+新安装默认关闭官方公网。在设置中开启“使用官方服务”后,先尝试直连,失败才申请官方中转;侧栏显示每日额度和用量。官方中转要求双方使用兼容客户端,局域网和自建服务器可独立运行。详见[隐私说明](PRIVACY.md)、[安全说明](SECURITY.md)及[公开协议](design/official-gateway.md)。
diff --git a/SECURITY.md b/SECURITY.md
new file mode 100644
index 0000000..641ea14
--- /dev/null
+++ b/SECURITY.md
@@ -0,0 +1,57 @@
+# Security model and reporting
+
+PasteFerry clients and the signaling/TURN server are open source under AGPL-3.0.
+Self-hosting never requires an official account, authorization service or
+closed-source component. See [the optional gateway protocol](design/official-gateway.md).
+
+## Trust boundaries
+
+- Device identity is an existing local random Ed25519 key. Pairing requires
+ comparing and confirming fingerprints. Server announcements alone do not
+ establish trust. A machine quota digest is neither a credential nor a key seed.
+- Device-to-device SDP fingerprints and signaling are signed. DTLS protects
+ clipboard/file data in transit, including over relay. The gateway can see
+ transport metadata and byte counts; it cannot read those encrypted contents.
+- Official access is optional and disabled for fresh installs. LAN and custom
+ modes do not request official authorization or report official usage.
+- The gateway can allow, deny, rate-limit or interrupt its own hosted network
+ resources. It cannot execute client code, read arbitrary local files, export
+ device keys, silently pair devices or change the cryptographic trust model.
+- Protocol parsing, body/frame limits, expiration, replay checks and destination
+ restrictions must remain client- and server-side validation, regardless of
+ the operator's implementation. Official endpoints are public configuration.
+ No server credential belongs in an application bundle.
+
+## Practical limits
+
+An administrator or modified client can replace machine identifiers. Hashed
+device metadata is linkable and is not an immutable hardware identity or proof
+of a unique person. Timing, IP addresses and ICE routing metadata are visible
+to the relevant network endpoints during connection establishment. LAN
+discovery intentionally advertises local presence. Physical compromise of a
+device can expose its local clipboard history and cached files.
+
+Ordinary Cloudflare HTTP proxying does not protect UDP STUN or carry TURN UDP.
+Quota limits control authorized service use, not provider-level DDoS ingress.
+Source review establishes the published application's behavior; it cannot by
+itself prove a private service's actual production retention or deployment.
+
+## Verify a build
+
+Review the release commit, dependency lock files, CI results and SHA256SUMS.
+Build instructions are in `scripts/build.sh`, `scripts/package.sh` and the
+server deployment documentation. A checksum confirms artifact integrity; it
+does not prove reproducible compilation. Do not claim reproducibility unless
+the actual platform artifacts have been independently compared.
+
+Recommended checks: `go vet ./...`, `go test -race ./...` in Go modules,
+`govulncheck ./...`, `flutter analyze`, `flutter test`, and the black-box
+gateway interoperability tests when an independently built gateway is supplied.
+
+## Report a vulnerability
+
+Use [GitHub private vulnerability reporting](https://github.com/baiyuze/pasteferry/security/advisories/new).
+Describe affected versions, reproduction steps and impact. Do not put device
+private keys, live authorization tokens, passwords or clipboard contents in a
+public issue. If private reporting is unavailable, open an issue requesting a
+private contact without publishing exploitation details.
diff --git a/client-core/cmd/gateway-smoke/main.go b/client-core/cmd/gateway-smoke/main.go
new file mode 100644
index 0000000..f2e7b35
--- /dev/null
+++ b/client-core/cmd/gateway-smoke/main.go
@@ -0,0 +1,157 @@
+// gateway-smoke uses fresh mutually known test identities to verify the public
+// gateway protocol against an unchanged signaling/TURN server. It deliberately
+// withholds direct candidates to exercise the eight-second fallback path.
+package main
+
+import (
+ "context"
+ "crypto/ed25519"
+ "crypto/rand"
+ "encoding/json"
+ "errors"
+ "flag"
+ "fmt"
+ "net"
+ "net/http"
+ "os"
+ "strings"
+ "sync/atomic"
+ "time"
+
+ "github.com/baiyuze/pasteferry/client-core/internal/gateway"
+ "github.com/baiyuze/pasteferry/client-core/internal/identity"
+ "github.com/baiyuze/pasteferry/client-core/internal/transport/p2p"
+ "github.com/baiyuze/pasteferry/client-core/internal/transport/signaling"
+ "github.com/baiyuze/pasteferry/client-core/internal/transport/signed"
+ pb "github.com/baiyuze/pasteferry/proto/gen/pasteferry/v1"
+)
+
+type node struct {
+ id *identity.Identity
+ gateway *gateway.Client
+ p2p *p2p.Manager
+ signal *signaling.Client
+ online atomic.Bool
+ connected atomic.Bool
+}
+
+func fresh() *identity.Identity {
+ b := make([]byte, 32)
+ if _, err := rand.Read(b); err != nil {
+ panic(err)
+ }
+ return identity.FromSeed(b)
+}
+func main() {
+ if err := run(); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+}
+func run() error {
+ base := flag.String("gateway", gateway.OfficialBaseURL, "explicit HTTPS gateway or loopback HTTP forward")
+ signalURL := flag.String("signal", gateway.OfficialSignalURL, "signaling WSS or loopback forward")
+ flag.Parse()
+ ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
+ defer cancel()
+ blackhole, err := net.ListenPacket("udp4", "127.0.0.1:0")
+ if err != nil {
+ return err
+ }
+ defer blackhole.Close()
+ blackholePort := blackhole.LocalAddr().(*net.UDPAddr).Port
+ a, b := &node{id: fresh()}, &node{id: fresh()}
+ received := make(chan string, 4)
+ for _, pair := range [][2]*node{{a, b}, {b, a}} {
+ self, peer := pair[0], pair[1]
+ var err error
+ self.gateway, err = gateway.NewClient(self.id, *base, nil)
+ if err != nil {
+ return err
+ }
+ defer self.gateway.Close()
+ self.p2p = p2p.NewManager(p2p.ManagerOptions{SelfID: self.id.DeviceID, Gateway: self.gateway, Official: func() bool { return true }, OfficialOnline: func(string) bool { return self.online.Load() }, DisableEgressProbe: true,
+ SendSignal: func(ctx context.Context, to string, msg *pb.SignalMessage) error {
+ if !msg.GetOfficialRelay() {
+ if msg.GetCandidate() != nil {
+ msg.GetCandidate().Candidate = fmt.Sprintf("candidate:1 1 udp 2130706431 127.0.0.1 %d typ host", blackholePort)
+ }
+ strip := func(s string) string {
+ var out []string
+ for _, line := range strings.Split(s, "\n") {
+ if !strings.HasPrefix(strings.TrimSpace(line), "a=candidate:") {
+ out = append(out, line)
+ }
+ }
+ return strings.Join(out, "\n")
+ }
+ if o := msg.GetOffer(); o != nil {
+ o.Sdp = strip(o.Sdp)
+ }
+ if a := msg.GetAnswer(); a != nil {
+ a.Sdp = strip(a.Sdp)
+ }
+ }
+ proof, err := signed.Sign(self.id, to, msg)
+ if err != nil {
+ return err
+ }
+ return self.signal.SendSigned(ctx, proof)
+ },
+ OnMessage: func(_ string, msg *pb.PeerMessage) {
+ if msg.GetFetch() != nil {
+ select {
+ case received <- msg.GetFetch().GetClipId():
+ default:
+ }
+ }
+ },
+ })
+ defer self.p2p.Close()
+ self.signal = signaling.New(signaling.Options{Identity: self.id, URL: *signalURL, DialHeaders: func(string) http.Header { return gateway.SignalHeaders(self.id) }, PublicKeyOf: func(id string) ed25519.PublicKey {
+ if id == peer.id.DeviceID {
+ return peer.id.PublicKey
+ }
+ return nil
+ }, DeviceInfo: func() (string, string, []string) { return "PasteFerry smoke fixture", "", []string{peer.id.DeviceID} }, Handlers: signaling.Handlers{OnConnected: func() { self.connected.Store(true) }, OnPresence: func(id string, online bool) {
+ if id == peer.id.DeviceID {
+ self.online.Store(online)
+ }
+ }, OnIceConfig: self.p2p.SetICEServers, OnSignal: func(from string, msg *pb.SignalMessage) { _ = self.p2p.HandleSignal(ctx, from, msg) }}})
+ }
+ go a.signal.Run(ctx)
+ go b.signal.Run(ctx)
+ for !a.connected.Load() || !b.connected.Load() || !a.online.Load() || !b.online.Load() {
+ select {
+ case <-ctx.Done():
+ return errors.New("authenticated signaling/presence timed out")
+ case <-time.After(50 * time.Millisecond):
+ }
+ }
+ offerer, answerer := a, b
+ if a.id.DeviceID > b.id.DeviceID {
+ offerer, answerer = b, a
+ }
+ if err := offerer.p2p.Connect(ctx, answerer.id.DeviceID); err != nil {
+ return err
+ }
+ for a.p2p.State(b.id.DeviceID) != p2p.StateRelay || b.p2p.State(a.id.DeviceID) != p2p.StateRelay {
+ select {
+ case <-ctx.Done():
+ return errors.New("gateway relay negotiation timed out")
+ case <-time.After(50 * time.Millisecond):
+ }
+ }
+ if err := a.p2p.Send(b.id.DeviceID, &pb.PeerMessage{Payload: &pb.PeerMessage_Fetch{Fetch: &pb.PeerFetch{ClipId: "gateway-smoke-ciphertext"}}}); err != nil {
+ return err
+ }
+ select {
+ case got := <-received:
+ if got != "gateway-smoke-ciphertext" {
+ return errors.New("wrong peer payload")
+ }
+ case <-ctx.Done():
+ return errors.New("encrypted transfer timed out")
+ }
+ return json.NewEncoder(os.Stdout).Encode(map[string]bool{"authenticated_signaling": true, "direct_first": true, "standard_turn": true, "gateway_relay": true, "encrypted_transfer": true})
+}
diff --git a/client-core/cmd/pasteferryd/main.go b/client-core/cmd/pasteferryd/main.go
index d6e4e2d..38c126a 100644
--- a/client-core/cmd/pasteferryd/main.go
+++ b/client-core/cmd/pasteferryd/main.go
@@ -312,14 +312,14 @@ func run(dataDir string) error {
if err := saveCfg(c); err != nil {
return err
}
- if c.SignalingURL != prev.SignalingURL {
- slog.Info("信令服务器地址已变更", "from", prev.SignalingURL, "to", c.SignalingURL)
- peerMgr.SetSignalingURL(c.SignalingURL)
+ if c.EffectiveSignalingURL() != prev.EffectiveSignalingURL() || c.ServiceMode != prev.ServiceMode {
+ slog.Info("公网连接模式已变更")
+ peerMgr.SetSignalingURL(c.EffectiveSignalingURL())
}
if c.LANDisabled != prev.LANDisabled {
peerMgr.SetLANEnabled(!c.LANDisabled)
}
- if c.SignalingURL != prev.SignalingURL || c.LANDisabled != prev.LANDisabled {
+ if c.EffectiveSignalingURL() != prev.EffectiveSignalingURL() || c.ServiceMode != prev.ServiceMode || c.LANDisabled != prev.LANDisabled {
select {
case statusDirty <- struct{}{}:
default:
@@ -363,6 +363,7 @@ func run(dataDir string) error {
SearchHistory: engine.SearchHistory,
ImagePreview: engine.ImagePreview,
CacheBytesUsed: blobs.Size,
+ OfficialUsage: peerMgr.OfficialUsage,
Permission: func() clipboard.Permission {
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()
diff --git a/client-core/go.mod b/client-core/go.mod
index 2cb7989..ae390c6 100644
--- a/client-core/go.mod
+++ b/client-core/go.mod
@@ -1,31 +1,36 @@
module github.com/baiyuze/pasteferry/client-core
-go 1.26.3
+go 1.26.9
require modernc.org/sqlite v1.59.0
require (
github.com/dustin/go-humanize v1.0.1 // indirect
+ github.com/ebitengine/purego v0.11.1 // indirect
+ github.com/go-ole/go-ole v1.2.6 // indirect
github.com/google/uuid v1.6.0 // indirect
+ github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mattn/go-isatty v0.0.24 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
- github.com/pion/datachannel v1.6.2 // indirect
- github.com/pion/dtls/v3 v3.1.8 // indirect
- github.com/pion/interceptor v0.1.48 // indirect
+ github.com/pion/datachannel v1.6.3 // indirect
+ github.com/pion/dtls/v3 v3.1.10 // indirect
+ github.com/pion/interceptor v0.1.49 // indirect
github.com/pion/randutil v0.1.0 // indirect
- github.com/pion/rtcp v1.2.17 // indirect
+ github.com/pion/rtcp v1.2.19 // indirect
github.com/pion/rtp v1.10.5 // indirect
- github.com/pion/sctp v1.11.1 // indirect
- github.com/pion/sdp/v3 v3.0.19 // indirect
- github.com/pion/srtp/v3 v3.0.13 // indirect
- github.com/pion/stun/v3 v3.0.1 // indirect
- github.com/pion/transport/v3 v3.0.8 // indirect
+ github.com/pion/sctp v1.12.0 // indirect
+ github.com/pion/sdp/v3 v3.0.20 // indirect
+ github.com/pion/srtp/v3 v3.1.3 // indirect
+ github.com/pion/stun/v3 v3.1.5 // indirect
github.com/pion/transport/v4 v4.1.0 // indirect
github.com/pion/turn/v4 v4.1.4 // indirect
- github.com/pion/turn/v5 v5.1.0 // indirect
+ github.com/power-devops/perfstat v0.0.0-20260805114148-88456608a4f6 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
+ github.com/tklauser/go-sysconf v0.4.0 // indirect
+ github.com/tklauser/numcpus v0.12.0 // indirect
github.com/wlynxg/anet v0.0.5 // indirect
- golang.org/x/crypto v0.54.0 // indirect
+ github.com/yusufpapurcu/wmi v1.2.4 // indirect
+ golang.org/x/crypto v0.57.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 // indirect
modernc.org/libc v1.75.7 // indirect
@@ -46,14 +51,17 @@ require (
github.com/baiyuze/pasteferry/server v0.0.0
github.com/jezek/xgb v1.3.1
github.com/klauspost/compress v1.20.0
- github.com/pion/ice/v4 v4.4.2
+ github.com/pion/ice/v4 v4.4.7
github.com/pion/logging v0.2.4
- github.com/pion/mdns/v2 v2.2.0
- github.com/pion/stun/v4 v4.0.0
- github.com/pion/webrtc/v4 v4.2.20
- golang.org/x/net v0.57.0
- golang.org/x/sys v0.47.0
- golang.org/x/text v0.40.0
+ github.com/pion/mdns/v2 v2.2.2
+ github.com/pion/stun/v4 v4.0.1
+ github.com/pion/transport/v5 v5.1.1
+ github.com/pion/turn/v5 v5.1.2
+ github.com/pion/webrtc/v4 v4.2.23
+ github.com/shirou/gopsutil/v4 v4.26.9
+ golang.org/x/net v0.60.0
+ golang.org/x/sys v0.48.0
+ golang.org/x/text v0.42.0
)
replace github.com/baiyuze/pasteferry/server => ../server
diff --git a/client-core/go.sum b/client-core/go.sum
index 9df31be..266c7a8 100644
--- a/client-core/go.sum
+++ b/client-core/go.sum
@@ -2,8 +2,13 @@ github.com/coder/websocket v1.8.15 h1:6B2JPeOGlpff2Uz6vOEH1Vzpi0iUz20A+lPVhPHtNU
github.com/coder/websocket v1.8.15/go.mod h1:NX3SzP+inril6yawo5CQXx8+fk145lPDC6pumgx0mVg=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
+github.com/ebitengine/purego v0.11.1 h1:2zpWRSQNVKN4eKsKO9eM1ILDgWfYMY9GwqRmK6XeQ/0=
+github.com/ebitengine/purego v0.11.1/go.mod h1:DCHPP08djqhNSoTfImcnHYQRZmd0qhakvrozqaEYhGQ=
+github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
+github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
+github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo=
@@ -16,72 +21,87 @@ github.com/jezek/xgb v1.3.1 h1:NQCAEfQyzN+3RjWUSHBuVIxQcy2YfG3/mNvKfs/0rEg=
github.com/jezek/xgb v1.3.1/go.mod h1:nrhwO0FX/enq75I7Y7G8iN1ubpSGZEiA3v9e9GyRFlk=
github.com/klauspost/compress v1.20.0 h1:a3C1ke2ohxFymNlb2HWAHjDeKCI90scRskErZkR0ezA=
github.com/klauspost/compress v1.20.0/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
+github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
+github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=
github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
-github.com/pion/datachannel v1.6.2 h1:7EXQ8TH3vTouBUdRWYbcX2edSx9Yj6k5zl5P+qyxEPc=
-github.com/pion/datachannel v1.6.2/go.mod h1:pzbdAZvyGtXbcHM1hBbsFaOTf40lZizU/dNlvVOak6E=
-github.com/pion/dtls/v3 v3.1.8 h1:aLcgjZqzrYn5AbjSds4LvK2WI5VzJc1PencExyDjYis=
-github.com/pion/dtls/v3 v3.1.8/go.mod h1:gz1K4jg6c+fq86oQMH4pilpCEOEPwmEr2jY+VcF/mkU=
-github.com/pion/ice/v4 v4.4.2 h1:asS17nbHJrzlVQl8fiSJaipxrxSY3Dq6DWgmB+0VwpI=
-github.com/pion/ice/v4 v4.4.2/go.mod h1:YZgNFOyJWXpLpLj0mb4ccqNAWRo9C2RtqKwuVTEz0Sc=
-github.com/pion/interceptor v0.1.48 h1:FF4gZ6Yh+N75gKMYpC7rYR8DdkiMBFtA7V2OBUKo7XQ=
-github.com/pion/interceptor v0.1.48/go.mod h1:5mg/N5xXMAa4codCUdrJYY9I1y4tVQhlpd7rfwAJpvI=
+github.com/pion/datachannel v1.6.3 h1:HZAYLpunVI0xi057ZiANl558d0uSpomcWw4UEPz3qXs=
+github.com/pion/datachannel v1.6.3/go.mod h1:oRmkXVVXxkUbqa8MatgdNHW29kvtQY3HUdjJQsfv2GE=
+github.com/pion/dtls/v3 v3.1.10 h1:HWC+QCZitP/ApADS/6+g7UIw2YmLgoK3CsynnjPJgMo=
+github.com/pion/dtls/v3 v3.1.10/go.mod h1:iKFQNYrjsN2TiA2YKKMqB9MOZaFpjFULBI/A4sW0eyc=
+github.com/pion/ice/v4 v4.4.7 h1:JiI6VId3XnIztxKE8RjTC0SeXrp7ppkAO0jGez3/sIE=
+github.com/pion/ice/v4 v4.4.7/go.mod h1:zCRRg4Mkpdbx9B+75fd4z2APvIXeIraeUOB7IMPt8mU=
+github.com/pion/interceptor v0.1.49 h1:iyBsNHRoLNNXZiJA/DdGvJgdyfS8YWDCzxIAlVjt5nY=
+github.com/pion/interceptor v0.1.49/go.mod h1:MZ6PJkja/TCo350HAnBrs/rUIyad9mWjpcvytrf3ViQ=
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
-github.com/pion/mdns/v2 v2.2.0 h1:AlAZ9MTUKtWgO+4itk35JdNak4sk5k7G/X4xnIBWHyA=
-github.com/pion/mdns/v2 v2.2.0/go.mod h1:IJddx58QMlojqhQYjHcOUmvuBQ5MnLNetkb80VMvk2Y=
+github.com/pion/mdns/v2 v2.2.2 h1:qq9Kj3PnjF0mfSwd8Icu0CXy5aoYdQKnNUIsGPeUpgk=
+github.com/pion/mdns/v2 v2.2.2/go.mod h1:ZX5f0AAH1D6TOjdjvcBORZZHaZuG0t9+br78lHEwiJ4=
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
-github.com/pion/rtcp v1.2.17 h1:PxiT6L79yPZKtXIsXdG1eakBl6dtBj4x+4oVEL0DlSw=
-github.com/pion/rtcp v1.2.17/go.mod h1:7kBpuBJaWwax4hzc/pgexY8vkOpvh8atgYDbaKZq0iU=
+github.com/pion/rtcp v1.2.19 h1:T79lR2Tfd/7zj+41nsUrftrUEee+Z03NQr9GSPSQ/WU=
+github.com/pion/rtcp v1.2.19/go.mod h1:vX7Es6skWYm4oVvOSC5+4WHLYUTZHcbGNmk5wjzMGH4=
github.com/pion/rtp v1.10.5 h1:ip0HhO/wYZqQ4bKS+R99KnZh/GRCmIT0jDXikub7vlE=
github.com/pion/rtp v1.10.5/go.mod h1:Au8fc6cEByy8RLTwKTQTEeQqDB/SJDxwL4mZuxYA5Pk=
-github.com/pion/sctp v1.11.1 h1:O4dIFyURw1KTST7w+gtD4gLeYXkhPa0xXLHMMoe/OSA=
-github.com/pion/sctp v1.11.1/go.mod h1:7KFmTwLcoYgJs/Z+99nJvsWL0qDpuyloSI0RbAqlrz0=
-github.com/pion/sdp/v3 v3.0.19 h1:1VMKs3gIkTQV5M3hNKfTAPrDXSNrYtOlmOD8+mSZUGQ=
-github.com/pion/sdp/v3 v3.0.19/go.mod h1:dE5WOSlzXrtiE/iuZqe9n+AcEbOjtAd3k5m5NtlV/qU=
-github.com/pion/srtp/v3 v3.0.13 h1:FmQaqgNbN1vUtMhEsmj8trldc3lNZr1xmN7nl8CyX+Q=
-github.com/pion/srtp/v3 v3.0.13/go.mod h1:7qR3L69t8RX0EPVQwGNwCa1Gy9keKKNDpWwQzZbeXDY=
-github.com/pion/stun/v3 v3.0.1 h1:jx1uUq6BdPihF0yF33Jj2mh+C9p0atY94IkdnW174kA=
-github.com/pion/stun/v3 v3.0.1/go.mod h1:RHnvlKFg+qHgoKIqtQWMOJF52wsImCAf/Jh5GjX+4Tw=
-github.com/pion/stun/v4 v4.0.0 h1:UuQy2q6iZR4EnMl/+G8kAtaWhf7jx/u8ZyN9oD4+YEQ=
-github.com/pion/stun/v4 v4.0.0/go.mod h1:JAojPsPtDH4iPeNQb7kvxBdzypmkWAROxy0coApKH2E=
-github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
-github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
+github.com/pion/sctp v1.12.0 h1:AzUdVkVBNyGY1W4crWO1/aOWzMaW3zsVHGrNuAfFQiI=
+github.com/pion/sctp v1.12.0/go.mod h1:6k1zrpkrxSwbisitn/AlzDQaa15DR49MFsrMochG/yc=
+github.com/pion/sdp/v3 v3.0.20 h1:TS6DViqcmp+49f0+mjw9anbr9xY3vJtsZewxAvlMCRQ=
+github.com/pion/sdp/v3 v3.0.20/go.mod h1:slIMXDK5OKj0nhISwjfeN18AzTBCt2LYZq9uPw0cU5Q=
+github.com/pion/srtp/v3 v3.1.3 h1:O3sfbfWfq/OyEaXRbX02Z0SNQRijS9nDdc/DEb8jxlU=
+github.com/pion/srtp/v3 v3.1.3/go.mod h1:v3uQtrCz9LH3aahau0jtzRDsWGwKkh4a0BiBwzzxhtQ=
+github.com/pion/stun/v3 v3.1.5 h1:Y1FHlhaI6+4UoC5i/zQf4F7JvdZtB24/05oyy/GF1x8=
+github.com/pion/stun/v3 v3.1.5/go.mod h1:zRUghXSQU32Lx5orJsz3uYMkIihweXb3mu5gIns02fs=
+github.com/pion/stun/v4 v4.0.1 h1:S2ggK4hsUJJKoZfpL90uIqIRTj6xJ0NOIEkXgcpQif0=
+github.com/pion/stun/v4 v4.0.1/go.mod h1:byktbPA8U7HjJ2H8w3moP7nzq0Q+kYNulvMLPaubQL4=
github.com/pion/transport/v4 v4.1.0 h1:8S+nF2reM2cJuqC6g78OVy2BBgmbdns+acx3jA97BvQ=
github.com/pion/transport/v4 v4.1.0/go.mod h1:06hFI+jCFcok2X2MekVufNZ/uzNZXivGBPfviSVcjgM=
+github.com/pion/transport/v5 v5.1.1 h1:Sauq8YJqRopgRfIgnpfKpdpKG14g0N4jWlRgpWsEfN8=
+github.com/pion/transport/v5 v5.1.1/go.mod h1:Qxw6fCEjFWQkRDZOhS4Vf+neJBcihauvA3uyEa1J1F0=
github.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=
github.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=
-github.com/pion/turn/v5 v5.1.0 h1:OSzLub7q4GssG1P4BEVrz39MnnJlxLy1LOvEkP9f46o=
-github.com/pion/turn/v5 v5.1.0/go.mod h1:6HJQO7UAe7pEPMrTtBrmj+tTfp+Ai8KAV2+GXHFi1nQ=
-github.com/pion/webrtc/v4 v4.2.20 h1:NYiNhBTFArA8aoP18a30y4LN0dyqSrF65HxU7KnhNOo=
-github.com/pion/webrtc/v4 v4.2.20/go.mod h1:aLGXbekuN0tHOu7IPX1o9Y/uN29Ovfjaaz4bL2P9ND8=
+github.com/pion/turn/v5 v5.1.2 h1:acEOO+D5txJ52vKfcilmSMItfP23Q9K6pJ1LM5P2VV0=
+github.com/pion/turn/v5 v5.1.2/go.mod h1:57Oadc8fHnac15VFyCd6nEaBTVZBxQe2POUMD4lsHRA=
+github.com/pion/webrtc/v4 v4.2.23 h1:AlVixhTtQmxrheSv6lAH0w2sH5qjM7OTos5Lt811nk0=
+github.com/pion/webrtc/v4 v4.2.23/go.mod h1:vzf5RQ0uMBuXAYTK2pabZUtnZyj2t3TF88eL4xzQZvI=
+github.com/power-devops/perfstat v0.0.0-20260805114148-88456608a4f6 h1:jL3a8soXdzuTCcRnKhOmtcsVOObdDTFf4O2B403HPRU=
+github.com/power-devops/perfstat v0.0.0-20260805114148-88456608a4f6/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
+github.com/shirou/gopsutil/v4 v4.26.9 h1:CaBo/hBFqvlJoLvAQEKdHdf5GD97/MN2ACfyv63+2Ig=
+github.com/shirou/gopsutil/v4 v4.26.9/go.mod h1:nKH+8wX2zxr/mDbsR+AAy6Qd2z4ZOQ7wfQaEp+yrYmg=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
+github.com/tklauser/go-sysconf v0.4.0 h1:7H0uAN+7RkwWRaxhYXDLqa5V3LPrJeV8wmD9dRUgPQU=
+github.com/tklauser/go-sysconf v0.4.0/go.mod h1:8mTNWyog7H+MpKijp4VmKJAd2bbYQ2zuUwkYRbUArPI=
+github.com/tklauser/numcpus v0.12.0 h1:NR85qdvHA9pFse3x3weVZ0r0ST8R6l5RHbZrlRaqob4=
+github.com/tklauser/numcpus v0.12.0/go.mod h1:ABHeXzJnr/qqwguhClkZKT1/8VABcYrsyUiUGobwWJg=
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
+github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
+github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
-golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
-golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
-golang.org/x/mod v0.38.0 h1:MECBjubtXD7yj4HrhIUcywNaGeNVUdfVnxmPajOk4yk=
-golang.org/x/mod v0.38.0/go.mod h1:V6Xz0pq8TQ3dGqVQ1FVHuelZpAL0uNhSkk9ogYP3c40=
-golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
-golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
-golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
-golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
-golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
-golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
-golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
-golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
+golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
+golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
+golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
+golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
+golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
+golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
+golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
+golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
+golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
+golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
+golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
+golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
-golang.org/x/tools v0.48.0 h1:3+hClM1aLL5mjMKm5ovokw9epgRXPuu2tILgismM6RE=
-golang.org/x/tools v0.48.0/go.mod h1:08xX0orndb/F7jJxGDicx061tyd5pcMto75YMAXr6lk=
+golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
+golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 h1:qEHAMpSaUhtD0p3NbEEI83HwNGFxEwaSJ1G9PLnCBZE=
diff --git a/client-core/internal/config/config.go b/client-core/internal/config/config.go
index 46b6d5d..8c0c6b7 100644
--- a/client-core/internal/config/config.go
+++ b/client-core/internal/config/config.go
@@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io/fs"
+ "net/url"
"os"
"path/filepath"
"runtime"
@@ -20,7 +21,10 @@ type Config struct {
DeviceName string `json:"device_name"`
// SignalingURL 是信令服务器地址。可以为空:同一局域网里的设备不需要服务器,
// 只有跨网络同步时才要填。
- SignalingURL string `json:"signaling_url"`
+ SignalingURL string `json:"signaling_url"`
+ ServiceMode string `json:"service_mode,omitempty"`
+ CustomSignalingURL string `json:"custom_signaling_url,omitempty"`
+ OfficialNoticeAck string `json:"official_notice_ack,omitempty"`
// 小于此值的内容在复制时自动推送给对端;大于则只同步元数据,
// 等用户在 UI 里手动拉取。这是 M-1 否决纯懒模式后的折中点。
@@ -54,7 +58,30 @@ type Config struct {
// CurrentVersion 是当前的配置格式版本。
//
// 版本 2(1.4.0):服务器变成可选,默认地址从 ws://127.0.0.1:8787/signal 改为空。
-const CurrentVersion = 2
+const CurrentVersion = 3
+
+const OfficialSignalURL = "wss://rtccpwsapi1.pasteferry.cc/signal"
+
+func (c Config) Official() bool { return c.ServiceMode == "official" }
+
+// UsesOfficialEndpoint hides system metadata even when an official address was
+// manually entered in custom mode. It does not enable gateway authorization.
+func (c Config) UsesOfficialEndpoint() bool {
+ u, err := url.Parse(c.EffectiveSignalingURL())
+ return err == nil && (u.Hostname() == "rtccpwsapi1.pasteferry.cc" || u.Hostname() == "pasteferry.cc")
+}
+func (c Config) EffectiveSignalingURL() string {
+ switch c.ServiceMode {
+ case "official":
+ return OfficialSignalURL
+ case "lan":
+ return ""
+ case "custom":
+ return c.CustomSignalingURL
+ default:
+ return c.SignalingURL
+ }
+}
// legacyDefaultURL 是 1.4.0 之前的默认服务器地址。没改过它的用户其实没有服务器,
// 升级后应当直接进入局域网模式,而不是一直显示「服务器连不上」。
@@ -83,6 +110,14 @@ func Default() Config {
// Validate 修正越界值,避免用户或损坏的配置文件把 daemon 带进坏状态。
func (c *Config) Validate() {
d := Default()
+ if c.ServiceMode != "" && c.ServiceMode != "lan" && c.ServiceMode != "official" && c.ServiceMode != "custom" {
+ c.ServiceMode = "lan"
+ }
+ if c.ServiceMode == "custom" {
+ c.SignalingURL = c.CustomSignalingURL
+ } else if c.ServiceMode == "official" || c.ServiceMode == "lan" {
+ c.SignalingURL = ""
+ }
if c.DeviceName == "" {
c.DeviceName = d.DeviceName
}
@@ -256,6 +291,18 @@ func (c *Config) migrate() bool {
if c.Version < 2 && c.SignalingURL == legacyDefaultURL {
c.SignalingURL = ""
}
+ if c.Version < 3 {
+ switch c.SignalingURL {
+ case OfficialSignalURL, "wss://pasteferry.cc/signal":
+ c.ServiceMode = "official"
+ c.SignalingURL = ""
+ case "":
+ c.ServiceMode = "lan"
+ default:
+ c.ServiceMode = "custom"
+ c.CustomSignalingURL = c.SignalingURL
+ }
+ }
c.Version = CurrentVersion
return true
}
diff --git a/client-core/internal/diag/redact.go b/client-core/internal/diag/redact.go
index abdb480..4355b60 100644
--- a/client-core/internal/diag/redact.go
+++ b/client-core/internal/diag/redact.go
@@ -60,9 +60,11 @@ func newRedactor(in Input) *redactor {
}
// 服务器:主机名或公网 IP 换掉,协议、端口、路径留着,排查时用得上
- if u, err := url.Parse(in.Config.SignalingURL); err == nil {
- if host := u.Hostname(); host != "" && !keepIP(host) {
- add(host, "<server>")
+ for _, address := range []string{in.Config.EffectiveSignalingURL(), in.Config.SignalingURL, in.Config.CustomSignalingURL} {
+ if u, err := url.Parse(address); err == nil {
+ if host := u.Hostname(); host != "" && !keepIP(host) {
+ add(host, "<server>")
+ }
}
}
diff --git a/client-core/internal/diag/report.go b/client-core/internal/diag/report.go
index 38b73a3..dd228b8 100644
--- a/client-core/internal/diag/report.go
+++ b/client-core/internal/diag/report.go
@@ -57,7 +57,8 @@ func Build(in Input) string {
c := in.Config
line("")
line("Settings")
- row("Server", or(c.SignalingURL, "not set"))
+ row("Service mode", or(c.ServiceMode, "lan or legacy custom"))
+ row("Server", or(c.EffectiveSignalingURL(), "not set"))
row("Find devices on LAN", onOff(!c.LANDisabled))
row("Public STUN servers", onOff(!c.OnlyOwnSTUN))
row("Auto-sync limit", fmt.Sprintf("%d MB", c.AutoSyncThresholdBytes>>20))
diff --git a/client-core/internal/gateway/client.go b/client-core/internal/gateway/client.go
new file mode 100644
index 0000000..290b17c
--- /dev/null
+++ b/client-core/internal/gateway/client.go
@@ -0,0 +1,275 @@
+package gateway
+
+import (
+ "bytes"
+ "context"
+ "encoding/json"
+ "errors"
+ "io"
+ "net/http"
+ "net/url"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/baiyuze/pasteferry/client-core/internal/identity"
+)
+
+type Client struct {
+ id *identity.Identity
+ base string
+ http *http.Client
+ mu sync.Mutex
+ access map[string]Access
+ peers map[string]string
+ conns map[*packetConn]bool
+ last Usage
+ usageAccess Access
+ onUsage func(Usage)
+ enabled bool
+ root context.Context
+ cancel context.CancelFunc
+}
+
+func (c *Client) ReportError(err error) {
+ u := c.Usage()
+ var ge *Error
+ if errors.As(err, &ge) {
+ if ge.Usage != nil {
+ u = *ge.Usage
+ }
+ u.Reason = ge.Code
+ } else if u.Reason == "" {
+ u.Available = false
+ u.Reason = "service_unavailable"
+ }
+ c.update(u)
+}
+
+func NewClient(id *identity.Identity, base string, onUsage func(Usage)) (*Client, error) {
+ u, err := url.Parse(base)
+ if err != nil || u.Host == "" || u.RawQuery != "" || u.User != nil || u.Fragment != "" {
+ return nil, errors.New("invalid gateway URL")
+ }
+ if u.Scheme != "https" && !(u.Scheme == "http" && (u.Hostname() == "127.0.0.1" || u.Hostname() == "localhost")) {
+ return nil, errors.New("gateway requires HTTPS")
+ }
+ root, cancel := context.WithCancel(context.Background())
+ return &Client{id: id, base: strings.TrimRight(base, "/"), http: &http.Client{Timeout: 15 * time.Second, CheckRedirect: func(*http.Request, []*http.Request) error { return errors.New("gateway redirects are not allowed") }}, access: map[string]Access{}, peers: map[string]string{}, conns: map[*packetConn]bool{}, onUsage: onUsage, enabled: true, root: root, cancel: cancel}, nil
+}
+
+func (c *Client) SetEnabled(enabled bool) {
+ if !enabled {
+ c.Close()
+ return
+ }
+ c.mu.Lock()
+ if !c.enabled {
+ c.root, c.cancel = context.WithCancel(context.Background())
+ c.enabled = true
+ }
+ c.mu.Unlock()
+}
+func (c *Client) request(ctx context.Context, method, path, token string, body, out any) error {
+ c.mu.Lock()
+ enabled, root := c.enabled, c.root
+ c.mu.Unlock()
+ if !enabled {
+ return &Error{Code: "disabled"}
+ }
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ stop := context.AfterFunc(root, cancel)
+ defer stop()
+ var r io.Reader
+ if body != nil {
+ b, err := json.Marshal(body)
+ if err != nil {
+ return err
+ }
+ r = bytes.NewReader(b)
+ }
+ req, err := http.NewRequestWithContext(ctx, method, c.base+"/gateway/v1/"+path, r)
+ if err != nil {
+ return err
+ }
+ if body != nil {
+ req.Header.Set("Content-Type", "application/json")
+ }
+ if token != "" {
+ req.Header.Set("Authorization", "Bearer "+token)
+ }
+ resp, err := c.http.Do(req)
+ if err != nil {
+ return errors.New("official service unavailable")
+ }
+ defer resp.Body.Close()
+ d := json.NewDecoder(io.LimitReader(resp.Body, 32768))
+ if resp.StatusCode != 200 {
+ e := &Error{Code: "service_unavailable"}
+ _ = d.Decode(e)
+ if e.Usage != nil {
+ c.update(*e.Usage)
+ }
+ return e
+ }
+ return d.Decode(out)
+}
+func (c *Client) update(u Usage) {
+ c.mu.Lock()
+ if !c.enabled {
+ c.mu.Unlock()
+ return
+ }
+ c.last = u
+ c.mu.Unlock()
+ if c.onUsage != nil {
+ c.onUsage(u)
+ }
+}
+func (c *Client) Usage() Usage { c.mu.Lock(); defer c.mu.Unlock(); return c.last }
+func (c *Client) Authorize(ctx context.Context, peer, session string) (Access, error) {
+ var nonce struct {
+ Nonce string `json:"nonce"`
+ }
+ if err := c.request(ctx, "GET", "challenge", "", nil, &nonce); err != nil {
+ return Access{}, err
+ }
+ // The only machine-ID read in the application happens after direct failure.
+ p := proof(c.id, "relay", nonce.Nonce, peer, session, MachineDigest())
+ var a Access
+ if err := c.request(ctx, "POST", "authorize", "", p, &a); err != nil {
+ var ge *Error
+ if errors.As(err, &ge) && ge.UsageToken != "" && ge.ExpiresAt > time.Now().Unix() {
+ c.mu.Lock()
+ if c.enabled {
+ c.usageAccess = Access{Token: ge.UsageToken, ExpiresAt: ge.ExpiresAt}
+ }
+ c.mu.Unlock()
+ }
+ return Access{}, err
+ }
+ if a.Token == "" || a.ExpiresAt <= time.Now().Unix() {
+ return Access{}, errors.New("invalid gateway response")
+ }
+ c.mu.Lock()
+ if !c.enabled {
+ c.mu.Unlock()
+ return Access{}, &Error{Code: "disabled"}
+ }
+ c.access[session] = a
+ c.usageAccess = a
+ c.peers[session] = peer
+ conns := make([]*packetConn, 0)
+ for conn := range c.conns {
+ if conn.session == session {
+ conns = append(conns, conn)
+ }
+ }
+ c.mu.Unlock()
+ for _, conn := range conns {
+ conn.refresh(a.Token)
+ }
+ c.update(a.Usage)
+ return a, nil
+}
+func (c *Client) Run(ctx context.Context) {
+ ticker := time.NewTicker(15 * time.Second)
+ defer ticker.Stop()
+ defer c.Close()
+ for {
+ select {
+ case <-ctx.Done():
+ return
+ case <-ticker.C:
+ c.mu.Lock()
+ owner := c.usageAccess
+ sessions := make(map[string]Access, len(c.access))
+ peers := make(map[string]string, len(c.peers))
+ for k, v := range c.access {
+ sessions[k] = v
+ peers[k] = c.peers[k]
+ }
+ c.mu.Unlock()
+ if len(sessions) == 0 && owner.Token != "" {
+ var err error
+ if time.Now().Unix() >= owner.ExpiresAt-120 {
+ err = c.refreshUsage(ctx)
+ } else {
+ var u Usage
+ err = c.request(ctx, "GET", "usage", owner.Token, nil, &u)
+ if err == nil {
+ c.update(u)
+ }
+ }
+ if err != nil {
+ c.ReportError(err)
+ }
+ }
+ for session, a := range sessions {
+ var err error
+ if time.Now().Unix() >= a.ExpiresAt-120 {
+ _, err = c.Authorize(ctx, peers[session], session)
+ } else {
+ var u Usage
+ err = c.request(ctx, "GET", "usage", a.Token, nil, &u)
+ if err == nil {
+ c.update(u)
+ }
+ }
+ if err != nil {
+ u := c.Usage()
+ u.Available = false
+ u.Reason = "service_unavailable"
+ var ge *Error
+ if errors.As(err, &ge) {
+ u.Reason = ge.Code
+ }
+ c.update(u)
+ }
+ }
+ }
+ }
+}
+func (c *Client) Close() {
+ c.mu.Lock()
+ c.enabled = false
+ c.cancel()
+ cs := make([]*packetConn, 0, len(c.conns))
+ for x := range c.conns {
+ cs = append(cs, x)
+ }
+ c.access = map[string]Access{}
+ c.peers = map[string]string{}
+ c.usageAccess = Access{}
+ c.mu.Unlock()
+ for _, x := range cs {
+ x.Close()
+ }
+}
+
+func (c *Client) ReleaseSession(session string) {
+ c.mu.Lock()
+ delete(c.access, session)
+ delete(c.peers, session)
+ c.mu.Unlock()
+}
+func (c *Client) refreshUsage(ctx context.Context) error {
+ var nonce struct {
+ Nonce string `json:"nonce"`
+ }
+ if err := c.request(ctx, "GET", "challenge", "", nil, &nonce); err != nil {
+ return err
+ }
+ var a Access
+ if err := c.request(ctx, "POST", "authorize", "", proof(c.id, "usage", nonce.Nonce, "", "", ""), &a); err != nil {
+ return err
+ }
+ c.mu.Lock()
+ if c.enabled {
+ c.usageAccess = a
+ }
+ c.mu.Unlock()
+ c.update(a.Usage)
+ return nil
+}
diff --git a/client-core/internal/gateway/gateway_test.go b/client-core/internal/gateway/gateway_test.go
new file mode 100644
index 0000000..8a5a2d4
--- /dev/null
+++ b/client-core/internal/gateway/gateway_test.go
@@ -0,0 +1,255 @@
+package gateway
+
+import (
+ "context"
+ "crypto/ed25519"
+ "crypto/sha256"
+ "database/sql"
+ "fmt"
+ "net"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/baiyuze/pasteferry/client-core/internal/identity"
+ "github.com/baiyuze/pasteferry/server/relay"
+ "github.com/pion/transport/v5/stdnet"
+ "github.com/pion/turn/v5"
+ _ "modernc.org/sqlite"
+)
+
+func TestMachineIDPolicy(t *testing.T) {
+ var paths []string
+ read := func(path string) ([]byte, error) {
+ paths = append(paths, path)
+ if path == "/etc/machine-id" {
+ return []byte("invalid"), nil
+ }
+ if path == "/var/lib/dbus/machine-id" {
+ return []byte("1234567890abcdef1234567890abcdef"), nil
+ }
+ return nil, os.ErrNotExist
+ }
+ raw, err := readMachineID(context.Background(), "linux", read, func(context.Context) (string, error) { t.Fatal("Linux must not call host fallback"); return "", nil })
+ if err != nil || raw == "" || len(paths) != 2 {
+ t.Fatal(raw, paths, err)
+ }
+ for _, bad := range []string{"", "00000000000000000000000000000000", "ffffffffffffffffffffffffffffffff", "unknown", "123"} {
+ if _, err := normalizeMachineID(bad); err == nil {
+ t.Fatalf("accepted %q", bad)
+ }
+ }
+}
+func TestSignedProof(t *testing.T) {
+ id := identity.FromSeed(make([]byte, 32))
+ p := proof(id, "relay", "nonce", "peer", "session", "")
+ sig := p.Signature
+ p.PeerID = "someone-else"
+ if p.Signature != sig {
+ t.Fatal("test invalid")
+ }
+ pub := id.PublicKey
+ _ = pub
+ if ed25519.Verify(pub, p.Message(), id.Sign(proof(id, "relay", "nonce", "peer", "session", "").Message())) {
+ t.Fatal("signature did not bind peer")
+ }
+}
+
+func freeTCP(t *testing.T) string {
+ t.Helper()
+ l, e := net.Listen("tcp", "127.0.0.1:0")
+ if e != nil {
+ t.Fatal(e)
+ }
+ a := l.Addr().String()
+ l.Close()
+ return a
+}
+
+// This black-box test consumes only the published gateway protocol. The
+// optional private executable is never imported, linked or shipped here.
+func TestGatewayTURNBlackBox(t *testing.T) {
+ binary := os.Getenv("PF_GATEWAY_TEST_BINARY")
+ if binary == "" {
+ t.Skip("set PF_GATEWAY_TEST_BINARY to independently built gateway")
+ }
+ udp, e := net.ListenPacket("udp4", "127.0.0.1:0")
+ if e != nil {
+ t.Fatal(e)
+ }
+ port := udp.LocalAddr().(*net.UDPAddr).Port
+ udp.Close()
+ backend, e := relay.New(relay.Options{PublicIP: "127.0.0.1", ListenIP: "127.0.0.1", Port: port, Secret: "integration-only-not-a-production-secret"})
+ if e != nil {
+ t.Fatal(e)
+ }
+ defer backend.Close()
+ addr := freeTCP(t)
+ dir := t.TempDir()
+ cmd := exec.Command(binary, "serve", "-listen", addr, "-db", filepath.Join(dir, "gateway.db"), "-secret-file", filepath.Join(dir, "secret"), "-signal", "http://127.0.0.1:1", "-turn", fmt.Sprintf("127.0.0.1:%d", port), "-udp-bind", "127.0.0.1", "-stun", "")
+ cmd.Stderr = os.Stderr
+ if e = cmd.Start(); e != nil {
+ t.Fatal(e)
+ }
+ defer func() { _ = cmd.Process.Kill(); _ = cmd.Wait() }()
+ ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
+ defer cancel()
+ base := "http://" + addr
+ for {
+ res, err := http.Get(base + "/healthz")
+ if err == nil {
+ res.Body.Close()
+ break
+ }
+ select {
+ case <-ctx.Done():
+ t.Fatal("gateway failed to start")
+ case <-time.After(50 * time.Millisecond):
+ }
+ }
+ seedB := sha256.Sum256([]byte("gateway peer b"))
+ aID, bID := identity.FromSeed(make([]byte, 32)), identity.FromSeed(seedB[:])
+ a, _ := NewClient(aID, base, nil)
+ b, _ := NewClient(bID, base, nil)
+ defer a.Close()
+ defer b.Close()
+ session := "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+ if _, e = a.Authorize(ctx, bID.DeviceID, session); e != nil {
+ t.Fatal(e)
+ }
+ if _, e = b.Authorize(ctx, aID.DeviceID, session); e != nil {
+ t.Fatal(e)
+ }
+ turnAddr := fmt.Sprintf("127.0.0.1:%d", port)
+ allocate := func(c *Client, id *identity.Identity) net.PacketConn {
+ t.Helper()
+ network, err := c.Network(ctx, session, turnAddr)
+ if err != nil {
+ t.Fatal(err)
+ }
+ pc, err := network.ListenPacket("udp4", "0.0.0.0:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ cred := backend.Issue(id.DeviceID)
+ n, _ := stdnet.NewNet()
+ tc, err := turn.NewClient(&turn.ClientConfig{TURNServerAddr: turnAddr, Conn: pc, Username: cred.Username, Password: cred.Password, Realm: "pasteferry", Net: n})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = tc.Listen(); err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(tc.Close)
+ allocation, err := tc.Allocate()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { allocation.Close() })
+ return allocation
+ }
+ ca, cb := allocate(a, aID), allocate(b, bID)
+ // Establish permission in both directions before testing actual forwarding.
+ if _, e = cb.WriteTo([]byte("ready"), ca.LocalAddr()); e != nil {
+ t.Fatal(e)
+ }
+ payload := []byte("end-to-end ciphertext fixture")
+ if _, e = ca.WriteTo(payload, cb.LocalAddr()); e != nil {
+ t.Fatal(e)
+ }
+ _ = cb.SetReadDeadline(time.Now().Add(5 * time.Second))
+ buf := make([]byte, 2048)
+ n, _, e := cb.ReadFrom(buf)
+ if e != nil {
+ t.Fatal(e)
+ }
+ if string(buf[:n]) != string(payload) {
+ t.Fatalf("unexpected datagram %q", buf[:n])
+ }
+ var u Usage
+ if e = a.request(ctx, "GET", "usage", a.access[session].Token, nil, &u); e != nil {
+ t.Fatal(e)
+ }
+ if !u.Available || u.Upload < int64(len(payload)) || u.Download < int64(len(payload)) {
+ t.Fatalf("missing server accounting: %+v", u)
+ }
+ // A real UDP sink must not receive an arbitrary-target packet, even though
+ // the test TURN backend itself would allow that destination without a gate.
+ sink, err := net.ListenPacket("udp4", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer sink.Close()
+ outsideAllocation := allocate(a, aID)
+ _, _ = outsideAllocation.WriteTo([]byte("must-not-forward"), sink.LocalAddr())
+ _ = sink.SetReadDeadline(time.Now().Add(200 * time.Millisecond))
+ if n, _, err := sink.ReadFrom(buf); err == nil {
+ t.Fatalf("arbitrary proxy target received %d bytes", n)
+ }
+ // Lower a live reservation below usage. Existing channels must stop; a
+ // previously issued credential and a large held chunk cannot bypass it.
+ db, err := sql.Open("sqlite", filepath.Join(dir, "gateway.db"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer db.Close()
+ if _, err = db.Exec(`UPDATE settings SET body='{"daily_limit":0,"rate_bps":2000000,"global_limit":1000000000,"paused":false}' WHERE id=1`); err != nil {
+ t.Fatal(err)
+ }
+ time.Sleep(1200 * time.Millisecond)
+ _, _ = ca.WriteTo([]byte("over-limit"), cb.LocalAddr())
+ until := time.Now().Add(5 * time.Second)
+ for time.Now().Before(until) && a.Usage().Reason != "quota_exhausted" {
+ time.Sleep(20 * time.Millisecond)
+ }
+ if a.Usage().Reason != "quota_exhausted" {
+ t.Fatal("an existing tunnel was not stopped at quota exhaustion")
+ }
+}
+
+func TestDisabledGatewayDoesNotEnroll(t *testing.T) {
+ var requests atomic.Int32
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { requests.Add(1); w.WriteHeader(500) }))
+ defer server.Close()
+ c, _ := NewClient(identity.FromSeed(make([]byte, 32)), server.URL, nil)
+ c.SetEnabled(false)
+ if _, err := c.Authorize(context.Background(), "peer", "session"); err == nil {
+ t.Fatal("disabled gateway enrolled")
+ }
+ if requests.Load() != 0 {
+ t.Fatal("disabled mode made an official request")
+ }
+}
+
+func TestDisablingCancelsTunnelHandshake(t *testing.T) {
+ started := make(chan struct{})
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { close(started); <-r.Context().Done() }))
+ defer server.Close()
+ c, _ := NewClient(identity.FromSeed(make([]byte, 32)), server.URL, nil)
+ defer c.Close()
+ c.access["session"] = Access{Token: "test-handshake-token"}
+ done := make(chan error, 1)
+ go func() {
+ _, err := c.openPacket(context.Background(), "session", &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 3478})
+ done <- err
+ }()
+ select {
+ case <-started:
+ case <-time.After(time.Second):
+ t.Fatal("tunnel handshake did not start")
+ }
+ c.SetEnabled(false)
+ select {
+ case err := <-done:
+ if err == nil {
+ t.Fatal("disabled tunnel completed")
+ }
+ case <-time.After(time.Second):
+ t.Fatal("disabling did not cancel handshake")
+ }
+}
diff --git a/client-core/internal/gateway/machine.go b/client-core/internal/gateway/machine.go
new file mode 100644
index 0000000..20afc6e
--- /dev/null
+++ b/client-core/internal/gateway/machine.go
@@ -0,0 +1,78 @@
+package gateway
+
+import (
+ "context"
+ "crypto/hmac"
+ "crypto/sha256"
+ "encoding/hex"
+ "errors"
+ "os"
+ "runtime"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/shirou/gopsutil/v4/host"
+)
+
+var machineOnce sync.Once
+var machineDigest string
+
+// MachineDigest is called only from relay authorization, never at startup.
+// An unavailable identifier leaves the server's previous binding intact.
+func MachineDigest() string {
+ machineOnce.Do(func() {
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
+ defer cancel()
+ raw, err := readMachineID(ctx, runtime.GOOS, os.ReadFile, host.HostIDWithContext)
+ if err != nil {
+ return
+ }
+ normalized, err := normalizeMachineID(raw)
+ if err != nil {
+ return
+ }
+ mac := hmac.New(sha256.New, []byte("PasteFerry official relay quota v1"))
+ mac.Write([]byte(normalized))
+ machineDigest = "v1:" + hex.EncodeToString(mac.Sum(nil))
+ })
+ return machineDigest
+}
+
+func readMachineID(ctx context.Context, platform string, read func(string) ([]byte, error), hostID func(context.Context) (string, error)) (string, error) {
+ if platform != "linux" {
+ return hostID(ctx)
+ }
+ for _, path := range []string{"/etc/machine-id", "/var/lib/dbus/machine-id"} {
+ if ctx.Err() != nil {
+ return "", ctx.Err()
+ }
+ if b, err := read(path); err == nil {
+ if _, err = normalizeMachineID(string(b)); err == nil {
+ return string(b), nil
+ }
+ }
+ }
+ return "", errors.New("stable machine ID unavailable")
+}
+
+func normalizeMachineID(raw string) (string, error) {
+ s := strings.ToLower(strings.TrimSpace(raw))
+ s = strings.ReplaceAll(s, "-", "")
+ if len(s) != 32 {
+ return "", errors.New("invalid machine ID")
+ }
+ b, err := hex.DecodeString(s)
+ if err != nil {
+ return "", err
+ }
+ allZero, allFF := true, true
+ for _, v := range b {
+ allZero = allZero && v == 0
+ allFF = allFF && v == 255
+ }
+ if allZero || allFF {
+ return "", errors.New("invalid machine ID")
+ }
+ return s, nil
+}
diff --git a/client-core/internal/gateway/net.go b/client-core/internal/gateway/net.go
new file mode 100644
index 0000000..a03bb8b
--- /dev/null
+++ b/client-core/internal/gateway/net.go
@@ -0,0 +1,275 @@
+package gateway
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "io"
+ "net"
+ "net/http"
+ "os"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/coder/websocket"
+ "github.com/pion/transport/v5"
+ "github.com/pion/transport/v5/stdnet"
+)
+
+// Net only exists for a relay-only PeerConnection. It is not a system proxy.
+type Net struct {
+ transport.Net
+ client *Client
+ session string
+ turn *net.UDPAddr
+ ctx context.Context
+}
+
+func (c *Client) Network(ctx context.Context, session, turnAddress string) (*Net, error) {
+ remote, err := net.ResolveUDPAddr("udp4", turnAddress)
+ if err != nil {
+ return nil, err
+ }
+ standard, err := stdnet.NewNet()
+ if err != nil {
+ return nil, err
+ }
+ return &Net{Net: standard, client: c, session: session, turn: remote, ctx: ctx}, nil
+}
+func (n *Net) ListenPacket(network, address string) (net.PacketConn, error) {
+ if network != "udp4" && network != "udp" {
+ return nil, errors.New("official relay supports UDP4 only")
+ }
+ return n.client.openPacket(n.ctx, n.session, n.turn)
+}
+func (n *Net) DialUDP(network string, local, remote *net.UDPAddr) (transport.UDPConn, error) {
+ return nil, errors.New("official relay does not permit direct UDP dialing")
+}
+func (n *Net) ListenUDP(network string, local *net.UDPAddr) (transport.UDPConn, error) {
+ return nil, errors.New("official relay uses a restricted packet transport")
+}
+func (n *Net) Dial(network, address string) (net.Conn, error) {
+ return nil, errors.New("official relay does not permit arbitrary dialing")
+}
+func (n *Net) DialTCP(network string, local, remote *net.TCPAddr) (transport.TCPConn, error) {
+ return nil, errors.New("official relay supports UDP TURN only")
+}
+
+type packetConn struct {
+ client *Client
+ session string
+ ws *websocket.Conn
+ local, remote *net.UDPAddr
+ ctx context.Context
+ cancel context.CancelFunc
+ packets chan []byte
+ mu sync.Mutex
+ readDeadline, writeDeadline time.Time
+ changed chan struct{}
+ once sync.Once
+}
+
+func (c *Client) openPacket(ctx context.Context, session string, remote *net.UDPAddr) (*packetConn, error) {
+ c.mu.Lock()
+ a, ok := c.access[session]
+ enabled, root := c.enabled, c.root
+ c.mu.Unlock()
+ if !ok || !enabled {
+ return nil, errors.New("relay is not authorized")
+ }
+ ctx, cancelRoot := context.WithCancel(ctx)
+ stopRoot := context.AfterFunc(root, cancelRoot)
+ owned := false
+ defer func() {
+ if !owned {
+ stopRoot()
+ cancelRoot()
+ }
+ }()
+ u := "ws" + strings.TrimPrefix(c.base, "http") + "/gateway/v1/tunnel"
+ header := make(http.Header)
+ header.Set("Authorization", "Bearer "+a.Token)
+ var ws *websocket.Conn
+ var err error
+ for attempt := 0; attempt < 30; attempt++ {
+ var resp *http.Response
+ ws, resp, err = websocket.Dial(ctx, u, &websocket.DialOptions{HTTPHeader: header, HTTPClient: c.http})
+ if err == nil {
+ break
+ }
+ if resp == nil || resp.StatusCode != 409 {
+ return nil, errors.New("official relay tunnel unavailable")
+ }
+ select {
+ case <-ctx.Done():
+ return nil, ctx.Err()
+ case <-time.After(300 * time.Millisecond):
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ ws.SetReadLimit(65536)
+ helloCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
+ _, data, err := ws.Read(helloCtx)
+ cancel()
+ if err != nil {
+ ws.CloseNow()
+ return nil, err
+ }
+ var hello struct {
+ Local string `json:"local_address"`
+ TURN string `json:"turn_address"`
+ }
+ if json.Unmarshal(data, &hello) != nil || hello.TURN != remote.String() {
+ ws.CloseNow()
+ return nil, errors.New("unexpected relay endpoint")
+ }
+ local, err := net.ResolveUDPAddr("udp4", hello.Local)
+ if err != nil {
+ ws.CloseNow()
+ return nil, err
+ }
+ connCtx, stop := context.WithCancel(ctx)
+ p := &packetConn{client: c, session: session, ws: ws, local: local, remote: remote, ctx: connCtx, cancel: func() { stop(); stopRoot(); cancelRoot() }, packets: make(chan []byte, 128), changed: make(chan struct{})}
+ c.mu.Lock()
+ if !c.enabled || root.Err() != nil {
+ c.mu.Unlock()
+ p.cancel()
+ ws.CloseNow()
+ return nil, errors.New("official service disabled")
+ }
+ c.conns[p] = true
+ c.mu.Unlock()
+ owned = true
+ go p.receive()
+ return p, nil
+}
+func (p *packetConn) receive() {
+ defer p.Close()
+ for {
+ kind, b, err := p.ws.Read(p.ctx)
+ if err != nil {
+ status := websocket.CloseStatus(err)
+ if status == websocket.StatusPolicyViolation {
+ u := p.client.Usage()
+ u.Reason = "service_unavailable"
+ var ce websocket.CloseError
+ if errors.As(err, &ce) {
+ switch ce.Reason {
+ case "quota_exhausted", "peer_quota_exhausted", "global_exhausted", "global_paused", "relay_blocked", "device_banned":
+ u.Reason = ce.Reason
+ }
+ }
+ p.client.update(u)
+ }
+ return
+ }
+ if kind != websocket.MessageBinary {
+ continue
+ }
+ select {
+ case p.packets <- b:
+ case <-p.ctx.Done():
+ return
+ default: /* bounded UDP-style receive queue */
+ }
+ }
+}
+func (p *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
+ for {
+ p.mu.Lock()
+ deadline, changed := p.readDeadline, p.changed
+ p.mu.Unlock()
+ var timer *time.Timer
+ var timeout <-chan time.Time
+ if !deadline.IsZero() {
+ left := time.Until(deadline)
+ if left <= 0 {
+ return 0, nil, os.ErrDeadlineExceeded
+ }
+ timer = time.NewTimer(left)
+ timeout = timer.C
+ }
+ select {
+ case data := <-p.packets:
+ if timer != nil {
+ timer.Stop()
+ }
+ n := copy(b, data)
+ if n < len(data) {
+ return n, p.remote, io.ErrShortBuffer
+ }
+ return n, p.remote, nil
+ case <-p.ctx.Done():
+ if timer != nil {
+ timer.Stop()
+ }
+ return 0, nil, net.ErrClosed
+ case <-changed:
+ if timer != nil {
+ timer.Stop()
+ }
+ continue
+ case <-timeout:
+ return 0, nil, os.ErrDeadlineExceeded
+ }
+ }
+}
+func (p *packetConn) WriteTo(b []byte, a net.Addr) (int, error) {
+ if a == nil || a.String() != p.remote.String() {
+ return 0, errors.New("relay destination is not permitted")
+ }
+ if len(b) > 65536 {
+ return 0, errors.New("datagram too large")
+ }
+ p.mu.Lock()
+ deadline := p.writeDeadline
+ p.mu.Unlock()
+ ctx := p.ctx
+ cancel := func() {}
+ if !deadline.IsZero() {
+ ctx, cancel = context.WithDeadline(ctx, deadline)
+ }
+ defer cancel()
+ if err := p.ws.Write(ctx, websocket.MessageBinary, b); err != nil {
+ return 0, err
+ }
+ return len(b), nil
+}
+func (p *packetConn) Close() error {
+ p.once.Do(func() {
+ p.cancel()
+ p.ws.CloseNow()
+ p.client.mu.Lock()
+ delete(p.client.conns, p)
+ p.client.mu.Unlock()
+ })
+ return nil
+}
+func (p *packetConn) LocalAddr() net.Addr { return p.local }
+func (p *packetConn) SetDeadline(t time.Time) error {
+ _ = p.SetReadDeadline(t)
+ return p.SetWriteDeadline(t)
+}
+func (p *packetConn) SetReadDeadline(t time.Time) error {
+ p.mu.Lock()
+ p.readDeadline = t
+ close(p.changed)
+ p.changed = make(chan struct{})
+ p.mu.Unlock()
+ return nil
+}
+func (p *packetConn) SetWriteDeadline(t time.Time) error {
+ p.mu.Lock()
+ p.writeDeadline = t
+ p.mu.Unlock()
+ return nil
+}
+func (p *packetConn) refresh(token string) {
+ ctx, cancel := context.WithTimeout(p.ctx, 5*time.Second)
+ defer cancel()
+ b, _ := json.Marshal(map[string]string{"token": token})
+ _ = p.ws.Write(ctx, websocket.MessageText, b)
+}
diff --git a/client-core/internal/gateway/protocol.go b/client-core/internal/gateway/protocol.go
new file mode 100644
index 0000000..965c093
--- /dev/null
+++ b/client-core/internal/gateway/protocol.go
@@ -0,0 +1,87 @@
+// Package gateway implements the optional, documented official transport.
+// It cannot change device trust or execute remotely supplied instructions.
+package gateway
+
+import (
+ "crypto/rand"
+ "encoding/base64"
+ "fmt"
+ "net/http"
+ "strings"
+ "time"
+
+ "github.com/baiyuze/pasteferry/client-core/internal/identity"
+)
+
+const (
+ OfficialSignalURL = "wss://rtccpwsapi1.pasteferry.cc/signal"
+ OfficialBaseURL = "https://rtccpwsapi1.pasteferry.cc"
+ Version = "pasteferry-gateway-v1"
+)
+
+// Proof is intentionally restricted to authentication and resource selection.
+// Raw machine IDs, host names, file metadata and OS details are never fields.
+type Proof struct {
+ PublicKey string `json:"public_key"`
+ DeviceID string `json:"device_id"`
+ Nonce string `json:"nonce"`
+ Purpose string `json:"purpose"`
+ PeerID string `json:"peer_id"`
+ SessionID string `json:"session_id"`
+ MachineDigest string `json:"machine_digest"`
+ Signature string `json:"signature"`
+}
+
+func (p Proof) Message() []byte {
+ return []byte(strings.Join([]string{Version, p.Purpose, p.Nonce, p.DeviceID, p.PublicKey, p.PeerID, p.SessionID, p.MachineDigest}, "\n"))
+}
+
+func proof(id *identity.Identity, purpose, nonce, peer, session, digest string) Proof {
+ p := Proof{PublicKey: base64.RawURLEncoding.EncodeToString(id.PublicKey), DeviceID: id.DeviceID, Nonce: nonce, Purpose: purpose, PeerID: peer, SessionID: session, MachineDigest: digest}
+ p.Signature = base64.RawURLEncoding.EncodeToString(id.Sign(p.Message()))
+ return p
+}
+
+// SignalHeaders does not read a machine identifier or request relay access.
+func SignalHeaders(id *identity.Identity) http.Header {
+ b := make([]byte, 24)
+ if _, err := rand.Read(b); err != nil {
+ return nil
+ }
+ nonce := fmt.Sprintf("%d.%s", time.Now().Unix(), base64.RawURLEncoding.EncodeToString(b))
+ p := proof(id, "signal", nonce, "", "", "")
+ h := make(http.Header)
+ h.Set("X-PasteFerry-Key", p.PublicKey)
+ h.Set("X-PasteFerry-Device", p.DeviceID)
+ h.Set("X-PasteFerry-Nonce", p.Nonce)
+ h.Set("X-PasteFerry-Signature", p.Signature)
+ return h
+}
+
+type Usage struct {
+ Available bool `json:"available"`
+ Day string `json:"day"`
+ Group string `json:"group"`
+ Upload int64 `json:"upload"`
+ Download int64 `json:"download"`
+ Limit int64 `json:"limit"`
+ Remaining int64 `json:"remaining"`
+ ResetAt int64 `json:"reset_at"`
+ UpdatedAt int64 `json:"updated_at"`
+ Reason string `json:"reason"`
+}
+
+type Access struct {
+ Token string `json:"token"`
+ ExpiresAt int64 `json:"expires_at"`
+ Usage Usage `json:"usage"`
+}
+
+type Error struct {
+ Code string `json:"code"`
+ Usage *Usage `json:"usage,omitempty"`
+ UsageToken string `json:"usage_token,omitempty"`
+ ExpiresAt int64 `json:"expires_at,omitempty"`
+}
+
+func (e *Error) Error() string { return "official service: " + e.Code }
diff --git a/client-core/internal/peers/manager.go b/client-core/internal/peers/manager.go
index a50e1cf..3ed4f34 100644
--- a/client-core/internal/peers/manager.go
+++ b/client-core/internal/peers/manager.go
@@ -13,12 +13,14 @@ import (
"errors"
"fmt"
"log/slog"
+ "net/http"
"net/netip"
"runtime"
"sync"
"time"
"github.com/baiyuze/pasteferry/client-core/internal/config"
+ "github.com/baiyuze/pasteferry/client-core/internal/gateway"
"github.com/baiyuze/pasteferry/client-core/internal/identity"
"github.com/baiyuze/pasteferry/client-core/internal/store"
"github.com/baiyuze/pasteferry/client-core/internal/transport/lan"
@@ -78,6 +80,7 @@ type Manager struct {
lan *lan.Transport
verifier *signed.Verifier
p2p *p2p.Manager
+ gateway *gateway.Client
mu sync.RWMutex
// 不能在持有 mu 时调用 lan 里会加它自己的锁的方法(Reachable 除外):
@@ -151,19 +154,40 @@ func NewManager(opts Options) (*Manager, error) {
m.known[d.ID] = d
}
+ m.gateway, err = gateway.NewClient(opts.Identity, gateway.OfficialBaseURL, func(u gateway.Usage) {
+ m.notifyStatus()
+ if m.p2p != nil && u.Available && u.Remaining > 0 && u.Reason == "" {
+ m.p2p.OfficialAllowanceChanged()
+ }
+ })
+ if err != nil {
+ return nil, err
+ }
+ m.gateway.SetEnabled(opts.LoadConfig().Official())
m.p2p = p2p.NewManager(p2p.ManagerOptions{
- SelfID: opts.Identity.DeviceID,
- Logger: log,
- SendSignal: m.sendSignal,
- OnState: m.handleP2PState,
- OnMessage: opts.OnPeerMessage,
- OnStream: opts.OnPeerStream,
- StatePath: opts.StatePath,
+ Gateway: m.gateway,
+ Official: func() bool { return opts.LoadConfig().Official() },
+ OfficialOnline: func(id string) bool { m.mu.RLock(); defer m.mu.RUnlock(); return m.serverOnline[id] },
+ SelfID: opts.Identity.DeviceID,
+ Logger: log,
+ SendSignal: m.sendSignal,
+ OnState: m.handleP2PState,
+ OnMessage: func(id string, msg *pb.PeerMessage) {
+ if display := msg.GetDisplay(); display != nil {
+ m.updatePeerDisplay(id, display)
+ return
+ }
+ if opts.OnPeerMessage != nil {
+ opts.OnPeerMessage(id, msg)
+ }
+ },
+ OnStream: opts.OnPeerStream,
+ StatePath: opts.StatePath,
// 公共 STUN 服务器 IP 分散,能探测到更多出口;用户可以在设置里关掉。
// 没有服务器时只在局域网里连,探测出口没有用,还会把公网 IP 暴露给公共服务器
ProbeServers: func() []string {
cfg := opts.LoadConfig()
- if cfg.OnlyOwnSTUN || cfg.SignalingURL == "" {
+ if cfg.OnlyOwnSTUN || cfg.EffectiveSignalingURL() == "" {
return nil
}
return p2p.DefaultProbeServers
@@ -192,8 +216,14 @@ func NewManager(opts Options) (*Manager, error) {
})
m.client = signaling.New(signaling.Options{
- Identity: opts.Identity,
- URL: opts.LoadConfig().SignalingURL,
+ Identity: opts.Identity,
+ URL: opts.LoadConfig().EffectiveSignalingURL(),
+ DialHeaders: func(url string) http.Header {
+ if opts.LoadConfig().Official() && url == gateway.OfficialSignalURL {
+ return gateway.SignalHeaders(opts.Identity)
+ }
+ return nil
+ },
Logger: log,
Verifier: m.verifier,
PublicKeyOf: m.publicKeyOf,
@@ -222,6 +252,7 @@ func (m *Manager) Run(ctx context.Context) {
}
}
go m.gcPending(ctx)
+ go m.gateway.Run(ctx)
go m.reconnectLoop(ctx)
m.client.Run(ctx)
m.lan.Stop()
@@ -282,7 +313,7 @@ func (m *Manager) connectPending(ctx context.Context) {
func (m *Manager) Connected() bool { return m.client.Connected() }
// ServerConfigured 报告设置里是否填了服务器地址。没填时只在局域网里同步。
-func (m *Manager) ServerConfigured() bool { return m.loadConfig().SignalingURL != "" }
+func (m *Manager) ServerConfigured() bool { return m.loadConfig().EffectiveSignalingURL() != "" }
// LANEnabled 报告局域网直连是否在运行。
func (m *Manager) LANEnabled() bool { return m.lan.Running() }
@@ -291,7 +322,41 @@ func (m *Manager) LANEnabled() bool { return m.lan.Running() }
func (m *Manager) LANBlocked() bool { return m.lan.Blocked() }
// SetSignalingURL 在用户于设置里改了服务器地址后调用,立即重连。
-func (m *Manager) SetSignalingURL(url string) { m.client.SetURL(url) }
+func (m *Manager) SetSignalingURL(url string) {
+ m.p2p.CloseAll()
+ m.p2p.SetICEServers(nil)
+ m.gateway.Close()
+ m.gateway.SetEnabled(m.loadConfig().Official())
+ m.client.SetURL(url)
+}
+
+func (m *Manager) OfficialUsage() *pb.OfficialUsage {
+ if !m.loadConfig().Official() {
+ return nil
+ }
+ u := m.gateway.Usage()
+ return &pb.OfficialUsage{Available: u.Available, Day: u.Day, QuotaGroup: u.Group, UploadBytes: u.Upload, DownloadBytes: u.Download, LimitBytes: u.Limit, RemainingBytes: u.Remaining, ResetAtUnix: u.ResetAt, UpdatedAtUnix: u.UpdatedAt, Reason: u.Reason}
+}
+
+func (m *Manager) updatePeerDisplay(id string, display *pb.PeerDisplay) {
+ if len(display.GetName()) > 256 || len(display.GetPlatform()) > 32 {
+ return
+ }
+ m.mu.Lock()
+ d, ok := m.known[id]
+ if ok && display.GetName() != "" {
+ d.Name = display.GetName()
+ d.Platform = display.GetPlatform()
+ m.known[id] = d
+ }
+ m.mu.Unlock()
+ if ok {
+ _ = m.store.PutDevice(d)
+ if p, ok := m.device(id); ok {
+ m.notify(p)
+ }
+ }
+}
// ─────────────────────── 信令回调 ───────────────────────
@@ -322,6 +387,9 @@ func (m *Manager) deviceInfo() (name, platform string, paired []string) {
for id := range m.known {
ids = append(ids, id)
}
+ if m.loadConfig().UsesOfficialEndpoint() {
+ return "PasteFerry " + m.identity.DeviceID[:8], "", ids
+ }
return m.loadConfig().DeviceName, runtime.GOOS, ids
}
@@ -492,6 +560,10 @@ func (m *Manager) handleP2PState(deviceID string, state p2p.ConnState) {
prev := m.conn[deviceID]
m.conn[deviceID] = state
m.mu.Unlock()
+ if connected(state) && !connected(prev) {
+ cfg := m.loadConfig()
+ _ = m.p2p.Send(deviceID, &pb.PeerMessage{Payload: &pb.PeerMessage_Display{Display: &pb.PeerDisplay{Name: cfg.DeviceName, Platform: runtime.GOOS}}})
+ }
m.log.Info("P2P 连接状态", "device", deviceID, "state", state)
if d, ok := m.device(deviceID); ok {
diff --git a/client-core/internal/rpc/convert.go b/client-core/internal/rpc/convert.go
index 23b1c00..feff5f4 100644
--- a/client-core/internal/rpc/convert.go
+++ b/client-core/internal/rpc/convert.go
@@ -56,6 +56,7 @@ func configToProto(c config.Config) *pb.Config {
OnlyOwnStun: c.OnlyOwnSTUN,
Language: c.Language,
LanDisabled: c.LANDisabled,
+ ServiceMode: serviceModeToProto(c), CustomSignalingUrl: c.CustomSignalingURL, OfficialNoticeAck: c.OfficialNoticeAck,
}
}
@@ -90,10 +91,55 @@ func configFromProto(in *pb.Config, base config.Config) config.Config {
c.Language = in.GetLanguage()
// 服务器地址同理:空字符串就是不用服务器
c.SignalingURL = in.GetSignalingUrl()
+ if in.GetServiceMode() != pb.ServiceMode_SERVICE_MODE_UNSPECIFIED {
+ c.CustomSignalingURL = in.GetCustomSignalingUrl()
+ }
+ switch in.GetServiceMode() {
+ case pb.ServiceMode_SERVICE_MODE_OFFICIAL:
+ c.ServiceMode = "official"
+ c.SignalingURL = ""
+ case pb.ServiceMode_SERVICE_MODE_CUSTOM:
+ c.ServiceMode = "custom"
+ c.CustomSignalingURL = in.GetCustomSignalingUrl()
+ if c.CustomSignalingURL == "" {
+ c.CustomSignalingURL = in.GetSignalingUrl()
+ }
+ c.SignalingURL = c.CustomSignalingURL
+ case pb.ServiceMode_SERVICE_MODE_LAN:
+ c.ServiceMode = "lan"
+ c.SignalingURL = ""
+ default:
+ if c.SignalingURL != "" {
+ c.ServiceMode = "custom"
+ c.CustomSignalingURL = c.SignalingURL
+ } else {
+ c.ServiceMode = "lan"
+ }
+ }
+ if in.GetCustomSignalingUrl() != "" {
+ c.CustomSignalingURL = in.GetCustomSignalingUrl()
+ }
+ c.OfficialNoticeAck = in.GetOfficialNoticeAck()
c.LANDisabled = in.GetLanDisabled()
return c
}
+func serviceModeToProto(c config.Config) pb.ServiceMode {
+ switch c.ServiceMode {
+ case "official":
+ return pb.ServiceMode_SERVICE_MODE_OFFICIAL
+ case "custom":
+ return pb.ServiceMode_SERVICE_MODE_CUSTOM
+ case "lan":
+ return pb.ServiceMode_SERVICE_MODE_LAN
+ default:
+ if c.SignalingURL != "" {
+ return pb.ServiceMode_SERVICE_MODE_CUSTOM
+ }
+ return pb.ServiceMode_SERVICE_MODE_LAN
+ }
+}
+
func permissionToProto(p clipboard.Permission) pb.ClipboardPermission {
switch p {
case clipboard.PermissionNotApplicable:
diff --git a/client-core/internal/rpc/server.go b/client-core/internal/rpc/server.go
index 003c7a4..39b2260 100644
--- a/client-core/internal/rpc/server.go
+++ b/client-core/internal/rpc/server.go
@@ -73,6 +73,7 @@ type Deps struct {
// OpenLocalNetworkSettings 让系统放行局域网访问(macOS 打开设置面板,Windows 放行防火墙)
OpenLocalNetworkSettings func() error
CacheBytesUsed func() int64
+ OfficialUsage func() *pb.OfficialUsage
}
type Server struct {
@@ -313,6 +314,9 @@ func (s *Server) GetStatus(context.Context, *pb.Empty) (*pb.Status, error) {
DeviceName: cfg.DeviceName,
Version: s.deps.Version,
}
+ if s.deps.OfficialUsage != nil {
+ st.OfficialUsage = s.deps.OfficialUsage()
+ }
if s.deps.Permission != nil {
st.ClipboardPermission = permissionToProto(s.deps.Permission())
}
diff --git a/client-core/internal/transport/p2p/manager.go b/client-core/internal/transport/p2p/manager.go
index 9737a58..f68542e 100644
--- a/client-core/internal/transport/p2p/manager.go
+++ b/client-core/internal/transport/p2p/manager.go
@@ -9,6 +9,7 @@ import (
"sync"
"time"
+ "github.com/baiyuze/pasteferry/client-core/internal/gateway"
"github.com/pion/ice/v4"
"github.com/pion/webrtc/v4"
@@ -17,8 +18,14 @@ import (
// Manager 管理与所有已配对设备的 P2P 连接。
type Manager struct {
- selfID string
- log *slog.Logger
+ gateway *gateway.Client
+ official func() bool
+ officialOnline func(string) bool
+ relays map[string]*officialAttempt
+ capable map[string]bool
+ fallbackTimers map[string]*time.Timer
+ selfID string
+ log *slog.Logger
sendSignal func(ctx context.Context, to string, msg *pb.SignalMessage) error
onState func(deviceID string, state ConnState)
@@ -48,12 +55,15 @@ type Manager struct {
}
type ManagerOptions struct {
- SelfID string
- Logger *slog.Logger
- SendSignal func(ctx context.Context, to string, msg *pb.SignalMessage) error
- OnState func(deviceID string, state ConnState)
- OnMessage func(deviceID string, msg *pb.PeerMessage)
- OnStream func(deviceID, label string, stream *Stream)
+ Gateway *gateway.Client
+ Official func() bool
+ OfficialOnline func(string) bool
+ SelfID string
+ Logger *slog.Logger
+ SendSignal func(ctx context.Context, to string, msg *pb.SignalMessage) error
+ OnState func(deviceID string, state ConnState)
+ OnMessage func(deviceID string, msg *pb.PeerMessage)
+ OnStream func(deviceID, label string, stream *Stream)
// ForceRelay 强制走 TURN 中转,用于验证中转链路
ForceRelay bool
@@ -74,6 +84,8 @@ func NewManager(opts ManagerOptions) *Manager {
log = slog.Default()
}
m := &Manager{
+ gateway: opts.Gateway, official: opts.Official, officialOnline: opts.OfficialOnline,
+ relays: make(map[string]*officialAttempt), capable: make(map[string]bool), fallbackTimers: make(map[string]*time.Timer),
selfID: opts.SelfID,
log: log,
sendSignal: opts.SendSignal,
@@ -87,6 +99,7 @@ func NewManager(opts ManagerOptions) *Manager {
history: loadEgressHistory(opts.StatePath),
stop: make(chan struct{}),
}
+ go m.officialRetryLoop()
if opts.DisableEgressProbe {
return m
@@ -321,17 +334,29 @@ func (m *Manager) Connect(ctx context.Context, deviceID string) error {
// HandleSignal 把验签后的信令分派给对应的 Peer。
func (m *Manager) HandleSignal(ctx context.Context, from string, msg *pb.SignalMessage) error {
+ if m.officialEnabled() {
+ m.mu.Lock()
+ m.capable[from] = m.capable[from] || msg.GetGatewayCapable()
+ m.mu.Unlock()
+ if msg.GetOfficialRelay() {
+ return m.handleOfficialSignal(from, msg)
+ }
+ }
p, err := m.peer(from)
if err != nil {
return err
}
- return p.HandleSignal(ctx, msg)
+ err = p.HandleSignal(ctx, msg)
+ if err == nil && (msg.GetOffer() != nil || msg.GetAnswer() != nil || msg.GetCandidate() != nil) {
+ m.scheduleFallback(from)
+ }
+ return err
}
// Send 向对端发送控制消息。
func (m *Manager) Send(deviceID string, msg *pb.PeerMessage) error {
m.mu.RLock()
- p := m.peers[deviceID]
+ p := m.selectedLocked(deviceID)
m.mu.RUnlock()
if p == nil {
@@ -344,7 +369,8 @@ func (m *Manager) Send(deviceID string, msg *pb.PeerMessage) error {
func (m *Manager) Broadcast(msg *pb.PeerMessage) int {
m.mu.RLock()
peers := make([]*Peer, 0, len(m.peers))
- for _, p := range m.peers {
+ for id := range m.peers {
+ p := m.selectedLocked(id)
peers = append(peers, p)
}
m.mu.RUnlock()
@@ -360,7 +386,7 @@ func (m *Manager) Broadcast(msg *pb.PeerMessage) int {
func (m *Manager) OpenStream(deviceID, label string) (*webrtc.DataChannel, error) {
m.mu.RLock()
- p := m.peers[deviceID]
+ p := m.selectedLocked(deviceID)
m.mu.RUnlock()
if p == nil {
@@ -371,7 +397,7 @@ func (m *Manager) OpenStream(deviceID, label string) (*webrtc.DataChannel, error
func (m *Manager) State(deviceID string) ConnState {
m.mu.RLock()
- p := m.peers[deviceID]
+ p := m.selectedLocked(deviceID)
m.mu.RUnlock()
if p == nil {
@@ -382,6 +408,7 @@ func (m *Manager) State(deviceID string) ConnState {
// Disconnect 断开并丢弃与某个对端的连接(解除配对或对端离线时)。
func (m *Manager) Disconnect(deviceID string) {
+ m.stopOfficial(deviceID)
m.mu.Lock()
p := m.peers[deviceID]
delete(m.peers, deviceID)
@@ -393,6 +420,7 @@ func (m *Manager) Disconnect(deviceID string) {
}
func (m *Manager) CloseAll() {
+ m.stopAllOfficial()
m.mu.Lock()
peers := m.peers
m.peers = make(map[string]*Peer)
@@ -411,6 +439,9 @@ func (m *Manager) peer(deviceID string) (*Peer, error) {
return p, nil
}
iceServers := m.iceServers
+ if m.officialEnabled() {
+ iceServers = directICEServers(iceServers)
+ }
forceRelay := m.forceRelay
m.mu.Unlock()
@@ -427,10 +458,21 @@ func (m *Manager) peer(deviceID string) (*Peer, error) {
UDPMux: mux,
ExtraCandidates: m.advertisedCandidates,
RefreshEgress: m.refreshEgress,
+ OnGathered: func() { m.scheduleFallback(deviceID) },
SendSignal: func(ctx context.Context, msg *pb.SignalMessage) error {
+ msg.GatewayCapable = m.officialEnabled()
return m.sendSignal(ctx, deviceID, msg)
},
OnState: func(s ConnState) {
+ if s == StateDirect {
+ m.stopOfficial(deviceID)
+ }
+ m.mu.RLock()
+ active := m.selectedLocked(deviceID)
+ m.mu.RUnlock()
+ if active != nil && active.State() == StateRelay {
+ s = StateRelay
+ }
if m.onState != nil {
m.onState(deviceID, s)
}
diff --git a/client-core/internal/transport/p2p/official.go b/client-core/internal/transport/p2p/official.go
new file mode 100644
index 0000000..523842d
--- /dev/null
+++ b/client-core/internal/transport/p2p/official.go
@@ -0,0 +1,395 @@
+package p2p
+
+import (
+ "context"
+ "crypto/rand"
+ "encoding/base64"
+ "errors"
+ "github.com/baiyuze/pasteferry/client-core/internal/gateway"
+ "net"
+ "strings"
+ "sync"
+ "time"
+
+ pb "github.com/baiyuze/pasteferry/proto/gen/pasteferry/v1"
+ "github.com/pion/webrtc/v4"
+)
+
+const officialDirectWait = 8 * time.Second
+
+type officialAttempt struct {
+ id string
+ ctx context.Context
+ peer *Peer
+ cancel context.CancelFunc
+ pending []*pb.SignalMessage
+ failedUntil time.Time
+ failReason string
+ mu sync.Mutex
+}
+
+func (m *Manager) officialEnabled() bool {
+ return m.gateway != nil && m.official != nil && m.official()
+}
+func (m *Manager) selectedLocked(id string) *Peer {
+ p := m.peers[id]
+ if p != nil && p.State() == StateDirect {
+ return p
+ }
+ if a := m.relays[id]; a != nil && a.peer != nil && a.peer.State() == StateRelay {
+ return a.peer
+ }
+ return p
+}
+func (m *Manager) scheduleFallback(id string) {
+ if !m.officialEnabled() || m.selfID > id {
+ return
+ }
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ if p := m.peers[id]; p == nil || !p.DirectAttemptReady() {
+ return
+ }
+ if !m.capable[id] || m.fallbackTimers[id] != nil {
+ return
+ }
+ m.fallbackTimers[id] = time.AfterFunc(officialDirectWait, func() {
+ m.mu.Lock()
+ delete(m.fallbackTimers, id)
+ p := m.peers[id]
+ existing := m.relays[id]
+ keepExisting := existing != nil && (time.Now().Before(existing.failedUntil) ||
+ existing.ctx != nil && existing.ctx.Err() == nil)
+ m.mu.Unlock()
+ if p == nil || p.State() == StateDirect || keepExisting {
+ return
+ }
+ if m.officialOnline != nil && !m.officialOnline(id) {
+ return
+ }
+ b := make([]byte, 32)
+ if _, err := rand.Read(b); err != nil {
+ return
+ }
+ m.startOfficial(id, base64.RawURLEncoding.EncodeToString(b), nil, true)
+ })
+}
+func (m *Manager) handleOfficialSignal(from string, msg *pb.SignalMessage) error {
+ id := msg.GetConnectionAttemptId()
+ b, err := base64.RawURLEncoding.DecodeString(id)
+ if err != nil || len(b) != 32 || !msg.GetGatewayCapable() {
+ return errors.New("invalid official connection attempt")
+ }
+ if m.officialOnline != nil && !m.officialOnline(from) {
+ return errors.New("peer is not online on official signaling")
+ }
+ if reason := msg.GetRelayDenialCode(); reason != "" {
+ m.mu.Lock()
+ a := m.relays[from]
+ if reason == "quota_available" {
+ if a != nil && a.id == id && a.failReason == "peer_quota_exhausted" {
+ a.failedUntil = time.Time{}
+ a.failReason = ""
+ }
+ m.mu.Unlock()
+ m.scheduleFallback(from)
+ return nil
+ }
+ m.mu.Unlock()
+ if a == nil || a.id != id {
+ return nil
+ }
+ switch reason {
+ case "quota_exhausted":
+ reason = "peer_quota_exhausted"
+ case "global_exhausted", "global_paused", "relay_blocked", "device_banned":
+ default:
+ return nil
+ }
+ m.officialFailed(from, a, &gateway.Error{Code: reason})
+ return nil
+ }
+ m.mu.Lock()
+ a := m.relays[from]
+ direct := m.peers[from]
+ if direct != nil && direct.State() == StateDirect {
+ m.mu.Unlock()
+ return nil
+ }
+ if a != nil && a.id == id {
+ p := a.peer
+ if p == nil {
+ if len(a.pending) < 256 {
+ a.pending = append(a.pending, msg)
+ }
+ m.mu.Unlock()
+ return nil
+ }
+ m.mu.Unlock()
+ return p.HandleSignal(context.Background(), msg)
+ }
+ m.mu.Unlock()
+ // Only the deterministic offerer may initiate a relay attempt.
+ if from > m.selfID || msg.GetOffer() == nil {
+ return nil
+ }
+ m.startOfficial(from, id, msg, false)
+ return nil
+}
+func (m *Manager) startOfficial(deviceID, id string, initial *pb.SignalMessage, offerer bool) {
+ if !m.officialEnabled() {
+ return
+ }
+ ctx, cancel := context.WithCancel(context.Background())
+ a := &officialAttempt{id: id, ctx: ctx, cancel: cancel}
+ if initial != nil {
+ a.pending = append(a.pending, initial)
+ }
+ m.mu.Lock()
+ old := m.relays[deviceID]
+ if old != nil && old.id == id {
+ m.mu.Unlock()
+ cancel()
+ return
+ }
+ m.relays[deviceID] = a
+ m.mu.Unlock()
+ if old != nil {
+ old.cancel()
+ m.gateway.ReleaseSession(old.id)
+ if old.peer != nil {
+ old.peer.Close()
+ }
+ }
+ go func() {
+ authCtx, stop := context.WithTimeout(ctx, 15*time.Second)
+ _, err := m.gateway.Authorize(authCtx, deviceID, id)
+ stop()
+ if err != nil {
+ m.officialFailed(deviceID, a, err)
+ return
+ }
+ m.mu.RLock()
+ servers := append([]webrtc.ICEServer(nil), m.iceServers...)
+ m.mu.RUnlock()
+ servers, addr := officialTURN(servers)
+ if addr == "" {
+ m.officialFailed(deviceID, a, errors.New("TURN configuration unavailable"))
+ return
+ }
+ network, err := m.gateway.Network(ctx, id, addr)
+ if err != nil {
+ m.officialFailed(deviceID, a, err)
+ return
+ }
+ p, err := NewPeer(PeerOptions{DeviceID: deviceID, SelfID: m.selfID, Logger: m.log, ICEServers: servers, ForceRelay: true, Net: network,
+ SendSignal: func(ctx context.Context, msg *pb.SignalMessage) error {
+ msg.GatewayCapable = true
+ msg.OfficialRelay = true
+ msg.ConnectionAttemptId = id
+ return m.sendSignal(ctx, deviceID, msg)
+ },
+ OnState: func(s ConnState) {
+ m.mu.RLock()
+ current := m.relays[deviceID] == a
+ direct := m.peers[deviceID]
+ m.mu.RUnlock()
+ if !current || direct != nil && direct.State() == StateDirect {
+ return
+ }
+ if s == StateOffline && ctx.Err() == nil {
+ go m.officialFailed(deviceID, a, errors.New("relay connection closed"))
+ return
+ }
+ if m.onState != nil {
+ m.onState(deviceID, s)
+ }
+ },
+ OnMessage: func(msg *pb.PeerMessage) {
+ if m.onMessage != nil {
+ m.onMessage(deviceID, msg)
+ }
+ }, OnStream: func(label string, stream *Stream) {
+ if m.onStream != nil {
+ m.onStream(deviceID, label, stream)
+ }
+ },
+ })
+ if err != nil {
+ m.officialFailed(deviceID, a, err)
+ return
+ }
+ m.mu.Lock()
+ if m.relays[deviceID] != a || ctx.Err() != nil {
+ m.mu.Unlock()
+ p.Close()
+ return
+ }
+ a.peer = p
+ pending := a.pending
+ a.pending = nil
+ m.mu.Unlock()
+ if offerer {
+ if err = p.Connect(ctx); err != nil {
+ m.officialFailed(deviceID, a, err)
+ return
+ }
+ }
+ for _, msg := range pending {
+ if err = p.HandleSignal(ctx, msg); err != nil {
+ m.officialFailed(deviceID, a, err)
+ return
+ }
+ }
+ }()
+}
+func officialTURN(servers []webrtc.ICEServer) ([]webrtc.ICEServer, string) {
+ for _, s := range servers {
+ for _, u := range s.URLs {
+ if !strings.HasPrefix(u, "turn:") || strings.Contains(u, "transport=tcp") {
+ continue
+ }
+ addr := strings.SplitN(strings.TrimPrefix(u, "turn:"), "?", 2)[0]
+ host, _, err := net.SplitHostPort(addr)
+ if err != nil || net.ParseIP(host).To4() == nil {
+ continue
+ }
+ s.URLs = []string{u}
+ return []webrtc.ICEServer{s}, addr
+ }
+ }
+ return nil, ""
+}
+func directICEServers(servers []webrtc.ICEServer) []webrtc.ICEServer {
+ var out []webrtc.ICEServer
+ for _, s := range servers {
+ var urls []string
+ for _, u := range s.URLs {
+ if strings.HasPrefix(u, "stun:") || strings.HasPrefix(u, "stuns:") {
+ urls = append(urls, u)
+ }
+ }
+ if len(urls) > 0 {
+ s.URLs = urls
+ out = append(out, s)
+ }
+ }
+ return out
+}
+func (m *Manager) officialFailed(id string, a *officialAttempt, err error) {
+ m.mu.Lock()
+ if m.relays[id] == a {
+ var ge *gateway.Error
+ if errors.As(err, &ge) {
+ a.failReason = ge.Code
+ }
+ u := m.gateway.Usage()
+ a.failedUntil = time.Now().Add(time.Minute)
+ if u.ResetAt > time.Now().Unix() && (u.Reason == "quota_exhausted" || u.Reason == "global_exhausted" || u.Reason == "peer_quota_exhausted") {
+ a.failedUntil = time.Unix(u.ResetAt, 0)
+ }
+ }
+ p := a.peer
+ m.mu.Unlock()
+ a.cancel()
+ m.gateway.ReleaseSession(a.id)
+ if p != nil {
+ p.Close()
+ }
+ m.gateway.ReportError(err)
+ var denied *gateway.Error
+ if errors.As(err, &denied) {
+ switch denied.Code {
+ case "quota_exhausted", "global_exhausted", "global_paused", "relay_blocked", "device_banned":
+ ctx, stop := context.WithTimeout(context.Background(), 5*time.Second)
+ defer stop()
+ _ = m.sendSignal(ctx, id, &pb.SignalMessage{GatewayCapable: true, OfficialRelay: true, ConnectionAttemptId: a.id, RelayDenialCode: denied.Code})
+ }
+ }
+}
+
+// A fresh owner snapshot can re-enable relay after a policy change or reset.
+// A paired peer receives only a signed availability hint; the gateway still
+// independently verifies all new grants and never controls pairing trust.
+func (m *Manager) OfficialAllowanceChanged() {
+ if !m.officialEnabled() {
+ return
+ }
+ m.mu.Lock()
+ ready := map[string]string{}
+ for id, a := range m.relays {
+ switch a.failReason {
+ case "quota_exhausted", "global_exhausted", "global_paused", "relay_blocked":
+ a.failedUntil = time.Time{}
+ a.failReason = ""
+ ready[id] = a.id
+ }
+ }
+ m.mu.Unlock()
+ for id, session := range ready {
+ m.scheduleFallback(id)
+ go func(id, session string) {
+ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+ defer cancel()
+ _ = m.sendSignal(ctx, id, &pb.SignalMessage{GatewayCapable: true, OfficialRelay: true, ConnectionAttemptId: session, RelayDenialCode: "quota_available"})
+ }(id, session)
+ }
+}
+func (m *Manager) stopOfficial(id string) {
+ m.mu.Lock()
+ a := m.relays[id]
+ delete(m.relays, id)
+ if t := m.fallbackTimers[id]; t != nil {
+ t.Stop()
+ delete(m.fallbackTimers, id)
+ }
+ m.mu.Unlock()
+ if a != nil {
+ a.cancel()
+ m.gateway.ReleaseSession(a.id)
+ if a.peer != nil {
+ a.peer.Close()
+ }
+ }
+}
+func (m *Manager) stopAllOfficial() {
+ m.mu.RLock()
+ ids := make([]string, 0, len(m.relays)+len(m.fallbackTimers))
+ for id := range m.relays {
+ ids = append(ids, id)
+ }
+ for id := range m.fallbackTimers {
+ ids = append(ids, id)
+ }
+ m.mu.RUnlock()
+ for _, id := range ids {
+ m.stopOfficial(id)
+ }
+}
+func (m *Manager) officialRetryLoop() {
+ t := time.NewTicker(30 * time.Second)
+ defer t.Stop()
+ for {
+ select {
+ case <-m.stop:
+ return
+ case <-t.C:
+ if !m.officialEnabled() {
+ continue
+ }
+ m.mu.RLock()
+ ps := map[string]*Peer{}
+ for id, a := range m.relays {
+ if a.peer != nil && a.peer.State() == StateRelay && !a.peer.busy() && m.selfID < id {
+ ps[id] = m.peers[id]
+ }
+ }
+ m.mu.RUnlock()
+ for _, p := range ps {
+ if p != nil && p.State() != StateDirect {
+ _ = p.Connect(context.Background())
+ }
+ }
+ }
+ }
+}
diff --git a/client-core/internal/transport/p2p/official_test.go b/client-core/internal/transport/p2p/official_test.go
new file mode 100644
index 0000000..73f293a
--- /dev/null
+++ b/client-core/internal/transport/p2p/official_test.go
@@ -0,0 +1,184 @@
+package p2p
+
+import (
+ "context"
+ "crypto/sha256"
+ "fmt"
+ "net"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "sync/atomic"
+ "testing"
+ "time"
+
+ "github.com/baiyuze/pasteferry/client-core/internal/gateway"
+ "github.com/baiyuze/pasteferry/client-core/internal/identity"
+ pb "github.com/baiyuze/pasteferry/proto/gen/pasteferry/v1"
+ turnrelay "github.com/baiyuze/pasteferry/server/relay"
+)
+
+func officialPair(t *testing.T, base string, backend *turnrelay.Server, dropDirect bool) (*Manager, *Manager, <-chan *pb.PeerMessage) {
+ t.Helper()
+ a := identity.FromSeed(make([]byte, 32))
+ seed := sha256.Sum256([]byte("official p2p b"))
+ b := identity.FromSeed(seed[:])
+ ac, _ := gateway.NewClient(a, base, nil)
+ bc, _ := gateway.NewClient(b, base, nil)
+ t.Cleanup(ac.Close)
+ t.Cleanup(bc.Close)
+ var am, bm *Manager
+ received := make(chan *pb.PeerMessage, 16)
+ blackhole, err := net.ListenPacket("udp4", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() { blackhole.Close() })
+ blackholePort := blackhole.LocalAddr().(*net.UDPAddr).Port
+ deliver := func(from string, target **Manager) func(context.Context, string, *pb.SignalMessage) error {
+ return func(ctx context.Context, to string, msg *pb.SignalMessage) error {
+ if dropDirect && !msg.GetOfficialRelay() {
+ if msg.GetCandidate() != nil {
+ msg.GetCandidate().Candidate = fmt.Sprintf("candidate:1 1 udp 2130706431 127.0.0.1 %d typ host", blackholePort)
+ }
+ if offer := msg.GetOffer(); offer != nil {
+ offer.Sdp = stripCandidates(offer.Sdp)
+ }
+ if answer := msg.GetAnswer(); answer != nil {
+ answer.Sdp = stripCandidates(answer.Sdp)
+ }
+ }
+ go func() { _ = (*target).HandleSignal(context.Background(), from, msg) }()
+ return nil
+ }
+ }
+ opts := func(id string, c *gateway.Client, send func(context.Context, string, *pb.SignalMessage) error) ManagerOptions {
+ return ManagerOptions{SelfID: id, Gateway: c, Official: func() bool { return true }, OfficialOnline: func(string) bool { return true }, DisableEgressProbe: true, SendSignal: send, OnMessage: func(_ string, msg *pb.PeerMessage) {
+ select {
+ case received <- msg:
+ default:
+ }
+ }}
+ }
+ am = NewManager(opts(a.DeviceID, ac, deliver(a.DeviceID, &bm)))
+ bm = NewManager(opts(b.DeviceID, bc, deliver(b.DeviceID, &am)))
+ t.Cleanup(am.Close)
+ t.Cleanup(bm.Close)
+ if backend != nil {
+ for _, x := range []struct {
+ m *Manager
+ id string
+ }{{am, a.DeviceID}, {bm, b.DeviceID}} {
+ cred := backend.Issue(x.id)
+ x.m.SetICEServers([]*pb.IceServer{{Urls: cred.URLs, Username: cred.Username, Credential: cred.Password}})
+ }
+ }
+ return am, bm, received
+}
+func stripCandidates(s string) string {
+ var lines []string
+ for _, line := range strings.Split(s, "\n") {
+ if !strings.HasPrefix(strings.TrimSpace(line), "a=candidate:") {
+ lines = append(lines, line)
+ }
+ }
+ return strings.Join(lines, "\n")
+}
+func waitPair(t *testing.T, a, b *Manager, want ConnState, timeout time.Duration) {
+ t.Helper()
+ until := time.Now().Add(timeout)
+ for time.Now().Before(until) {
+ if a.State(b.selfID) == want && b.State(a.selfID) == want {
+ return
+ }
+ time.Sleep(20 * time.Millisecond)
+ }
+ t.Fatalf("pair states %v/%v; expected %v", a.State(b.selfID), b.State(a.selfID), want)
+}
+func TestOfficialDirectNeverRequestsGateway(t *testing.T) {
+ var requests atomic.Int32
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { requests.Add(1); w.WriteHeader(500) }))
+ defer server.Close()
+ a, b, _ := officialPair(t, server.URL, nil, false)
+ if a.selfID < b.selfID {
+ _ = a.Connect(context.Background(), b.selfID)
+ } else {
+ _ = b.Connect(context.Background(), a.selfID)
+ }
+ waitPair(t, a, b, StateDirect, 10*time.Second)
+ if requests.Load() != 0 {
+ t.Fatal("direct path contacted relay authorization")
+ }
+}
+func TestOfficialDirectThenGatewayTURN(t *testing.T) {
+ binary := os.Getenv("PF_GATEWAY_TEST_BINARY")
+ if binary == "" {
+ t.Skip("set PF_GATEWAY_TEST_BINARY for independent gateway interoperability")
+ }
+ udp, e := net.ListenPacket("udp4", "127.0.0.1:0")
+ if e != nil {
+ t.Fatal(e)
+ }
+ port := udp.LocalAddr().(*net.UDPAddr).Port
+ udp.Close()
+ backend, e := turnrelay.New(turnrelay.Options{PublicIP: "127.0.0.1", ListenIP: "127.0.0.1", Port: port, Secret: "test-only-separate-turn-secret"})
+ if e != nil {
+ t.Fatal(e)
+ }
+ defer backend.Close()
+ tcp, e := net.Listen("tcp", "127.0.0.1:0")
+ if e != nil {
+ t.Fatal(e)
+ }
+ addr := tcp.Addr().String()
+ tcp.Close()
+ dir := t.TempDir()
+ cmd := exec.Command(binary, "serve", "-listen", addr, "-db", filepath.Join(dir, "gateway.db"), "-secret-file", filepath.Join(dir, "secret"), "-signal", "http://127.0.0.1:1", "-turn", fmt.Sprintf("127.0.0.1:%d", port), "-udp-bind", "127.0.0.1", "-stun", "")
+ cmd.Stderr = os.Stderr
+ if e = cmd.Start(); e != nil {
+ t.Fatal(e)
+ }
+ defer func() { cmd.Process.Kill(); cmd.Wait() }()
+ base := "http://" + addr
+ until := time.Now().Add(5 * time.Second)
+ for {
+ r, e := http.Get(base + "/healthz")
+ if e == nil {
+ r.Body.Close()
+ break
+ }
+ if time.Now().After(until) {
+ t.Fatal("gateway startup failed")
+ }
+ time.Sleep(30 * time.Millisecond)
+ }
+ a, b, messages := officialPair(t, base, backend, true)
+ start := time.Now()
+ if a.selfID < b.selfID {
+ _ = a.Connect(context.Background(), b.selfID)
+ } else {
+ _ = b.Connect(context.Background(), a.selfID)
+ }
+ time.Sleep(time.Second)
+ if a.gateway.Usage().UpdatedAt != 0 || b.gateway.Usage().UpdatedAt != 0 {
+ t.Fatal("relay authorization happened before direct attempt")
+ }
+ waitPair(t, a, b, StateRelay, 25*time.Second)
+ if time.Since(start) < officialDirectWait {
+ t.Fatal("relay selected before direct budget")
+ }
+ if e = a.Send(b.selfID, &pb.PeerMessage{Payload: &pb.PeerMessage_Fetch{Fetch: &pb.PeerFetch{ClipId: "through-independent-gateway"}}}); e != nil {
+ t.Fatal(e)
+ }
+ select {
+ case msg := <-messages:
+ if msg.GetFetch().GetClipId() != "through-independent-gateway" {
+ t.Fatal("wrong end-to-end message")
+ }
+ case <-time.After(5 * time.Second):
+ t.Fatal("encrypted peer channel did not deliver")
+ }
+}
diff --git a/client-core/internal/transport/p2p/peer.go b/client-core/internal/transport/p2p/peer.go
index 6d49db2..a5b09a1 100644
--- a/client-core/internal/transport/p2p/peer.go
+++ b/client-core/internal/transport/p2p/peer.go
@@ -16,6 +16,7 @@ import (
"time"
"github.com/pion/ice/v4"
+ "github.com/pion/transport/v5"
"github.com/pion/webrtc/v4"
"google.golang.org/protobuf/proto"
@@ -93,7 +94,9 @@ type Peer struct {
onState func(ConnState)
onMessage func(*pb.PeerMessage)
// onStream 处理对端新开的数据流(大文件传输用)
- onStream func(label string, stream *Stream)
+ onStream func(label string, stream *Stream)
+ onGathered func()
+ remoteCandidateSeen bool
// extraCands 返回出口探测得到的公网地址,见 sendExtraCandidates
extraCands func() []string
// refreshEgress 重新探测一轮出口,见 tryUpgrade
@@ -143,6 +146,8 @@ type Peer struct {
}
type PeerOptions struct {
+ OnGathered func()
+ Net transport.Net
DeviceID string
SelfID string
Logger *slog.Logger
@@ -174,6 +179,11 @@ func NewPeer(opts PeerOptions) (*Peer, error) {
// 分片与背压(BufferedAmount / OnBufferedAmountLow)本来就要自己处理,
// 统一走消息接口反而让两类通道的代码保持一致。
settings := webrtc.SettingEngine{}
+ if opts.Net != nil {
+ settings.SetNet(opts.Net)
+ settings.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
+ settings.SetNetworkTypes([]webrtc.NetworkType{webrtc.NetworkTypeUDP4})
+ }
if opts.UDPMux != nil {
settings.SetICEUDPMux(opts.UDPMux)
}
@@ -193,6 +203,7 @@ func NewPeer(opts PeerOptions) (*Peer, error) {
onState: opts.OnState,
onMessage: opts.OnMessage,
onStream: opts.OnStream,
+ onGathered: opts.OnGathered,
extraCands: opts.ExtraCandidates,
refreshEgress: opts.RefreshEgress,
api: webrtc.NewAPI(webrtc.WithSettingEngine(settings)),
@@ -210,6 +221,15 @@ func (p *Peer) State() ConnState {
return p.state
}
+func (p *Peer) DirectAttemptReady() bool {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ if p.pc == nil || p.state == StateDirect || p.pc.RemoteDescription() == nil || p.pc.ICEGatheringState() != webrtc.ICEGatheringStateComplete {
+ return false
+ }
+ return p.remoteCandidateSeen || strings.Contains(p.pc.RemoteDescription().SDP, "a=candidate:")
+}
+
func (p *Peer) setState(s ConnState) {
p.mu.Lock()
changed := p.state != s
@@ -638,6 +658,9 @@ func (p *Peer) handleCandidate(c *pb.IceCandidate) error {
if err := pc.AddICECandidate(init); err != nil {
return err
}
+ p.mu.Lock()
+ p.remoteCandidateSeen = true
+ p.mu.Unlock()
p.noteRemoteCandidate(init.Candidate)
return nil
}
@@ -683,6 +706,9 @@ func (p *Peer) flushPendingCandidates() {
continue
}
p.noteRemoteCandidate(c.Candidate)
+ p.mu.Lock()
+ p.remoteCandidateSeen = true
+ p.mu.Unlock()
}
}
@@ -694,6 +720,9 @@ func (p *Peer) newPeerConnection() (*webrtc.PeerConnection, error) {
pc.OnICECandidate(func(c *webrtc.ICECandidate) {
if c == nil {
+ if p.onGathered != nil {
+ go p.onGathered()
+ }
return // candidate 收集完毕
}
init := c.ToJSON()
@@ -1081,6 +1110,7 @@ func (p *Peer) closeLocked() {
p.makingOffer = false
p.pendingKind = StateOffline
p.remoteRelayed = false
+ p.remoteCandidateSeen = false
p.dialing = false
if p.connectTimer != nil {
p.connectTimer.Stop()
diff --git a/client-core/internal/transport/signaling/client.go b/client-core/internal/transport/signaling/client.go
index f55b88b..e65a44a 100644
--- a/client-core/internal/transport/signaling/client.go
+++ b/client-core/internal/transport/signaling/client.go
@@ -15,6 +15,7 @@ import (
"fmt"
"log/slog"
"math/rand"
+ "net/http"
"sync"
"time"
@@ -54,7 +55,8 @@ type Client struct {
verifier *signed.Verifier
// DeviceInfo 提供每次握手时上报的设备名与已配对列表
- deviceInfo func() (name, platform string, pairedIDs []string)
+ deviceInfo func() (name, platform string, pairedIDs []string)
+ dialHeaders func(string) http.Header
mu sync.Mutex
conn *websocket.Conn
@@ -76,6 +78,7 @@ type Options struct {
// 此时来自该设备的消息一律丢弃。
PublicKeyOf func(deviceID string) ed25519.PublicKey
DeviceInfo func() (name, platform string, pairedIDs []string)
+ DialHeaders func(string) http.Header
}
func New(opts Options) *Client {
@@ -88,13 +91,14 @@ func New(opts Options) *Client {
verifier = signed.NewVerifier(opts.Identity.DeviceID, opts.PublicKeyOf)
}
return &Client{
- identity: opts.Identity,
- url: opts.URL,
- log: log,
- handlers: opts.Handlers,
- verifier: verifier,
- deviceInfo: opts.DeviceInfo,
- urlChanged: make(chan struct{}, 1),
+ identity: opts.Identity,
+ url: opts.URL,
+ log: log,
+ handlers: opts.Handlers,
+ verifier: verifier,
+ deviceInfo: opts.DeviceInfo,
+ dialHeaders: opts.DialHeaders,
+ urlChanged: make(chan struct{}, 1),
}
}
@@ -185,7 +189,11 @@ func (c *Client) session(ctx context.Context) (established bool, err error) {
}
dialCtx, cancel := context.WithTimeout(ctx, dialTimeout)
- conn, _, err := websocket.Dial(dialCtx, url, nil)
+ var dialOpts *websocket.DialOptions
+ if c.dialHeaders != nil {
+ dialOpts = &websocket.DialOptions{HTTPHeader: c.dialHeaders(url)}
+ }
+ conn, _, err := websocket.Dial(dialCtx, url, dialOpts)
cancel()
if err != nil {
return false, fmt.Errorf("连接 %s: %w", url, err)
diff --git a/design/official-gateway.md b/design/official-gateway.md
new file mode 100644
index 0000000..8e0cd69
--- /dev/null
+++ b/design/official-gateway.md
@@ -0,0 +1,170 @@
+# Optional official gateway protocol v1
+
+The application and the signaling/TURN server remain independent AGPL software.
+This document describes an optional, independently implemented service at the
+official hosting boundary. Neither server calls the gateway, sends accounting
+callbacks, imports a private SDK, or requires the gateway for self-hosting.
+The gateway speaks ordinary HTTP/WebSocket and standard TURN on its data path.
+
+## Selection and connection order
+
+Fresh installations use LAN mode. Config v3 adds `service_mode` (`lan`,
+`official`, `custom`), a remembered `custom_signaling_url` and local-only notice
+acknowledgements. Selecting LAN or custom must cancel official HTTP requests,
+usage polling and tunnels. No automatic fallback between service providers.
+
+Official signaling: `wss://rtccpwsapi1.pasteferry.cc/signal`.
+Official gateway base: `https://rtccpwsapi1.pasteferry.cc`.
+Official STUN is the separate Binding-only endpoint at `104.223.127.214:3478`.
+Addresses are public configuration, not credentials. Cloudflare proxies WSS,
+not this UDP STUN endpoint. Public STUN probes are separately user-controlled;
+their provider addresses are listed in `client-core/internal/transport/p2p/egress.go`.
+
+Initially filter TURN out of the active ICE configuration, retaining it only
+in memory. After an online, capable peer exchanges offer/answer and direct
+connection fails for eight seconds, the lexically lower device ID creates a
+random 32-byte attempt ID. Both devices independently authorize that same
+attempt. Only then create relay-only PeerConnections with the WSS packet
+adapter. Keep the direct connection independent so a later successful direct
+attempt can release the relay. An offline/legacy peer or signaling error is
+not evidence that relay authorization should be requested.
+
+Signed SignalMessage adds optional `connection_attempt_id`, `official_relay`
+and `gateway_capable` and `relay_denial_code` fields. The server forwards the original signed payload;
+it does not interpret these capabilities. PeerDisplay travels only inside the
+authenticated encrypted device channel. Official ClientHello and pairing
+requests use a generic device label, not the real hostname or OS details.
+
+## Canonical signed proof
+
+All strings are UTF-8 without embedded newlines. Public keys and signatures
+use unpadded base64url. Device IDs retain the existing SHA-256(public key),
+first 16 bytes, lowercase unpadded base32 derivation. The signed bytes are
+these eight values, joined with a single LF, with no final LF:
+
+```
+pasteferry-gateway-v1
+purpose
+nonce
+device_id
+public_key
+peer_id
+session_id
+machine_digest
+```
+
+Sign with the existing device Ed25519 key. This never changes pairing trust.
+For signaling, purpose is `signal`, nonce is `unix_seconds.random_base64url`
+(24 random bytes), and the final three fields are empty. Accept timestamps
+within 60 seconds and reject replay. Send the following headers only to the
+official signal endpoint: `X-PasteFerry-Key`, `X-PasteFerry-Device`,
+`X-PasteFerry-Nonce`, `X-PasteFerry-Signature`. The proxy removes these headers
+before forwarding to the unchanged signaling server. This is an access identity
+proof, not a relay quota check. Legacy connections are counted separately.
+
+## Relay and usage API
+
+Every route is under `/gateway/v1/`. HTTPS is mandatory except explicit
+loopback interoperability tests. Redirects are rejected. JSON requests are
+limited to 8 KiB; response bodies to the client are limited to 32 KiB.
+
+| Method / route | Request | Response |
+| --- | --- | --- |
+| GET `challenge` | No machine or device information | `nonce`, `expires_in:60` |
+| POST `authorize` | Proof fields above plus `signature`; purpose `relay` | `token`, `expires_at`, `usage` |
+| GET `usage` | `Authorization: Bearer token` | Authoritative usage snapshot |
+| GET `tunnel` | WebSocket upgrade and same Authorization header | Packet connection |
+
+Challenges are random, single-use, and consumed even on invalid signatures.
+Session IDs are 32 random bytes in unpadded base64url. Enrollment binds the
+current device to its quota group; changing a later digest cannot reset that
+binding. Missing machine information retains the existing binding, or falls
+back to persistent device identity on first enrollment. Tokens are random,
+memory-only, expire after 15 minutes, and bind device, peer, session and group.
+Both reciprocal grants must exist before opening a tunnel.
+
+After first relay enrollment, `authorize` also accepts purpose `usage` with
+empty peer, session and machine-digest fields and a fresh challenge signature.
+It can only issue a read-only usage token for an already-bound device. That
+token cannot open or renew a tunnel, and does not create a peer session.
+A denied relay grant may include `usage_token` and `expires_at` so the client
+can observe reset or administrator changes without retrying relay constantly.
+Disabling the official mode clears all tokens and cancels these requests.
+
+A signed `relay_denial_code` is limited to quota/policy denial and the
+`quota_available` retry hint. It cannot grant access: the gateway still checks
+both devices. It never carries an executable instruction or pairing approval.
+
+Usage fields: `available`, `day`, `group`, `upload`, `download`, `limit`,
+`remaining`, `reserved`, `reset_at`, `updated_at`, `reason`. Bytes are integer
+decimal bytes; timestamps are Unix seconds. Unknown/stale data is not zero.
+Reserved bytes left after a crash remain conservatively unavailable that day.
+The server never accepts client-supplied usage totals or a client reset clock.
+
+Failure responses have `code` and optionally `usage`. Stable reasons include
+`unauthorized`, `challenge_expired`, `invalid_proof`, `session_mismatch`,
+`peer_pending`, `quota_exhausted`, `global_exhausted`, `global_paused`,
+`relay_blocked`, `device_banned`, `rate_limited`, `service_unavailable`.
+The client maps allowed codes to local translated messages; it does not
+execute or directly render remotely supplied instructions.
+
+## Packet tunnel
+
+Each WSS connection represents exactly one connected UDP socket to the fixed
+private TURN control address. The first server text frame is JSON containing
+`local_address` and `turn_address`; the latter must match the selected TURN
+configuration. Binary frames contain one unchanged UDP datagram, up to 65536
+bytes. There is no arbitrary-destination field or SOCKS/CONNECT capability.
+
+A client text frame `{ "token": "new token" }` renews authorization on the
+same tunnel; it must bind the same device, group, peer and session. Credentials
+never appear in query parameters. The tunnel is closed when authorization
+expires or gateway policy denies forwarding. Queue lengths and I/O deadlines
+are bounded; closing the transport cancels outstanding reads and writes.
+
+The independent proxy observes standard TURN allocation responses and outer
+Send/CreatePermission/ChannelBind messages. It permits peer addresses only
+when the other allocation belongs to the reciprocally authorized session.
+It never decrypts DTLS application records. The TURN server still validates
+its own standard credentials and message integrity, without gateway secrets.
+
+## Accounting and failure behavior
+
+Policy inputs use a number with an MB/GB selector, with a minimum adjustment
+of 1 MB; speed uses Mbps. 1 GB = 1000 MB. API/storage retain integer base units
+so changing display units never changes the actual allowance. Usage is shown
+in whole MB (`<1 MB` for positive amounts below 1 MB); packets are accumulated
+at their real length, never rounded up individually to 1 MB.
+
+Default quota: 100 MB per machine group per Beijing calendar day,
+upload plus download. Shared rate: 2,000,000 bits/s. Each device boundary is
+charged once; same-group endpoints share the total. Server-internal TURN hops
+are not extra charges. Bill forwarded encrypted payload bytes, including
+encryption overhead; file size and usage therefore differ. Normal bounded
+TURN/STUN/ICE control exchanges are not charged to the device data quota.
+
+Global budget: 1,000,000,000 outbound tunnel datagram bytes/day, including
+control. This measures the gateway application boundary, not TCP/TLS headers,
+TCP retransmissions or the hosting provider's bill. Per-group in-memory
+enforcement uses bounded durable reservations and idempotent settlement;
+never perform a SQLite transaction per packet. Exhaustion blocks existing
+and new relay data. Policy changes apply within five seconds.
+
+Auth/ledger outages fail new relay credit closed. Already reserved credit is
+the maximum that can be spent before service recovers. A proxy outage affects
+official signaling entry, but cannot revoke LAN/direct cryptographic trust or
+disable self-hosting. There are no remote-code, file-read, key-export or update
+commands in this protocol.
+
+## Deployment contract
+
+Only the private gateway and Nginx are public entry points. The unchanged
+signaling/TURN binary runs in a network namespace, advertising its private
+relay address. All relay ports are unreachable directly from the Internet;
+both clients reach them through TURN encapsulation in the authenticated
+tunnels. Backend egress is isolated so it cannot serve as a general proxy.
+A separate public Binding-only STUN responder does not forward Allocate.
+
+Custom/self-hosted server binaries need none of this configuration. The
+gateway implementation and operator dashboard may be private; this protocol,
+client implementation and complete self-hosted server remain public.
diff --git a/docs/cloud/index.html b/docs/cloud/index.html
index e991060..9487521 100644
--- a/docs/cloud/index.html
+++ b/docs/cloud/index.html
@@ -297,6 +297,7 @@ sudo ./install.sh 203.0.113.10</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="../cloud/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/design/lan-mode.html b/docs/design/lan-mode.html
index 8576c6c..388687c 100644
--- a/docs/design/lan-mode.html
+++ b/docs/design/lan-mode.html
@@ -110,6 +110,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/design/linux-client.html b/docs/design/linux-client.html
index 7c9e987..36dbce0 100644
--- a/docs/design/linux-client.html
+++ b/docs/design/linux-client.html
@@ -79,6 +79,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/design/nat-traversal.html b/docs/design/nat-traversal.html
index 4bb8fe0..1d8c88c 100644
--- a/docs/design/nat-traversal.html
+++ b/docs/design/nat-traversal.html
@@ -141,6 +141,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/design/windows-client.html b/docs/design/windows-client.html
index 7ffda6b..e015fb4 100644
--- a/docs/design/windows-client.html
+++ b/docs/design/windows-client.html
@@ -125,6 +125,7 @@ pasteferry-cli.exe(命令行,排障用)</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/download/index.html b/docs/download/index.html
index c056138..593c41a 100644
--- a/docs/download/index.html
+++ b/docs/download/index.html
@@ -176,6 +176,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="../download/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/en/cloud/index.html b/docs/en/cloud/index.html
index 4cd7735..c7cdb24 100644
--- a/docs/en/cloud/index.html
+++ b/docs/en/cloud/index.html
@@ -297,6 +297,7 @@ Open in your firewall: TCP 8787 (signaling), UDP 3478 (STUN and TURN), UDP 32768
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href="../../cloud/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/en/download/index.html b/docs/en/download/index.html
index 436e743..e53cf95 100644
--- a/docs/en/download/index.html
+++ b/docs/en/download/index.html
@@ -176,6 +176,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href="../../download/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/en/index.html b/docs/en/index.html
index 7e8a70a..1e1903a 100644
--- a/docs/en/index.html
+++ b/docs/en/index.html
@@ -593,6 +593,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/en/lan/index.html b/docs/en/lan/index.html
index 342e9e9..996ca49 100644
--- a/docs/en/lan/index.html
+++ b/docs/en/lan/index.html
@@ -218,6 +218,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href="../../lan/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/en/privacy/index.html b/docs/en/privacy/index.html
new file mode 100644
index 0000000..bef5b00
--- /dev/null
+++ b/docs/en/privacy/index.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Privacy and essential data — PasteFerry</title>
+ <meta name="description" content="Fresh installs use LAN mode. Official access and essential connection statistics begin only when enabled. Custom servers do not report to the official service. Direct connections are attempted first; machine quota identification and relay authorization happen only after direct failure.">
+ <link rel="canonical" href="https://pasteferry.cc/en/privacy/">
+ <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/">
+ <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/">
+ <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/">
+ <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/">
+ <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/">
+ <meta name="theme-color" content="#141416">
+ <meta property="og:type" content="article">
+ <meta property="og:site_name" content="PasteFerry">
+ <meta property="og:title" content="Privacy and essential data — PasteFerry">
+ <meta property="og:description" content="Fresh installs use LAN mode. Official access and essential connection statistics begin only when enabled. Custom servers do not report to the official service. Direct connections are attempted first; machine quota identification and relay authorization happen only after direct failure.">
+ <meta property="og:url" content="https://pasteferry.cc/en/privacy/">
+ <meta property="og:image" content="https://pasteferry.cc/assets/og-en.png">
+ <meta property="og:locale" content="en_US">
+ <meta name="twitter:card" content="summary_large_image">
+ <link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
+ <link rel="icon" href="../../assets/favicon-32.png" sizes="32x32" type="image/png">
+ <link rel="apple-touch-icon" href="../../assets/apple-touch-icon.png">
+ <link rel="stylesheet" href="../../assets/site.css">
+</head>
+<body>
+ <a class="skip" href="#main">Skip to content</a>
+
+ <header class="bar">
+ <div class="wrap">
+ <a class="brand" href="../../en/" aria-label="PasteFerry home"><img src="../../assets/icon.svg" alt="" width="26" height="26">PasteFerry</a>
+ <nav aria-label="Page">
+ <a href="../../en/start/">Quick start</a>
+ <a class="wide" href="../../en/#how">How it works</a>
+ <a class="wide" href="../../en/#faq">FAQ</a>
+ <a class="mid" href="../../en/start/#server">Ways to connect</a>
+ <a href="../../en/download/">Download</a>
+ <a class="wide" href="https://github.com/baiyuze/pasteferry">GitHub</a>
+ <details class="lang">
+ <summary aria-label="Language:English"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>English</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
+ <ul>
+ <li><a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a></li>
+ <li><a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a></li>
+ <li><a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a></li>
+ <li><a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en" aria-current="page">English</a></li>
+ <li><a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a></li>
+ </ul>
+ </details>
+ </nav>
+ </div>
+ </header>
+<main id="main" class="wrap" style="max-width:850px;padding-top:5rem;padding-bottom:5rem;line-height:1.9"><h1>Privacy and essential data</h1><section><h2>Official service is optional</h2><p>Fresh installs use LAN mode. Official access and essential connection statistics begin only when enabled. Custom servers do not report to the official service. Direct connections are attempted first; machine quota identification and relay authorization happen only after direct failure.</p></section>
+<section><h2>Minimal service records</h2><p>The gateway retains pseudonymous device numbers, first/last access times, daily relay usage, essential quota bindings and cumulative totals. Daily device detail is retained for 90 days. Official device counts are not people or total installations.</p></section>
+<section><h2>Content and identifiers</h2><p>Content and real device names travel through the encrypted device channel. The gateway does not collect filenames, paths, usernames, MAC addresses, UA or behavior trails. Raw system identifiers are not uploaded; the application-specific digest groups relay quota and can be forged by a modified client.</p></section>
+<section><h2>Network visibility and allowance</h2><p>Network endpoints necessarily see transient routing/address metadata; official statistics and ordinary proxy logs do not retain it. The default allowance is 100 MB/day, upload plus download, reset at midnight Beijing time. Direct traffic is not charged. Disabling official access stops its requests, polling and tunnels.</p></section>
+<section><h2>Website and audit boundary</h2><p>This website uses its existing Cloudflare Web Analytics beacon. Visits are not software-user counts. The client and signaling/TURN server remain open source, with gateway fields and protocol published. Actual private production retention still requires deployment audit.</p></section><p><a href="https://github.com/baiyuze/pasteferry/blob/main/PRIVACY.md">PRIVACY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/SECURITY.md">SECURITY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/design/official-gateway.md">Gateway protocol v1</a></p></main>
+ <footer class="footer">
+ <div class="wrap">
+ <p>PasteFerry is open source under the GNU AGPL-3.0.</p>
+ <nav aria-label="Footer">
+ <a href="https://github.com/baiyuze/pasteferry/releases">All releases</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">Changelog</a>
+ <a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
+ <a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
+ </nav>
+ <nav aria-label="Language">
+ <a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
+ <a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a>
+ <a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a>
+ <a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en" aria-current="page">English</a>
+ <a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a>
+ </nav>
+ </div>
+ </footer>
+
+ <script src="../../assets/site.js" defer></script>
+ <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
+</body>
+</html>
diff --git a/docs/en/server/index.html b/docs/en/server/index.html
index d251944..b4da6fd 100644
--- a/docs/en/server/index.html
+++ b/docs/en/server/index.html
@@ -393,6 +393,7 @@ Open in your firewall: TCP 8787 (signaling), UDP 3478 (STUN and TURN), UDP 32768
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href="../../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/en/start/index.html b/docs/en/start/index.html
index d945195..cc81b5f 100644
--- a/docs/en/start/index.html
+++ b/docs/en/start/index.html
@@ -231,6 +231,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href="../../start/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/en/tailscale/index.html b/docs/en/tailscale/index.html
index 6691f34..de90fd7 100644
--- a/docs/en/tailscale/index.html
+++ b/docs/en/tailscale/index.html
@@ -242,6 +242,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">Design notes (Chinese)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">License</a>
<a href="https://github.com/baiyuze/pasteferry/issues">Report an issue</a>
+ <a href="../../en/privacy/">Privacy and essential data</a>
</nav>
<nav aria-label="Language">
<a href="../../tailscale/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/index.html b/docs/index.html
index cab0f38..ac73527 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -617,6 +617,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="./" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/ja/cloud/index.html b/docs/ja/cloud/index.html
index cf7be16..a7edc27 100644
--- a/docs/ja/cloud/index.html
+++ b/docs/ja/cloud/index.html
@@ -297,6 +297,7 @@ Open in your firewall: TCP 8787 (signaling), UDP 3478 (STUN and TURN), UDP 32768
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href="../../cloud/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/ja/download/index.html b/docs/ja/download/index.html
index fff6ac1..cebc23e 100644
--- a/docs/ja/download/index.html
+++ b/docs/ja/download/index.html
@@ -176,6 +176,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href="../../download/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/ja/index.html b/docs/ja/index.html
index 0f381c8..f4a5e8c 100644
--- a/docs/ja/index.html
+++ b/docs/ja/index.html
@@ -593,6 +593,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/ja/lan/index.html b/docs/ja/lan/index.html
index 8231214..395e46f 100644
--- a/docs/ja/lan/index.html
+++ b/docs/ja/lan/index.html
@@ -218,6 +218,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href="../../lan/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/ja/privacy/index.html b/docs/ja/privacy/index.html
new file mode 100644
index 0000000..5c30993
--- /dev/null
+++ b/docs/ja/privacy/index.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html lang="ja">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>プライバシーと必要なデータ — PasteFerry</title>
+ <meta name="description" content="新規インストールではLANのみを使用します。有効にした場合のみ公式シグナリングに接続し、必要な接続統計を記録します。独自サーバーは公式へ報告しません。まず直接接続を試し、失敗した場合のみ中継の認証と端末の残量識別を行います。">
+ <link rel="canonical" href="https://pasteferry.cc/ja/privacy/">
+ <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/">
+ <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/">
+ <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/">
+ <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/">
+ <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/">
+ <meta name="theme-color" content="#141416">
+ <meta property="og:type" content="article">
+ <meta property="og:site_name" content="PasteFerry">
+ <meta property="og:title" content="プライバシーと必要なデータ — PasteFerry">
+ <meta property="og:description" content="新規インストールではLANのみを使用します。有効にした場合のみ公式シグナリングに接続し、必要な接続統計を記録します。独自サーバーは公式へ報告しません。まず直接接続を試し、失敗した場合のみ中継の認証と端末の残量識別を行います。">
+ <meta property="og:url" content="https://pasteferry.cc/ja/privacy/">
+ <meta property="og:image" content="https://pasteferry.cc/assets/og-en.png">
+ <meta property="og:locale" content="ja_JP">
+ <meta name="twitter:card" content="summary_large_image">
+ <link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
+ <link rel="icon" href="../../assets/favicon-32.png" sizes="32x32" type="image/png">
+ <link rel="apple-touch-icon" href="../../assets/apple-touch-icon.png">
+ <link rel="stylesheet" href="../../assets/site.css">
+</head>
+<body>
+ <a class="skip" href="#main">本文へ移動</a>
+
+ <header class="bar">
+ <div class="wrap">
+ <a class="brand" href="../../ja/" aria-label="PasteFerry ホーム"><img src="../../assets/icon.svg" alt="" width="26" height="26">PasteFerry</a>
+ <nav aria-label="ページ内の移動">
+ <a href="../../ja/start/">はじめかた</a>
+ <a class="wide" href="../../ja/#how">しくみ</a>
+ <a class="wide" href="../../ja/#faq">よくある質問</a>
+ <a class="mid" href="../../ja/start/#server">接続方法</a>
+ <a href="../../ja/download/">ダウンロード</a>
+ <a class="wide" href="https://github.com/baiyuze/pasteferry">GitHub</a>
+ <details class="lang">
+ <summary aria-label="言語:日本語"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>日本語</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
+ <ul>
+ <li><a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a></li>
+ <li><a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a></li>
+ <li><a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a></li>
+ <li><a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a></li>
+ <li><a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja" aria-current="page">日本語</a></li>
+ </ul>
+ </details>
+ </nav>
+ </div>
+ </header>
+<main id="main" class="wrap" style="max-width:850px;padding-top:5rem;padding-bottom:5rem;line-height:1.9"><h1>プライバシーと必要なデータ</h1><section><h2>公式サービスは任意です</h2><p>新規インストールではLANのみを使用します。有効にした場合のみ公式シグナリングに接続し、必要な接続統計を記録します。独自サーバーは公式へ報告しません。まず直接接続を試し、失敗した場合のみ中継の認証と端末の残量識別を行います。</p></section>
+<section><h2>最小限の記録</h2><p>仮名化した端末番号、初回・最終接続時刻、日別中継使用量、必要な上限の紐付けと累計を保持します。端末の日別明細は90日間保持します。公式端末数は人数や全インストール数ではありません。</p></section>
+<section><h2>内容と識別子</h2><p>内容と実際の端末名は端末間の暗号化通信で送信します。ファイル名、パス、ユーザー名、MAC、UA、行動履歴を収集しません。元のシステム識別子は送信せず、専用ダイジェストを中継上限の分類にのみ使います。改変クライアントによる偽装は防ぎきれません。</p></section>
+<section><h2>ネットワークと残量</h2><p>通信先は一時的な経路・アドレスを認識しますが、公式統計と通常のプロキシログには保存しません。中継上限は送受信合計100 MB/日で、北京時間午前0時にリセットします。直接接続は消費しません。無効化すると公式の要求、照会とトンネルを停止します。</p></section>
+<section><h2>ウェブサイトと監査</h2><p>当サイトは既存のCloudflare Web Analyticsを使います。閲覧数はソフトの利用者数ではありません。クライアント、シグナリングとTURNはオープンソースを維持し、ゲートウェイの仕様と項目を公開します。非公開の本番環境の保持実態には配備監査が必要です。</p></section><p><a href="https://github.com/baiyuze/pasteferry/blob/main/PRIVACY.md">PRIVACY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/SECURITY.md">SECURITY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/design/official-gateway.md">Gateway protocol v1</a></p></main>
+ <footer class="footer">
+ <div class="wrap">
+ <p>PasteFerry は GNU AGPL-3.0 のオープンソースです。</p>
+ <nav aria-label="フッターのリンク">
+ <a href="https://github.com/baiyuze/pasteferry/releases">すべてのリリース</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新履歴</a>
+ <a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
+ <a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
+ </nav>
+ <nav aria-label="言語">
+ <a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
+ <a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a>
+ <a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a>
+ <a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a>
+ <a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja" aria-current="page">日本語</a>
+ </nav>
+ </div>
+ </footer>
+
+ <script src="../../assets/site.js" defer></script>
+ <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
+</body>
+</html>
diff --git a/docs/ja/server/index.html b/docs/ja/server/index.html
index 5796dd0..fdcf95b 100644
--- a/docs/ja/server/index.html
+++ b/docs/ja/server/index.html
@@ -393,6 +393,7 @@ Open in your firewall: TCP 8787 (signaling), UDP 3478 (STUN and TURN), UDP 32768
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href="../../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/ja/start/index.html b/docs/ja/start/index.html
index 40be557..e9ec595 100644
--- a/docs/ja/start/index.html
+++ b/docs/ja/start/index.html
@@ -231,6 +231,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href="../../start/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/ja/tailscale/index.html b/docs/ja/tailscale/index.html
index b8cee09..dffc891 100644
--- a/docs/ja/tailscale/index.html
+++ b/docs/ja/tailscale/index.html
@@ -242,6 +242,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術資料(中国語)</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">ライセンス</a>
<a href="https://github.com/baiyuze/pasteferry/issues">問題を報告</a>
+ <a href="../../ja/privacy/">プライバシーと必要なデータ</a>
</nav>
<nav aria-label="言語">
<a href="../../tailscale/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/lan/index.html b/docs/lan/index.html
index e52e378..37dccf8 100644
--- a/docs/lan/index.html
+++ b/docs/lan/index.html
@@ -218,6 +218,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="../lan/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/privacy/index.html b/docs/privacy/index.html
new file mode 100644
index 0000000..c588124
--- /dev/null
+++ b/docs/privacy/index.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html lang="zh-CN">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>隐私与必要数据 — PasteFerry</title>
+ <meta name="description" content="新安装默认只使用局域网。开启官方公网后才连接官方信令并记录必要接入统计;自建服务器模式不向官方上报。先尝试直连,失败后才申请中转授权和读取机器额度摘要。">
+ <link rel="canonical" href="https://pasteferry.cc/privacy/">
+ <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/">
+ <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/">
+ <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/">
+ <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/">
+ <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/">
+ <meta name="theme-color" content="#141416">
+ <meta property="og:type" content="article">
+ <meta property="og:site_name" content="隔空贴">
+ <meta property="og:title" content="隐私与必要数据 — PasteFerry">
+ <meta property="og:description" content="新安装默认只使用局域网。开启官方公网后才连接官方信令并记录必要接入统计;自建服务器模式不向官方上报。先尝试直连,失败后才申请中转授权和读取机器额度摘要。">
+ <meta property="og:url" content="https://pasteferry.cc/privacy/">
+ <meta property="og:image" content="https://pasteferry.cc/assets/og.png">
+ <meta property="og:locale" content="zh_CN">
+ <meta name="twitter:card" content="summary_large_image">
+ <link rel="icon" href="../assets/favicon.svg" type="image/svg+xml">
+ <link rel="icon" href="../assets/favicon-32.png" sizes="32x32" type="image/png">
+ <link rel="apple-touch-icon" href="../assets/apple-touch-icon.png">
+ <link rel="stylesheet" href="../assets/site.css">
+</head>
+<body>
+ <a class="skip" href="#main">跳到正文</a>
+
+ <header class="bar">
+ <div class="wrap">
+ <a class="brand" href=".././" aria-label="隔空贴首页"><img src="../assets/icon.svg" alt="" width="26" height="26">隔空贴</a>
+ <nav aria-label="页面导航">
+ <a href="../start/">快速开始</a>
+ <a class="wide" href=".././#how">工作原理</a>
+ <a class="wide" href=".././#faq">常见问题</a>
+ <a class="mid" href="../start/#server">连接方式</a>
+ <a href="../download/">下载</a>
+ <a class="wide" href="https://github.com/baiyuze/pasteferry">GitHub</a>
+ <details class="lang">
+ <summary aria-label="语言:简体中文"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>简体中文</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
+ <ul>
+ <li><a href="../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a></li>
+ <li><a href="../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a></li>
+ <li><a href="../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a></li>
+ <li><a href="../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a></li>
+ <li><a href="../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a></li>
+ </ul>
+ </details>
+ </nav>
+ </div>
+ </header>
+<main id="main" class="wrap" style="max-width:850px;padding-top:5rem;padding-bottom:5rem;line-height:1.9"><h1>隐私与必要数据</h1><section><h2>你决定是否使用官方服务</h2><p>新安装默认只使用局域网。开启官方公网后才连接官方信令并记录必要接入统计;自建服务器模式不向官方上报。先尝试直连,失败后才申请中转授权和读取机器额度摘要。</p></section>
+<section><h2>仅保留服务所需数据</h2><p>官方网关保留脱敏设备编号、首次及最近接入时间、每日中转用量、必要额度绑定和累计汇总。每日设备明细保留 90 天。统计表示官方服务设备数,不能代表真实人数或全部安装量。</p></section>
+<section><h2>内容与机器标识</h2><p>剪贴板、文件内容与真实设备名通过设备间加密通道传输。网关不收集文件名、路径、用户名、MAC、UA 或行为轨迹;原始系统标识不上传,机器摘要仅用于中转额度归组,不能保证不可伪造。</p></section>
+<section><h2>网络可见性和额度</h2><p>联网端点必然能看到临时网络地址和路由信息,但官方统计库及普通代理日志不保存这些信息。默认每日 100 MB 中转额度,上下行合计,北京时间零点重置;直连不消耗额度。关闭官方服务会停止其请求、轮询与中转通道。</p></section>
+<section><h2>网站与可审计边界</h2><p>本站使用既有的 Cloudflare Web Analytics,网站访问不等于软件用户统计。客户端、信令和 TURN 保持开源,公开所有官方网关协议与字段;私有生产后台的实际存储行为仍需要部署审计。</p></section><p><a href="https://github.com/baiyuze/pasteferry/blob/main/PRIVACY.md">PRIVACY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/SECURITY.md">SECURITY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/design/official-gateway.md">Gateway protocol v1</a></p></main>
+ <footer class="footer">
+ <div class="wrap">
+ <p>隔空贴以 GNU AGPL-3.0 开源。</p>
+ <nav aria-label="页脚链接">
+ <a href="https://github.com/baiyuze/pasteferry/releases">所有版本</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新记录</a>
+ <a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
+ <a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
+ </nav>
+ <nav aria-label="语言">
+ <a href="../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
+ <a href="../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a>
+ <a href="../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a>
+ <a href="../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a>
+ <a href="../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a>
+ </nav>
+ </div>
+ </footer>
+
+ <script src="../assets/site.js" defer></script>
+ <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
+</body>
+</html>
diff --git a/docs/server/index.html b/docs/server/index.html
index 1286428..66618a0 100644
--- a/docs/server/index.html
+++ b/docs/server/index.html
@@ -393,6 +393,7 @@ sudo ./install.sh</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index a29a3d5..b4bb941 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -366,6 +366,51 @@
<xhtml:link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/tour/"/>
<xhtml:link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/tour/"/>
</url>
+ <url>
+ <loc>https://pasteferry.cc/privacy/</loc>
+ <lastmod>2026-10-14</lastmod>
+ <xhtml:link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/"/>
+ </url>
+ <url>
+ <loc>https://pasteferry.cc/zh-tw/privacy/</loc>
+ <lastmod>2026-10-14</lastmod>
+ <xhtml:link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/"/>
+ </url>
+ <url>
+ <loc>https://pasteferry.cc/zh-hk/privacy/</loc>
+ <lastmod>2026-10-14</lastmod>
+ <xhtml:link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/"/>
+ </url>
+ <url>
+ <loc>https://pasteferry.cc/en/privacy/</loc>
+ <lastmod>2026-10-14</lastmod>
+ <xhtml:link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/"/>
+ </url>
+ <url>
+ <loc>https://pasteferry.cc/ja/privacy/</loc>
+ <lastmod>2026-10-14</lastmod>
+ <xhtml:link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/"/>
+ <xhtml:link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/"/>
+ </url>
<url>
<loc>https://pasteferry.cc/design/nat-traversal.html</loc>
<lastmod>2026-10-14</lastmod>
diff --git a/docs/start/index.html b/docs/start/index.html
index b0df489..44edcd8 100644
--- a/docs/start/index.html
+++ b/docs/start/index.html
@@ -231,6 +231,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="../start/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/tailscale/index.html b/docs/tailscale/index.html
index 50828b9..5cda082 100644
--- a/docs/tailscale/index.html
+++ b/docs/tailscale/index.html
@@ -242,6 +242,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技术方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">许可说明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">反馈问题</a>
+ <a href="../privacy/">隐私与必要数据</a>
</nav>
<nav aria-label="语言">
<a href="../tailscale/" hreflang="zh-CN" lang="zh-CN" data-lang="zh" aria-current="page">简体中文</a>
diff --git a/docs/zh-hk/cloud/index.html b/docs/zh-hk/cloud/index.html
index dbe67fc..6b3617e 100644
--- a/docs/zh-hk/cloud/index.html
+++ b/docs/zh-hk/cloud/index.html
@@ -297,6 +297,7 @@ sudo ./install.sh 203.0.113.10</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../cloud/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-hk/download/index.html b/docs/zh-hk/download/index.html
index ec49655..09cb158 100644
--- a/docs/zh-hk/download/index.html
+++ b/docs/zh-hk/download/index.html
@@ -176,6 +176,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../download/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-hk/index.html b/docs/zh-hk/index.html
index 61f8466..2ff1165 100644
--- a/docs/zh-hk/index.html
+++ b/docs/zh-hk/index.html
@@ -593,6 +593,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-hk/lan/index.html b/docs/zh-hk/lan/index.html
index 9e9e22c..f38c31c 100644
--- a/docs/zh-hk/lan/index.html
+++ b/docs/zh-hk/lan/index.html
@@ -218,6 +218,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../lan/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-hk/privacy/index.html b/docs/zh-hk/privacy/index.html
new file mode 100644
index 0000000..1edb104
--- /dev/null
+++ b/docs/zh-hk/privacy/index.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html lang="zh-HK">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>私隱與必要資料 — PasteFerry</title>
+ <meta name="description" content="新安裝預設只使用區域網絡。啟用官方公網後才連接官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中轉並讀取機器額度摘要。">
+ <link rel="canonical" href="https://pasteferry.cc/zh-hk/privacy/">
+ <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/">
+ <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/">
+ <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/">
+ <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/">
+ <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/">
+ <meta name="theme-color" content="#141416">
+ <meta property="og:type" content="article">
+ <meta property="og:site_name" content="隔空貼">
+ <meta property="og:title" content="私隱與必要資料 — PasteFerry">
+ <meta property="og:description" content="新安裝預設只使用區域網絡。啟用官方公網後才連接官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中轉並讀取機器額度摘要。">
+ <meta property="og:url" content="https://pasteferry.cc/zh-hk/privacy/">
+ <meta property="og:image" content="https://pasteferry.cc/assets/og-zh-hant.png">
+ <meta property="og:locale" content="zh_HK">
+ <meta name="twitter:card" content="summary_large_image">
+ <link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
+ <link rel="icon" href="../../assets/favicon-32.png" sizes="32x32" type="image/png">
+ <link rel="apple-touch-icon" href="../../assets/apple-touch-icon.png">
+ <link rel="stylesheet" href="../../assets/site.css">
+</head>
+<body>
+ <a class="skip" href="#main">跳至主要內容</a>
+
+ <header class="bar">
+ <div class="wrap">
+ <a class="brand" href="../../zh-hk/" aria-label="隔空貼首頁"><img src="../../assets/icon.svg" alt="" width="26" height="26">隔空貼</a>
+ <nav aria-label="頁面導覽">
+ <a href="../../zh-hk/start/">快速開始</a>
+ <a class="wide" href="../../zh-hk/#how">運作原理</a>
+ <a class="wide" href="../../zh-hk/#faq">常見問題</a>
+ <a class="mid" href="../../zh-hk/start/#server">連線方式</a>
+ <a href="../../zh-hk/download/">下載</a>
+ <a class="wide" href="https://github.com/baiyuze/pasteferry">GitHub</a>
+ <details class="lang">
+ <summary aria-label="語言:繁體中文(香港)"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>繁體中文(香港)</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
+ <ul>
+ <li><a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a></li>
+ <li><a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a></li>
+ <li><a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk" aria-current="page">繁體中文(香港)</a></li>
+ <li><a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a></li>
+ <li><a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a></li>
+ </ul>
+ </details>
+ </nav>
+ </div>
+ </header>
+<main id="main" class="wrap" style="max-width:850px;padding-top:5rem;padding-bottom:5rem;line-height:1.9"><h1>私隱與必要資料</h1><section><h2>由你決定使用官方服務</h2><p>新安裝預設只使用區域網絡。啟用官方公網後才連接官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中轉並讀取機器額度摘要。</p></section>
+<section><h2>最少必要資料</h2><p>網關保留去識別化裝置編號、首次與最近連線時間、每日中轉用量、必要額度綁定和累計彙總。每日裝置明細保留 90 天。這是官方服務裝置數,不是人數或全部安裝量。</p></section>
+<section><h2>內容與機器識別碼</h2><p>內容與真實裝置名稱透過裝置間加密通道傳送。不收集檔案名稱、路徑、用戶名稱、MAC、UA 或行為軌跡。原始系統識別碼不上傳;摘要只用於額度分組,並非不可偽造。</p></section>
+<section><h2>網絡資料與額度</h2><p>網絡端點暫時可見路由和網絡地址,官方統計庫及一般代理日誌不保存這些資料。每日 100 MB 中轉額度,含上下行,北京時間午夜重設;直連不計入。關閉官方服務會停止其請求、輪詢及通道。</p></section>
+<section><h2>網站與審計</h2><p>本站使用既有的 Cloudflare Web Analytics,瀏覽量不代表軟件用戶數。用戶端、信令及 TURN 持續開源,網關協定和欄位公開;私有正式環境的儲存行為仍需部署審計。</p></section><p><a href="https://github.com/baiyuze/pasteferry/blob/main/PRIVACY.md">PRIVACY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/SECURITY.md">SECURITY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/design/official-gateway.md">Gateway protocol v1</a></p></main>
+ <footer class="footer">
+ <div class="wrap">
+ <p>隔空貼以 GNU AGPL-3.0 開源。</p>
+ <nav aria-label="頁尾連結">
+ <a href="https://github.com/baiyuze/pasteferry/releases">所有版本</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新記錄</a>
+ <a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
+ <a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
+ </nav>
+ <nav aria-label="語言">
+ <a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
+ <a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw">繁體中文(台灣)</a>
+ <a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk" aria-current="page">繁體中文(香港)</a>
+ <a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a>
+ <a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a>
+ </nav>
+ </div>
+ </footer>
+
+ <script src="../../assets/site.js" defer></script>
+ <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
+</body>
+</html>
diff --git a/docs/zh-hk/server/index.html b/docs/zh-hk/server/index.html
index 7d3cf66..97888f4 100644
--- a/docs/zh-hk/server/index.html
+++ b/docs/zh-hk/server/index.html
@@ -393,6 +393,7 @@ sudo ./install.sh</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-hk/start/index.html b/docs/zh-hk/start/index.html
index 155a738..dfd4b57 100644
--- a/docs/zh-hk/start/index.html
+++ b/docs/zh-hk/start/index.html
@@ -231,6 +231,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../start/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-hk/tailscale/index.html b/docs/zh-hk/tailscale/index.html
index 356c915..9364ead 100644
--- a/docs/zh-hk/tailscale/index.html
+++ b/docs/zh-hk/tailscale/index.html
@@ -242,6 +242,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術方案</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-hk/privacy/">私隱與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../tailscale/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/cloud/index.html b/docs/zh-tw/cloud/index.html
index 32d0817..e87b7fb 100644
--- a/docs/zh-tw/cloud/index.html
+++ b/docs/zh-tw/cloud/index.html
@@ -297,6 +297,7 @@ sudo ./install.sh 203.0.113.10</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../cloud/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/download/index.html b/docs/zh-tw/download/index.html
index d3e5371..3b69eb4 100644
--- a/docs/zh-tw/download/index.html
+++ b/docs/zh-tw/download/index.html
@@ -176,6 +176,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../download/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/index.html b/docs/zh-tw/index.html
index c5d4c59..38738e3 100644
--- a/docs/zh-tw/index.html
+++ b/docs/zh-tw/index.html
@@ -593,6 +593,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href=".././" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/lan/index.html b/docs/zh-tw/lan/index.html
index bdc9de0..aa9050c 100644
--- a/docs/zh-tw/lan/index.html
+++ b/docs/zh-tw/lan/index.html
@@ -218,6 +218,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../lan/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/privacy/index.html b/docs/zh-tw/privacy/index.html
new file mode 100644
index 0000000..4adf35b
--- /dev/null
+++ b/docs/zh-tw/privacy/index.html
@@ -0,0 +1,83 @@
+<!doctype html>
+<html lang="zh-TW">
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>隱私與必要資料 — PasteFerry</title>
+ <meta name="description" content="新安裝預設僅使用區域網路。啟用官方公網後才連線官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中繼並讀取機器額度摘要。">
+ <link rel="canonical" href="https://pasteferry.cc/zh-tw/privacy/">
+ <link rel="alternate" hreflang="zh-CN" href="https://pasteferry.cc/privacy/">
+ <link rel="alternate" hreflang="zh-TW" href="https://pasteferry.cc/zh-tw/privacy/">
+ <link rel="alternate" hreflang="zh-HK" href="https://pasteferry.cc/zh-hk/privacy/">
+ <link rel="alternate" hreflang="en" href="https://pasteferry.cc/en/privacy/">
+ <link rel="alternate" hreflang="ja" href="https://pasteferry.cc/ja/privacy/">
+ <meta name="theme-color" content="#141416">
+ <meta property="og:type" content="article">
+ <meta property="og:site_name" content="隔空貼">
+ <meta property="og:title" content="隱私與必要資料 — PasteFerry">
+ <meta property="og:description" content="新安裝預設僅使用區域網路。啟用官方公網後才連線官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中繼並讀取機器額度摘要。">
+ <meta property="og:url" content="https://pasteferry.cc/zh-tw/privacy/">
+ <meta property="og:image" content="https://pasteferry.cc/assets/og-zh-hant.png">
+ <meta property="og:locale" content="zh_TW">
+ <meta name="twitter:card" content="summary_large_image">
+ <link rel="icon" href="../../assets/favicon.svg" type="image/svg+xml">
+ <link rel="icon" href="../../assets/favicon-32.png" sizes="32x32" type="image/png">
+ <link rel="apple-touch-icon" href="../../assets/apple-touch-icon.png">
+ <link rel="stylesheet" href="../../assets/site.css">
+</head>
+<body>
+ <a class="skip" href="#main">跳到主要內容</a>
+
+ <header class="bar">
+ <div class="wrap">
+ <a class="brand" href="../../zh-tw/" aria-label="隔空貼首頁"><img src="../../assets/icon.svg" alt="" width="26" height="26">隔空貼</a>
+ <nav aria-label="頁面導覽">
+ <a href="../../zh-tw/start/">快速入門</a>
+ <a class="wide" href="../../zh-tw/#how">運作原理</a>
+ <a class="wide" href="../../zh-tw/#faq">常見問題</a>
+ <a class="mid" href="../../zh-tw/start/#server">連線方式</a>
+ <a href="../../zh-tw/download/">下載</a>
+ <a class="wide" href="https://github.com/baiyuze/pasteferry">GitHub</a>
+ <details class="lang">
+ <summary aria-label="語言:繁體中文(台灣)"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.4" aria-hidden="true"><circle cx="10" cy="10" r="7.25"/><path d="M2.75 10h14.5M10 2.75c-2.1 2-3.1 4.4-3.1 7.25s1 5.25 3.1 7.25M10 2.75c2.1 2 3.1 4.4 3.1 7.25s-1 5.25-3.1 7.25"/></svg><span>繁體中文(台灣)</span><svg class="chev" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3 4.5 3 3 3-3"/></svg></summary>
+ <ul>
+ <li><a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a></li>
+ <li><a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw" aria-current="page">繁體中文(台灣)</a></li>
+ <li><a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a></li>
+ <li><a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a></li>
+ <li><a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a></li>
+ </ul>
+ </details>
+ </nav>
+ </div>
+ </header>
+<main id="main" class="wrap" style="max-width:850px;padding-top:5rem;padding-bottom:5rem;line-height:1.9"><h1>隱私與必要資料</h1><section><h2>由你決定使用官方服務</h2><p>新安裝預設僅使用區域網路。啟用官方公網後才連線官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中繼並讀取機器額度摘要。</p></section>
+<section><h2>最少必要資料</h2><p>網關保留去識別化裝置編號、首次與最近連線時間、每日中繼用量、必要額度綁定和累計彙總。每日裝置明細保留 90 天。這是官方服務裝置數,不是人數或全部安裝量。</p></section>
+<section><h2>內容與機器識別碼</h2><p>內容與真實裝置名稱透過裝置間加密通道傳送。不收集檔名、路徑、使用者名稱、MAC、UA 或行為軌跡。原始系統識別碼不上傳;摘要只用於額度分組,並非不可偽造。</p></section>
+<section><h2>網路資訊與額度</h2><p>網路端點暫時可見路由和網路位址,官方統計庫及一般代理日誌不保存這些資訊。每日 100 MB 中繼額度,含上下行,北京時間午夜重設;直連不計入。關閉官方服務會停止其請求、輪詢及通道。</p></section>
+<section><h2>網站與稽核</h2><p>本站使用既有的 Cloudflare Web Analytics,瀏覽量不代表軟體使用者數。用戶端、信令及 TURN 持續開源,網關協定和欄位公開;私有正式環境的儲存行為仍需部署稽核。</p></section><p><a href="https://github.com/baiyuze/pasteferry/blob/main/PRIVACY.md">PRIVACY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/SECURITY.md">SECURITY.md</a> · <a href="https://github.com/baiyuze/pasteferry/blob/main/design/official-gateway.md">Gateway protocol v1</a></p></main>
+ <footer class="footer">
+ <div class="wrap">
+ <p>隔空貼以 GNU AGPL-3.0 授權開源。</p>
+ <nav aria-label="頁尾連結">
+ <a href="https://github.com/baiyuze/pasteferry/releases">所有版本</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/CHANGELOG.md">更新記錄</a>
+ <a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
+ <a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
+ <a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
+ </nav>
+ <nav aria-label="語言">
+ <a href="../../privacy/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
+ <a href="../../zh-tw/privacy/" hreflang="zh-TW" lang="zh-TW" data-lang="zh-tw" aria-current="page">繁體中文(台灣)</a>
+ <a href="../../zh-hk/privacy/" hreflang="zh-HK" lang="zh-HK" data-lang="zh-hk">繁體中文(香港)</a>
+ <a href="../../en/privacy/" hreflang="en" lang="en" data-lang="en">English</a>
+ <a href="../../ja/privacy/" hreflang="ja" lang="ja" data-lang="ja">日本語</a>
+ </nav>
+ </div>
+ </footer>
+
+ <script src="../../assets/site.js" defer></script>
+ <script type="module" src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "7ee226baf4a949a397c4bfd69a9e7461"}'></script>
+</body>
+</html>
diff --git a/docs/zh-tw/server/index.html b/docs/zh-tw/server/index.html
index 32ae513..2bc982d 100644
--- a/docs/zh-tw/server/index.html
+++ b/docs/zh-tw/server/index.html
@@ -393,6 +393,7 @@ sudo ./install.sh</code></pre>
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../server/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/start/index.html b/docs/zh-tw/start/index.html
index 9b25f1f..f90d217 100644
--- a/docs/zh-tw/start/index.html
+++ b/docs/zh-tw/start/index.html
@@ -231,6 +231,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../start/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/docs/zh-tw/tailscale/index.html b/docs/zh-tw/tailscale/index.html
index 9fb87fc..52c65cc 100644
--- a/docs/zh-tw/tailscale/index.html
+++ b/docs/zh-tw/tailscale/index.html
@@ -242,6 +242,7 @@
<a href="https://pasteferry.cc/design/nat-traversal.html">技術說明</a>
<a href="https://github.com/baiyuze/pasteferry/blob/main/LICENSING.md">授權說明</a>
<a href="https://github.com/baiyuze/pasteferry/issues">回報問題</a>
+ <a href="../../zh-tw/privacy/">隱私與必要資料</a>
</nav>
<nav aria-label="語言">
<a href="../../tailscale/" hreflang="zh-CN" lang="zh-CN" data-lang="zh">简体中文</a>
diff --git a/go.work b/go.work
index eb0501e..e60fa6f 100644
--- a/go.work
+++ b/go.work
@@ -1,4 +1,4 @@
-go 1.26.3
+go 1.26.9
use (
./proto
diff --git a/go.work.sum b/go.work.sum
index cf77978..e3446a6 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -1,15 +1,11 @@
-github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/pion/transport/v4 v4.0.2/go.mod h1:06hFI+jCFcok2X2MekVufNZ/uzNZXivGBPfviSVcjgM=
-github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/pion/transport/v5 v5.0.0/go.mod h1:Qxw6fCEjFWQkRDZOhS4Vf+neJBcihauvA3uyEa1J1F0=
github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0=
-github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
-github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
-go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/crypto v0.48.0/go.mod h1:r0kV5h3qnFPlQnBSrULhlsRfryS2pmewsg+XfMgkVos=
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec=
+golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
+golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/proto/gen/pasteferry/v1/daemon.pb.go b/proto/gen/pasteferry/v1/daemon.pb.go
index d971bc6..687207c 100644
--- a/proto/gen/pasteferry/v1/daemon.pb.go
+++ b/proto/gen/pasteferry/v1/daemon.pb.go
@@ -251,6 +251,58 @@ func (ClipboardPermission) EnumDescriptor() ([]byte, []int) {
return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{3}
}
+type ServiceMode int32
+
+const (
+ ServiceMode_SERVICE_MODE_UNSPECIFIED ServiceMode = 0
+ ServiceMode_SERVICE_MODE_LAN ServiceMode = 1
+ ServiceMode_SERVICE_MODE_OFFICIAL ServiceMode = 2
+ ServiceMode_SERVICE_MODE_CUSTOM ServiceMode = 3
+)
+
+// Enum value maps for ServiceMode.
+var (
+ ServiceMode_name = map[int32]string{
+ 0: "SERVICE_MODE_UNSPECIFIED",
+ 1: "SERVICE_MODE_LAN",
+ 2: "SERVICE_MODE_OFFICIAL",
+ 3: "SERVICE_MODE_CUSTOM",
+ }
+ ServiceMode_value = map[string]int32{
+ "SERVICE_MODE_UNSPECIFIED": 0,
+ "SERVICE_MODE_LAN": 1,
+ "SERVICE_MODE_OFFICIAL": 2,
+ "SERVICE_MODE_CUSTOM": 3,
+ }
+)
+
+func (x ServiceMode) Enum() *ServiceMode {
+ p := new(ServiceMode)
+ *p = x
+ return p
+}
+
+func (x ServiceMode) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (ServiceMode) Descriptor() protoreflect.EnumDescriptor {
+ return file_pasteferry_v1_daemon_proto_enumTypes[4].Descriptor()
+}
+
+func (ServiceMode) Type() protoreflect.EnumType {
+ return &file_pasteferry_v1_daemon_proto_enumTypes[4]
+}
+
+func (x ServiceMode) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use ServiceMode.Descriptor instead.
+func (ServiceMode) EnumDescriptor() ([]byte, []int) {
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{4}
+}
+
type Empty struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
@@ -1696,9 +1748,13 @@ type Config struct {
Language string `protobuf:"bytes,13,opt,name=language,proto3" json:"language,omitempty"`
// 不在局域网里查找设备、也不接受局域网里的配对请求。
// 默认 false(即开启):写成反向的,旧配置不用迁移。
- LanDisabled bool `protobuf:"varint,14,opt,name=lan_disabled,json=lanDisabled,proto3" json:"lan_disabled,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
+ LanDisabled bool `protobuf:"varint,14,opt,name=lan_disabled,json=lanDisabled,proto3" json:"lan_disabled,omitempty"`
+ // Official service is opt-in; remembered custom URLs are inactive otherwise.
+ ServiceMode ServiceMode `protobuf:"varint,15,opt,name=service_mode,json=serviceMode,proto3,enum=pasteferry.v1.ServiceMode" json:"service_mode,omitempty"`
+ CustomSignalingUrl string `protobuf:"bytes,16,opt,name=custom_signaling_url,json=customSignalingUrl,proto3" json:"custom_signaling_url,omitempty"`
+ OfficialNoticeAck string `protobuf:"bytes,17,opt,name=official_notice_ack,json=officialNoticeAck,proto3" json:"official_notice_ack,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
}
func (x *Config) Reset() {
@@ -1829,6 +1885,143 @@ func (x *Config) GetLanDisabled() bool {
return false
}
+func (x *Config) GetServiceMode() ServiceMode {
+ if x != nil {
+ return x.ServiceMode
+ }
+ return ServiceMode_SERVICE_MODE_UNSPECIFIED
+}
+
+func (x *Config) GetCustomSignalingUrl() string {
+ if x != nil {
+ return x.CustomSignalingUrl
+ }
+ return ""
+}
+
+func (x *Config) GetOfficialNoticeAck() string {
+ if x != nil {
+ return x.OfficialNoticeAck
+ }
+ return ""
+}
+
+type OfficialUsage struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Available bool `protobuf:"varint,1,opt,name=available,proto3" json:"available,omitempty"`
+ Day string `protobuf:"bytes,2,opt,name=day,proto3" json:"day,omitempty"`
+ QuotaGroup string `protobuf:"bytes,3,opt,name=quota_group,json=quotaGroup,proto3" json:"quota_group,omitempty"`
+ UploadBytes int64 `protobuf:"varint,4,opt,name=upload_bytes,json=uploadBytes,proto3" json:"upload_bytes,omitempty"`
+ DownloadBytes int64 `protobuf:"varint,5,opt,name=download_bytes,json=downloadBytes,proto3" json:"download_bytes,omitempty"`
+ LimitBytes int64 `protobuf:"varint,6,opt,name=limit_bytes,json=limitBytes,proto3" json:"limit_bytes,omitempty"`
+ RemainingBytes int64 `protobuf:"varint,7,opt,name=remaining_bytes,json=remainingBytes,proto3" json:"remaining_bytes,omitempty"`
+ ResetAtUnix int64 `protobuf:"varint,8,opt,name=reset_at_unix,json=resetAtUnix,proto3" json:"reset_at_unix,omitempty"`
+ UpdatedAtUnix int64 `protobuf:"varint,9,opt,name=updated_at_unix,json=updatedAtUnix,proto3" json:"updated_at_unix,omitempty"`
+ Reason string `protobuf:"bytes,10,opt,name=reason,proto3" json:"reason,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *OfficialUsage) Reset() {
+ *x = OfficialUsage{}
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[23]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *OfficialUsage) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*OfficialUsage) ProtoMessage() {}
+
+func (x *OfficialUsage) ProtoReflect() protoreflect.Message {
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[23]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use OfficialUsage.ProtoReflect.Descriptor instead.
+func (*OfficialUsage) Descriptor() ([]byte, []int) {
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{23}
+}
+
+func (x *OfficialUsage) GetAvailable() bool {
+ if x != nil {
+ return x.Available
+ }
+ return false
+}
+
+func (x *OfficialUsage) GetDay() string {
+ if x != nil {
+ return x.Day
+ }
+ return ""
+}
+
+func (x *OfficialUsage) GetQuotaGroup() string {
+ if x != nil {
+ return x.QuotaGroup
+ }
+ return ""
+}
+
+func (x *OfficialUsage) GetUploadBytes() int64 {
+ if x != nil {
+ return x.UploadBytes
+ }
+ return 0
+}
+
+func (x *OfficialUsage) GetDownloadBytes() int64 {
+ if x != nil {
+ return x.DownloadBytes
+ }
+ return 0
+}
+
+func (x *OfficialUsage) GetLimitBytes() int64 {
+ if x != nil {
+ return x.LimitBytes
+ }
+ return 0
+}
+
+func (x *OfficialUsage) GetRemainingBytes() int64 {
+ if x != nil {
+ return x.RemainingBytes
+ }
+ return 0
+}
+
+func (x *OfficialUsage) GetResetAtUnix() int64 {
+ if x != nil {
+ return x.ResetAtUnix
+ }
+ return 0
+}
+
+func (x *OfficialUsage) GetUpdatedAtUnix() int64 {
+ if x != nil {
+ return x.UpdatedAtUnix
+ }
+ return 0
+}
+
+func (x *OfficialUsage) GetReason() string {
+ if x != nil {
+ return x.Reason
+ }
+ return ""
+}
+
// 最近一轮网络出口探测的结果。
type NetworkInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -1844,7 +2037,7 @@ type NetworkInfo struct {
func (x *NetworkInfo) Reset() {
*x = NetworkInfo{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[23]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[24]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1856,7 +2049,7 @@ func (x *NetworkInfo) String() string {
func (*NetworkInfo) ProtoMessage() {}
func (x *NetworkInfo) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[23]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[24]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1869,7 +2062,7 @@ func (x *NetworkInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use NetworkInfo.ProtoReflect.Descriptor instead.
func (*NetworkInfo) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{23}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{24}
}
func (x *NetworkInfo) GetLocalPort() int32 {
@@ -1929,7 +2122,7 @@ type LanInfo struct {
func (x *LanInfo) Reset() {
*x = LanInfo{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[24]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[25]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -1941,7 +2134,7 @@ func (x *LanInfo) String() string {
func (*LanInfo) ProtoMessage() {}
func (x *LanInfo) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[24]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[25]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -1954,7 +2147,7 @@ func (x *LanInfo) ProtoReflect() protoreflect.Message {
// Deprecated: Use LanInfo.ProtoReflect.Descriptor instead.
func (*LanInfo) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{24}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{25}
}
func (x *LanInfo) GetEnabled() bool {
@@ -2013,7 +2206,7 @@ type LanPeer struct {
func (x *LanPeer) Reset() {
*x = LanPeer{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[25]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[26]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2025,7 +2218,7 @@ func (x *LanPeer) String() string {
func (*LanPeer) ProtoMessage() {}
func (x *LanPeer) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[25]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[26]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2038,7 +2231,7 @@ func (x *LanPeer) ProtoReflect() protoreflect.Message {
// Deprecated: Use LanPeer.ProtoReflect.Descriptor instead.
func (*LanPeer) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{25}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{26}
}
func (x *LanPeer) GetDeviceId() string {
@@ -2095,7 +2288,7 @@ type NetworkEgress struct {
func (x *NetworkEgress) Reset() {
*x = NetworkEgress{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[26]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[27]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2107,7 +2300,7 @@ func (x *NetworkEgress) String() string {
func (*NetworkEgress) ProtoMessage() {}
func (x *NetworkEgress) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[26]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[27]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2120,7 +2313,7 @@ func (x *NetworkEgress) ProtoReflect() protoreflect.Message {
// Deprecated: Use NetworkEgress.ProtoReflect.Descriptor instead.
func (*NetworkEgress) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{26}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{27}
}
func (x *NetworkEgress) GetAddress() string {
@@ -2166,14 +2359,15 @@ type Status struct {
// 系统拦下了本机发往局域网的包:macOS 上是没允许「本地网络」权限
LanBlocked bool `protobuf:"varint,10,opt,name=lan_blocked,json=lanBlocked,proto3" json:"lan_blocked,omitempty"`
// 详细日志打开到什么时候;0 表示没打开
- VerboseLogUntilUnix int64 `protobuf:"varint,11,opt,name=verbose_log_until_unix,json=verboseLogUntilUnix,proto3" json:"verbose_log_until_unix,omitempty"`
+ VerboseLogUntilUnix int64 `protobuf:"varint,11,opt,name=verbose_log_until_unix,json=verboseLogUntilUnix,proto3" json:"verbose_log_until_unix,omitempty"`
+ OfficialUsage *OfficialUsage `protobuf:"bytes,12,opt,name=official_usage,json=officialUsage,proto3" json:"official_usage,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Status) Reset() {
*x = Status{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[27]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[28]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2185,7 +2379,7 @@ func (x *Status) String() string {
func (*Status) ProtoMessage() {}
func (x *Status) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[27]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[28]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2198,7 +2392,7 @@ func (x *Status) ProtoReflect() protoreflect.Message {
// Deprecated: Use Status.ProtoReflect.Descriptor instead.
func (*Status) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{27}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{28}
}
func (x *Status) GetDeviceId() string {
@@ -2278,6 +2472,13 @@ func (x *Status) GetVerboseLogUntilUnix() int64 {
return 0
}
+func (x *Status) GetOfficialUsage() *OfficialUsage {
+ if x != nil {
+ return x.OfficialUsage
+ }
+ return nil
+}
+
type ExportDiagnosticsRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
LogLines int32 `protobuf:"varint,1,opt,name=log_lines,json=logLines,proto3" json:"log_lines,omitempty"` // 带上最近多少行日志
@@ -2288,7 +2489,7 @@ type ExportDiagnosticsRequest struct {
func (x *ExportDiagnosticsRequest) Reset() {
*x = ExportDiagnosticsRequest{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[28]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[29]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2300,7 +2501,7 @@ func (x *ExportDiagnosticsRequest) String() string {
func (*ExportDiagnosticsRequest) ProtoMessage() {}
func (x *ExportDiagnosticsRequest) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[28]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[29]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2313,7 +2514,7 @@ func (x *ExportDiagnosticsRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use ExportDiagnosticsRequest.ProtoReflect.Descriptor instead.
func (*ExportDiagnosticsRequest) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{28}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{29}
}
func (x *ExportDiagnosticsRequest) GetLogLines() int32 {
@@ -2339,7 +2540,7 @@ type Diagnostics struct {
func (x *Diagnostics) Reset() {
*x = Diagnostics{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[29]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[30]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2351,7 +2552,7 @@ func (x *Diagnostics) String() string {
func (*Diagnostics) ProtoMessage() {}
func (x *Diagnostics) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[29]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[30]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2364,7 +2565,7 @@ func (x *Diagnostics) ProtoReflect() protoreflect.Message {
// Deprecated: Use Diagnostics.ProtoReflect.Descriptor instead.
func (*Diagnostics) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{29}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{30}
}
func (x *Diagnostics) GetReport() string {
@@ -2383,7 +2584,7 @@ type SetVerboseLogRequest struct {
func (x *SetVerboseLogRequest) Reset() {
*x = SetVerboseLogRequest{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[30]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[31]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2395,7 +2596,7 @@ func (x *SetVerboseLogRequest) String() string {
func (*SetVerboseLogRequest) ProtoMessage() {}
func (x *SetVerboseLogRequest) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[30]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[31]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2408,7 +2609,7 @@ func (x *SetVerboseLogRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SetVerboseLogRequest.ProtoReflect.Descriptor instead.
func (*SetVerboseLogRequest) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{30}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{31}
}
func (x *SetVerboseLogRequest) GetMinutes() int32 {
@@ -2428,7 +2629,7 @@ type GetImagePreviewRequest struct {
func (x *GetImagePreviewRequest) Reset() {
*x = GetImagePreviewRequest{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[31]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[32]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2440,7 +2641,7 @@ func (x *GetImagePreviewRequest) String() string {
func (*GetImagePreviewRequest) ProtoMessage() {}
func (x *GetImagePreviewRequest) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[31]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[32]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2453,7 +2654,7 @@ func (x *GetImagePreviewRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetImagePreviewRequest.ProtoReflect.Descriptor instead.
func (*GetImagePreviewRequest) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{31}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{32}
}
func (x *GetImagePreviewRequest) GetClipId() string {
@@ -2481,7 +2682,7 @@ type GetImagePreviewResponse struct {
func (x *GetImagePreviewResponse) Reset() {
*x = GetImagePreviewResponse{}
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[32]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[33]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2493,7 +2694,7 @@ func (x *GetImagePreviewResponse) String() string {
func (*GetImagePreviewResponse) ProtoMessage() {}
func (x *GetImagePreviewResponse) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_daemon_proto_msgTypes[32]
+ mi := &file_pasteferry_v1_daemon_proto_msgTypes[33]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2506,7 +2707,7 @@ func (x *GetImagePreviewResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetImagePreviewResponse.ProtoReflect.Descriptor instead.
func (*GetImagePreviewResponse) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{32}
+ return file_pasteferry_v1_daemon_proto_rawDescGZIP(), []int{33}
}
func (x *GetImagePreviewResponse) GetPath() string {
@@ -2635,7 +2836,7 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\"P\n" +
"\x17SetDeviceAddressRequest\x12\x1b\n" +
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\x12\x18\n" +
- "\aaddress\x18\x02 \x01(\tR\aaddress\"\x9d\x04\n" +
+ "\aaddress\x18\x02 \x01(\tR\aaddress\"\xbe\x05\n" +
"\x06Config\x129\n" +
"\x19auto_sync_threshold_bytes\x18\x01 \x01(\x03R\x16autoSyncThresholdBytes\x12.\n" +
"\x13history_ttl_seconds\x18\x02 \x01(\x03R\x11historyTtlSeconds\x12*\n" +
@@ -2653,7 +2854,24 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +
"\rsignaling_url\x18\v \x01(\tR\fsignalingUrl\x12\"\n" +
"\ronly_own_stun\x18\f \x01(\bR\vonlyOwnStun\x12\x1a\n" +
"\blanguage\x18\r \x01(\tR\blanguage\x12!\n" +
- "\flan_disabled\x18\x0e \x01(\bR\vlanDisabled\"\xea\x01\n" +
+ "\flan_disabled\x18\x0e \x01(\bR\vlanDisabled\x12=\n" +
+ "\fservice_mode\x18\x0f \x01(\x0e2\x1a.pasteferry.v1.ServiceModeR\vserviceMode\x120\n" +
+ "\x14custom_signaling_url\x18\x10 \x01(\tR\x12customSignalingUrl\x12.\n" +
+ "\x13official_notice_ack\x18\x11 \x01(\tR\x11officialNoticeAck\"\xd8\x02\n" +
+ "\rOfficialUsage\x12\x1c\n" +
+ "\tavailable\x18\x01 \x01(\bR\tavailable\x12\x10\n" +
+ "\x03day\x18\x02 \x01(\tR\x03day\x12\x1f\n" +
+ "\vquota_group\x18\x03 \x01(\tR\n" +
+ "quotaGroup\x12!\n" +
+ "\fupload_bytes\x18\x04 \x01(\x03R\vuploadBytes\x12%\n" +
+ "\x0edownload_bytes\x18\x05 \x01(\x03R\rdownloadBytes\x12\x1f\n" +
+ "\vlimit_bytes\x18\x06 \x01(\x03R\n" +
+ "limitBytes\x12'\n" +
+ "\x0fremaining_bytes\x18\a \x01(\x03R\x0eremainingBytes\x12\"\n" +
+ "\rreset_at_unix\x18\b \x01(\x03R\vresetAtUnix\x12&\n" +
+ "\x0fupdated_at_unix\x18\t \x01(\x03R\rupdatedAtUnix\x12\x16\n" +
+ "\x06reason\x18\n" +
+ " \x01(\tR\x06reason\"\xea\x01\n" +
"\vNetworkInfo\x12\x1d\n" +
"\n" +
"local_port\x18\x01 \x01(\x05R\tlocalPort\x128\n" +
@@ -2683,7 +2901,7 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +
"\aaddress\x18\x01 \x01(\tR\aaddress\x12%\n" +
"\x0eport_preserved\x18\x02 \x01(\bR\rportPreserved\x12\x18\n" +
"\aguessed\x18\x03 \x01(\bR\aguessed\x12\x10\n" +
- "\x03via\x18\x04 \x03(\tR\x03via\"\xd9\x03\n" +
+ "\x03via\x18\x04 \x03(\tR\x03via\"\x9e\x04\n" +
"\x06Status\x12\x1b\n" +
"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\x12\x1f\n" +
"\vdevice_name\x18\x02 \x01(\tR\n" +
@@ -2699,7 +2917,8 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +
"\vlan_blocked\x18\n" +
" \x01(\bR\n" +
"lanBlocked\x123\n" +
- "\x16verbose_log_until_unix\x18\v \x01(\x03R\x13verboseLogUntilUnix\"V\n" +
+ "\x16verbose_log_until_unix\x18\v \x01(\x03R\x13verboseLogUntilUnix\x12C\n" +
+ "\x0eofficial_usage\x18\f \x01(\v2\x1c.pasteferry.v1.OfficialUsageR\rofficialUsage\"V\n" +
"\x18ExportDiagnosticsRequest\x12\x1b\n" +
"\tlog_lines\x18\x01 \x01(\x05R\blogLines\x12\x1d\n" +
"\n" +
@@ -2740,7 +2959,12 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +
"\x1cCLIPBOARD_PERMISSION_DEFAULT\x10\x02\x12\x1c\n" +
"\x18CLIPBOARD_PERMISSION_ASK\x10\x03\x12%\n" +
"!CLIPBOARD_PERMISSION_ALWAYS_ALLOW\x10\x04\x12$\n" +
- " CLIPBOARD_PERMISSION_ALWAYS_DENY\x10\x052\x9a\r\n" +
+ " CLIPBOARD_PERMISSION_ALWAYS_DENY\x10\x05*u\n" +
+ "\vServiceMode\x12\x1c\n" +
+ "\x18SERVICE_MODE_UNSPECIFIED\x10\x00\x12\x14\n" +
+ "\x10SERVICE_MODE_LAN\x10\x01\x12\x19\n" +
+ "\x15SERVICE_MODE_OFFICIAL\x10\x02\x12\x17\n" +
+ "\x13SERVICE_MODE_CUSTOM\x10\x032\x9a\r\n" +
"\rDaemonService\x12D\n" +
"\tSubscribe\x12\x1f.pasteferry.v1.SubscribeRequest\x1a\x14.pasteferry.v1.Event0\x01\x12T\n" +
"\vListHistory\x12!.pasteferry.v1.ListHistoryRequest\x1a\".pasteferry.v1.ListHistoryResponse\x12J\n" +
@@ -2779,117 +3003,121 @@ func file_pasteferry_v1_daemon_proto_rawDescGZIP() []byte {
return file_pasteferry_v1_daemon_proto_rawDescData
}
-var file_pasteferry_v1_daemon_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
-var file_pasteferry_v1_daemon_proto_msgTypes = make([]protoimpl.MessageInfo, 33)
+var file_pasteferry_v1_daemon_proto_enumTypes = make([]protoimpl.EnumInfo, 5)
+var file_pasteferry_v1_daemon_proto_msgTypes = make([]protoimpl.MessageInfo, 34)
var file_pasteferry_v1_daemon_proto_goTypes = []any{
(ClipKind)(0), // 0: pasteferry.v1.ClipKind
(ClipStatus)(0), // 1: pasteferry.v1.ClipStatus
(ConnectionKind)(0), // 2: pasteferry.v1.ConnectionKind
(ClipboardPermission)(0), // 3: pasteferry.v1.ClipboardPermission
- (*Empty)(nil), // 4: pasteferry.v1.Empty
- (*ClipItem)(nil), // 5: pasteferry.v1.ClipItem
- (*ClipRecord)(nil), // 6: pasteferry.v1.ClipRecord
- (*SubscribeRequest)(nil), // 7: pasteferry.v1.SubscribeRequest
- (*TransferProgress)(nil), // 8: pasteferry.v1.TransferProgress
- (*Device)(nil), // 9: pasteferry.v1.Device
- (*Event)(nil), // 10: pasteferry.v1.Event
- (*ListHistoryRequest)(nil), // 11: pasteferry.v1.ListHistoryRequest
- (*ListHistoryResponse)(nil), // 12: pasteferry.v1.ListHistoryResponse
- (*DeleteHistoryRequest)(nil), // 13: pasteferry.v1.DeleteHistoryRequest
- (*FetchRequest)(nil), // 14: pasteferry.v1.FetchRequest
- (*ApplyToClipboardRequest)(nil), // 15: pasteferry.v1.ApplyToClipboardRequest
- (*ListDevicesResponse)(nil), // 16: pasteferry.v1.ListDevicesResponse
- (*CreatePairingCodeResponse)(nil), // 17: pasteferry.v1.CreatePairingCodeResponse
- (*RedeemPairingCodeRequest)(nil), // 18: pasteferry.v1.RedeemPairingCodeRequest
- (*RedeemPairingCodeResponse)(nil), // 19: pasteferry.v1.RedeemPairingCodeResponse
- (*ConfirmPairingRequest)(nil), // 20: pasteferry.v1.ConfirmPairingRequest
- (*NearbyDevice)(nil), // 21: pasteferry.v1.NearbyDevice
- (*NearbyDevices)(nil), // 22: pasteferry.v1.NearbyDevices
- (*PairNearbyRequest)(nil), // 23: pasteferry.v1.PairNearbyRequest
- (*UnpairRequest)(nil), // 24: pasteferry.v1.UnpairRequest
- (*SetDeviceAddressRequest)(nil), // 25: pasteferry.v1.SetDeviceAddressRequest
- (*Config)(nil), // 26: pasteferry.v1.Config
- (*NetworkInfo)(nil), // 27: pasteferry.v1.NetworkInfo
- (*LanInfo)(nil), // 28: pasteferry.v1.LanInfo
- (*LanPeer)(nil), // 29: pasteferry.v1.LanPeer
- (*NetworkEgress)(nil), // 30: pasteferry.v1.NetworkEgress
- (*Status)(nil), // 31: pasteferry.v1.Status
- (*ExportDiagnosticsRequest)(nil), // 32: pasteferry.v1.ExportDiagnosticsRequest
- (*Diagnostics)(nil), // 33: pasteferry.v1.Diagnostics
- (*SetVerboseLogRequest)(nil), // 34: pasteferry.v1.SetVerboseLogRequest
- (*GetImagePreviewRequest)(nil), // 35: pasteferry.v1.GetImagePreviewRequest
- (*GetImagePreviewResponse)(nil), // 36: pasteferry.v1.GetImagePreviewResponse
+ (ServiceMode)(0), // 4: pasteferry.v1.ServiceMode
+ (*Empty)(nil), // 5: pasteferry.v1.Empty
+ (*ClipItem)(nil), // 6: pasteferry.v1.ClipItem
+ (*ClipRecord)(nil), // 7: pasteferry.v1.ClipRecord
+ (*SubscribeRequest)(nil), // 8: pasteferry.v1.SubscribeRequest
+ (*TransferProgress)(nil), // 9: pasteferry.v1.TransferProgress
+ (*Device)(nil), // 10: pasteferry.v1.Device
+ (*Event)(nil), // 11: pasteferry.v1.Event
+ (*ListHistoryRequest)(nil), // 12: pasteferry.v1.ListHistoryRequest
+ (*ListHistoryResponse)(nil), // 13: pasteferry.v1.ListHistoryResponse
+ (*DeleteHistoryRequest)(nil), // 14: pasteferry.v1.DeleteHistoryRequest
+ (*FetchRequest)(nil), // 15: pasteferry.v1.FetchRequest
+ (*ApplyToClipboardRequest)(nil), // 16: pasteferry.v1.ApplyToClipboardRequest
+ (*ListDevicesResponse)(nil), // 17: pasteferry.v1.ListDevicesResponse
+ (*CreatePairingCodeResponse)(nil), // 18: pasteferry.v1.CreatePairingCodeResponse
+ (*RedeemPairingCodeRequest)(nil), // 19: pasteferry.v1.RedeemPairingCodeRequest
+ (*RedeemPairingCodeResponse)(nil), // 20: pasteferry.v1.RedeemPairingCodeResponse
+ (*ConfirmPairingRequest)(nil), // 21: pasteferry.v1.ConfirmPairingRequest
+ (*NearbyDevice)(nil), // 22: pasteferry.v1.NearbyDevice
+ (*NearbyDevices)(nil), // 23: pasteferry.v1.NearbyDevices
+ (*PairNearbyRequest)(nil), // 24: pasteferry.v1.PairNearbyRequest
+ (*UnpairRequest)(nil), // 25: pasteferry.v1.UnpairRequest
+ (*SetDeviceAddressRequest)(nil), // 26: pasteferry.v1.SetDeviceAddressRequest
+ (*Config)(nil), // 27: pasteferry.v1.Config
+ (*OfficialUsage)(nil), // 28: pasteferry.v1.OfficialUsage
+ (*NetworkInfo)(nil), // 29: pasteferry.v1.NetworkInfo
+ (*LanInfo)(nil), // 30: pasteferry.v1.LanInfo
+ (*LanPeer)(nil), // 31: pasteferry.v1.LanPeer
+ (*NetworkEgress)(nil), // 32: pasteferry.v1.NetworkEgress
+ (*Status)(nil), // 33: pasteferry.v1.Status
+ (*ExportDiagnosticsRequest)(nil), // 34: pasteferry.v1.ExportDiagnosticsRequest
+ (*Diagnostics)(nil), // 35: pasteferry.v1.Diagnostics
+ (*SetVerboseLogRequest)(nil), // 36: pasteferry.v1.SetVerboseLogRequest
+ (*GetImagePreviewRequest)(nil), // 37: pasteferry.v1.GetImagePreviewRequest
+ (*GetImagePreviewResponse)(nil), // 38: pasteferry.v1.GetImagePreviewResponse
}
var file_pasteferry_v1_daemon_proto_depIdxs = []int32{
0, // 0: pasteferry.v1.ClipRecord.kind:type_name -> pasteferry.v1.ClipKind
1, // 1: pasteferry.v1.ClipRecord.status:type_name -> pasteferry.v1.ClipStatus
- 5, // 2: pasteferry.v1.ClipRecord.items:type_name -> pasteferry.v1.ClipItem
+ 6, // 2: pasteferry.v1.ClipRecord.items:type_name -> pasteferry.v1.ClipItem
2, // 3: pasteferry.v1.Device.connection:type_name -> pasteferry.v1.ConnectionKind
- 6, // 4: pasteferry.v1.Event.clip_added:type_name -> pasteferry.v1.ClipRecord
- 6, // 5: pasteferry.v1.Event.clip_updated:type_name -> pasteferry.v1.ClipRecord
- 8, // 6: pasteferry.v1.Event.progress:type_name -> pasteferry.v1.TransferProgress
- 9, // 7: pasteferry.v1.Event.device_changed:type_name -> pasteferry.v1.Device
+ 7, // 4: pasteferry.v1.Event.clip_added:type_name -> pasteferry.v1.ClipRecord
+ 7, // 5: pasteferry.v1.Event.clip_updated:type_name -> pasteferry.v1.ClipRecord
+ 9, // 6: pasteferry.v1.Event.progress:type_name -> pasteferry.v1.TransferProgress
+ 10, // 7: pasteferry.v1.Event.device_changed:type_name -> pasteferry.v1.Device
3, // 8: pasteferry.v1.Event.permission_changed:type_name -> pasteferry.v1.ClipboardPermission
- 31, // 9: pasteferry.v1.Event.status_changed:type_name -> pasteferry.v1.Status
+ 33, // 9: pasteferry.v1.Event.status_changed:type_name -> pasteferry.v1.Status
0, // 10: pasteferry.v1.ListHistoryRequest.kind_filter:type_name -> pasteferry.v1.ClipKind
- 6, // 11: pasteferry.v1.ListHistoryResponse.records:type_name -> pasteferry.v1.ClipRecord
- 9, // 12: pasteferry.v1.ListDevicesResponse.self:type_name -> pasteferry.v1.Device
- 9, // 13: pasteferry.v1.ListDevicesResponse.peers:type_name -> pasteferry.v1.Device
- 9, // 14: pasteferry.v1.RedeemPairingCodeResponse.peer:type_name -> pasteferry.v1.Device
- 21, // 15: pasteferry.v1.NearbyDevices.devices:type_name -> pasteferry.v1.NearbyDevice
- 30, // 16: pasteferry.v1.NetworkInfo.egresses:type_name -> pasteferry.v1.NetworkEgress
- 28, // 17: pasteferry.v1.NetworkInfo.lan:type_name -> pasteferry.v1.LanInfo
- 29, // 18: pasteferry.v1.LanInfo.peers:type_name -> pasteferry.v1.LanPeer
- 3, // 19: pasteferry.v1.Status.clipboard_permission:type_name -> pasteferry.v1.ClipboardPermission
- 7, // 20: pasteferry.v1.DaemonService.Subscribe:input_type -> pasteferry.v1.SubscribeRequest
- 11, // 21: pasteferry.v1.DaemonService.ListHistory:input_type -> pasteferry.v1.ListHistoryRequest
- 13, // 22: pasteferry.v1.DaemonService.DeleteHistory:input_type -> pasteferry.v1.DeleteHistoryRequest
- 14, // 23: pasteferry.v1.DaemonService.Fetch:input_type -> pasteferry.v1.FetchRequest
- 15, // 24: pasteferry.v1.DaemonService.ApplyToClipboard:input_type -> pasteferry.v1.ApplyToClipboardRequest
- 35, // 25: pasteferry.v1.DaemonService.GetImagePreview:input_type -> pasteferry.v1.GetImagePreviewRequest
- 4, // 26: pasteferry.v1.DaemonService.ListDevices:input_type -> pasteferry.v1.Empty
- 4, // 27: pasteferry.v1.DaemonService.CreatePairingCode:input_type -> pasteferry.v1.Empty
- 18, // 28: pasteferry.v1.DaemonService.RedeemPairingCode:input_type -> pasteferry.v1.RedeemPairingCodeRequest
- 20, // 29: pasteferry.v1.DaemonService.ConfirmPairing:input_type -> pasteferry.v1.ConfirmPairingRequest
- 24, // 30: pasteferry.v1.DaemonService.Unpair:input_type -> pasteferry.v1.UnpairRequest
- 25, // 31: pasteferry.v1.DaemonService.SetDeviceAddress:input_type -> pasteferry.v1.SetDeviceAddressRequest
- 4, // 32: pasteferry.v1.DaemonService.WatchNearby:input_type -> pasteferry.v1.Empty
- 23, // 33: pasteferry.v1.DaemonService.PairNearby:input_type -> pasteferry.v1.PairNearbyRequest
- 4, // 34: pasteferry.v1.DaemonService.GetConfig:input_type -> pasteferry.v1.Empty
- 26, // 35: pasteferry.v1.DaemonService.UpdateConfig:input_type -> pasteferry.v1.Config
- 4, // 36: pasteferry.v1.DaemonService.GetStatus:input_type -> pasteferry.v1.Empty
- 4, // 37: pasteferry.v1.DaemonService.RequestClipboardPermission:input_type -> pasteferry.v1.Empty
- 4, // 38: pasteferry.v1.DaemonService.RequestLocalNetworkPermission:input_type -> pasteferry.v1.Empty
- 4, // 39: pasteferry.v1.DaemonService.GetNetwork:input_type -> pasteferry.v1.Empty
- 32, // 40: pasteferry.v1.DaemonService.ExportDiagnostics:input_type -> pasteferry.v1.ExportDiagnosticsRequest
- 34, // 41: pasteferry.v1.DaemonService.SetVerboseLog:input_type -> pasteferry.v1.SetVerboseLogRequest
- 10, // 42: pasteferry.v1.DaemonService.Subscribe:output_type -> pasteferry.v1.Event
- 12, // 43: pasteferry.v1.DaemonService.ListHistory:output_type -> pasteferry.v1.ListHistoryResponse
- 4, // 44: pasteferry.v1.DaemonService.DeleteHistory:output_type -> pasteferry.v1.Empty
- 4, // 45: pasteferry.v1.DaemonService.Fetch:output_type -> pasteferry.v1.Empty
- 4, // 46: pasteferry.v1.DaemonService.ApplyToClipboard:output_type -> pasteferry.v1.Empty
- 36, // 47: pasteferry.v1.DaemonService.GetImagePreview:output_type -> pasteferry.v1.GetImagePreviewResponse
- 16, // 48: pasteferry.v1.DaemonService.ListDevices:output_type -> pasteferry.v1.ListDevicesResponse
- 17, // 49: pasteferry.v1.DaemonService.CreatePairingCode:output_type -> pasteferry.v1.CreatePairingCodeResponse
- 19, // 50: pasteferry.v1.DaemonService.RedeemPairingCode:output_type -> pasteferry.v1.RedeemPairingCodeResponse
- 4, // 51: pasteferry.v1.DaemonService.ConfirmPairing:output_type -> pasteferry.v1.Empty
- 4, // 52: pasteferry.v1.DaemonService.Unpair:output_type -> pasteferry.v1.Empty
- 4, // 53: pasteferry.v1.DaemonService.SetDeviceAddress:output_type -> pasteferry.v1.Empty
- 22, // 54: pasteferry.v1.DaemonService.WatchNearby:output_type -> pasteferry.v1.NearbyDevices
- 19, // 55: pasteferry.v1.DaemonService.PairNearby:output_type -> pasteferry.v1.RedeemPairingCodeResponse
- 26, // 56: pasteferry.v1.DaemonService.GetConfig:output_type -> pasteferry.v1.Config
- 26, // 57: pasteferry.v1.DaemonService.UpdateConfig:output_type -> pasteferry.v1.Config
- 31, // 58: pasteferry.v1.DaemonService.GetStatus:output_type -> pasteferry.v1.Status
- 4, // 59: pasteferry.v1.DaemonService.RequestClipboardPermission:output_type -> pasteferry.v1.Empty
- 4, // 60: pasteferry.v1.DaemonService.RequestLocalNetworkPermission:output_type -> pasteferry.v1.Empty
- 27, // 61: pasteferry.v1.DaemonService.GetNetwork:output_type -> pasteferry.v1.NetworkInfo
- 33, // 62: pasteferry.v1.DaemonService.ExportDiagnostics:output_type -> pasteferry.v1.Diagnostics
- 31, // 63: pasteferry.v1.DaemonService.SetVerboseLog:output_type -> pasteferry.v1.Status
- 42, // [42:64] is the sub-list for method output_type
- 20, // [20:42] is the sub-list for method input_type
- 20, // [20:20] is the sub-list for extension type_name
- 20, // [20:20] is the sub-list for extension extendee
- 0, // [0:20] is the sub-list for field type_name
+ 7, // 11: pasteferry.v1.ListHistoryResponse.records:type_name -> pasteferry.v1.ClipRecord
+ 10, // 12: pasteferry.v1.ListDevicesResponse.self:type_name -> pasteferry.v1.Device
+ 10, // 13: pasteferry.v1.ListDevicesResponse.peers:type_name -> pasteferry.v1.Device
+ 10, // 14: pasteferry.v1.RedeemPairingCodeResponse.peer:type_name -> pasteferry.v1.Device
+ 22, // 15: pasteferry.v1.NearbyDevices.devices:type_name -> pasteferry.v1.NearbyDevice
+ 4, // 16: pasteferry.v1.Config.service_mode:type_name -> pasteferry.v1.ServiceMode
+ 32, // 17: pasteferry.v1.NetworkInfo.egresses:type_name -> pasteferry.v1.NetworkEgress
+ 30, // 18: pasteferry.v1.NetworkInfo.lan:type_name -> pasteferry.v1.LanInfo
+ 31, // 19: pasteferry.v1.LanInfo.peers:type_name -> pasteferry.v1.LanPeer
+ 3, // 20: pasteferry.v1.Status.clipboard_permission:type_name -> pasteferry.v1.ClipboardPermission
+ 28, // 21: pasteferry.v1.Status.official_usage:type_name -> pasteferry.v1.OfficialUsage
+ 8, // 22: pasteferry.v1.DaemonService.Subscribe:input_type -> pasteferry.v1.SubscribeRequest
+ 12, // 23: pasteferry.v1.DaemonService.ListHistory:input_type -> pasteferry.v1.ListHistoryRequest
+ 14, // 24: pasteferry.v1.DaemonService.DeleteHistory:input_type -> pasteferry.v1.DeleteHistoryRequest
+ 15, // 25: pasteferry.v1.DaemonService.Fetch:input_type -> pasteferry.v1.FetchRequest
+ 16, // 26: pasteferry.v1.DaemonService.ApplyToClipboard:input_type -> pasteferry.v1.ApplyToClipboardRequest
+ 37, // 27: pasteferry.v1.DaemonService.GetImagePreview:input_type -> pasteferry.v1.GetImagePreviewRequest
+ 5, // 28: pasteferry.v1.DaemonService.ListDevices:input_type -> pasteferry.v1.Empty
+ 5, // 29: pasteferry.v1.DaemonService.CreatePairingCode:input_type -> pasteferry.v1.Empty
+ 19, // 30: pasteferry.v1.DaemonService.RedeemPairingCode:input_type -> pasteferry.v1.RedeemPairingCodeRequest
+ 21, // 31: pasteferry.v1.DaemonService.ConfirmPairing:input_type -> pasteferry.v1.ConfirmPairingRequest
+ 25, // 32: pasteferry.v1.DaemonService.Unpair:input_type -> pasteferry.v1.UnpairRequest
+ 26, // 33: pasteferry.v1.DaemonService.SetDeviceAddress:input_type -> pasteferry.v1.SetDeviceAddressRequest
+ 5, // 34: pasteferry.v1.DaemonService.WatchNearby:input_type -> pasteferry.v1.Empty
+ 24, // 35: pasteferry.v1.DaemonService.PairNearby:input_type -> pasteferry.v1.PairNearbyRequest
+ 5, // 36: pasteferry.v1.DaemonService.GetConfig:input_type -> pasteferry.v1.Empty
+ 27, // 37: pasteferry.v1.DaemonService.UpdateConfig:input_type -> pasteferry.v1.Config
+ 5, // 38: pasteferry.v1.DaemonService.GetStatus:input_type -> pasteferry.v1.Empty
+ 5, // 39: pasteferry.v1.DaemonService.RequestClipboardPermission:input_type -> pasteferry.v1.Empty
+ 5, // 40: pasteferry.v1.DaemonService.RequestLocalNetworkPermission:input_type -> pasteferry.v1.Empty
+ 5, // 41: pasteferry.v1.DaemonService.GetNetwork:input_type -> pasteferry.v1.Empty
+ 34, // 42: pasteferry.v1.DaemonService.ExportDiagnostics:input_type -> pasteferry.v1.ExportDiagnosticsRequest
+ 36, // 43: pasteferry.v1.DaemonService.SetVerboseLog:input_type -> pasteferry.v1.SetVerboseLogRequest
+ 11, // 44: pasteferry.v1.DaemonService.Subscribe:output_type -> pasteferry.v1.Event
+ 13, // 45: pasteferry.v1.DaemonService.ListHistory:output_type -> pasteferry.v1.ListHistoryResponse
+ 5, // 46: pasteferry.v1.DaemonService.DeleteHistory:output_type -> pasteferry.v1.Empty
+ 5, // 47: pasteferry.v1.DaemonService.Fetch:output_type -> pasteferry.v1.Empty
+ 5, // 48: pasteferry.v1.DaemonService.ApplyToClipboard:output_type -> pasteferry.v1.Empty
+ 38, // 49: pasteferry.v1.DaemonService.GetImagePreview:output_type -> pasteferry.v1.GetImagePreviewResponse
+ 17, // 50: pasteferry.v1.DaemonService.ListDevices:output_type -> pasteferry.v1.ListDevicesResponse
+ 18, // 51: pasteferry.v1.DaemonService.CreatePairingCode:output_type -> pasteferry.v1.CreatePairingCodeResponse
+ 20, // 52: pasteferry.v1.DaemonService.RedeemPairingCode:output_type -> pasteferry.v1.RedeemPairingCodeResponse
+ 5, // 53: pasteferry.v1.DaemonService.ConfirmPairing:output_type -> pasteferry.v1.Empty
+ 5, // 54: pasteferry.v1.DaemonService.Unpair:output_type -> pasteferry.v1.Empty
+ 5, // 55: pasteferry.v1.DaemonService.SetDeviceAddress:output_type -> pasteferry.v1.Empty
+ 23, // 56: pasteferry.v1.DaemonService.WatchNearby:output_type -> pasteferry.v1.NearbyDevices
+ 20, // 57: pasteferry.v1.DaemonService.PairNearby:output_type -> pasteferry.v1.RedeemPairingCodeResponse
+ 27, // 58: pasteferry.v1.DaemonService.GetConfig:output_type -> pasteferry.v1.Config
+ 27, // 59: pasteferry.v1.DaemonService.UpdateConfig:output_type -> pasteferry.v1.Config
+ 33, // 60: pasteferry.v1.DaemonService.GetStatus:output_type -> pasteferry.v1.Status
+ 5, // 61: pasteferry.v1.DaemonService.RequestClipboardPermission:output_type -> pasteferry.v1.Empty
+ 5, // 62: pasteferry.v1.DaemonService.RequestLocalNetworkPermission:output_type -> pasteferry.v1.Empty
+ 29, // 63: pasteferry.v1.DaemonService.GetNetwork:output_type -> pasteferry.v1.NetworkInfo
+ 35, // 64: pasteferry.v1.DaemonService.ExportDiagnostics:output_type -> pasteferry.v1.Diagnostics
+ 33, // 65: pasteferry.v1.DaemonService.SetVerboseLog:output_type -> pasteferry.v1.Status
+ 44, // [44:66] is the sub-list for method output_type
+ 22, // [22:44] is the sub-list for method input_type
+ 22, // [22:22] is the sub-list for extension type_name
+ 22, // [22:22] is the sub-list for extension extendee
+ 0, // [0:22] is the sub-list for field type_name
}
func init() { file_pasteferry_v1_daemon_proto_init() }
@@ -2911,8 +3139,8 @@ func file_pasteferry_v1_daemon_proto_init() {
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_pasteferry_v1_daemon_proto_rawDesc), len(file_pasteferry_v1_daemon_proto_rawDesc)),
- NumEnums: 4,
- NumMessages: 33,
+ NumEnums: 5,
+ NumMessages: 34,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/gen/pasteferry/v1/wire.pb.go b/proto/gen/pasteferry/v1/wire.pb.go
index b046b87..4d96c8b 100644
--- a/proto/gen/pasteferry/v1/wire.pb.go
+++ b/proto/gen/pasteferry/v1/wire.pb.go
@@ -195,6 +195,12 @@ type SignalMessage struct {
Nonce []byte `protobuf:"bytes,2,opt,name=nonce,proto3" json:"nonce,omitempty"`
// 接收方只收发给自己的消息:局域网里谁都能把截到的消息转发给第三台设备
ToDeviceId string `protobuf:"bytes,3,opt,name=to_device_id,json=toDeviceId,proto3" json:"to_device_id,omitempty"`
+ // Client-only negotiation metadata; the server forwards Signed unchanged.
+ ConnectionAttemptId string `protobuf:"bytes,4,opt,name=connection_attempt_id,json=connectionAttemptId,proto3" json:"connection_attempt_id,omitempty"`
+ OfficialRelay bool `protobuf:"varint,5,opt,name=official_relay,json=officialRelay,proto3" json:"official_relay,omitempty"`
+ GatewayCapable bool `protobuf:"varint,6,opt,name=gateway_capable,json=gatewayCapable,proto3" json:"gateway_capable,omitempty"`
+ // Fixed relay-only denial codes; these never change pairing or direct trust.
+ RelayDenialCode string `protobuf:"bytes,7,opt,name=relay_denial_code,json=relayDenialCode,proto3" json:"relay_denial_code,omitempty"`
// Types that are valid to be assigned to Payload:
//
// *SignalMessage_Offer
@@ -258,6 +264,34 @@ func (x *SignalMessage) GetToDeviceId() string {
return ""
}
+func (x *SignalMessage) GetConnectionAttemptId() string {
+ if x != nil {
+ return x.ConnectionAttemptId
+ }
+ return ""
+}
+
+func (x *SignalMessage) GetOfficialRelay() bool {
+ if x != nil {
+ return x.OfficialRelay
+ }
+ return false
+}
+
+func (x *SignalMessage) GetGatewayCapable() bool {
+ if x != nil {
+ return x.GatewayCapable
+ }
+ return false
+}
+
+func (x *SignalMessage) GetRelayDenialCode() string {
+ if x != nil {
+ return x.RelayDenialCode
+ }
+ return ""
+}
+
func (x *SignalMessage) GetPayload() isSignalMessage_Payload {
if x != nil {
return x.Payload
@@ -2039,6 +2073,7 @@ type PeerMessage struct {
// *PeerMessage_Header
// *PeerMessage_Done
// *PeerMessage_Link
+ // *PeerMessage_Display
Payload isPeerMessage_Payload `protobuf_oneof:"payload"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
@@ -2135,6 +2170,15 @@ func (x *PeerMessage) GetLink() *LinkInfo {
return nil
}
+func (x *PeerMessage) GetDisplay() *PeerDisplay {
+ if x != nil {
+ if x, ok := x.Payload.(*PeerMessage_Display); ok {
+ return x.Display
+ }
+ }
+ return nil
+}
+
type isPeerMessage_Payload interface {
isPeerMessage_Payload()
}
@@ -2163,6 +2207,10 @@ type PeerMessage_Link struct {
Link *LinkInfo `protobuf:"bytes,6,opt,name=link,proto3,oneof"` // 连接建立后互相告知本端是否经中转
}
+type PeerMessage_Display struct {
+ Display *PeerDisplay `protobuf:"bytes,7,opt,name=display,proto3,oneof"` // 仅通过加密的设备间通道交换真实名称
+}
+
func (*PeerMessage_Offer) isPeerMessage_Payload() {}
func (*PeerMessage_Fetch) isPeerMessage_Payload() {}
@@ -2175,6 +2223,8 @@ func (*PeerMessage_Done) isPeerMessage_Payload() {}
func (*PeerMessage_Link) isPeerMessage_Payload() {}
+func (*PeerMessage_Display) isPeerMessage_Payload() {}
+
// 连接就绪后各自发一次。只有本端能确定自己发出的数据是否走 TURN:
// 对端经中转发来的包,在本端看来可能只是一个普通地址(peer-reflexive),
// 单靠自己的视角会把中转误判成直连。两端交换后,任一端经中转即显示为中转。
@@ -2222,6 +2272,58 @@ func (x *LinkInfo) GetRelayed() bool {
return false
}
+type PeerDisplay struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Platform string `protobuf:"bytes,2,opt,name=platform,proto3" json:"platform,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *PeerDisplay) Reset() {
+ *x = PeerDisplay{}
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[27]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *PeerDisplay) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*PeerDisplay) ProtoMessage() {}
+
+func (x *PeerDisplay) ProtoReflect() protoreflect.Message {
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[27]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use PeerDisplay.ProtoReflect.Descriptor instead.
+func (*PeerDisplay) Descriptor() ([]byte, []int) {
+ return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{27}
+}
+
+func (x *PeerDisplay) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+func (x *PeerDisplay) GetPlatform() string {
+ if x != nil {
+ return x.Platform
+ }
+ return ""
+}
+
// 复制发生时广播给所有在线对端。
// 小于阈值的内容会紧接着主动推送;大于阈值的只发这条,等对方来取。
type ClipOffer struct {
@@ -2245,7 +2347,7 @@ type ClipOffer struct {
func (x *ClipOffer) Reset() {
*x = ClipOffer{}
- mi := &file_pasteferry_v1_wire_proto_msgTypes[27]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[28]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2257,7 +2359,7 @@ func (x *ClipOffer) String() string {
func (*ClipOffer) ProtoMessage() {}
func (x *ClipOffer) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_wire_proto_msgTypes[27]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[28]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2270,7 +2372,7 @@ func (x *ClipOffer) ProtoReflect() protoreflect.Message {
// Deprecated: Use ClipOffer.ProtoReflect.Descriptor instead.
func (*ClipOffer) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{27}
+ return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{28}
}
func (x *ClipOffer) GetClipId() string {
@@ -2346,7 +2448,7 @@ type PeerFetch struct {
func (x *PeerFetch) Reset() {
*x = PeerFetch{}
- mi := &file_pasteferry_v1_wire_proto_msgTypes[28]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[29]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2358,7 +2460,7 @@ func (x *PeerFetch) String() string {
func (*PeerFetch) ProtoMessage() {}
func (x *PeerFetch) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_wire_proto_msgTypes[28]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[29]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2371,7 +2473,7 @@ func (x *PeerFetch) ProtoReflect() protoreflect.Message {
// Deprecated: Use PeerFetch.ProtoReflect.Descriptor instead.
func (*PeerFetch) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{28}
+ return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{29}
}
func (x *PeerFetch) GetClipId() string {
@@ -2391,7 +2493,7 @@ type FetchReject struct {
func (x *FetchReject) Reset() {
*x = FetchReject{}
- mi := &file_pasteferry_v1_wire_proto_msgTypes[29]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[30]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2403,7 +2505,7 @@ func (x *FetchReject) String() string {
func (*FetchReject) ProtoMessage() {}
func (x *FetchReject) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_wire_proto_msgTypes[29]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[30]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2416,7 +2518,7 @@ func (x *FetchReject) ProtoReflect() protoreflect.Message {
// Deprecated: Use FetchReject.ProtoReflect.Descriptor instead.
func (*FetchReject) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{29}
+ return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{30}
}
func (x *FetchReject) GetClipId() string {
@@ -2447,7 +2549,7 @@ type TransferHeader struct {
func (x *TransferHeader) Reset() {
*x = TransferHeader{}
- mi := &file_pasteferry_v1_wire_proto_msgTypes[30]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[31]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2459,7 +2561,7 @@ func (x *TransferHeader) String() string {
func (*TransferHeader) ProtoMessage() {}
func (x *TransferHeader) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_wire_proto_msgTypes[30]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[31]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2472,7 +2574,7 @@ func (x *TransferHeader) ProtoReflect() protoreflect.Message {
// Deprecated: Use TransferHeader.ProtoReflect.Descriptor instead.
func (*TransferHeader) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{30}
+ return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{31}
}
func (x *TransferHeader) GetClipId() string {
@@ -2523,7 +2625,7 @@ type TransferDone struct {
func (x *TransferDone) Reset() {
*x = TransferDone{}
- mi := &file_pasteferry_v1_wire_proto_msgTypes[31]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[32]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2535,7 +2637,7 @@ func (x *TransferDone) String() string {
func (*TransferDone) ProtoMessage() {}
func (x *TransferDone) ProtoReflect() protoreflect.Message {
- mi := &file_pasteferry_v1_wire_proto_msgTypes[31]
+ mi := &file_pasteferry_v1_wire_proto_msgTypes[32]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2548,7 +2650,7 @@ func (x *TransferDone) ProtoReflect() protoreflect.Message {
// Deprecated: Use TransferDone.ProtoReflect.Descriptor instead.
func (*TransferDone) Descriptor() ([]byte, []int) {
- return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{31}
+ return file_pasteferry_v1_wire_proto_rawDescGZIP(), []int{32}
}
func (x *TransferDone) GetClipId() string {
@@ -2594,12 +2696,16 @@ const file_pasteferry_v1_wire_proto_rawDesc = "" +
"\x06Signed\x12\x18\n" +
"\apayload\x18\x01 \x01(\fR\apayload\x12\x1c\n" +
"\tsignature\x18\x02 \x01(\fR\tsignature\x12$\n" +
- "\x0efrom_device_id\x18\x03 \x01(\tR\ffromDeviceId\"\xfe\x02\n" +
+ "\x0efrom_device_id\x18\x03 \x01(\tR\ffromDeviceId\"\xae\x04\n" +
"\rSignalMessage\x12%\n" +
"\x0etimestamp_unix\x18\x01 \x01(\x03R\rtimestampUnix\x12\x14\n" +
"\x05nonce\x18\x02 \x01(\fR\x05nonce\x12 \n" +
"\fto_device_id\x18\x03 \x01(\tR\n" +
- "toDeviceId\x12/\n" +
+ "toDeviceId\x122\n" +
+ "\x15connection_attempt_id\x18\x04 \x01(\tR\x13connectionAttemptId\x12%\n" +
+ "\x0eofficial_relay\x18\x05 \x01(\bR\rofficialRelay\x12'\n" +
+ "\x0fgateway_capable\x18\x06 \x01(\bR\x0egatewayCapable\x12*\n" +
+ "\x11relay_denial_code\x18\a \x01(\tR\x0frelayDenialCode\x12/\n" +
"\x05offer\x18\n" +
" \x01(\v2\x17.pasteferry.v1.SdpOfferH\x00R\x05offer\x122\n" +
"\x06answer\x18\v \x01(\v2\x18.pasteferry.v1.SdpAnswerH\x00R\x06answer\x12;\n" +
@@ -2730,17 +2836,21 @@ const file_pasteferry_v1_wire_proto_rawDesc = "" +
"\binstance\x18\x01 \x01(\tR\binstance\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12\x1a\n" +
"\bplatform\x18\x03 \x01(\tR\bplatform\x12\x14\n" +
- "\x05token\x18\x04 \x01(\tR\x05token\"\xcd\x02\n" +
+ "\x05token\x18\x04 \x01(\tR\x05token\"\x85\x03\n" +
"\vPeerMessage\x120\n" +
"\x05offer\x18\x01 \x01(\v2\x18.pasteferry.v1.ClipOfferH\x00R\x05offer\x120\n" +
"\x05fetch\x18\x02 \x01(\v2\x18.pasteferry.v1.PeerFetchH\x00R\x05fetch\x124\n" +
"\x06reject\x18\x03 \x01(\v2\x1a.pasteferry.v1.FetchRejectH\x00R\x06reject\x127\n" +
"\x06header\x18\x04 \x01(\v2\x1d.pasteferry.v1.TransferHeaderH\x00R\x06header\x121\n" +
"\x04done\x18\x05 \x01(\v2\x1b.pasteferry.v1.TransferDoneH\x00R\x04done\x12-\n" +
- "\x04link\x18\x06 \x01(\v2\x17.pasteferry.v1.LinkInfoH\x00R\x04linkB\t\n" +
+ "\x04link\x18\x06 \x01(\v2\x17.pasteferry.v1.LinkInfoH\x00R\x04link\x126\n" +
+ "\adisplay\x18\a \x01(\v2\x1a.pasteferry.v1.PeerDisplayH\x00R\adisplayB\t\n" +
"\apayload\"$\n" +
"\bLinkInfo\x12\x18\n" +
- "\arelayed\x18\x01 \x01(\bR\arelayed\"\xc0\x02\n" +
+ "\arelayed\x18\x01 \x01(\bR\arelayed\"=\n" +
+ "\vPeerDisplay\x12\x12\n" +
+ "\x04name\x18\x01 \x01(\tR\x04name\x12\x1a\n" +
+ "\bplatform\x18\x02 \x01(\tR\bplatform\"\xc0\x02\n" +
"\tClipOffer\x12\x17\n" +
"\aclip_id\x18\x01 \x01(\tR\x06clipId\x12+\n" +
"\x04kind\x18\x02 \x01(\x0e2\x17.pasteferry.v1.ClipKindR\x04kind\x12-\n" +
@@ -2793,7 +2903,7 @@ func file_pasteferry_v1_wire_proto_rawDescGZIP() []byte {
}
var file_pasteferry_v1_wire_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
-var file_pasteferry_v1_wire_proto_msgTypes = make([]protoimpl.MessageInfo, 32)
+var file_pasteferry_v1_wire_proto_msgTypes = make([]protoimpl.MessageInfo, 33)
var file_pasteferry_v1_wire_proto_goTypes = []any{
(Compression)(0), // 0: pasteferry.v1.Compression
(Packaging)(0), // 1: pasteferry.v1.Packaging
@@ -2824,13 +2934,14 @@ var file_pasteferry_v1_wire_proto_goTypes = []any{
(*LanNearbyPing)(nil), // 26: pasteferry.v1.LanNearbyPing
(*PeerMessage)(nil), // 27: pasteferry.v1.PeerMessage
(*LinkInfo)(nil), // 28: pasteferry.v1.LinkInfo
- (*ClipOffer)(nil), // 29: pasteferry.v1.ClipOffer
- (*PeerFetch)(nil), // 30: pasteferry.v1.PeerFetch
- (*FetchReject)(nil), // 31: pasteferry.v1.FetchReject
- (*TransferHeader)(nil), // 32: pasteferry.v1.TransferHeader
- (*TransferDone)(nil), // 33: pasteferry.v1.TransferDone
- (ClipKind)(0), // 34: pasteferry.v1.ClipKind
- (*ClipItem)(nil), // 35: pasteferry.v1.ClipItem
+ (*PeerDisplay)(nil), // 29: pasteferry.v1.PeerDisplay
+ (*ClipOffer)(nil), // 30: pasteferry.v1.ClipOffer
+ (*PeerFetch)(nil), // 31: pasteferry.v1.PeerFetch
+ (*FetchReject)(nil), // 32: pasteferry.v1.FetchReject
+ (*TransferHeader)(nil), // 33: pasteferry.v1.TransferHeader
+ (*TransferDone)(nil), // 34: pasteferry.v1.TransferDone
+ (ClipKind)(0), // 35: pasteferry.v1.ClipKind
+ (*ClipItem)(nil), // 36: pasteferry.v1.ClipItem
}
var file_pasteferry_v1_wire_proto_depIdxs = []int32{
4, // 0: pasteferry.v1.SignalMessage.offer:type_name -> pasteferry.v1.SdpOffer
@@ -2858,21 +2969,22 @@ var file_pasteferry_v1_wire_proto_depIdxs = []int32{
25, // 22: pasteferry.v1.LanPacket.pair_reject:type_name -> pasteferry.v1.LanPairReject
23, // 23: pasteferry.v1.LanPacket.nearby_request:type_name -> pasteferry.v1.LanPairSigned
26, // 24: pasteferry.v1.LanPacket.nearby_ping:type_name -> pasteferry.v1.LanNearbyPing
- 29, // 25: pasteferry.v1.PeerMessage.offer:type_name -> pasteferry.v1.ClipOffer
- 30, // 26: pasteferry.v1.PeerMessage.fetch:type_name -> pasteferry.v1.PeerFetch
- 31, // 27: pasteferry.v1.PeerMessage.reject:type_name -> pasteferry.v1.FetchReject
- 32, // 28: pasteferry.v1.PeerMessage.header:type_name -> pasteferry.v1.TransferHeader
- 33, // 29: pasteferry.v1.PeerMessage.done:type_name -> pasteferry.v1.TransferDone
+ 30, // 25: pasteferry.v1.PeerMessage.offer:type_name -> pasteferry.v1.ClipOffer
+ 31, // 26: pasteferry.v1.PeerMessage.fetch:type_name -> pasteferry.v1.PeerFetch
+ 32, // 27: pasteferry.v1.PeerMessage.reject:type_name -> pasteferry.v1.FetchReject
+ 33, // 28: pasteferry.v1.PeerMessage.header:type_name -> pasteferry.v1.TransferHeader
+ 34, // 29: pasteferry.v1.PeerMessage.done:type_name -> pasteferry.v1.TransferDone
28, // 30: pasteferry.v1.PeerMessage.link:type_name -> pasteferry.v1.LinkInfo
- 34, // 31: pasteferry.v1.ClipOffer.kind:type_name -> pasteferry.v1.ClipKind
- 35, // 32: pasteferry.v1.ClipOffer.items:type_name -> pasteferry.v1.ClipItem
- 0, // 33: pasteferry.v1.TransferHeader.compression:type_name -> pasteferry.v1.Compression
- 1, // 34: pasteferry.v1.TransferHeader.packaging:type_name -> pasteferry.v1.Packaging
- 35, // [35:35] is the sub-list for method output_type
- 35, // [35:35] is the sub-list for method input_type
- 35, // [35:35] is the sub-list for extension type_name
- 35, // [35:35] is the sub-list for extension extendee
- 0, // [0:35] is the sub-list for field type_name
+ 29, // 31: pasteferry.v1.PeerMessage.display:type_name -> pasteferry.v1.PeerDisplay
+ 35, // 32: pasteferry.v1.ClipOffer.kind:type_name -> pasteferry.v1.ClipKind
+ 36, // 33: pasteferry.v1.ClipOffer.items:type_name -> pasteferry.v1.ClipItem
+ 0, // 34: pasteferry.v1.TransferHeader.compression:type_name -> pasteferry.v1.Compression
+ 1, // 35: pasteferry.v1.TransferHeader.packaging:type_name -> pasteferry.v1.Packaging
+ 36, // [36:36] is the sub-list for method output_type
+ 36, // [36:36] is the sub-list for method input_type
+ 36, // [36:36] is the sub-list for extension type_name
+ 36, // [36:36] is the sub-list for extension extendee
+ 0, // [0:36] is the sub-list for field type_name
}
func init() { file_pasteferry_v1_wire_proto_init() }
@@ -2919,6 +3031,7 @@ func file_pasteferry_v1_wire_proto_init() {
(*PeerMessage_Header)(nil),
(*PeerMessage_Done)(nil),
(*PeerMessage_Link)(nil),
+ (*PeerMessage_Display)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{
@@ -2926,7 +3039,7 @@ func file_pasteferry_v1_wire_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_pasteferry_v1_wire_proto_rawDesc), len(file_pasteferry_v1_wire_proto_rawDesc)),
NumEnums: 2,
- NumMessages: 32,
+ NumMessages: 33,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/proto/go.mod b/proto/go.mod
index 44ada57..727f5a7 100644
--- a/proto/go.mod
+++ b/proto/go.mod
@@ -1,6 +1,6 @@
module github.com/baiyuze/pasteferry/proto
-go 1.26.3
+go 1.26.9
require (
google.golang.org/grpc v1.84.0
diff --git a/proto/pasteferry/v1/daemon.proto b/proto/pasteferry/v1/daemon.proto
index dab9c31..3d7cd42 100644
--- a/proto/pasteferry/v1/daemon.proto
+++ b/proto/pasteferry/v1/daemon.proto
@@ -288,6 +288,31 @@ message Config {
// 不在局域网里查找设备、也不接受局域网里的配对请求。
// 默认 false(即开启):写成反向的,旧配置不用迁移。
bool lan_disabled = 14;
+
+ // Official service is opt-in; remembered custom URLs are inactive otherwise.
+ ServiceMode service_mode = 15;
+ string custom_signaling_url = 16;
+ string official_notice_ack = 17;
+}
+
+enum ServiceMode {
+ SERVICE_MODE_UNSPECIFIED = 0;
+ SERVICE_MODE_LAN = 1;
+ SERVICE_MODE_OFFICIAL = 2;
+ SERVICE_MODE_CUSTOM = 3;
+}
+
+message OfficialUsage {
+ bool available = 1;
+ string day = 2;
+ string quota_group = 3;
+ int64 upload_bytes = 4;
+ int64 download_bytes = 5;
+ int64 limit_bytes = 6;
+ int64 remaining_bytes = 7;
+ int64 reset_at_unix = 8;
+ int64 updated_at_unix = 9;
+ string reason = 10;
}
// 最近一轮网络出口探测的结果。
@@ -341,6 +366,7 @@ message Status {
bool lan_blocked = 10;
// 详细日志打开到什么时候;0 表示没打开
int64 verbose_log_until_unix = 11;
+ OfficialUsage official_usage = 12;
}
message ExportDiagnosticsRequest {
diff --git a/proto/pasteferry/v1/wire.proto b/proto/pasteferry/v1/wire.proto
index 4d7a4b5..f8f3e9e 100644
--- a/proto/pasteferry/v1/wire.proto
+++ b/proto/pasteferry/v1/wire.proto
@@ -30,6 +30,12 @@ message SignalMessage {
bytes nonce = 2;
// 接收方只收发给自己的消息:局域网里谁都能把截到的消息转发给第三台设备
string to_device_id = 3;
+ // Client-only negotiation metadata; the server forwards Signed unchanged.
+ string connection_attempt_id = 4;
+ bool official_relay = 5;
+ bool gateway_capable = 6;
+ // Fixed relay-only denial codes; these never change pairing or direct trust.
+ string relay_denial_code = 7;
oneof payload {
SdpOffer offer = 10;
@@ -246,6 +252,7 @@ message PeerMessage {
TransferHeader header = 4; // 数据流即将开始
TransferDone done = 5;
LinkInfo link = 6; // 连接建立后互相告知本端是否经中转
+ PeerDisplay display = 7; // 仅通过加密的设备间通道交换真实名称
}
}
@@ -256,6 +263,11 @@ message LinkInfo {
bool relayed = 1;
}
+message PeerDisplay {
+ string name = 1;
+ string platform = 2;
+}
+
// 复制发生时广播给所有在线对端。
// 小于阈值的内容会紧接着主动推送;大于阈值的只发这条,等对方来取。
message ClipOffer {
diff --git a/server/go.mod b/server/go.mod
index 03e2dfb..271acbe 100644
--- a/server/go.mod
+++ b/server/go.mod
@@ -1,6 +1,6 @@
module github.com/baiyuze/pasteferry/server
-go 1.26.3
+go 1.26.9
replace github.com/baiyuze/pasteferry/proto => ../proto
@@ -8,21 +8,20 @@ require (
github.com/baiyuze/pasteferry/proto v0.0.0-00010101000000-000000000000
github.com/coder/websocket v1.8.15
github.com/pion/turn/v4 v4.1.4
- golang.org/x/sys v0.47.0
+ golang.org/x/sys v0.48.0
google.golang.org/protobuf v1.36.12
)
require (
- github.com/pion/dtls/v3 v3.0.7 // indirect
+ github.com/pion/dtls/v3 v3.1.8 // indirect
github.com/pion/logging v0.2.4 // indirect
github.com/pion/randutil v0.1.0 // indirect
- github.com/pion/stun/v3 v3.0.1 // indirect
- github.com/pion/transport/v3 v3.0.8 // indirect
- github.com/pion/transport/v4 v4.0.1 // indirect
+ github.com/pion/stun/v3 v3.1.5 // indirect
+ github.com/pion/transport/v4 v4.0.2 // indirect
github.com/wlynxg/anet v0.0.5 // indirect
- golang.org/x/crypto v0.54.0 // indirect
- golang.org/x/net v0.57.0 // indirect
- golang.org/x/text v0.40.0 // indirect
+ golang.org/x/crypto v0.57.0 // indirect
+ golang.org/x/net v0.60.0 // indirect
+ golang.org/x/text v0.42.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 // indirect
google.golang.org/grpc v1.84.0 // indirect
)
diff --git a/server/go.sum b/server/go.sum
index c4c7ea8..608b16d 100644
--- a/server/go.sum
+++ b/server/go.sum
@@ -6,18 +6,16 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
-github.com/pion/dtls/v3 v3.0.7 h1:bItXtTYYhZwkPFk4t1n3Kkf5TDrfj6+4wG+CZR8uI9Q=
-github.com/pion/dtls/v3 v3.0.7/go.mod h1:uDlH5VPrgOQIw59irKYkMudSFprY9IEFCqz/eTz16f8=
+github.com/pion/dtls/v3 v3.1.8 h1:aLcgjZqzrYn5AbjSds4LvK2WI5VzJc1PencExyDjYis=
+github.com/pion/dtls/v3 v3.1.8/go.mod h1:gz1K4jg6c+fq86oQMH4pilpCEOEPwmEr2jY+VcF/mkU=
github.com/pion/logging v0.2.4 h1:tTew+7cmQ+Mc1pTBLKH2puKsOvhm32dROumOZ655zB8=
github.com/pion/logging v0.2.4/go.mod h1:DffhXTKYdNZU+KtJ5pyQDjvOAh/GsNSyv1lbkFbe3so=
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
-github.com/pion/stun/v3 v3.0.1 h1:jx1uUq6BdPihF0yF33Jj2mh+C9p0atY94IkdnW174kA=
-github.com/pion/stun/v3 v3.0.1/go.mod h1:RHnvlKFg+qHgoKIqtQWMOJF52wsImCAf/Jh5GjX+4Tw=
-github.com/pion/transport/v3 v3.0.8 h1:oI3myyYnTKUSTthu/NZZ8eu2I5sHbxbUNNFW62olaYc=
-github.com/pion/transport/v3 v3.0.8/go.mod h1:+c2eewC5WJQHiAA46fkMMzoYZSuGzA/7E2FPrOYHctQ=
-github.com/pion/transport/v4 v4.0.1 h1:sdROELU6BZ63Ab7FrOLn13M6YdJLY20wldXW2Cu2k8o=
-github.com/pion/transport/v4 v4.0.1/go.mod h1:nEuEA4AD5lPdcIegQDpVLgNoDGreqM/YqmEx3ovP4jM=
+github.com/pion/stun/v3 v3.1.5 h1:Y1FHlhaI6+4UoC5i/zQf4F7JvdZtB24/05oyy/GF1x8=
+github.com/pion/stun/v3 v3.1.5/go.mod h1:zRUghXSQU32Lx5orJsz3uYMkIihweXb3mu5gIns02fs=
+github.com/pion/transport/v4 v4.0.2 h1:ifYlPqNwsy6aKQ9y8yzxXlHae5431ZrH2avkD/Rn6Tk=
+github.com/pion/transport/v4 v4.0.2/go.mod h1:06hFI+jCFcok2X2MekVufNZ/uzNZXivGBPfviSVcjgM=
github.com/pion/turn/v4 v4.1.4 h1:EU11yMXKIsK43FhcUnjLlrhE4nboHZq+TXBIi3QpcxQ=
github.com/pion/turn/v4 v4.1.4/go.mod h1:ES1DXVFKnOhuDkqn9hn5VJlSWmZPaRJLyBXoOeO/BmQ=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -26,16 +24,16 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/wlynxg/anet v0.0.5 h1:J3VJGi1gvo0JwZ/P1/Yc/8p63SoW98B5dHkYDmpgvvU=
github.com/wlynxg/anet v0.0.5/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
-golang.org/x/crypto v0.54.0 h1:YLIA59K4fiNzHzjnZt2tUJQjQtUWfWbeHBqKtk3eScw=
-golang.org/x/crypto v0.54.0/go.mod h1:KWL8ny2AZdGR2cWmzeHrp2azQPGogOv+HeQaVEXC2dk=
-golang.org/x/net v0.57.0 h1:K5+3DljvIuDG9/Jv9rvyMywYNFCQ9RSUY6OOTTkT+tE=
-golang.org/x/net v0.57.0/go.mod h1:KpXc8iv+r3XplLAG/f7Jsf9RPszJzdR0f58q9vGOuEU=
-golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
-golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
-golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
-golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
-golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
-golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
+golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
+golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
+golang.org/x/net v0.60.0 h1:79p50tfZlm0J9YfoDsSi639qSXNGVwEzOPLCxM2FsYU=
+golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
+golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
+golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
+golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
+golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
+golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
+golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260706201446-f0a921348800 h1:qEHAMpSaUhtD0p3NbEEI83HwNGFxEwaSJ1G9PLnCBZE=
diff --git a/tools/site/build.py b/tools/site/build.py
index 461b761..e998f10 100644
--- a/tools/site/build.py
+++ b/tools/site/build.py
@@ -16,6 +16,7 @@ import re
from pathlib import Path
from content.tour import localized as tour_copy
+from content.privacy import COPY as PRIVACY_COPY
ROOT = Path(__file__).resolve().parents[2]
DOCS = ROOT / "docs"
@@ -59,7 +60,8 @@ TAILSCALE = "tailscale/"
# 下载页:所有「下载」按钮都指向它,按系统、芯片选具体的安装包
DOWNLOAD = "download/"
TOUR = "tour/"
-SUBPAGES = [START, LAN, CLOUD, GUIDE, TAILSCALE, DOWNLOAD, TOUR]
+PRIVACY = "privacy/"
+SUBPAGES = [START, LAN, CLOUD, GUIDE, TAILSCALE, DOWNLOAD, TOUR, PRIVACY]
DEPLOY_PAGES = [LAN, CLOUD, GUIDE, TAILSCALE]
# 放到网站上的技术方案:文件名 → 网页名。其他 design/*.md 链接到 GitHub
@@ -156,6 +158,7 @@ def footer(c: dict, code: str, up: str, sub: str = "") -> str:
cur = ' aria-current="page"' if other == code else ""
langs.append(f'<a href="{up}{path + sub or "./"}" hreflang="{hl}" lang="{hl}" data-lang="{other}"{cur}>{name}</a>')
links = "".join(f'\n <a href="{href}">{label}</a>' for label, href in c["footer_links"])
+ links += f'\n <a href="{up}{LANGS[code][0]}{PRIVACY}">{PRIVACY_COPY[code][0]}</a>'
return f""" <footer class="footer">
<div class="wrap">
<p>{c["footer_license"]}</p>
@@ -2162,6 +2165,15 @@ def write(path: Path, text: str) -> None:
path.write_text(text, encoding="utf-8")
print("✓", path.relative_to(ROOT))
+def privacy_page(code: str) -> str:
+ c = load(code)
+ title, sections = PRIVACY_COPY[code]
+ body = "\n".join(f'<section><h2>{esc(h)}</h2><p>{esc(p)}</p></section>' for h, p in sections)
+ return (page_top(c, code, PRIVACY, f'{esc(title)} — PasteFerry', sections[0][1])
+ + f'<main id="main" class="wrap" style="max-width:850px;padding-top:5rem;padding-bottom:5rem;line-height:1.9"><h1>{esc(title)}</h1>{body}'
+ + f'<p><a href="{REPO}/blob/main/PRIVACY.md">PRIVACY.md</a> · <a href="{REPO}/blob/main/SECURITY.md">SECURITY.md</a> · <a href="{REPO}/blob/main/design/official-gateway.md">Gateway protocol v1</a></p></main>'
+ + page_bottom(c, code, PRIVACY))
+
def main() -> None:
for code, (path, _, _, _) in LANGS.items():
@@ -2173,6 +2185,7 @@ def main() -> None:
write(DOCS / path / CLOUD / "index.html", cloud_page(code))
write(DOCS / path / TAILSCALE / "index.html", tailscale_page(code))
write(DOCS / path / DOWNLOAD / "index.html", download_page(code))
+ write(DOCS / path / PRIVACY / "index.html", privacy_page(code))
for md_name, page in DESIGN_DOCS.items():
write(DOCS / "design" / f"{page}.html", design_page(md_name, page))
write(DOCS / "404.html", not_found())
diff --git a/tools/site/content/privacy.py b/tools/site/content/privacy.py
new file mode 100644
index 0000000..cc498fc
--- /dev/null
+++ b/tools/site/content/privacy.py
@@ -0,0 +1,39 @@
+"""Localized public-service privacy notice. No installation analytics."""
+
+COPY = {
+ "zh": ("隐私与必要数据", [
+ ("你决定是否使用官方服务", "新安装默认只使用局域网。开启官方公网后才连接官方信令并记录必要接入统计;自建服务器模式不向官方上报。先尝试直连,失败后才申请中转授权和读取机器额度摘要。"),
+ ("仅保留服务所需数据", "官方网关保留脱敏设备编号、首次及最近接入时间、每日中转用量、必要额度绑定和累计汇总。每日设备明细保留 90 天。统计表示官方服务设备数,不能代表真实人数或全部安装量。"),
+ ("内容与机器标识", "剪贴板、文件内容与真实设备名通过设备间加密通道传输。网关不收集文件名、路径、用户名、MAC、UA 或行为轨迹;原始系统标识不上传,机器摘要仅用于中转额度归组,不能保证不可伪造。"),
+ ("网络可见性和额度", "联网端点必然能看到临时网络地址和路由信息,但官方统计库及普通代理日志不保存这些信息。默认每日 100 MB 中转额度,上下行合计,北京时间零点重置;直连不消耗额度。关闭官方服务会停止其请求、轮询与中转通道。"),
+ ("网站与可审计边界", "本站使用既有的 Cloudflare Web Analytics,网站访问不等于软件用户统计。客户端、信令和 TURN 保持开源,公开所有官方网关协议与字段;私有生产后台的实际存储行为仍需要部署审计。"),
+ ]),
+ "zh-tw": ("隱私與必要資料", [
+ ("由你決定使用官方服務", "新安裝預設僅使用區域網路。啟用官方公網後才連線官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中繼並讀取機器額度摘要。"),
+ ("最少必要資料", "網關保留去識別化裝置編號、首次與最近連線時間、每日中繼用量、必要額度綁定和累計彙總。每日裝置明細保留 90 天。這是官方服務裝置數,不是人數或全部安裝量。"),
+ ("內容與機器識別碼", "內容與真實裝置名稱透過裝置間加密通道傳送。不收集檔名、路徑、使用者名稱、MAC、UA 或行為軌跡。原始系統識別碼不上傳;摘要只用於額度分組,並非不可偽造。"),
+ ("網路資訊與額度", "網路端點暫時可見路由和網路位址,官方統計庫及一般代理日誌不保存這些資訊。每日 100 MB 中繼額度,含上下行,北京時間午夜重設;直連不計入。關閉官方服務會停止其請求、輪詢及通道。"),
+ ("網站與稽核", "本站使用既有的 Cloudflare Web Analytics,瀏覽量不代表軟體使用者數。用戶端、信令及 TURN 持續開源,網關協定和欄位公開;私有正式環境的儲存行為仍需部署稽核。"),
+ ]),
+ "zh-hk": ("私隱與必要資料", [
+ ("由你決定使用官方服務", "新安裝預設只使用區域網絡。啟用官方公網後才連接官方信令並記錄必要連線統計;自訂伺服器不向官方回報。先嘗試直連,失敗才申請中轉並讀取機器額度摘要。"),
+ ("最少必要資料", "網關保留去識別化裝置編號、首次與最近連線時間、每日中轉用量、必要額度綁定和累計彙總。每日裝置明細保留 90 天。這是官方服務裝置數,不是人數或全部安裝量。"),
+ ("內容與機器識別碼", "內容與真實裝置名稱透過裝置間加密通道傳送。不收集檔案名稱、路徑、用戶名稱、MAC、UA 或行為軌跡。原始系統識別碼不上傳;摘要只用於額度分組,並非不可偽造。"),
+ ("網絡資料與額度", "網絡端點暫時可見路由和網絡地址,官方統計庫及一般代理日誌不保存這些資料。每日 100 MB 中轉額度,含上下行,北京時間午夜重設;直連不計入。關閉官方服務會停止其請求、輪詢及通道。"),
+ ("網站與審計", "本站使用既有的 Cloudflare Web Analytics,瀏覽量不代表軟件用戶數。用戶端、信令及 TURN 持續開源,網關協定和欄位公開;私有正式環境的儲存行為仍需部署審計。"),
+ ]),
+ "en": ("Privacy and essential data", [
+ ("Official service is optional", "Fresh installs use LAN mode. Official access and essential connection statistics begin only when enabled. Custom servers do not report to the official service. Direct connections are attempted first; machine quota identification and relay authorization happen only after direct failure."),
+ ("Minimal service records", "The gateway retains pseudonymous device numbers, first/last access times, daily relay usage, essential quota bindings and cumulative totals. Daily device detail is retained for 90 days. Official device counts are not people or total installations."),
+ ("Content and identifiers", "Content and real device names travel through the encrypted device channel. The gateway does not collect filenames, paths, usernames, MAC addresses, UA or behavior trails. Raw system identifiers are not uploaded; the application-specific digest groups relay quota and can be forged by a modified client."),
+ ("Network visibility and allowance", "Network endpoints necessarily see transient routing/address metadata; official statistics and ordinary proxy logs do not retain it. The default allowance is 100 MB/day, upload plus download, reset at midnight Beijing time. Direct traffic is not charged. Disabling official access stops its requests, polling and tunnels."),
+ ("Website and audit boundary", "This website uses its existing Cloudflare Web Analytics beacon. Visits are not software-user counts. The client and signaling/TURN server remain open source, with gateway fields and protocol published. Actual private production retention still requires deployment audit."),
+ ]),
+ "ja": ("プライバシーと必要なデータ", [
+ ("公式サービスは任意です", "新規インストールではLANのみを使用します。有効にした場合のみ公式シグナリングに接続し、必要な接続統計を記録します。独自サーバーは公式へ報告しません。まず直接接続を試し、失敗した場合のみ中継の認証と端末の残量識別を行います。"),
+ ("最小限の記録", "仮名化した端末番号、初回・最終接続時刻、日別中継使用量、必要な上限の紐付けと累計を保持します。端末の日別明細は90日間保持します。公式端末数は人数や全インストール数ではありません。"),
+ ("内容と識別子", "内容と実際の端末名は端末間の暗号化通信で送信します。ファイル名、パス、ユーザー名、MAC、UA、行動履歴を収集しません。元のシステム識別子は送信せず、専用ダイジェストを中継上限の分類にのみ使います。改変クライアントによる偽装は防ぎきれません。"),
+ ("ネットワークと残量", "通信先は一時的な経路・アドレスを認識しますが、公式統計と通常のプロキシログには保存しません。中継上限は送受信合計100 MB/日で、北京時間午前0時にリセットします。直接接続は消費しません。無効化すると公式の要求、照会とトンネルを停止します。"),
+ ("ウェブサイトと監査", "当サイトは既存のCloudflare Web Analyticsを使います。閲覧数はソフトの利用者数ではありません。クライアント、シグナリングとTURNはオープンソースを維持し、ゲートウェイの仕様と項目を公開します。非公開の本番環境の保持実態には配備監査が必要です。"),
+ ]),
+}
diff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dart
index c61940b..3317f40 100644
--- a/ui/lib/app_state.dart
+++ b/ui/lib/app_state.dart
@@ -16,14 +16,22 @@ enum LinkState { connecting, online, offline }
typedef PairingCode = ({String code, List<String> addresses});
/// 配对失败的原因。后台服务把原因写在错误消息开头(见 rpc/server.go 的 pairingStatus)。
-enum PairingFailure { notFound, wrongCode, codeExpired, badAddress, noChannel, other }
+enum PairingFailure {
+ notFound,
+ wrongCode,
+ codeExpired,
+ badAddress,
+ noChannel,
+ other,
+}
/// 应用的单一状态源。
///
/// 所有与 daemon 的交互都经过这里:页面只读状态、调方法,不直接碰 gRPC。
/// 这样断线重连、事件合并这些琐事集中在一处,页面代码保持干净。
class AppState extends ChangeNotifier {
- AppState({BackgroundService? service}) : service = service ?? BackgroundService();
+ AppState({BackgroundService? service})
+ : service = service ?? BackgroundService();
final BackgroundService service;
@@ -70,7 +78,8 @@ class AppState extends ChangeNotifier {
String get searchQuery => _query.trim();
/// 搜到的记录,按时间倒序;没在搜索、或这次搜索还没出结果时为 null。
- List<ClipRecord>? get searchResults => _searchResults == null ? null : List.unmodifiable(_searchResults!);
+ List<ClipRecord>? get searchResults =>
+ _searchResults == null ? null : List.unmodifiable(_searchResults!);
/// 传输进度;总量未知或尚未开始时为 null。
double? progressOf(String clipId) => _progress[clipId];
@@ -83,6 +92,56 @@ class AppState extends ChangeNotifier {
/// 设置里填了服务器地址。没填时只在局域网里同步,不算异常。
bool get serverConfigured => _status?.serverConfigured ?? false;
bool get lanEnabled => _status?.lanEnabled ?? false;
+ bool get officialEnabled =>
+ _config?.serviceMode == ServiceMode.SERVICE_MODE_OFFICIAL;
+ OfficialUsage? get officialUsage =>
+ _status?.hasOfficialUsage() == true ? _status!.officialUsage : null;
+ int _officialNavigationSerial = 0;
+ int get officialNavigationSerial => _officialNavigationSerial;
+ final Set<String> _acknowledgedOfficial = {};
+ String? get officialNoticeKey {
+ if (!officialEnabled) return null;
+ final u = officialUsage;
+ if (u == null ||
+ !const {
+ 'quota_exhausted',
+ 'peer_quota_exhausted',
+ 'global_exhausted',
+ 'global_paused',
+ 'relay_blocked',
+ 'device_banned',
+ }.contains(u.reason)) {
+ return null;
+ }
+ final day = u.day.isNotEmpty
+ ? u.day
+ : DateTime.now()
+ .toUtc()
+ .add(const Duration(hours: 8))
+ .toIso8601String()
+ .substring(0, 10);
+ final key = '${u.quotaGroup}:$day:${u.reason}';
+ if (_acknowledgedOfficial.contains(key) ||
+ (_config?.officialNoticeAck ?? '').split('\n').contains(key)) {
+ return null;
+ }
+ return key;
+ }
+
+ Future<void> acknowledgeOfficialNotice(String key) async {
+ _acknowledgedOfficial.add(key);
+ final cfg = _config;
+ if (cfg == null) return;
+ final keys = {
+ ...cfg.officialNoticeAck.split('\n').where((s) => s.isNotEmpty),
+ key,
+ }.toList();
+ final next = cfg.deepCopy()
+ ..officialNoticeAck = keys
+ .skip(keys.length > 64 ? keys.length - 64 : 0)
+ .join('\n');
+ await updateConfig(next);
+ }
/// macOS 拦下了发往局域网的包:用户还没允许「本地网络」权限。
bool get lanBlocked => _status?.lanBlocked ?? false;
@@ -90,7 +149,9 @@ class AppState extends ChangeNotifier {
/// 详细日志打开到什么时候;没打开时为 null。
DateTime? get verboseLogUntil {
final until = _status?.verboseLogUntilUnix.toInt() ?? 0;
- return until == 0 ? null : DateTime.fromMillisecondsSinceEpoch(until * 1000);
+ return until == 0
+ ? null
+ : DateTime.fromMillisecondsSinceEpoch(until * 1000);
}
@override
@@ -128,9 +189,12 @@ class AppState extends ChangeNotifier {
await _loadDevices();
- _events = conn.client.subscribe(SubscribeRequest()).listen(
+ _events = conn.client
+ .subscribe(SubscribeRequest())
+ .listen(
_onEvent,
- onError: (Object e) => _scheduleRetry(appL10n.linkConnectionLost(_describe(e))),
+ onError: (Object e) =>
+ _scheduleRetry(appL10n.linkConnectionLost(_describe(e))),
onDone: () => _scheduleRetry(appL10n.linkServiceDisconnected),
);
@@ -279,7 +343,9 @@ class AppState extends ChangeNotifier {
case Event_Payload.clipAdded:
_upsert(ev.clipAdded);
// 新记录该不该出现在搜索结果里,只有后台服务知道
- if (!_patchSearch(ev.clipAdded)) _scheduleSearch(const Duration(milliseconds: 300));
+ if (!_patchSearch(ev.clipAdded)) {
+ _scheduleSearch(const Duration(milliseconds: 300));
+ }
case Event_Payload.clipUpdated:
_upsert(ev.clipUpdated);
@@ -330,7 +396,10 @@ class AppState extends ChangeNotifier {
return; // 已经传完的记录,迟到的进度事件不能把它拉回「接收中」
}
if (p.total > 0) {
- _progress[p.clipId] = (p.transferred.toInt() / p.total.toInt()).clamp(0.0, 1.0);
+ _progress[p.clipId] = (p.transferred.toInt() / p.total.toInt()).clamp(
+ 0.0,
+ 1.0,
+ );
}
}
@@ -371,7 +440,10 @@ class AppState extends ChangeNotifier {
/// [address] 是对方配对码下面显示的地址,不在同一网段时才需要。
Future<Device> redeemPairingCode(String code, {String address = ''}) async {
final resp = await _client.redeemPairingCode(
- RedeemPairingCodeRequest(code: code.trim().toUpperCase(), address: address.trim()),
+ RedeemPairingCodeRequest(
+ code: code.trim().toUpperCase(),
+ address: address.trim(),
+ ),
// 在局域网里找对方要几秒,找不到再去服务器上兑换
options: CallOptions(timeout: const Duration(seconds: 30)),
);
@@ -423,10 +495,13 @@ class AppState extends ChangeNotifier {
/// 手动告诉后台服务某台设备的地址:跨网段、或两边都换了地址时用。
Future<void> setDeviceAddress(String deviceId, String address) =>
- _client.setDeviceAddress(SetDeviceAddressRequest(deviceId: deviceId, address: address.trim()));
+ _client.setDeviceAddress(
+ SetDeviceAddressRequest(deviceId: deviceId, address: address.trim()),
+ );
/// macOS 打开「本地网络」设置;Windows 申请管理员权限放行防火墙。
- Future<void> requestLocalNetworkPermission() => _client.requestLocalNetworkPermission(Empty());
+ Future<void> requestLocalNetworkPermission() =>
+ _client.requestLocalNetworkPermission(Empty());
Future<void> unpair(String deviceId) async {
await _client.unpair(UnpairRequest(deviceId: deviceId));
@@ -435,7 +510,9 @@ class AppState extends ChangeNotifier {
}
Future<void> updateConfig(Config next) async {
+ final wasOfficial = officialEnabled;
_config = await _client.updateConfig(next);
+ if (!wasOfficial && officialEnabled) _officialNavigationSerial++;
notifyListeners();
}
@@ -443,11 +520,15 @@ class AppState extends ChangeNotifier {
/// 反馈问题用的诊断报告,由后台服务生成并脱敏,带上最近 [logLines] 行日志。
Future<String> exportDiagnostics({int logLines = 200}) async =>
- (await _client.exportDiagnostics(ExportDiagnosticsRequest(logLines: logLines, uiVersion: appVersion))).report;
+ (await _client.exportDiagnostics(
+ ExportDiagnosticsRequest(logLines: logLines, uiVersion: appVersion),
+ )).report;
/// 临时打开详细日志 [minutes] 分钟,0 表示立即关闭。
Future<void> setVerboseLog(int minutes) async {
- _status = await _client.setVerboseLog(SetVerboseLogRequest(minutes: minutes));
+ _status = await _client.setVerboseLog(
+ SetVerboseLogRequest(minutes: minutes),
+ );
notifyListeners();
}
@@ -494,7 +575,9 @@ class AppState extends ChangeNotifier {
try {
final r = await requestSearch(query);
// 旧版后台服务不认识搜索词,会原样返回全部记录:退回到只在已加载的记录里找
- found = r.searched ? List.of(r.records) : _records.where((x) => matchesSearch(x, query)).toList();
+ found = r.searched
+ ? List.of(r.records)
+ : _records.where((x) => matchesSearch(x, query)).toList();
} catch (_) {
found = _records.where((x) => matchesSearch(x, query)).toList();
}
@@ -529,9 +612,13 @@ class AppState extends ChangeNotifier {
/// 一条记录里第 [index] 张图片:本机路径、文件名,以及能预览的图片总数。
/// HEIC 这类格式由后台服务先转换,大图可能要一两秒,超时放宽一些。
- Future<GetImagePreviewResponse> imagePreview(String clipId, {int index = 0}) =>
- _client.getImagePreview(GetImagePreviewRequest(clipId: clipId, index: index),
- options: CallOptions(timeout: const Duration(seconds: 20)));
+ Future<GetImagePreviewResponse> imagePreview(
+ String clipId, {
+ int index = 0,
+ }) => _client.getImagePreview(
+ GetImagePreviewRequest(clipId: clipId, index: index),
+ options: CallOptions(timeout: const Duration(seconds: 20)),
+ );
Future<void> requestClipboardPermission() =>
_client.requestClipboardPermission(Empty());
@@ -569,7 +656,10 @@ class AppState extends ChangeNotifier {
/// 只在后台服务不支持搜索时用;正常情况下由后台服务按全文搜索。
bool matchesSearch(ClipRecord r, String query) {
final q = query.toLowerCase();
- if (r.kind != ClipKind.CLIP_KIND_IMAGE && r.items.any((i) => i.name.toLowerCase().contains(q))) return true;
+ if (r.kind != ClipKind.CLIP_KIND_IMAGE &&
+ r.items.any((i) => i.name.toLowerCase().contains(q))) {
+ return true;
+ }
return r.kind != ClipKind.CLIP_KIND_FILE &&
r.kind != ClipKind.CLIP_KIND_IMAGE &&
r.textPreview.toLowerCase().contains(q);
diff --git a/ui/lib/gen/pasteferry/v1/daemon.pb.dart b/ui/lib/gen/pasteferry/v1/daemon.pb.dart
index 81a8f04..ee83121 100644
--- a/ui/lib/gen/pasteferry/v1/daemon.pb.dart
+++ b/ui/lib/gen/pasteferry/v1/daemon.pb.dart
@@ -1899,6 +1899,9 @@ class Config extends $pb.GeneratedMessage {
$core.bool? onlyOwnStun,
$core.String? language,
$core.bool? lanDisabled,
+ ServiceMode? serviceMode,
+ $core.String? customSignalingUrl,
+ $core.String? officialNoticeAck,
}) {
final result = Config._();
if (autoSyncThresholdBytes != null)
@@ -1917,6 +1920,10 @@ class Config extends $pb.GeneratedMessage {
if (onlyOwnStun != null) result.onlyOwnStun = onlyOwnStun;
if (language != null) result.language = language;
if (lanDisabled != null) result.lanDisabled = lanDisabled;
+ if (serviceMode != null) result.serviceMode = serviceMode;
+ if (customSignalingUrl != null)
+ result.customSignalingUrl = customSignalingUrl;
+ if (officialNoticeAck != null) result.officialNoticeAck = officialNoticeAck;
return result;
}
@@ -1947,6 +1954,10 @@ class Config extends $pb.GeneratedMessage {
..aOB(12, _omitFieldNames ? '' : 'onlyOwnStun')
..aOS(13, _omitFieldNames ? '' : 'language')
..aOB(14, _omitFieldNames ? '' : 'lanDisabled')
+ ..aE<ServiceMode>(15, _omitFieldNames ? '' : 'serviceMode',
+ enumValues: ServiceMode.values)
+ ..aOS(16, _omitFieldNames ? '' : 'customSignalingUrl')
+ ..aOS(17, _omitFieldNames ? '' : 'officialNoticeAck')
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -2102,6 +2113,199 @@ class Config extends $pb.GeneratedMessage {
$core.bool hasLanDisabled() => $_has(13);
@$pb.TagNumber(14)
void clearLanDisabled() => $_clearField(14);
+
+ /// Official service is opt-in; remembered custom URLs are inactive otherwise.
+ @$pb.TagNumber(15)
+ ServiceMode get serviceMode => $_getN(14);
+ @$pb.TagNumber(15)
+ set serviceMode(ServiceMode value) => $_setField(15, value);
+ @$pb.TagNumber(15)
+ $core.bool hasServiceMode() => $_has(14);
+ @$pb.TagNumber(15)
+ void clearServiceMode() => $_clearField(15);
+
+ @$pb.TagNumber(16)
+ $core.String get customSignalingUrl => $_getSZ(15);
+ @$pb.TagNumber(16)
+ set customSignalingUrl($core.String value) => $_setString(15, value);
+ @$pb.TagNumber(16)
+ $core.bool hasCustomSignalingUrl() => $_has(15);
+ @$pb.TagNumber(16)
+ void clearCustomSignalingUrl() => $_clearField(16);
+
+ @$pb.TagNumber(17)
+ $core.String get officialNoticeAck => $_getSZ(16);
+ @$pb.TagNumber(17)
+ set officialNoticeAck($core.String value) => $_setString(16, value);
+ @$pb.TagNumber(17)
+ $core.bool hasOfficialNoticeAck() => $_has(16);
+ @$pb.TagNumber(17)
+ void clearOfficialNoticeAck() => $_clearField(17);
+}
+
+class OfficialUsage extends $pb.GeneratedMessage {
+ factory OfficialUsage({
+ $core.bool? available,
+ $core.String? day,
+ $core.String? quotaGroup,
+ $fixnum.Int64? uploadBytes,
+ $fixnum.Int64? downloadBytes,
+ $fixnum.Int64? limitBytes,
+ $fixnum.Int64? remainingBytes,
+ $fixnum.Int64? resetAtUnix,
+ $fixnum.Int64? updatedAtUnix,
+ $core.String? reason,
+ }) {
+ final result = OfficialUsage._();
+ if (available != null) result.available = available;
+ if (day != null) result.day = day;
+ if (quotaGroup != null) result.quotaGroup = quotaGroup;
+ if (uploadBytes != null) result.uploadBytes = uploadBytes;
+ if (downloadBytes != null) result.downloadBytes = downloadBytes;
+ if (limitBytes != null) result.limitBytes = limitBytes;
+ if (remainingBytes != null) result.remainingBytes = remainingBytes;
+ if (resetAtUnix != null) result.resetAtUnix = resetAtUnix;
+ if (updatedAtUnix != null) result.updatedAtUnix = updatedAtUnix;
+ if (reason != null) result.reason = reason;
+ return result;
+ }
+
+ OfficialUsage._();
+
+ factory OfficialUsage.fromBuffer($core.List<$core.int> data,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ OfficialUsage()..mergeFromBuffer(data, registry);
+ factory OfficialUsage.fromJson($core.String json,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ OfficialUsage()..mergeFromJson(json, registry);
+
+ static final $pb.BuilderInfo _i = $pb.BuilderInfo(
+ _omitMessageNames ? '' : 'OfficialUsage',
+ package: const $pb.PackageName(_omitMessageNames ? '' : 'pasteferry.v1'),
+ createEmptyInstance: OfficialUsage.$_createMessage)
+ ..aOB(1, _omitFieldNames ? '' : 'available')
+ ..aOS(2, _omitFieldNames ? '' : 'day')
+ ..aOS(3, _omitFieldNames ? '' : 'quotaGroup')
+ ..aInt64(4, _omitFieldNames ? '' : 'uploadBytes')
+ ..aInt64(5, _omitFieldNames ? '' : 'downloadBytes')
+ ..aInt64(6, _omitFieldNames ? '' : 'limitBytes')
+ ..aInt64(7, _omitFieldNames ? '' : 'remainingBytes')
+ ..aInt64(8, _omitFieldNames ? '' : 'resetAtUnix')
+ ..aInt64(9, _omitFieldNames ? '' : 'updatedAtUnix')
+ ..aOS(10, _omitFieldNames ? '' : 'reason')
+ ..hasRequiredFields = false;
+
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ OfficialUsage clone() => deepCopy();
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ OfficialUsage copyWith(void Function(OfficialUsage) updates) =>
+ super.copyWith((message) => updates(message as OfficialUsage))
+ as OfficialUsage;
+
+ @$core.override
+ $pb.BuilderInfo get info_ => _i;
+
+ @$core.pragma('dart2js:noInline')
+ @$core.Deprecated('Use OfficialUsage() / OfficialUsage.new instead')
+ static OfficialUsage create() => OfficialUsage._();
+ static $pb.GeneratedMessage $_createMessage() => OfficialUsage._();
+ @$core.override
+ OfficialUsage createEmptyInstance() => OfficialUsage._();
+ @$core.pragma('dart2js:noInline')
+ static OfficialUsage getDefault() =>
+ _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<OfficialUsage>(
+ OfficialUsage.$_createMessage);
+ static OfficialUsage? _defaultInstance;
+
+ @$pb.TagNumber(1)
+ $core.bool get available => $_getBF(0);
+ @$pb.TagNumber(1)
+ set available($core.bool value) => $_setBool(0, value);
+ @$pb.TagNumber(1)
+ $core.bool hasAvailable() => $_has(0);
+ @$pb.TagNumber(1)
+ void clearAvailable() => $_clearField(1);
+
+ @$pb.TagNumber(2)
+ $core.String get day => $_getSZ(1);
+ @$pb.TagNumber(2)
+ set day($core.String value) => $_setString(1, value);
+ @$pb.TagNumber(2)
+ $core.bool hasDay() => $_has(1);
+ @$pb.TagNumber(2)
+ void clearDay() => $_clearField(2);
+
+ @$pb.TagNumber(3)
+ $core.String get quotaGroup => $_getSZ(2);
+ @$pb.TagNumber(3)
+ set quotaGroup($core.String value) => $_setString(2, value);
+ @$pb.TagNumber(3)
+ $core.bool hasQuotaGroup() => $_has(2);
+ @$pb.TagNumber(3)
+ void clearQuotaGroup() => $_clearField(3);
+
+ @$pb.TagNumber(4)
+ $fixnum.Int64 get uploadBytes => $_getI64(3);
+ @$pb.TagNumber(4)
+ set uploadBytes($fixnum.Int64 value) => $_setInt64(3, value);
+ @$pb.TagNumber(4)
+ $core.bool hasUploadBytes() => $_has(3);
+ @$pb.TagNumber(4)
+ void clearUploadBytes() => $_clearField(4);
+
+ @$pb.TagNumber(5)
+ $fixnum.Int64 get downloadBytes => $_getI64(4);
+ @$pb.TagNumber(5)
+ set downloadBytes($fixnum.Int64 value) => $_setInt64(4, value);
+ @$pb.TagNumber(5)
+ $core.bool hasDownloadBytes() => $_has(4);
+ @$pb.TagNumber(5)
+ void clearDownloadBytes() => $_clearField(5);
+
+ @$pb.TagNumber(6)
+ $fixnum.Int64 get limitBytes => $_getI64(5);
+ @$pb.TagNumber(6)
+ set limitBytes($fixnum.Int64 value) => $_setInt64(5, value);
+ @$pb.TagNumber(6)
+ $core.bool hasLimitBytes() => $_has(5);
+ @$pb.TagNumber(6)
+ void clearLimitBytes() => $_clearField(6);
+
+ @$pb.TagNumber(7)
+ $fixnum.Int64 get remainingBytes => $_getI64(6);
+ @$pb.TagNumber(7)
+ set remainingBytes($fixnum.Int64 value) => $_setInt64(6, value);
+ @$pb.TagNumber(7)
+ $core.bool hasRemainingBytes() => $_has(6);
+ @$pb.TagNumber(7)
+ void clearRemainingBytes() => $_clearField(7);
+
+ @$pb.TagNumber(8)
+ $fixnum.Int64 get resetAtUnix => $_getI64(7);
+ @$pb.TagNumber(8)
+ set resetAtUnix($fixnum.Int64 value) => $_setInt64(7, value);
+ @$pb.TagNumber(8)
+ $core.bool hasResetAtUnix() => $_has(7);
+ @$pb.TagNumber(8)
+ void clearResetAtUnix() => $_clearField(8);
+
+ @$pb.TagNumber(9)
+ $fixnum.Int64 get updatedAtUnix => $_getI64(8);
+ @$pb.TagNumber(9)
+ set updatedAtUnix($fixnum.Int64 value) => $_setInt64(8, value);
+ @$pb.TagNumber(9)
+ $core.bool hasUpdatedAtUnix() => $_has(8);
+ @$pb.TagNumber(9)
+ void clearUpdatedAtUnix() => $_clearField(9);
+
+ @$pb.TagNumber(10)
+ $core.String get reason => $_getSZ(9);
+ @$pb.TagNumber(10)
+ set reason($core.String value) => $_setString(9, value);
+ @$pb.TagNumber(10)
+ $core.bool hasReason() => $_has(9);
+ @$pb.TagNumber(10)
+ void clearReason() => $_clearField(10);
}
/// 最近一轮网络出口探测的结果。
@@ -2534,6 +2738,7 @@ class Status extends $pb.GeneratedMessage {
$core.bool? lanEnabled,
$core.bool? lanBlocked,
$fixnum.Int64? verboseLogUntilUnix,
+ OfficialUsage? officialUsage,
}) {
final result = Status._();
if (deviceId != null) result.deviceId = deviceId;
@@ -2550,6 +2755,7 @@ class Status extends $pb.GeneratedMessage {
if (lanBlocked != null) result.lanBlocked = lanBlocked;
if (verboseLogUntilUnix != null)
result.verboseLogUntilUnix = verboseLogUntilUnix;
+ if (officialUsage != null) result.officialUsage = officialUsage;
return result;
}
@@ -2578,6 +2784,8 @@ class Status extends $pb.GeneratedMessage {
..aOB(9, _omitFieldNames ? '' : 'lanEnabled')
..aOB(10, _omitFieldNames ? '' : 'lanBlocked')
..aInt64(11, _omitFieldNames ? '' : 'verboseLogUntilUnix')
+ ..aOM<OfficialUsage>(12, _omitFieldNames ? '' : 'officialUsage',
+ subBuilder: OfficialUsage.$_createMessage)
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -2701,6 +2909,17 @@ class Status extends $pb.GeneratedMessage {
$core.bool hasVerboseLogUntilUnix() => $_has(10);
@$pb.TagNumber(11)
void clearVerboseLogUntilUnix() => $_clearField(11);
+
+ @$pb.TagNumber(12)
+ OfficialUsage get officialUsage => $_getN(11);
+ @$pb.TagNumber(12)
+ set officialUsage(OfficialUsage value) => $_setField(12, value);
+ @$pb.TagNumber(12)
+ $core.bool hasOfficialUsage() => $_has(11);
+ @$pb.TagNumber(12)
+ void clearOfficialUsage() => $_clearField(12);
+ @$pb.TagNumber(12)
+ OfficialUsage ensureOfficialUsage() => $_ensure(11);
}
class ExportDiagnosticsRequest extends $pb.GeneratedMessage {
diff --git a/ui/lib/gen/pasteferry/v1/daemon.pbenum.dart b/ui/lib/gen/pasteferry/v1/daemon.pbenum.dart
index 0850fcc..5426e08 100644
--- a/ui/lib/gen/pasteferry/v1/daemon.pbenum.dart
+++ b/ui/lib/gen/pasteferry/v1/daemon.pbenum.dart
@@ -137,5 +137,30 @@ class ClipboardPermission extends $pb.ProtobufEnum {
const ClipboardPermission._(super.value, super.name);
}
+class ServiceMode extends $pb.ProtobufEnum {
+ static const ServiceMode SERVICE_MODE_UNSPECIFIED =
+ ServiceMode._(0, _omitEnumNames ? '' : 'SERVICE_MODE_UNSPECIFIED');
+ static const ServiceMode SERVICE_MODE_LAN =
+ ServiceMode._(1, _omitEnumNames ? '' : 'SERVICE_MODE_LAN');
+ static const ServiceMode SERVICE_MODE_OFFICIAL =
+ ServiceMode._(2, _omitEnumNames ? '' : 'SERVICE_MODE_OFFICIAL');
+ static const ServiceMode SERVICE_MODE_CUSTOM =
+ ServiceMode._(3, _omitEnumNames ? '' : 'SERVICE_MODE_CUSTOM');
+
+ static const $core.List<ServiceMode> values = <ServiceMode>[
+ SERVICE_MODE_UNSPECIFIED,
+ SERVICE_MODE_LAN,
+ SERVICE_MODE_OFFICIAL,
+ SERVICE_MODE_CUSTOM,
+ ];
+
+ static final $core.List<ServiceMode?> _byValue =
+ $pb.ProtobufEnum.$_initByValueList(values, 3);
+ static ServiceMode? valueOf($core.int value) =>
+ value < 0 || value >= _byValue.length ? null : _byValue[value];
+
+ const ServiceMode._(super.value, super.name);
+}
+
const $core.bool _omitEnumNames =
$core.bool.fromEnvironment('protobuf.omit_enum_names');
diff --git a/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart b/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart
index 85d84c1..719835b 100644
--- a/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart
+++ b/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart
@@ -91,6 +91,23 @@ final $typed_data.Uint8List clipboardPermissionDescriptor = $convert.base64Decod
'ohQ0xJUEJPQVJEX1BFUk1JU1NJT05fQUxXQVlTX0FMTE9XEAQSJAogQ0xJUEJPQVJEX1BFUk1J'
'U1NJT05fQUxXQVlTX0RFTlkQBQ==');
+@$core.Deprecated('Use serviceModeDescriptor instead')
+const ServiceMode$json = {
+ '1': 'ServiceMode',
+ '2': [
+ {'1': 'SERVICE_MODE_UNSPECIFIED', '2': 0},
+ {'1': 'SERVICE_MODE_LAN', '2': 1},
+ {'1': 'SERVICE_MODE_OFFICIAL', '2': 2},
+ {'1': 'SERVICE_MODE_CUSTOM', '2': 3},
+ ],
+};
+
+/// Descriptor for `ServiceMode`. Decode as a `google.protobuf.EnumDescriptorProto`.
+final $typed_data.Uint8List serviceModeDescriptor = $convert.base64Decode(
+ 'CgtTZXJ2aWNlTW9kZRIcChhTRVJWSUNFX01PREVfVU5TUEVDSUZJRUQQABIUChBTRVJWSUNFX0'
+ '1PREVfTEFOEAESGQoVU0VSVklDRV9NT0RFX09GRklDSUFMEAISFwoTU0VSVklDRV9NT0RFX0NV'
+ 'U1RPTRAD');
+
@$core.Deprecated('Use emptyDescriptor instead')
const Empty$json = {
'1': 'Empty',
@@ -615,6 +632,28 @@ const Config$json = {
{'1': 'only_own_stun', '3': 12, '4': 1, '5': 8, '10': 'onlyOwnStun'},
{'1': 'language', '3': 13, '4': 1, '5': 9, '10': 'language'},
{'1': 'lan_disabled', '3': 14, '4': 1, '5': 8, '10': 'lanDisabled'},
+ {
+ '1': 'service_mode',
+ '3': 15,
+ '4': 1,
+ '5': 14,
+ '6': '.pasteferry.v1.ServiceMode',
+ '10': 'serviceMode'
+ },
+ {
+ '1': 'custom_signaling_url',
+ '3': 16,
+ '4': 1,
+ '5': 9,
+ '10': 'customSignalingUrl'
+ },
+ {
+ '1': 'official_notice_ack',
+ '3': 17,
+ '4': 1,
+ '5': 9,
+ '10': 'officialNoticeAck'
+ },
],
};
@@ -629,7 +668,37 @@ final $typed_data.Uint8List configDescriptor = $convert.base64Decode(
'JgoPbGF1bmNoX2F0X2xvZ2luGAkgASgIUg1sYXVuY2hBdExvZ2luEh8KC2RldmljZV9uYW1lGA'
'ogASgJUgpkZXZpY2VOYW1lEiMKDXNpZ25hbGluZ191cmwYCyABKAlSDHNpZ25hbGluZ1VybBIi'
'Cg1vbmx5X293bl9zdHVuGAwgASgIUgtvbmx5T3duU3R1bhIaCghsYW5ndWFnZRgNIAEoCVIIbG'
- 'FuZ3VhZ2USIQoMbGFuX2Rpc2FibGVkGA4gASgIUgtsYW5EaXNhYmxlZA==');
+ 'FuZ3VhZ2USIQoMbGFuX2Rpc2FibGVkGA4gASgIUgtsYW5EaXNhYmxlZBI9CgxzZXJ2aWNlX21v'
+ 'ZGUYDyABKA4yGi5wYXN0ZWZlcnJ5LnYxLlNlcnZpY2VNb2RlUgtzZXJ2aWNlTW9kZRIwChRjdX'
+ 'N0b21fc2lnbmFsaW5nX3VybBgQIAEoCVISY3VzdG9tU2lnbmFsaW5nVXJsEi4KE29mZmljaWFs'
+ 'X25vdGljZV9hY2sYESABKAlSEW9mZmljaWFsTm90aWNlQWNr');
+
+@$core.Deprecated('Use officialUsageDescriptor instead')
+const OfficialUsage$json = {
+ '1': 'OfficialUsage',
+ '2': [
+ {'1': 'available', '3': 1, '4': 1, '5': 8, '10': 'available'},
+ {'1': 'day', '3': 2, '4': 1, '5': 9, '10': 'day'},
+ {'1': 'quota_group', '3': 3, '4': 1, '5': 9, '10': 'quotaGroup'},
+ {'1': 'upload_bytes', '3': 4, '4': 1, '5': 3, '10': 'uploadBytes'},
+ {'1': 'download_bytes', '3': 5, '4': 1, '5': 3, '10': 'downloadBytes'},
+ {'1': 'limit_bytes', '3': 6, '4': 1, '5': 3, '10': 'limitBytes'},
+ {'1': 'remaining_bytes', '3': 7, '4': 1, '5': 3, '10': 'remainingBytes'},
+ {'1': 'reset_at_unix', '3': 8, '4': 1, '5': 3, '10': 'resetAtUnix'},
+ {'1': 'updated_at_unix', '3': 9, '4': 1, '5': 3, '10': 'updatedAtUnix'},
+ {'1': 'reason', '3': 10, '4': 1, '5': 9, '10': 'reason'},
+ ],
+};
+
+/// Descriptor for `OfficialUsage`. Decode as a `google.protobuf.DescriptorProto`.
+final $typed_data.Uint8List officialUsageDescriptor = $convert.base64Decode(
+ 'Cg1PZmZpY2lhbFVzYWdlEhwKCWF2YWlsYWJsZRgBIAEoCFIJYXZhaWxhYmxlEhAKA2RheRgCIA'
+ 'EoCVIDZGF5Eh8KC3F1b3RhX2dyb3VwGAMgASgJUgpxdW90YUdyb3VwEiEKDHVwbG9hZF9ieXRl'
+ 'cxgEIAEoA1ILdXBsb2FkQnl0ZXMSJQoOZG93bmxvYWRfYnl0ZXMYBSABKANSDWRvd25sb2FkQn'
+ 'l0ZXMSHwoLbGltaXRfYnl0ZXMYBiABKANSCmxpbWl0Qnl0ZXMSJwoPcmVtYWluaW5nX2J5dGVz'
+ 'GAcgASgDUg5yZW1haW5pbmdCeXRlcxIiCg1yZXNldF9hdF91bml4GAggASgDUgtyZXNldEF0VW'
+ '5peBImCg91cGRhdGVkX2F0X3VuaXgYCSABKANSDXVwZGF0ZWRBdFVuaXgSFgoGcmVhc29uGAog'
+ 'ASgJUgZyZWFzb24=');
@$core.Deprecated('Use networkInfoDescriptor instead')
const NetworkInfo$json = {
@@ -770,6 +839,14 @@ const Status$json = {
'5': 3,
'10': 'verboseLogUntilUnix'
},
+ {
+ '1': 'official_usage',
+ '3': 12,
+ '4': 1,
+ '5': 11,
+ '6': '.pasteferry.v1.OfficialUsage',
+ '10': 'officialUsage'
+ },
],
};
@@ -783,7 +860,8 @@ final $typed_data.Uint8List statusDescriptor = $convert.base64Decode(
'9ubGluZRIYCgd2ZXJzaW9uGAcgASgJUgd2ZXJzaW9uEisKEXNlcnZlcl9jb25maWd1cmVkGAgg'
'ASgIUhBzZXJ2ZXJDb25maWd1cmVkEh8KC2xhbl9lbmFibGVkGAkgASgIUgpsYW5FbmFibGVkEh'
'8KC2xhbl9ibG9ja2VkGAogASgIUgpsYW5CbG9ja2VkEjMKFnZlcmJvc2VfbG9nX3VudGlsX3Vu'
- 'aXgYCyABKANSE3ZlcmJvc2VMb2dVbnRpbFVuaXg=');
+ 'aXgYCyABKANSE3ZlcmJvc2VMb2dVbnRpbFVuaXgSQwoOb2ZmaWNpYWxfdXNhZ2UYDCABKAsyHC'
+ '5wYXN0ZWZlcnJ5LnYxLk9mZmljaWFsVXNhZ2VSDW9mZmljaWFsVXNhZ2U=');
@$core.Deprecated('Use exportDiagnosticsRequestDescriptor instead')
const ExportDiagnosticsRequest$json = {
diff --git a/ui/lib/gen/pasteferry/v1/wire.pb.dart b/ui/lib/gen/pasteferry/v1/wire.pb.dart
index 24510bc..228203b 100644
--- a/ui/lib/gen/pasteferry/v1/wire.pb.dart
+++ b/ui/lib/gen/pasteferry/v1/wire.pb.dart
@@ -112,6 +112,10 @@ class SignalMessage extends $pb.GeneratedMessage {
$fixnum.Int64? timestampUnix,
$core.List<$core.int>? nonce,
$core.String? toDeviceId,
+ $core.String? connectionAttemptId,
+ $core.bool? officialRelay,
+ $core.bool? gatewayCapable,
+ $core.String? relayDenialCode,
SdpOffer? offer,
SdpAnswer? answer,
IceCandidate? candidate,
@@ -122,6 +126,11 @@ class SignalMessage extends $pb.GeneratedMessage {
if (timestampUnix != null) result.timestampUnix = timestampUnix;
if (nonce != null) result.nonce = nonce;
if (toDeviceId != null) result.toDeviceId = toDeviceId;
+ if (connectionAttemptId != null)
+ result.connectionAttemptId = connectionAttemptId;
+ if (officialRelay != null) result.officialRelay = officialRelay;
+ if (gatewayCapable != null) result.gatewayCapable = gatewayCapable;
+ if (relayDenialCode != null) result.relayDenialCode = relayDenialCode;
if (offer != null) result.offer = offer;
if (answer != null) result.answer = answer;
if (candidate != null) result.candidate = candidate;
@@ -157,6 +166,10 @@ class SignalMessage extends $pb.GeneratedMessage {
..a<$core.List<$core.int>>(
2, _omitFieldNames ? '' : 'nonce', $pb.PbFieldType.OY)
..aOS(3, _omitFieldNames ? '' : 'toDeviceId')
+ ..aOS(4, _omitFieldNames ? '' : 'connectionAttemptId')
+ ..aOB(5, _omitFieldNames ? '' : 'officialRelay')
+ ..aOB(6, _omitFieldNames ? '' : 'gatewayCapable')
+ ..aOS(7, _omitFieldNames ? '' : 'relayDenialCode')
..aOM<SdpOffer>(10, _omitFieldNames ? '' : 'offer',
subBuilder: SdpOffer.$_createMessage)
..aOM<SdpAnswer>(11, _omitFieldNames ? '' : 'answer',
@@ -234,60 +247,98 @@ class SignalMessage extends $pb.GeneratedMessage {
@$pb.TagNumber(3)
void clearToDeviceId() => $_clearField(3);
+ /// Client-only negotiation metadata; the server forwards Signed unchanged.
+ @$pb.TagNumber(4)
+ $core.String get connectionAttemptId => $_getSZ(3);
+ @$pb.TagNumber(4)
+ set connectionAttemptId($core.String value) => $_setString(3, value);
+ @$pb.TagNumber(4)
+ $core.bool hasConnectionAttemptId() => $_has(3);
+ @$pb.TagNumber(4)
+ void clearConnectionAttemptId() => $_clearField(4);
+
+ @$pb.TagNumber(5)
+ $core.bool get officialRelay => $_getBF(4);
+ @$pb.TagNumber(5)
+ set officialRelay($core.bool value) => $_setBool(4, value);
+ @$pb.TagNumber(5)
+ $core.bool hasOfficialRelay() => $_has(4);
+ @$pb.TagNumber(5)
+ void clearOfficialRelay() => $_clearField(5);
+
+ @$pb.TagNumber(6)
+ $core.bool get gatewayCapable => $_getBF(5);
+ @$pb.TagNumber(6)
+ set gatewayCapable($core.bool value) => $_setBool(5, value);
+ @$pb.TagNumber(6)
+ $core.bool hasGatewayCapable() => $_has(5);
+ @$pb.TagNumber(6)
+ void clearGatewayCapable() => $_clearField(6);
+
+ /// Fixed relay-only denial codes; these never change pairing or direct trust.
+ @$pb.TagNumber(7)
+ $core.String get relayDenialCode => $_getSZ(6);
+ @$pb.TagNumber(7)
+ set relayDenialCode($core.String value) => $_setString(6, value);
+ @$pb.TagNumber(7)
+ $core.bool hasRelayDenialCode() => $_has(6);
+ @$pb.TagNumber(7)
+ void clearRelayDenialCode() => $_clearField(7);
+
@$pb.TagNumber(10)
- SdpOffer get offer => $_getN(3);
+ SdpOffer get offer => $_getN(7);
@$pb.TagNumber(10)
set offer(SdpOffer value) => $_setField(10, value);
@$pb.TagNumber(10)
- $core.bool hasOffer() => $_has(3);
+ $core.bool hasOffer() => $_has(7);
@$pb.TagNumber(10)
void clearOffer() => $_clearField(10);
@$pb.TagNumber(10)
- SdpOffer ensureOffer() => $_ensure(3);
+ SdpOffer ensureOffer() => $_ensure(7);
@$pb.TagNumber(11)
- SdpAnswer get answer => $_getN(4);
+ SdpAnswer get answer => $_getN(8);
@$pb.TagNumber(11)
set answer(SdpAnswer value) => $_setField(11, value);
@$pb.TagNumber(11)
- $core.bool hasAnswer() => $_has(4);
+ $core.bool hasAnswer() => $_has(8);
@$pb.TagNumber(11)
void clearAnswer() => $_clearField(11);
@$pb.TagNumber(11)
- SdpAnswer ensureAnswer() => $_ensure(4);
+ SdpAnswer ensureAnswer() => $_ensure(8);
@$pb.TagNumber(12)
- IceCandidate get candidate => $_getN(5);
+ IceCandidate get candidate => $_getN(9);
@$pb.TagNumber(12)
set candidate(IceCandidate value) => $_setField(12, value);
@$pb.TagNumber(12)
- $core.bool hasCandidate() => $_has(5);
+ $core.bool hasCandidate() => $_has(9);
@$pb.TagNumber(12)
void clearCandidate() => $_clearField(12);
@$pb.TagNumber(12)
- IceCandidate ensureCandidate() => $_ensure(5);
+ IceCandidate ensureCandidate() => $_ensure(9);
@$pb.TagNumber(13)
- Ping get ping => $_getN(6);
+ Ping get ping => $_getN(10);
@$pb.TagNumber(13)
set ping(Ping value) => $_setField(13, value);
@$pb.TagNumber(13)
- $core.bool hasPing() => $_has(6);
+ $core.bool hasPing() => $_has(10);
@$pb.TagNumber(13)
void clearPing() => $_clearField(13);
@$pb.TagNumber(13)
- Ping ensurePing() => $_ensure(6);
+ Ping ensurePing() => $_ensure(10);
@$pb.TagNumber(14)
- LanHello get lanHello => $_getN(7);
+ LanHello get lanHello => $_getN(11);
@$pb.TagNumber(14)
set lanHello(LanHello value) => $_setField(14, value);
@$pb.TagNumber(14)
- $core.bool hasLanHello() => $_has(7);
+ $core.bool hasLanHello() => $_has(11);
@$pb.TagNumber(14)
void clearLanHello() => $_clearField(14);
@$pb.TagNumber(14)
- LanHello ensureLanHello() => $_ensure(7);
+ LanHello ensureLanHello() => $_ensure(11);
}
class SdpOffer extends $pb.GeneratedMessage {
@@ -2464,7 +2515,16 @@ class LanNearbyPing extends $pb.GeneratedMessage {
void clearToken() => $_clearField(4);
}
-enum PeerMessage_Payload { offer, fetch, reject, header, done, link, notSet }
+enum PeerMessage_Payload {
+ offer,
+ fetch,
+ reject,
+ header,
+ done,
+ link,
+ display,
+ notSet
+}
/// 控制通道消息
class PeerMessage extends $pb.GeneratedMessage {
@@ -2475,6 +2535,7 @@ class PeerMessage extends $pb.GeneratedMessage {
TransferHeader? header,
TransferDone? done,
LinkInfo? link,
+ PeerDisplay? display,
}) {
final result = PeerMessage._();
if (offer != null) result.offer = offer;
@@ -2483,6 +2544,7 @@ class PeerMessage extends $pb.GeneratedMessage {
if (header != null) result.header = header;
if (done != null) result.done = done;
if (link != null) result.link = link;
+ if (display != null) result.display = display;
return result;
}
@@ -2503,13 +2565,14 @@ class PeerMessage extends $pb.GeneratedMessage {
4: PeerMessage_Payload.header,
5: PeerMessage_Payload.done,
6: PeerMessage_Payload.link,
+ 7: PeerMessage_Payload.display,
0: PeerMessage_Payload.notSet
};
static final $pb.BuilderInfo _i = $pb.BuilderInfo(
_omitMessageNames ? '' : 'PeerMessage',
package: const $pb.PackageName(_omitMessageNames ? '' : 'pasteferry.v1'),
createEmptyInstance: PeerMessage.$_createMessage)
- ..oo(0, [1, 2, 3, 4, 5, 6])
+ ..oo(0, [1, 2, 3, 4, 5, 6, 7])
..aOM<ClipOffer>(1, _omitFieldNames ? '' : 'offer',
subBuilder: ClipOffer.$_createMessage)
..aOM<PeerFetch>(2, _omitFieldNames ? '' : 'fetch',
@@ -2522,6 +2585,8 @@ class PeerMessage extends $pb.GeneratedMessage {
subBuilder: TransferDone.$_createMessage)
..aOM<LinkInfo>(6, _omitFieldNames ? '' : 'link',
subBuilder: LinkInfo.$_createMessage)
+ ..aOM<PeerDisplay>(7, _omitFieldNames ? '' : 'display',
+ subBuilder: PeerDisplay.$_createMessage)
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -2552,6 +2617,7 @@ class PeerMessage extends $pb.GeneratedMessage {
@$pb.TagNumber(4)
@$pb.TagNumber(5)
@$pb.TagNumber(6)
+ @$pb.TagNumber(7)
PeerMessage_Payload whichPayload() =>
_PeerMessage_PayloadByTag[$_whichOneof(0)]!;
@$pb.TagNumber(1)
@@ -2560,6 +2626,7 @@ class PeerMessage extends $pb.GeneratedMessage {
@$pb.TagNumber(4)
@$pb.TagNumber(5)
@$pb.TagNumber(6)
+ @$pb.TagNumber(7)
void clearPayload() => $_clearField($_whichOneof(0));
@$pb.TagNumber(1)
@@ -2627,6 +2694,17 @@ class PeerMessage extends $pb.GeneratedMessage {
void clearLink() => $_clearField(6);
@$pb.TagNumber(6)
LinkInfo ensureLink() => $_ensure(5);
+
+ @$pb.TagNumber(7)
+ PeerDisplay get display => $_getN(6);
+ @$pb.TagNumber(7)
+ set display(PeerDisplay value) => $_setField(7, value);
+ @$pb.TagNumber(7)
+ $core.bool hasDisplay() => $_has(6);
+ @$pb.TagNumber(7)
+ void clearDisplay() => $_clearField(7);
+ @$pb.TagNumber(7)
+ PeerDisplay ensureDisplay() => $_ensure(6);
}
/// 连接就绪后各自发一次。只有本端能确定自己发出的数据是否走 TURN:
@@ -2687,6 +2765,75 @@ class LinkInfo extends $pb.GeneratedMessage {
void clearRelayed() => $_clearField(1);
}
+class PeerDisplay extends $pb.GeneratedMessage {
+ factory PeerDisplay({
+ $core.String? name,
+ $core.String? platform,
+ }) {
+ final result = PeerDisplay._();
+ if (name != null) result.name = name;
+ if (platform != null) result.platform = platform;
+ return result;
+ }
+
+ PeerDisplay._();
+
+ factory PeerDisplay.fromBuffer($core.List<$core.int> data,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ PeerDisplay()..mergeFromBuffer(data, registry);
+ factory PeerDisplay.fromJson($core.String json,
+ [$pb.ExtensionRegistry registry = $pb.ExtensionRegistry.EMPTY]) =>
+ PeerDisplay()..mergeFromJson(json, registry);
+
+ static final $pb.BuilderInfo _i = $pb.BuilderInfo(
+ _omitMessageNames ? '' : 'PeerDisplay',
+ package: const $pb.PackageName(_omitMessageNames ? '' : 'pasteferry.v1'),
+ createEmptyInstance: PeerDisplay.$_createMessage)
+ ..aOS(1, _omitFieldNames ? '' : 'name')
+ ..aOS(2, _omitFieldNames ? '' : 'platform')
+ ..hasRequiredFields = false;
+
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ PeerDisplay clone() => deepCopy();
+ @$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
+ PeerDisplay copyWith(void Function(PeerDisplay) updates) =>
+ super.copyWith((message) => updates(message as PeerDisplay))
+ as PeerDisplay;
+
+ @$core.override
+ $pb.BuilderInfo get info_ => _i;
+
+ @$core.pragma('dart2js:noInline')
+ @$core.Deprecated('Use PeerDisplay() / PeerDisplay.new instead')
+ static PeerDisplay create() => PeerDisplay._();
+ static $pb.GeneratedMessage $_createMessage() => PeerDisplay._();
+ @$core.override
+ PeerDisplay createEmptyInstance() => PeerDisplay._();
+ @$core.pragma('dart2js:noInline')
+ static PeerDisplay getDefault() =>
+ _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<PeerDisplay>(
+ PeerDisplay.$_createMessage);
+ static PeerDisplay? _defaultInstance;
+
+ @$pb.TagNumber(1)
+ $core.String get name => $_getSZ(0);
+ @$pb.TagNumber(1)
+ set name($core.String value) => $_setString(0, value);
+ @$pb.TagNumber(1)
+ $core.bool hasName() => $_has(0);
+ @$pb.TagNumber(1)
+ void clearName() => $_clearField(1);
+
+ @$pb.TagNumber(2)
+ $core.String get platform => $_getSZ(1);
+ @$pb.TagNumber(2)
+ set platform($core.String value) => $_setString(1, value);
+ @$pb.TagNumber(2)
+ $core.bool hasPlatform() => $_has(1);
+ @$pb.TagNumber(2)
+ void clearPlatform() => $_clearField(2);
+}
+
/// 复制发生时广播给所有在线对端。
/// 小于阈值的内容会紧接着主动推送;大于阈值的只发这条,等对方来取。
class ClipOffer extends $pb.GeneratedMessage {
diff --git a/ui/lib/gen/pasteferry/v1/wire.pbjson.dart b/ui/lib/gen/pasteferry/v1/wire.pbjson.dart
index ce0bf52..d4fc67b 100644
--- a/ui/lib/gen/pasteferry/v1/wire.pbjson.dart
+++ b/ui/lib/gen/pasteferry/v1/wire.pbjson.dart
@@ -67,6 +67,16 @@ const SignalMessage$json = {
{'1': 'timestamp_unix', '3': 1, '4': 1, '5': 3, '10': 'timestampUnix'},
{'1': 'nonce', '3': 2, '4': 1, '5': 12, '10': 'nonce'},
{'1': 'to_device_id', '3': 3, '4': 1, '5': 9, '10': 'toDeviceId'},
+ {
+ '1': 'connection_attempt_id',
+ '3': 4,
+ '4': 1,
+ '5': 9,
+ '10': 'connectionAttemptId'
+ },
+ {'1': 'official_relay', '3': 5, '4': 1, '5': 8, '10': 'officialRelay'},
+ {'1': 'gateway_capable', '3': 6, '4': 1, '5': 8, '10': 'gatewayCapable'},
+ {'1': 'relay_denial_code', '3': 7, '4': 1, '5': 9, '10': 'relayDenialCode'},
{
'1': 'offer',
'3': 10,
@@ -122,11 +132,15 @@ const SignalMessage$json = {
final $typed_data.Uint8List signalMessageDescriptor = $convert.base64Decode(
'Cg1TaWduYWxNZXNzYWdlEiUKDnRpbWVzdGFtcF91bml4GAEgASgDUg10aW1lc3RhbXBVbml4Eh'
'QKBW5vbmNlGAIgASgMUgVub25jZRIgCgx0b19kZXZpY2VfaWQYAyABKAlSCnRvRGV2aWNlSWQS'
- 'LwoFb2ZmZXIYCiABKAsyFy5wYXN0ZWZlcnJ5LnYxLlNkcE9mZmVySABSBW9mZmVyEjIKBmFuc3'
- 'dlchgLIAEoCzIYLnBhc3RlZmVycnkudjEuU2RwQW5zd2VySABSBmFuc3dlchI7CgljYW5kaWRh'
- 'dGUYDCABKAsyGy5wYXN0ZWZlcnJ5LnYxLkljZUNhbmRpZGF0ZUgAUgljYW5kaWRhdGUSKQoEcG'
- 'luZxgNIAEoCzITLnBhc3RlZmVycnkudjEuUGluZ0gAUgRwaW5nEjYKCWxhbl9oZWxsbxgOIAEo'
- 'CzIXLnBhc3RlZmVycnkudjEuTGFuSGVsbG9IAFIIbGFuSGVsbG9CCQoHcGF5bG9hZA==');
+ 'MgoVY29ubmVjdGlvbl9hdHRlbXB0X2lkGAQgASgJUhNjb25uZWN0aW9uQXR0ZW1wdElkEiUKDm'
+ '9mZmljaWFsX3JlbGF5GAUgASgIUg1vZmZpY2lhbFJlbGF5EicKD2dhdGV3YXlfY2FwYWJsZRgG'
+ 'IAEoCFIOZ2F0ZXdheUNhcGFibGUSKgoRcmVsYXlfZGVuaWFsX2NvZGUYByABKAlSD3JlbGF5RG'
+ 'VuaWFsQ29kZRIvCgVvZmZlchgKIAEoCzIXLnBhc3RlZmVycnkudjEuU2RwT2ZmZXJIAFIFb2Zm'
+ 'ZXISMgoGYW5zd2VyGAsgASgLMhgucGFzdGVmZXJyeS52MS5TZHBBbnN3ZXJIAFIGYW5zd2VyEj'
+ 'sKCWNhbmRpZGF0ZRgMIAEoCzIbLnBhc3RlZmVycnkudjEuSWNlQ2FuZGlkYXRlSABSCWNhbmRp'
+ 'ZGF0ZRIpCgRwaW5nGA0gASgLMhMucGFzdGVmZXJyeS52MS5QaW5nSABSBHBpbmcSNgoJbGFuX2'
+ 'hlbGxvGA4gASgLMhcucGFzdGVmZXJyeS52MS5MYW5IZWxsb0gAUghsYW5IZWxsb0IJCgdwYXls'
+ 'b2Fk');
@$core.Deprecated('Use sdpOfferDescriptor instead')
const SdpOffer$json = {
@@ -744,6 +758,15 @@ const PeerMessage$json = {
'9': 0,
'10': 'link'
},
+ {
+ '1': 'display',
+ '3': 7,
+ '4': 1,
+ '5': 11,
+ '6': '.pasteferry.v1.PeerDisplay',
+ '9': 0,
+ '10': 'display'
+ },
],
'8': [
{'1': 'payload'},
@@ -757,7 +780,9 @@ final $typed_data.Uint8List peerMessageDescriptor = $convert.base64Decode(
'Y2gSNAoGcmVqZWN0GAMgASgLMhoucGFzdGVmZXJyeS52MS5GZXRjaFJlamVjdEgAUgZyZWplY3'
'QSNwoGaGVhZGVyGAQgASgLMh0ucGFzdGVmZXJyeS52MS5UcmFuc2ZlckhlYWRlckgAUgZoZWFk'
'ZXISMQoEZG9uZRgFIAEoCzIbLnBhc3RlZmVycnkudjEuVHJhbnNmZXJEb25lSABSBGRvbmUSLQ'
- 'oEbGluaxgGIAEoCzIXLnBhc3RlZmVycnkudjEuTGlua0luZm9IAFIEbGlua0IJCgdwYXlsb2Fk');
+ 'oEbGluaxgGIAEoCzIXLnBhc3RlZmVycnkudjEuTGlua0luZm9IAFIEbGluaxI2CgdkaXNwbGF5'
+ 'GAcgASgLMhoucGFzdGVmZXJyeS52MS5QZWVyRGlzcGxheUgAUgdkaXNwbGF5QgkKB3BheWxvYW'
+ 'Q=');
@$core.Deprecated('Use linkInfoDescriptor instead')
const LinkInfo$json = {
@@ -771,6 +796,20 @@ const LinkInfo$json = {
final $typed_data.Uint8List linkInfoDescriptor =
$convert.base64Decode('CghMaW5rSW5mbxIYCgdyZWxheWVkGAEgASgIUgdyZWxheWVk');
+@$core.Deprecated('Use peerDisplayDescriptor instead')
+const PeerDisplay$json = {
+ '1': 'PeerDisplay',
+ '2': [
+ {'1': 'name', '3': 1, '4': 1, '5': 9, '10': 'name'},
+ {'1': 'platform', '3': 2, '4': 1, '5': 9, '10': 'platform'},
+ ],
+};
+
+/// Descriptor for `PeerDisplay`. Decode as a `google.protobuf.DescriptorProto`.
+final $typed_data.Uint8List peerDisplayDescriptor = $convert.base64Decode(
+ 'CgtQZWVyRGlzcGxheRISCgRuYW1lGAEgASgJUgRuYW1lEhoKCHBsYXRmb3JtGAIgASgJUghwbG'
+ 'F0Zm9ybQ==');
+
@$core.Deprecated('Use clipOfferDescriptor instead')
const ClipOffer$json = {
'1': 'ClipOffer',
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
index 22c4a63..0601936 100644
--- a/ui/lib/l10n/app_en.arb
+++ b/ui/lib/l10n/app_en.arb
@@ -391,7 +391,7 @@
"server": "Server (optional)",
"serverFootnote": "Only needed to sync between different networks, such as home and office. Devices on the same network connect without it. The server only helps devices find each other and can't see what they send.",
"signalingUrl": "Signaling server",
- "signalingUrlDesc": "Press Return to save. Leave it empty to sync on this network only.",
+ "signalingUrlDesc": "Click Save and connect or press Enter. Leave it empty to sync on this network only.",
"signalingUrlPlaceholder": "ws://server-address:8787/signal",
"publicStun": "Probe with public servers",
"publicStunDesc": "On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.",
@@ -518,5 +518,31 @@
}
}
},
- "svcCanDisable": "You can turn background sync off anytime in Settings."
+ "svcCanDisable": "You can turn background sync off anytime in Settings.",
+ "officialService": "Official service",
+ "useOfficialService": "Use official service",
+ "officialPrivacy": "Connects to the official service only when enabled and records essential access statistics. Direct connections are tried first; relay access is requested only if they fail. Content, real device names and raw system identifiers are not uploaded.",
+ "officialEnableTitle": "Enable official Internet service?",
+ "officialSwitchConfirm": "This switches away from your custom server. Its saved address will be retained.",
+ "customServer": "Custom server",
+ "saveAndConnect": "Save and connect",
+ "officialUnused": "Relay not requested; allowance not yet verified",
+ "officialUnavailable": "Usage is unavailable; existing data may be out of date",
+ "officialQuotaTitle": "Daily relay allowance used up",
+ "officialQuotaBody": "Official relay is paused until the daily reset at midnight Beijing time. LAN and direct Internet connections remain available. Failed transfers can be retried later.",
+ "officialPeerQuota": "The peer has no relay allowance left. Direct connections remain available.",
+ "officialPaused": "Official relay is unavailable. Direct connections remain available.",
+ "officialViewUsage": "View usage",
+ "officialAcknowledge": "Got it",
+ "officialToday": "Today's relay usage",
+ "officialUsed": "Used",
+ "officialRemaining": "Remaining",
+ "officialDailyLimit": "Daily allowance",
+ "officialUpload": "Upload",
+ "officialDownload": "Download",
+ "officialReset": "Reset time (Beijing)",
+ "officialUpdated": "Last updated",
+ "officialDeviceID": "Device ID",
+ "officialWarning": "90% of the daily relay allowance has been used. Direct connections do not consume it.",
+ "officialAccounting": "Upload and download combined, including encryption overhead. Only official relay usage is measured; direct content and traffic are not recorded."
}
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
index c551ee4..6aef0bf 100644
--- a/ui/lib/l10n/app_ja.arb
+++ b/ui/lib/l10n/app_ja.arb
@@ -159,7 +159,7 @@
"server": "サーバー(任意)",
"serverFootnote": "家と会社のように、別々のネットワーク間で同期するときだけ必要です。同じネットワーク内のデバイスはサーバーなしで直接つながります。サーバーはデバイス同士を引き合わせるだけで、やり取りする内容は見えません。",
"signalingUrl": "シグナリングサーバー",
- "signalingUrlDesc": "Enter で保存。空欄にするとこのネットワーク内だけで同期します",
+ "signalingUrlDesc": "「保存して接続」をクリックするか Enter を押します。空欄にするとこのネットワーク内だけで同期します",
"signalingUrlPlaceholder": "ws://サーバーアドレス:8787/signal",
"publicStun": "公開サーバーで出口を調べる",
"publicStunDesc": "複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。",
@@ -251,5 +251,31 @@
"svcDevBodyLinux": "開発ビルドのため pasteferryd がありません。ソースフォルダで ./scripts/package-linux.sh を実行して完全版をビルドしてください。",
"svcDevBodyMac": "開発ビルドのためバックグラウンドサービスが含まれていません。ソースフォルダで ./scripts/install-macos.sh を実行してインストールしてください。",
"svcLogPath": "ログ:{path}",
- "svcCanDisable": "バックグラウンド同期は「設定」でいつでもオフにできます。"
+ "svcCanDisable": "バックグラウンド同期は「設定」でいつでもオフにできます。",
+ "officialService": "公式サービス",
+ "useOfficialService": "公式サービスを使う",
+ "officialPrivacy": "有効にした場合のみ公式サービスに接続し、必要最小限の接続情報を記録します。まず直接接続を試み、失敗した場合のみ中継を申請します。内容、実際の端末名、元のシステム識別子は送信しません。",
+ "officialEnableTitle": "公式インターネットサービスを有効にしますか?",
+ "officialSwitchConfirm": "現在のカスタムサーバーから切り替えます。保存済みのアドレスは保持されます。",
+ "customServer": "カスタムサーバー",
+ "saveAndConnect": "保存して接続",
+ "officialUnused": "中継は未申請です。残量は未確認です",
+ "officialUnavailable": "使用量を取得できません。表示データは古い可能性があります",
+ "officialQuotaTitle": "本日の中継上限に達しました",
+ "officialQuotaBody": "公式中継は北京時間の午前0時にリセットされるまで停止します。LANと直接接続は引き続き利用できます。失敗した転送は後で再試行できます。",
+ "officialPeerQuota": "相手の中継残量がありません。直接接続は引き続き利用できます",
+ "officialPaused": "公式中継は現在利用できません。直接接続は引き続き利用できます",
+ "officialViewUsage": "使用量を表示",
+ "officialAcknowledge": "確認しました",
+ "officialToday": "本日の中継使用量",
+ "officialUsed": "使用済み",
+ "officialRemaining": "残量",
+ "officialDailyLimit": "1日の上限",
+ "officialUpload": "アップロード",
+ "officialDownload": "ダウンロード",
+ "officialReset": "リセット時刻(北京時間)",
+ "officialUpdated": "最終更新",
+ "officialDeviceID": "端末 ID",
+ "officialWarning": "本日の中継上限の90%を使用しました。直接接続ではこの残量は消費しません。",
+ "officialAccounting": "暗号化の通信量を含む送受信の合計です。公式中継のみ計測し、直接接続の内容や通信量は記録しません。"
}
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
index d455c85..856b850 100644
--- a/ui/lib/l10n/app_localizations.dart
+++ b/ui/lib/l10n/app_localizations.dart
@@ -1067,7 +1067,7 @@ abstract class AppLocalizations {
/// No description provided for @signalingUrlDesc.
///
/// In en, this message translates to:
- /// **'Press Return to save. Leave it empty to sync on this network only.'**
+ /// **'Click Save and connect or press Enter. Leave it empty to sync on this network only.'**
String get signalingUrlDesc;
/// No description provided for @signalingUrlPlaceholder.
@@ -1621,6 +1621,162 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'You can turn background sync off anytime in Settings.'**
String get svcCanDisable;
+
+ /// No description provided for @officialService.
+ ///
+ /// In en, this message translates to:
+ /// **'Official service'**
+ String get officialService;
+
+ /// No description provided for @useOfficialService.
+ ///
+ /// In en, this message translates to:
+ /// **'Use official service'**
+ String get useOfficialService;
+
+ /// No description provided for @officialPrivacy.
+ ///
+ /// In en, this message translates to:
+ /// **'Connects to the official service only when enabled and records essential access statistics. Direct connections are tried first; relay access is requested only if they fail. Content, real device names and raw system identifiers are not uploaded.'**
+ String get officialPrivacy;
+
+ /// No description provided for @officialEnableTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Enable official Internet service?'**
+ String get officialEnableTitle;
+
+ /// No description provided for @officialSwitchConfirm.
+ ///
+ /// In en, this message translates to:
+ /// **'This switches away from your custom server. Its saved address will be retained.'**
+ String get officialSwitchConfirm;
+
+ /// No description provided for @customServer.
+ ///
+ /// In en, this message translates to:
+ /// **'Custom server'**
+ String get customServer;
+
+ /// No description provided for @saveAndConnect.
+ ///
+ /// In en, this message translates to:
+ /// **'Save and connect'**
+ String get saveAndConnect;
+
+ /// No description provided for @officialUnused.
+ ///
+ /// In en, this message translates to:
+ /// **'Relay not requested; allowance not yet verified'**
+ String get officialUnused;
+
+ /// No description provided for @officialUnavailable.
+ ///
+ /// In en, this message translates to:
+ /// **'Usage is unavailable; existing data may be out of date'**
+ String get officialUnavailable;
+
+ /// No description provided for @officialQuotaTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Daily relay allowance used up'**
+ String get officialQuotaTitle;
+
+ /// No description provided for @officialQuotaBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Official relay is paused until the daily reset at midnight Beijing time. LAN and direct Internet connections remain available. Failed transfers can be retried later.'**
+ String get officialQuotaBody;
+
+ /// No description provided for @officialPeerQuota.
+ ///
+ /// In en, this message translates to:
+ /// **'The peer has no relay allowance left. Direct connections remain available.'**
+ String get officialPeerQuota;
+
+ /// No description provided for @officialPaused.
+ ///
+ /// In en, this message translates to:
+ /// **'Official relay is unavailable. Direct connections remain available.'**
+ String get officialPaused;
+
+ /// No description provided for @officialViewUsage.
+ ///
+ /// In en, this message translates to:
+ /// **'View usage'**
+ String get officialViewUsage;
+
+ /// No description provided for @officialAcknowledge.
+ ///
+ /// In en, this message translates to:
+ /// **'Got it'**
+ String get officialAcknowledge;
+
+ /// No description provided for @officialToday.
+ ///
+ /// In en, this message translates to:
+ /// **'Today\'s relay usage'**
+ String get officialToday;
+
+ /// No description provided for @officialUsed.
+ ///
+ /// In en, this message translates to:
+ /// **'Used'**
+ String get officialUsed;
+
+ /// No description provided for @officialRemaining.
+ ///
+ /// In en, this message translates to:
+ /// **'Remaining'**
+ String get officialRemaining;
+
+ /// No description provided for @officialDailyLimit.
+ ///
+ /// In en, this message translates to:
+ /// **'Daily allowance'**
+ String get officialDailyLimit;
+
+ /// No description provided for @officialUpload.
+ ///
+ /// In en, this message translates to:
+ /// **'Upload'**
+ String get officialUpload;
+
+ /// No description provided for @officialDownload.
+ ///
+ /// In en, this message translates to:
+ /// **'Download'**
+ String get officialDownload;
+
+ /// No description provided for @officialReset.
+ ///
+ /// In en, this message translates to:
+ /// **'Reset time (Beijing)'**
+ String get officialReset;
+
+ /// No description provided for @officialUpdated.
+ ///
+ /// In en, this message translates to:
+ /// **'Last updated'**
+ String get officialUpdated;
+
+ /// No description provided for @officialDeviceID.
+ ///
+ /// In en, this message translates to:
+ /// **'Device ID'**
+ String get officialDeviceID;
+
+ /// No description provided for @officialWarning.
+ ///
+ /// In en, this message translates to:
+ /// **'90% of the daily relay allowance has been used. Direct connections do not consume it.'**
+ String get officialWarning;
+
+ /// No description provided for @officialAccounting.
+ ///
+ /// In en, this message translates to:
+ /// **'Upload and download combined, including encryption overhead. Only official relay usage is measured; direct content and traffic are not recorded.'**
+ String get officialAccounting;
}
class _AppLocalizationsDelegate
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
index 22536a2..b3e4a7b 100644
--- a/ui/lib/l10n/app_localizations_en.dart
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -631,7 +631,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get signalingUrlDesc =>
- 'Press Return to save. Leave it empty to sync on this network only.';
+ 'Click Save and connect or press Enter. Leave it empty to sync on this network only.';
@override
String get signalingUrlPlaceholder => 'ws://server-address:8787/signal';
@@ -942,4 +942,91 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get svcCanDisable =>
'You can turn background sync off anytime in Settings.';
+
+ @override
+ String get officialService => 'Official service';
+
+ @override
+ String get useOfficialService => 'Use official service';
+
+ @override
+ String get officialPrivacy =>
+ 'Connects to the official service only when enabled and records essential access statistics. Direct connections are tried first; relay access is requested only if they fail. Content, real device names and raw system identifiers are not uploaded.';
+
+ @override
+ String get officialEnableTitle => 'Enable official Internet service?';
+
+ @override
+ String get officialSwitchConfirm =>
+ 'This switches away from your custom server. Its saved address will be retained.';
+
+ @override
+ String get customServer => 'Custom server';
+
+ @override
+ String get saveAndConnect => 'Save and connect';
+
+ @override
+ String get officialUnused =>
+ 'Relay not requested; allowance not yet verified';
+
+ @override
+ String get officialUnavailable =>
+ 'Usage is unavailable; existing data may be out of date';
+
+ @override
+ String get officialQuotaTitle => 'Daily relay allowance used up';
+
+ @override
+ String get officialQuotaBody =>
+ 'Official relay is paused until the daily reset at midnight Beijing time. LAN and direct Internet connections remain available. Failed transfers can be retried later.';
+
+ @override
+ String get officialPeerQuota =>
+ 'The peer has no relay allowance left. Direct connections remain available.';
+
+ @override
+ String get officialPaused =>
+ 'Official relay is unavailable. Direct connections remain available.';
+
+ @override
+ String get officialViewUsage => 'View usage';
+
+ @override
+ String get officialAcknowledge => 'Got it';
+
+ @override
+ String get officialToday => 'Today\'s relay usage';
+
+ @override
+ String get officialUsed => 'Used';
+
+ @override
+ String get officialRemaining => 'Remaining';
+
+ @override
+ String get officialDailyLimit => 'Daily allowance';
+
+ @override
+ String get officialUpload => 'Upload';
+
+ @override
+ String get officialDownload => 'Download';
+
+ @override
+ String get officialReset => 'Reset time (Beijing)';
+
+ @override
+ String get officialUpdated => 'Last updated';
+
+ @override
+ String get officialDeviceID => 'Device ID';
+
+ @override
+ String get officialWarning =>
+ '90% of the daily relay allowance has been used. Direct connections do not consume it.';
+
+ @override
+ String get officialAccounting =>
+ 'Upload and download combined, including encryption overhead. Only official relay usage is measured; direct content and traffic are not recorded.';
}
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
index ca3db42..80acdbf 100644
--- a/ui/lib/l10n/app_localizations_ja.dart
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -557,7 +557,8 @@ class AppLocalizationsJa extends AppLocalizations {
String get signalingUrl => 'シグナリングサーバー';
@override
- String get signalingUrlDesc => 'Enter で保存。空欄にするとこのネットワーク内だけで同期します';
+ String get signalingUrlDesc =>
+ '「保存して接続」をクリックするか Enter を押します。空欄にするとこのネットワーク内だけで同期します';
@override
String get signalingUrlPlaceholder => 'ws://サーバーアドレス:8787/signal';
@@ -863,4 +864,85 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get svcCanDisable => 'バックグラウンド同期は「設定」でいつでもオフにできます。';
+
+ @override
+ String get officialService => '公式サービス';
+
+ @override
+ String get useOfficialService => '公式サービスを使う';
+
+ @override
+ String get officialPrivacy =>
+ '有効にした場合のみ公式サービスに接続し、必要最小限の接続情報を記録します。まず直接接続を試み、失敗した場合のみ中継を申請します。内容、実際の端末名、元のシステム識別子は送信しません。';
+
+ @override
+ String get officialEnableTitle => '公式インターネットサービスを有効にしますか?';
+
+ @override
+ String get officialSwitchConfirm => '現在のカスタムサーバーから切り替えます。保存済みのアドレスは保持されます。';
+
+ @override
+ String get customServer => 'カスタムサーバー';
+
+ @override
+ String get saveAndConnect => '保存して接続';
+
+ @override
+ String get officialUnused => '中継は未申請です。残量は未確認です';
+
+ @override
+ String get officialUnavailable => '使用量を取得できません。表示データは古い可能性があります';
+
+ @override
+ String get officialQuotaTitle => '本日の中継上限に達しました';
+
+ @override
+ String get officialQuotaBody =>
+ '公式中継は北京時間の午前0時にリセットされるまで停止します。LANと直接接続は引き続き利用できます。失敗した転送は後で再試行できます。';
+
+ @override
+ String get officialPeerQuota => '相手の中継残量がありません。直接接続は引き続き利用できます';
+
+ @override
+ String get officialPaused => '公式中継は現在利用できません。直接接続は引き続き利用できます';
+
+ @override
+ String get officialViewUsage => '使用量を表示';
+
+ @override
+ String get officialAcknowledge => '確認しました';
+
+ @override
+ String get officialToday => '本日の中継使用量';
+
+ @override
+ String get officialUsed => '使用済み';
+
+ @override
+ String get officialRemaining => '残量';
+
+ @override
+ String get officialDailyLimit => '1日の上限';
+
+ @override
+ String get officialUpload => 'アップロード';
+
+ @override
+ String get officialDownload => 'ダウンロード';
+
+ @override
+ String get officialReset => 'リセット時刻(北京時間)';
+
+ @override
+ String get officialUpdated => '最終更新';
+
+ @override
+ String get officialDeviceID => '端末 ID';
+
+ @override
+ String get officialWarning => '本日の中継上限の90%を使用しました。直接接続ではこの残量は消費しません。';
+
+ @override
+ String get officialAccounting =>
+ '暗号化の通信量を含む送受信の合計です。公式中継のみ計測し、直接接続の内容や通信量は記録しません。';
}
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
index 6c1e6e1..39a0637 100644
--- a/ui/lib/l10n/app_localizations_zh.dart
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -554,7 +554,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get signalingUrl => '信令服务器地址';
@override
- String get signalingUrlDesc => '按回车保存。留空表示只在局域网里同步';
+ String get signalingUrlDesc => '点击“保存并连接”或按回车。留空表示只在局域网里同步';
@override
String get signalingUrlPlaceholder => 'ws://服务器地址:8787/signal';
@@ -854,6 +854,85 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get svcCanDisable => '随时可以在「设置」中停用后台同步。';
+
+ @override
+ String get officialService => '官方服务';
+
+ @override
+ String get useOfficialService => '使用官方服务';
+
+ @override
+ String get officialPrivacy =>
+ '仅开启后连接官方服务并统计必要接入信息。先尝试直连,失败才申请中转;不上传内容、真实设备名或原始系统标识。';
+
+ @override
+ String get officialEnableTitle => '启用官方公网服务?';
+
+ @override
+ String get officialSwitchConfirm => '这会切换当前自定义服务器,已保存的地址仍会保留。';
+
+ @override
+ String get customServer => '自定义服务器';
+
+ @override
+ String get saveAndConnect => '保存并连接';
+
+ @override
+ String get officialUnused => '尚未申请中转,余额待核验';
+
+ @override
+ String get officialUnavailable => '用量暂不可用,已有数据可能过期';
+
+ @override
+ String get officialQuotaTitle => '今日中转额度已用完';
+
+ @override
+ String get officialQuotaBody => '官方中转已暂停,北京时间零点重置。局域网和公网直连仍可使用;传输失败时可稍后重试。';
+
+ @override
+ String get officialPeerQuota => '对端中转额度不足,直连仍可使用';
+
+ @override
+ String get officialPaused => '官方中转暂不可用,直连仍可使用';
+
+ @override
+ String get officialViewUsage => '查看用量';
+
+ @override
+ String get officialAcknowledge => '知道了';
+
+ @override
+ String get officialToday => '今日中转用量';
+
+ @override
+ String get officialUsed => '已使用';
+
+ @override
+ String get officialRemaining => '剩余额度';
+
+ @override
+ String get officialDailyLimit => '每日额度';
+
+ @override
+ String get officialUpload => '上传';
+
+ @override
+ String get officialDownload => '下载';
+
+ @override
+ String get officialReset => '重置时间(北京时间)';
+
+ @override
+ String get officialUpdated => '最后更新';
+
+ @override
+ String get officialDeviceID => '设备 ID';
+
+ @override
+ String get officialWarning => '今日中转额度已使用 90%,直连不消耗此额度。';
+
+ @override
+ String get officialAccounting => '上下行合计,包含加密传输开销;只统计官方中转,不统计直连内容或流量。';
}
/// The translations for Chinese, as used in Hong Kong, using the Han script (`zh_Hant_HK`).
@@ -1406,7 +1485,7 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
String get signalingUrl => '信令伺服器地址';
@override
- String get signalingUrlDesc => '按 Enter 儲存。留空表示只在區域網絡裏同步';
+ String get signalingUrlDesc => '點擊「儲存並連線」或按 Enter。留空表示只在區域網絡裏同步';
@override
String get signalingUrlPlaceholder => 'ws://伺服器地址:8787/signal';
@@ -1706,6 +1785,85 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {
@override
String get svcCanDisable => '隨時可以在「設定」中停用背景同步。';
+
+ @override
+ String get officialService => '官方服務';
+
+ @override
+ String get useOfficialService => '使用官方服務';
+
+ @override
+ String get officialPrivacy =>
+ '只在啟用後連接官方服務並統計必要連線資料。先嘗試直連,失敗才申請中轉;不傳送內容、真實裝置名稱或原始系統識別碼。';
+
+ @override
+ String get officialEnableTitle => '啟用官方公網服務?';
+
+ @override
+ String get officialSwitchConfirm => '這會切換目前的自訂伺服器,已儲存的地址仍會保留。';
+
+ @override
+ String get customServer => '自訂伺服器';
+
+ @override
+ String get saveAndConnect => '儲存並連接';
+
+ @override
+ String get officialUnused => '尚未申請中轉,餘額待確認';
+
+ @override
+ String get officialUnavailable => '用量暫時無法取得,現有資料可能過期';
+
+ @override
+ String get officialQuotaTitle => '今日中轉額度已用完';
+
+ @override
+ String get officialQuotaBody => '官方中轉已暫停,北京時間午夜重設。區域網絡和公網直連仍可使用;傳輸失敗時可稍後重試。';
+
+ @override
+ String get officialPeerQuota => '對方中轉額度不足,直連仍可使用';
+
+ @override
+ String get officialPaused => '官方中轉暫時無法使用,直連仍可使用';
+
+ @override
+ String get officialViewUsage => '查看用量';
+
+ @override
+ String get officialAcknowledge => '知道了';
+
+ @override
+ String get officialToday => '今日中轉用量';
+
+ @override
+ String get officialUsed => '已使用';
+
+ @override
+ String get officialRemaining => '剩餘額度';
+
+ @override
+ String get officialDailyLimit => '每日額度';
+
+ @override
+ String get officialUpload => '上傳';
+
+ @override
+ String get officialDownload => '下載';
+
+ @override
+ String get officialReset => '重設時間(北京時間)';
+
+ @override
+ String get officialUpdated => '上次更新';
+
+ @override
+ String get officialDeviceID => '裝置 ID';
+
+ @override
+ String get officialWarning => '今日中轉額度已使用 90%,直連不消耗此額度。';
+
+ @override
+ String get officialAccounting => '上下行合計,包含加密傳輸開銷;只統計官方中轉,不統計直連內容或流量。';
}
/// The translations for Chinese, as used in Taiwan, using the Han script (`zh_Hant_TW`).
@@ -2258,7 +2416,7 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
String get signalingUrl => '信令伺服器位址';
@override
- String get signalingUrlDesc => '按 Enter 儲存。留空表示只在區域網路裡同步';
+ String get signalingUrlDesc => '點擊「儲存並連線」或按 Enter。留空表示只在區域網路裡同步';
@override
String get signalingUrlPlaceholder => 'ws://伺服器位址:8787/signal';
@@ -2558,4 +2716,83 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {
@override
String get svcCanDisable => '隨時可以在「設定」中停用背景同步。';
+
+ @override
+ String get officialService => '官方服務';
+
+ @override
+ String get useOfficialService => '使用官方服務';
+
+ @override
+ String get officialPrivacy =>
+ '僅開啟後連線官方服務並統計必要連線資訊。先嘗試直連,失敗才申請中繼;不傳送內容、真實裝置名稱或原始系統識別碼。';
+
+ @override
+ String get officialEnableTitle => '啟用官方公網服務?';
+
+ @override
+ String get officialSwitchConfirm => '這會切換目前的自訂伺服器,已儲存的位址仍會保留。';
+
+ @override
+ String get customServer => '自訂伺服器';
+
+ @override
+ String get saveAndConnect => '儲存並連線';
+
+ @override
+ String get officialUnused => '尚未申請中繼,餘額待確認';
+
+ @override
+ String get officialUnavailable => '用量暫時無法取得,現有資料可能過期';
+
+ @override
+ String get officialQuotaTitle => '今日中繼額度已用完';
+
+ @override
+ String get officialQuotaBody => '官方中繼已暫停,北京時間午夜重設。區域網路和公網直連仍可使用;傳輸失敗時可稍後重試。';
+
+ @override
+ String get officialPeerQuota => '對方中繼額度不足,直連仍可使用';
+
+ @override
+ String get officialPaused => '官方中繼暫時無法使用,直連仍可使用';
+
+ @override
+ String get officialViewUsage => '查看用量';
+
+ @override
+ String get officialAcknowledge => '知道了';
+
+ @override
+ String get officialToday => '今日中繼用量';
+
+ @override
+ String get officialUsed => '已使用';
+
+ @override
+ String get officialRemaining => '剩餘額度';
+
+ @override
+ String get officialDailyLimit => '每日額度';
+
+ @override
+ String get officialUpload => '上傳';
+
+ @override
+ String get officialDownload => '下載';
+
+ @override
+ String get officialReset => '重設時間(北京時間)';
+
+ @override
+ String get officialUpdated => '上次更新';
+
+ @override
+ String get officialDeviceID => '裝置 ID';
+
+ @override
+ String get officialWarning => '今日中繼額度已使用 90%,直連不消耗此額度。';
+
+ @override
+ String get officialAccounting => '上下行合計,包含加密傳輸開銷;僅統計官方中繼,不統計直連內容或流量。';
}
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
index 5990ff6..3e628ed 100644
--- a/ui/lib/l10n/app_zh.arb
+++ b/ui/lib/l10n/app_zh.arb
@@ -159,7 +159,7 @@
"server": "服务器(可选)",
"serverFootnote": "只在不同网络之间同步时需要,比如家里和公司;同一网络里的设备不用服务器也能直接连上。服务器只负责让设备找到彼此,看不到传输的内容。",
"signalingUrl": "信令服务器地址",
- "signalingUrlDesc": "按回车保存。留空表示只在局域网里同步",
+ "signalingUrlDesc": "点击“保存并连接”或按回车。留空表示只在局域网里同步",
"signalingUrlPlaceholder": "ws://服务器地址:8787/signal",
"publicStun": "用公共服务器探测网络出口",
"publicStunDesc": "公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP",
@@ -251,5 +251,31 @@
"svcDevBodyLinux": "这是开发构建,旁边没有 pasteferryd。在源码目录运行 ./scripts/package-linux.sh 构建完整的版本。",
"svcDevBodyMac": "这是开发构建,App 里没有内置后台服务。在源码目录运行 ./scripts/install-macos.sh 安装它。",
"svcLogPath": "运行日志:{path}",
- "svcCanDisable": "随时可以在「设置」中停用后台同步。"
+ "svcCanDisable": "随时可以在「设置」中停用后台同步。",
+ "officialService": "官方服务",
+ "useOfficialService": "使用官方服务",
+ "officialPrivacy": "仅开启后连接官方服务并统计必要接入信息。先尝试直连,失败才申请中转;不上传内容、真实设备名或原始系统标识。",
+ "officialEnableTitle": "启用官方公网服务?",
+ "officialSwitchConfirm": "这会切换当前自定义服务器,已保存的地址仍会保留。",
+ "customServer": "自定义服务器",
+ "saveAndConnect": "保存并连接",
+ "officialUnused": "尚未申请中转,余额待核验",
+ "officialUnavailable": "用量暂不可用,已有数据可能过期",
+ "officialQuotaTitle": "今日中转额度已用完",
+ "officialQuotaBody": "官方中转已暂停,北京时间零点重置。局域网和公网直连仍可使用;传输失败时可稍后重试。",
+ "officialPeerQuota": "对端中转额度不足,直连仍可使用",
+ "officialPaused": "官方中转暂不可用,直连仍可使用",
+ "officialViewUsage": "查看用量",
+ "officialAcknowledge": "知道了",
+ "officialToday": "今日中转用量",
+ "officialUsed": "已使用",
+ "officialRemaining": "剩余额度",
+ "officialDailyLimit": "每日额度",
+ "officialUpload": "上传",
+ "officialDownload": "下载",
+ "officialReset": "重置时间(北京时间)",
+ "officialUpdated": "最后更新",
+ "officialDeviceID": "设备 ID",
+ "officialWarning": "今日中转额度已使用 90%,直连不消耗此额度。",
+ "officialAccounting": "上下行合计,包含加密传输开销;只统计官方中转,不统计直连内容或流量。"
}
diff --git a/ui/lib/l10n/app_zh_Hant_HK.arb b/ui/lib/l10n/app_zh_Hant_HK.arb
index 2eb8f82..4f55c96 100644
--- a/ui/lib/l10n/app_zh_Hant_HK.arb
+++ b/ui/lib/l10n/app_zh_Hant_HK.arb
@@ -159,7 +159,7 @@
"server": "伺服器(可選)",
"serverFootnote": "只在不同網絡之間同步時需要,例如家裏和公司;同一網絡裏的裝置不用伺服器也能直接連上。伺服器只負責讓裝置找到彼此,看不到傳輸的內容。",
"signalingUrl": "信令伺服器地址",
- "signalingUrlDesc": "按 Enter 儲存。留空表示只在區域網絡裏同步",
+ "signalingUrlDesc": "點擊「儲存並連線」或按 Enter。留空表示只在區域網絡裏同步",
"signalingUrlPlaceholder": "ws://伺服器地址:8787/signal",
"publicStun": "用公共伺服器探測網絡出口",
"publicStunDesc": "在公司雙線這類多出口網絡裏,能找到更多可以直連的路徑。公共伺服器只會看到你的公網 IP",
@@ -251,5 +251,31 @@
"svcDevBodyLinux": "這是開發版本,旁邊沒有 pasteferryd。在原始碼目錄執行 ./scripts/package-linux.sh 建置完整的版本。",
"svcDevBodyMac": "這是開發版本,App 裏沒有內建背景服務。在原始碼目錄執行 ./scripts/install-macos.sh 安裝它。",
"svcLogPath": "執行日誌:{path}",
- "svcCanDisable": "隨時可以在「設定」中停用背景同步。"
+ "svcCanDisable": "隨時可以在「設定」中停用背景同步。",
+ "officialService": "官方服務",
+ "useOfficialService": "使用官方服務",
+ "officialPrivacy": "只在啟用後連接官方服務並統計必要連線資料。先嘗試直連,失敗才申請中轉;不傳送內容、真實裝置名稱或原始系統識別碼。",
+ "officialEnableTitle": "啟用官方公網服務?",
+ "officialSwitchConfirm": "這會切換目前的自訂伺服器,已儲存的地址仍會保留。",
+ "customServer": "自訂伺服器",
+ "saveAndConnect": "儲存並連接",
+ "officialUnused": "尚未申請中轉,餘額待確認",
+ "officialUnavailable": "用量暫時無法取得,現有資料可能過期",
+ "officialQuotaTitle": "今日中轉額度已用完",
+ "officialQuotaBody": "官方中轉已暫停,北京時間午夜重設。區域網絡和公網直連仍可使用;傳輸失敗時可稍後重試。",
+ "officialPeerQuota": "對方中轉額度不足,直連仍可使用",
+ "officialPaused": "官方中轉暫時無法使用,直連仍可使用",
+ "officialViewUsage": "查看用量",
+ "officialAcknowledge": "知道了",
+ "officialToday": "今日中轉用量",
+ "officialUsed": "已使用",
+ "officialRemaining": "剩餘額度",
+ "officialDailyLimit": "每日額度",
+ "officialUpload": "上傳",
+ "officialDownload": "下載",
+ "officialReset": "重設時間(北京時間)",
+ "officialUpdated": "上次更新",
+ "officialDeviceID": "裝置 ID",
+ "officialWarning": "今日中轉額度已使用 90%,直連不消耗此額度。",
+ "officialAccounting": "上下行合計,包含加密傳輸開銷;只統計官方中轉,不統計直連內容或流量。"
}
diff --git a/ui/lib/l10n/app_zh_Hant_TW.arb b/ui/lib/l10n/app_zh_Hant_TW.arb
index 81c38e2..029105b 100644
--- a/ui/lib/l10n/app_zh_Hant_TW.arb
+++ b/ui/lib/l10n/app_zh_Hant_TW.arb
@@ -159,7 +159,7 @@
"server": "伺服器(選用)",
"serverFootnote": "只在不同網路之間同步時需要,例如家裡和公司;同一個網路裡的裝置不用伺服器也能直接連上。伺服器只負責讓裝置找到彼此,看不到傳輸的內容。",
"signalingUrl": "信令伺服器位址",
- "signalingUrlDesc": "按 Enter 儲存。留空表示只在區域網路裡同步",
+ "signalingUrlDesc": "點擊「儲存並連線」或按 Enter。留空表示只在區域網路裡同步",
"signalingUrlPlaceholder": "ws://伺服器位址:8787/signal",
"publicStun": "用公共伺服器偵測網路出口",
"publicStunDesc": "在公司雙線路這類多出口網路裡,能找到更多可以直連的路徑。公共伺服器只會看到你的公用 IP",
@@ -251,5 +251,31 @@
"svcDevBodyLinux": "這是開發版本,旁邊沒有 pasteferryd。在原始碼資料夾執行 ./scripts/package-linux.sh 建置完整的版本。",
"svcDevBodyMac": "這是開發版本,App 裡沒有內建背景服務。在原始碼資料夾執行 ./scripts/install-macos.sh 安裝它。",
"svcLogPath": "記錄檔:{path}",
- "svcCanDisable": "隨時可以在「設定」中停用背景同步。"
+ "svcCanDisable": "隨時可以在「設定」中停用背景同步。",
+ "officialService": "官方服務",
+ "useOfficialService": "使用官方服務",
+ "officialPrivacy": "僅開啟後連線官方服務並統計必要連線資訊。先嘗試直連,失敗才申請中繼;不傳送內容、真實裝置名稱或原始系統識別碼。",
+ "officialEnableTitle": "啟用官方公網服務?",
+ "officialSwitchConfirm": "這會切換目前的自訂伺服器,已儲存的位址仍會保留。",
+ "customServer": "自訂伺服器",
+ "saveAndConnect": "儲存並連線",
+ "officialUnused": "尚未申請中繼,餘額待確認",
+ "officialUnavailable": "用量暫時無法取得,現有資料可能過期",
+ "officialQuotaTitle": "今日中繼額度已用完",
+ "officialQuotaBody": "官方中繼已暫停,北京時間午夜重設。區域網路和公網直連仍可使用;傳輸失敗時可稍後重試。",
+ "officialPeerQuota": "對方中繼額度不足,直連仍可使用",
+ "officialPaused": "官方中繼暫時無法使用,直連仍可使用",
+ "officialViewUsage": "查看用量",
+ "officialAcknowledge": "知道了",
+ "officialToday": "今日中繼用量",
+ "officialUsed": "已使用",
+ "officialRemaining": "剩餘額度",
+ "officialDailyLimit": "每日額度",
+ "officialUpload": "上傳",
+ "officialDownload": "下載",
+ "officialReset": "重設時間(北京時間)",
+ "officialUpdated": "上次更新",
+ "officialDeviceID": "裝置 ID",
+ "officialWarning": "今日中繼額度已使用 90%,直連不消耗此額度。",
+ "officialAccounting": "上下行合計,包含加密傳輸開銷;僅統計官方中繼,不統計直連內容或流量。"
}
diff --git a/ui/lib/main.dart b/ui/lib/main.dart
index f7ac583..0874765 100644
--- a/ui/lib/main.dart
+++ b/ui/lib/main.dart
@@ -9,6 +9,7 @@ import 'pages/devices_page.dart';
import 'pages/history_page.dart';
import 'pages/service_page.dart';
import 'pages/settings_page.dart';
+import 'pages/official_service_page.dart';
import 'theme.dart';
import 'widgets/common.dart';
import 'widgets/pairing_dialog.dart';
@@ -57,13 +58,18 @@ class _PasteFerryAppState extends State<PasteFerryApp> {
final locale = localeFromSetting(_state.config?.language ?? '');
// zh、zh-Hant-TW、zh-Hant-HK、en、ja:Windows 与 Linux 上按它挑汉字字体
final language =
- (locale ?? resolveLocale(WidgetsBinding.instance.platformDispatcher.locales)).toLanguageTag();
+ (locale ??
+ resolveLocale(
+ WidgetsBinding.instance.platformDispatcher.locales,
+ ))
+ .toLanguageTag();
final (light, dark) = _themes.putIfAbsent(
- language,
- () => (
- buildTheme(Brightness.light, language: language),
- buildTheme(Brightness.dark, language: language),
- ));
+ language,
+ () => (
+ buildTheme(Brightness.light, language: language),
+ buildTheme(Brightness.dark, language: language),
+ ),
+ );
return MaterialApp(
title: 'PasteFerry',
debugShowCheckedModeBanner: false,
@@ -72,7 +78,8 @@ class _PasteFerryAppState extends State<PasteFerryApp> {
locale: locale,
supportedLocales: supportedLocales,
localizationsDelegates: AppLocalizations.localizationsDelegates,
- localeListResolutionCallback: (preferred, _) => resolveLocale(preferred),
+ localeListResolutionCallback: (preferred, _) =>
+ resolveLocale(preferred),
builder: (context, child) {
appL10n = context.l10n;
return child!;
@@ -89,7 +96,7 @@ class _PasteFerryAppState extends State<PasteFerryApp> {
/// provider 之类的依赖——状态只有一个,没必要为此多一个包。
class AppScope extends InheritedNotifier<AppState> {
const AppScope({super.key, required AppState state, required super.child})
- : super(notifier: state);
+ : super(notifier: state);
static AppState of(BuildContext context) {
final scope = context.dependOnInheritedWidgetOfExactType<AppScope>();
@@ -102,7 +109,7 @@ class AppScope extends InheritedNotifier<AppState> {
context.getInheritedWidgetOfExactType<AppScope>()!.notifier!;
}
-enum Section { history, devices, settings }
+enum Section { history, devices, official, settings }
class Shell extends StatefulWidget {
const Shell({super.key, this.initialSection = Section.history});
@@ -113,17 +120,46 @@ class Shell extends StatefulWidget {
State<Shell> createState() => _ShellState();
}
-class _ShellState extends State<Shell> {
+class _ShellState extends State<Shell> with WidgetsBindingObserver {
late Section _section = widget.initialSection;
bool _pairingDialogOpen = false;
+ bool _officialDialogOpen = false;
+ int _seenOfficialNavigation = 0;
+ AppLifecycleState _lifecycle = AppLifecycleState.resumed;
+
+ @override
+ void initState() {
+ super.initState();
+ WidgetsBinding.instance.addObserver(this);
+ _lifecycle =
+ WidgetsBinding.instance.lifecycleState ?? AppLifecycleState.resumed;
+ }
+
+ @override
+ void dispose() {
+ WidgetsBinding.instance.removeObserver(this);
+ super.dispose();
+ }
+
+ @override
+ void didChangeAppLifecycleState(AppLifecycleState state) {
+ if (mounted) setState(() => _lifecycle = state);
+ }
@override
Widget build(BuildContext context) {
final state = AppScope.of(context);
+ if (state.officialNavigationSerial != _seenOfficialNavigation) {
+ _seenOfficialNavigation = state.officialNavigationSerial;
+ if (state.officialEnabled) _section = Section.official;
+ }
+ if (!state.officialEnabled && _section == Section.official) {
+ _section = Section.settings;
+ }
// 对端发起配对时主动弹出确认——指纹核对不能等用户自己去翻页面
final pending = state.pendingPairing;
- if (pending != null && !_pairingDialogOpen) {
+ if (pending != null && !_pairingDialogOpen && !_officialDialogOpen) {
_pairingDialogOpen = true;
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (!mounted) return;
@@ -135,23 +171,88 @@ class _ShellState extends State<Shell> {
if (mounted) setState(() => _pairingDialogOpen = false);
});
}
+ final notice = state.officialNoticeKey;
+ if (notice != null &&
+ pending == null &&
+ !_pairingDialogOpen &&
+ !_officialDialogOpen &&
+ _lifecycle == AppLifecycleState.resumed) {
+ _officialDialogOpen = true;
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
+ if (!mounted) return;
+ if (state.officialNoticeKey != notice ||
+ _lifecycle != AppLifecycleState.resumed) {
+ setState(() => _officialDialogOpen = false);
+ return;
+ }
+ final l = context.l10n;
+ final reason = state.officialUsage?.reason;
+ final view = await showDialog<bool>(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text(
+ reason == 'quota_exhausted'
+ ? l.officialQuotaTitle
+ : l.officialService,
+ ),
+ content: Text(
+ reason == 'quota_exhausted'
+ ? l.officialQuotaBody
+ : reason == 'peer_quota_exhausted'
+ ? l.officialPeerQuota
+ : l.officialPaused,
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(ctx, false),
+ child: Text(l.officialAcknowledge),
+ ),
+ FilledButton(
+ onPressed: () => Navigator.pop(ctx, true),
+ child: Text(l.officialViewUsage),
+ ),
+ ],
+ ),
+ );
+ try {
+ await state.acknowledgeOfficialNotice(notice);
+ } catch (e) {
+ if (context.mounted) {
+ showToast(context, AppState.describeError(e), error: true);
+ }
+ }
+ if (mounted) {
+ setState(() {
+ _officialDialogOpen = false;
+ if (view == true && state.officialEnabled) {
+ _section = Section.official;
+ }
+ });
+ }
+ });
+ }
// 后台服务没装或没在跑时,其他页面都无从谈起,先引导把它启用
final service = state.serviceState;
- final needsService = state.link == LinkState.offline &&
+ final needsService =
+ state.link == LinkState.offline &&
service != null &&
service != ServiceState.running;
return Scaffold(
body: Row(
children: [
- _Sidebar(current: _section, onSelect: (s) => setState(() => _section = s)),
+ _Sidebar(
+ current: _section,
+ onSelect: (s) => setState(() => _section = s),
+ ),
Expanded(
child: needsService
? const ServicePage()
: switch (_section) {
Section.history => const HistoryPage(),
Section.devices => const DevicesPage(),
+ Section.official => const OfficialServicePage(),
Section.settings => const SettingsPage(),
},
),
@@ -186,7 +287,12 @@ class _Sidebar extends StatelessWidget {
// Windows 用系统标题栏,内容从标题栏下面开始
SizedBox(height: Platform.isMacOS ? 52 : Insets.lg),
Padding(
- padding: const EdgeInsets.fromLTRB(Insets.lg, 0, Insets.lg, Insets.lg),
+ padding: const EdgeInsets.fromLTRB(
+ Insets.lg,
+ 0,
+ Insets.lg,
+ Insets.lg,
+ ),
child: Row(
children: [
const AppMark(size: 22),
@@ -208,6 +314,13 @@ class _Sidebar extends StatelessWidget {
selected: current == Section.devices,
onTap: () => onSelect(Section.devices),
),
+ if (state.officialEnabled)
+ _NavItem(
+ icon: Icons.cloud_outlined,
+ label: l.officialService,
+ selected: current == Section.official,
+ onTap: () => onSelect(Section.official),
+ ),
_NavItem(
icon: AppIcons.gear,
label: l.navSettings,
@@ -261,12 +374,18 @@ class _NavItemState extends State<_NavItem> {
height: 30,
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(
- color: selected ? p.selection : (_hovered ? p.hover : Colors.transparent),
+ color: selected
+ ? p.selection
+ : (_hovered ? p.hover : Colors.transparent),
borderRadius: BorderRadius.circular(Radii.sm),
),
child: Row(
children: [
- Icon(widget.icon, size: 16, color: selected ? p.accent : p.textDim),
+ Icon(
+ widget.icon,
+ size: 16,
+ color: selected ? p.accent : p.textDim,
+ ),
const SizedBox(width: 10),
Expanded(
child: Text(
@@ -305,16 +424,28 @@ class _ConnectionFooter extends StatelessWidget {
LinkState.offline => (p.danger, state.error ?? l.linkServiceNotRunning),
LinkState.online when state.lanBlocked => (p.warning, l.linkLanBlocked),
LinkState.online when online > 0 => (p.online, l.linkOnlinePeers(online)),
- LinkState.online when state.serverConfigured && !signaling =>
- (p.warning, state.lanEnabled ? l.linkServerUnreachable : l.notConnected),
- LinkState.online when state.serverConfigured => (p.online, l.linkServerConnected),
+ LinkState.online when state.serverConfigured && !signaling => (
+ p.warning,
+ state.lanEnabled ? l.linkServerUnreachable : l.notConnected,
+ ),
+ LinkState.online when state.serverConfigured => (
+ p.online,
+ l.linkServerConnected,
+ ),
LinkState.online when state.lanEnabled => (p.textFaint, l.linkLanMode),
LinkState.online => (p.warning, l.linkNothingOn),
};
return Container(
- padding: const EdgeInsets.fromLTRB(Insets.lg, Insets.md, Insets.lg, Insets.md),
- decoration: BoxDecoration(border: Border(top: BorderSide(color: p.border))),
+ padding: const EdgeInsets.fromLTRB(
+ Insets.lg,
+ Insets.md,
+ Insets.lg,
+ Insets.md,
+ ),
+ decoration: BoxDecoration(
+ border: Border(top: BorderSide(color: p.border)),
+ ),
child: Row(
children: [
Container(
diff --git a/ui/lib/pages/official_service_page.dart b/ui/lib/pages/official_service_page.dart
new file mode 100644
index 0000000..5efe209
--- /dev/null
+++ b/ui/lib/pages/official_service_page.dart
@@ -0,0 +1,200 @@
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+import '../i18n.dart';
+import '../main.dart';
+import '../theme.dart';
+import '../widgets/common.dart';
+
+class OfficialServicePage extends StatelessWidget {
+ const OfficialServicePage({super.key});
+ String _mb(int bytes) =>
+ bytes > 0 && bytes < 1000000 ? '<1 MB' : '${bytes ~/ 1000000} MB';
+ String _time(int seconds, {bool beijing = false}) {
+ var d = DateTime.fromMillisecondsSinceEpoch(seconds * 1000, isUtc: true);
+ d = beijing ? d.add(const Duration(hours: 8)) : d.toLocal();
+ String pad(int n) => n.toString().padLeft(2, '0');
+ return '${d.year}-${pad(d.month)}-${pad(d.day)} ${pad(d.hour)}:${pad(d.minute)}';
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final state = AppScope.of(context), l = context.l10n, p = context.palette;
+ final u = state.officialUsage;
+ final known = u != null && u.updatedAtUnix.toInt() > 0;
+ final fresh =
+ known &&
+ u.available &&
+ DateTime.now().millisecondsSinceEpoch ~/ 1000 -
+ u.updatedAtUnix.toInt() <
+ 60;
+ final used = known ? u.uploadBytes.toInt() + u.downloadBytes.toInt() : 0;
+ final limit = known ? u.limitBytes.toInt() : 0;
+ Widget row(String title, String value) => Padding(
+ padding: const EdgeInsets.symmetric(vertical: 10),
+ child: Row(
+ children: [
+ Expanded(
+ child: Text(
+ title,
+ style: context.text.bodyMedium?.copyWith(color: p.textDim),
+ ),
+ ),
+ SelectableText(value, style: context.text.bodyMedium),
+ ],
+ ),
+ );
+ final reason = u?.reason ?? '';
+ final status = switch (reason) {
+ 'quota_exhausted' => l.officialQuotaTitle,
+ 'peer_quota_exhausted' => l.officialPeerQuota,
+ 'global_exhausted' ||
+ 'global_paused' ||
+ 'relay_blocked' ||
+ 'device_banned' => l.officialPaused,
+ _ =>
+ !known
+ ? l.officialUnused
+ : !fresh
+ ? l.officialUnavailable
+ : state.status?.signalingConnected == true
+ ? l.connected
+ : l.notConnected,
+ };
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ PageHeader(title: l.officialService),
+ Expanded(
+ child: ListView(
+ padding: const EdgeInsets.fromLTRB(
+ Insets.xl,
+ 0,
+ Insets.xl,
+ Insets.xxl,
+ ),
+ children: [
+ GroupSection(
+ title: l.connectionStatus,
+ child: GroupBox(
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(Insets.lg),
+ child: Text(
+ status,
+ style: context.text.bodyMedium?.copyWith(
+ color: fresh ? p.text : p.warning,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ GroupSection(
+ title: l.officialToday,
+ footnote: l.officialAccounting,
+ child: GroupBox(
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(Insets.lg),
+ child: Column(
+ children: [
+ if (known) ...[
+ row(l.officialUsed, _mb(used)),
+ LinearProgressIndicator(
+ value: limit > 0
+ ? (used / limit).clamp(0.0, 1.0)
+ : 0,
+ color: used >= limit * .9 ? p.warning : p.accent,
+ backgroundColor: p.fill,
+ ),
+ const SizedBox(height: 12),
+ row(
+ l.officialRemaining,
+ _mb(u.remainingBytes.toInt()),
+ ),
+ row(l.officialDailyLimit, _mb(limit)),
+ row(l.officialUpload, _mb(u.uploadBytes.toInt())),
+ row(
+ l.officialDownload,
+ _mb(u.downloadBytes.toInt()),
+ ),
+ row(
+ l.officialReset,
+ _time(u.resetAtUnix.toInt(), beijing: true),
+ ),
+ row(
+ l.officialUpdated,
+ _time(u.updatedAtUnix.toInt()),
+ ),
+ if (limit > 0 && used >= limit * .9)
+ Padding(
+ padding: const EdgeInsets.only(top: 12),
+ child: Text(
+ l.officialWarning,
+ style: context.text.bodySmall?.copyWith(
+ color: p.warning,
+ ),
+ ),
+ ),
+ ] else
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 24),
+ child: Text(
+ l.officialUnused,
+ style: context.text.bodyMedium,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ GroupSection(
+ title: l.officialDeviceID,
+ child: GroupBox(
+ children: [
+ Padding(
+ padding: const EdgeInsets.all(Insets.lg),
+ child: Row(
+ children: [
+ Expanded(
+ child: SelectableText(
+ state.status?.deviceId ?? state.self?.id ?? '',
+ style: context.text.bodyMedium?.copyWith(
+ fontFamily: monoFamily,
+ ),
+ ),
+ ),
+ IconButton(
+ tooltip: MaterialLocalizations.of(
+ context,
+ ).copyButtonLabel,
+ onPressed: () => Clipboard.setData(
+ ClipboardData(
+ text:
+ state.status?.deviceId ??
+ state.self?.id ??
+ '',
+ ),
+ ),
+ icon: const Icon(Icons.copy_outlined, size: 18),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ Text(
+ l.officialPrivacy,
+ style: context.text.bodySmall?.copyWith(color: p.textDim),
+ ),
+ ],
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/ui/lib/pages/settings_page.dart b/ui/lib/pages/settings_page.dart
index 8989342..55f40cd 100644
--- a/ui/lib/pages/settings_page.dart
+++ b/ui/lib/pages/settings_page.dart
@@ -1,4 +1,3 @@
-
import 'dart:io';
import 'package:fixnum/fixnum.dart';
@@ -25,6 +24,7 @@ class _SettingsPageState extends State<SettingsPage> {
final _serverController = TextEditingController();
final _nameController = TextEditingController();
bool _serverDirty = false;
+ bool _serverSaving = false;
bool _nameDirty = false;
String? _lastLoadedServer;
String? _lastLoadedName;
@@ -39,9 +39,12 @@ class _SettingsPageState extends State<SettingsPage> {
/// 用户正在编辑时不要用服务端下发的值覆盖输入框,
/// 否则打字打到一半会被"吃掉"。
void _syncControllers(Config cfg) {
- if (!_serverDirty && cfg.signalingUrl != _lastLoadedServer) {
- _serverController.text = cfg.signalingUrl;
- _lastLoadedServer = cfg.signalingUrl;
+ final custom = cfg.customSignalingUrl.isNotEmpty
+ ? cfg.customSignalingUrl
+ : cfg.signalingUrl;
+ if (!_serverDirty && custom != _lastLoadedServer) {
+ _serverController.text = custom;
+ _lastLoadedServer = custom;
}
if (!_nameDirty && cfg.deviceName != _lastLoadedName) {
_nameController.text = cfg.deviceName;
@@ -63,7 +66,10 @@ class _SettingsPageState extends State<SettingsPage> {
final l = context.l10n;
final connected = state.status?.signalingConnected == true;
// 服务器是可选的:没填地址不是故障,用中性色
- final (Color statusColor, String statusLabel, String statusDesc) = switch ((state.serverConfigured, connected)) {
+ final (Color statusColor, String statusLabel, String statusDesc) = switch ((
+ state.serverConfigured,
+ connected,
+ )) {
(false, _) => (p.textFaint, l.notSet, l.notSetDesc),
(true, true) => (p.online, l.connected, l.connectedDesc),
(true, false) => (p.danger, l.notConnected, l.disconnectedDesc),
@@ -75,245 +81,301 @@ class _SettingsPageState extends State<SettingsPage> {
PageHeader(title: l.navSettings),
Expanded(
child: ListView(
- padding: const EdgeInsets.fromLTRB(Insets.xl, 0, Insets.xl, Insets.xxl),
+ padding: const EdgeInsets.fromLTRB(
+ Insets.xl,
+ 0,
+ Insets.xl,
+ Insets.xxl,
+ ),
children: [
GroupSection(
title: l.server,
footnote: l.serverFootnote,
- child: GroupBox(children: [
- SettingRow(
- title: l.signalingUrl,
- description: l.signalingUrlDesc,
- child: SizedBox(
- width: 290,
- child: TextField(
- controller: _serverController,
- style: context.text.bodyMedium?.copyWith(fontFamily: monoFamily, fontSize: 12),
- decoration: InputDecoration(
- hintText: l.signalingUrlPlaceholder,
- suffixIcon: _serverDirty
- ? IconButton(
- tooltip: l.save,
- icon: Icon(AppIcons.checkmark, size: 14, color: p.accent),
- onPressed: () => _saveServer(state, cfg),
- )
- : null,
+ child: GroupBox(
+ children: [
+ SettingRow(
+ title: l.useOfficialService,
+ description: l.officialPrivacy,
+ child: SmallSwitch(
+ value: state.officialEnabled,
+ onChanged: _serverSaving
+ ? null
+ : (v) => _setOfficial(state, cfg, v),
+ ),
+ ),
+ SettingRow(
+ title: l.customServer,
+ description: l.signalingUrlDesc,
+ child: SizedBox(
+ width: 290,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ TextField(
+ controller: _serverController,
+ style: context.text.bodyMedium?.copyWith(
+ fontFamily: monoFamily,
+ fontSize: 12,
+ ),
+ decoration: InputDecoration(
+ hintText: l.signalingUrlPlaceholder,
+ ),
+ onChanged: (_) =>
+ setState(() => _serverDirty = true),
+ onSubmitted: (_) => _saveServer(state, cfg),
+ ),
+ const SizedBox(height: 8),
+ FilledButton(
+ onPressed: _serverSaving
+ ? null
+ : () => _saveServer(state, cfg),
+ child: Text(l.saveAndConnect),
+ ),
+ ],
),
- onChanged: (_) => setState(() => _serverDirty = true),
- onSubmitted: (_) => _saveServer(state, cfg),
),
),
- ),
- SettingRow(
- title: l.publicStun,
- description: l.publicStunDesc,
- child: SmallSwitch(
- value: !cfg.onlyOwnStun,
- onChanged: (v) => _update(state, cfg..onlyOwnStun = !v),
+ SettingRow(
+ title: l.publicStun,
+ description: l.publicStunDesc,
+ child: SmallSwitch(
+ value: !cfg.onlyOwnStun,
+ onChanged: (v) => _update(state, cfg..onlyOwnStun = !v),
+ ),
),
- ),
- SettingRow(
- title: l.connectionStatus,
- description: statusDesc,
- child: StatusDot(color: statusColor, label: statusLabel),
- ),
- ]),
+ SettingRow(
+ title: l.connectionStatus,
+ description: statusDesc,
+ child: StatusDot(color: statusColor, label: statusLabel),
+ ),
+ ],
+ ),
),
GroupSection(
title: l.localNetwork,
footnote: l.lanFootnote,
- child: GroupBox(children: [
- SettingRow(
- title: l.lanDiscovery,
- description: l.lanDiscoveryDesc,
- child: SmallSwitch(
- value: !cfg.lanDisabled,
- onChanged: (v) => _update(state, cfg..lanDisabled = !v),
- ),
- ),
- if (Platform.isMacOS)
+ child: GroupBox(
+ children: [
SettingRow(
- title: l.macLocalNetwork,
- description: l.macLocalNetworkDesc,
- child: OutlinedButton(
- onPressed: () => _allowLocalNetwork(state, null),
- child: Text(l.openSystemSettings),
+ title: l.lanDiscovery,
+ description: l.lanDiscoveryDesc,
+ child: SmallSwitch(
+ value: !cfg.lanDisabled,
+ onChanged: (v) => _update(state, cfg..lanDisabled = !v),
),
),
- if (Platform.isWindows)
- SettingRow(
- title: l.allowLan,
- description: l.allowLanDesc,
- child: OutlinedButton(
- onPressed: () => _allowLocalNetwork(state, l.allowLanDone),
- child: Text(l.allow),
+ if (Platform.isMacOS)
+ SettingRow(
+ title: l.macLocalNetwork,
+ description: l.macLocalNetworkDesc,
+ child: OutlinedButton(
+ onPressed: () => _allowLocalNetwork(state, null),
+ child: Text(l.openSystemSettings),
+ ),
),
- ),
- ]),
+ if (Platform.isWindows)
+ SettingRow(
+ title: l.allowLan,
+ description: l.allowLanDesc,
+ child: OutlinedButton(
+ onPressed: () =>
+ _allowLocalNetwork(state, l.allowLanDone),
+ child: Text(l.allow),
+ ),
+ ),
+ ],
+ ),
),
GroupSection(
title: Wording.thisDevice,
- child: GroupBox(children: [
- SettingRow(
- title: l.deviceName,
- description: l.deviceNameDesc,
- child: SizedBox(
- width: 220,
- child: TextField(
- controller: _nameController,
- decoration: InputDecoration(
- suffixIcon: _nameDirty
- ? IconButton(
- tooltip: l.save,
- icon: Icon(AppIcons.checkmark, size: 14, color: p.accent),
- onPressed: () => _saveName(state, cfg),
- )
- : null,
+ child: GroupBox(
+ children: [
+ SettingRow(
+ title: l.deviceName,
+ description: l.deviceNameDesc,
+ child: SizedBox(
+ width: 220,
+ child: TextField(
+ controller: _nameController,
+ decoration: InputDecoration(
+ suffixIcon: _nameDirty
+ ? IconButton(
+ tooltip: l.save,
+ icon: Icon(
+ AppIcons.checkmark,
+ size: 14,
+ color: p.accent,
+ ),
+ onPressed: () => _saveName(state, cfg),
+ )
+ : null,
+ ),
+ onChanged: (_) => setState(() => _nameDirty = true),
+ onSubmitted: (_) => _saveName(state, cfg),
),
- onChanged: (_) => setState(() => _nameDirty = true),
- onSubmitted: (_) => _saveName(state, cfg),
),
),
- ),
- SettingRow(
- title: l.language,
- child: _Dropdown<String>(
- value: cfg.language,
- // 语言名用各自的写法,选错了语言的人也认得出自己的
- items: [
- MapEntry('', l.languageSystem),
- const MapEntry('zh-Hans', '简体中文'),
- const MapEntry('zh-Hant-TW', '繁體中文(台灣)'),
- const MapEntry('zh-Hant-HK', '繁體中文(香港)'),
- const MapEntry('en', 'English'),
- const MapEntry('ja', '日本語'),
- ],
- onChanged: (v) => _update(state, cfg..language = v),
+ SettingRow(
+ title: l.language,
+ child: _Dropdown<String>(
+ value: cfg.language,
+ // 语言名用各自的写法,选错了语言的人也认得出自己的
+ items: [
+ MapEntry('', l.languageSystem),
+ const MapEntry('zh-Hans', '简体中文'),
+ const MapEntry('zh-Hant-TW', '繁體中文(台灣)'),
+ const MapEntry('zh-Hant-HK', '繁體中文(香港)'),
+ const MapEntry('en', 'English'),
+ const MapEntry('ja', '日本語'),
+ ],
+ onChanged: (v) => _update(state, cfg..language = v),
+ ),
),
- ),
- ]),
+ ],
+ ),
),
GroupSection(
title: l.sync,
footnote: l.syncFootnote,
- child: GroupBox(children: [
- SettingRow(
- title: l.autoSyncLimit,
- description: l.autoSyncLimitDesc,
- child: _ThresholdSelector(
- value: cfg.autoSyncThresholdBytes.toInt(),
- onChanged: (v) => _update(state, cfg..autoSyncThresholdBytes = Int64(v)),
+ child: GroupBox(
+ children: [
+ SettingRow(
+ title: l.autoSyncLimit,
+ description: l.autoSyncLimitDesc,
+ child: _ThresholdSelector(
+ value: cfg.autoSyncThresholdBytes.toInt(),
+ onChanged: (v) => _update(
+ state,
+ cfg..autoSyncThresholdBytes = Int64(v),
+ ),
+ ),
),
- ),
- SettingRow(
- title: l.autoApply,
- description: l.autoApplyDesc,
- child: SmallSwitch(
- value: cfg.autoApplyToClipboard,
- onChanged: (v) => _update(state, cfg..autoApplyToClipboard = v),
+ SettingRow(
+ title: l.autoApply,
+ description: l.autoApplyDesc,
+ child: SmallSwitch(
+ value: cfg.autoApplyToClipboard,
+ onChanged: (v) =>
+ _update(state, cfg..autoApplyToClipboard = v),
+ ),
),
- ),
- ]),
+ ],
+ ),
),
GroupSection(
title: l.whatToSync,
- child: GroupBox(children: [
- _ToggleRow(
- title: l.syncFiles,
- value: cfg.syncFile,
- onChanged: (v) => _update(state, cfg..syncFile = v),
- ),
- _ToggleRow(
- title: l.syncText,
- value: cfg.syncText,
- onChanged: (v) => _update(state, cfg..syncText = v),
- ),
- _ToggleRow(
- title: l.syncRich,
- value: cfg.syncHtml,
- onChanged: (v) => _update(state, cfg..syncHtml = v),
- ),
- _ToggleRow(
- title: l.syncImages,
- value: cfg.syncImage,
- onChanged: (v) => _update(state, cfg..syncImage = v),
- ),
- ]),
+ child: GroupBox(
+ children: [
+ _ToggleRow(
+ title: l.syncFiles,
+ value: cfg.syncFile,
+ onChanged: (v) => _update(state, cfg..syncFile = v),
+ ),
+ _ToggleRow(
+ title: l.syncText,
+ value: cfg.syncText,
+ onChanged: (v) => _update(state, cfg..syncText = v),
+ ),
+ _ToggleRow(
+ title: l.syncRich,
+ value: cfg.syncHtml,
+ onChanged: (v) => _update(state, cfg..syncHtml = v),
+ ),
+ _ToggleRow(
+ title: l.syncImages,
+ value: cfg.syncImage,
+ onChanged: (v) => _update(state, cfg..syncImage = v),
+ ),
+ ],
+ ),
),
GroupSection(
title: l.storage,
footnote: l.storageFootnote,
- child: GroupBox(children: [
- SettingRow(
- title: l.keepHistory,
- child: _DurationSelector(
- seconds: cfg.historyTtlSeconds.toInt(),
- onChanged: (v) => _update(state, cfg..historyTtlSeconds = Int64(v)),
+ child: GroupBox(
+ children: [
+ SettingRow(
+ title: l.keepHistory,
+ child: _DurationSelector(
+ seconds: cfg.historyTtlSeconds.toInt(),
+ onChanged: (v) =>
+ _update(state, cfg..historyTtlSeconds = Int64(v)),
+ ),
),
- ),
- SettingRow(
- title: l.keepCache,
- description: l.keepCacheDesc,
- child: _DurationSelector(
- seconds: cfg.cacheTtlSeconds.toInt(),
- onChanged: (v) => _update(state, cfg..cacheTtlSeconds = Int64(v)),
+ SettingRow(
+ title: l.keepCache,
+ description: l.keepCacheDesc,
+ child: _DurationSelector(
+ seconds: cfg.cacheTtlSeconds.toInt(),
+ onChanged: (v) =>
+ _update(state, cfg..cacheTtlSeconds = Int64(v)),
+ ),
),
- ),
- SettingRow(
- title: l.cacheUsage,
- child: Text(
- humanBytes(state.status?.cacheBytesUsed.toInt() ?? 0),
- style: context.text.bodyMedium?.copyWith(color: p.textDim),
+ SettingRow(
+ title: l.cacheUsage,
+ child: Text(
+ humanBytes(state.status?.cacheBytesUsed.toInt() ?? 0),
+ style: context.text.bodyMedium?.copyWith(
+ color: p.textDim,
+ ),
+ ),
),
- ),
- ]),
+ ],
+ ),
),
if (state.service.available)
GroupSection(
title: l.backgroundSync,
footnote: l.backgroundFootnote,
- child: GroupBox(children: [
+ child: GroupBox(
+ children: [
+ SettingRow(
+ title: l.backgroundService,
+ description: l.backgroundServiceDesc,
+ child: Row(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ OutlinedButton(
+ onPressed: () => _serviceAction(
+ state.restartService,
+ l.restarted,
+ ),
+ child: Text(l.restart),
+ ),
+ const SizedBox(width: Insets.sm),
+ OutlinedButton(
+ onPressed: () => _confirmDisable(state),
+ child: Text(l.disableEllipsis),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ GroupSection(
+ title: l.about,
+ child: GroupBox(
+ children: [
SettingRow(
- title: l.backgroundService,
- description: l.backgroundServiceDesc,
+ title: '${l.appName} ${state.status?.version ?? ''}',
+ description: l.aboutDesc,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
- OutlinedButton(
- onPressed: () => _serviceAction(state.restartService, l.restarted),
- child: Text(l.restart),
+ TextButton(
+ onPressed: () => _open('https://pasteferry.cc/'),
+ child: Text(l.homepage),
),
- const SizedBox(width: Insets.sm),
- OutlinedButton(
- onPressed: () => _confirmDisable(state),
- child: Text(l.disableEllipsis),
+ TextButton(
+ onPressed: () => showFeedbackDialog(context),
+ child: Text(l.feedback),
),
],
),
),
- ]),
+ ],
),
- GroupSection(
- title: l.about,
- child: GroupBox(children: [
- SettingRow(
- title: '${l.appName} ${state.status?.version ?? ''}',
- description: l.aboutDesc,
- child: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- TextButton(
- onPressed: () => _open('https://pasteferry.cc/'),
- child: Text(l.homepage),
- ),
- TextButton(
- onPressed: () => showFeedbackDialog(context),
- child: Text(l.feedback),
- ),
- ],
- ),
- ),
- ]),
),
],
),
@@ -324,7 +386,10 @@ class _SettingsPageState extends State<SettingsPage> {
static void _open(String url) => openUrl(url);
- Future<void> _serviceAction(Future<void> Function() action, String message) async {
+ Future<void> _serviceAction(
+ Future<void> Function() action,
+ String message,
+ ) async {
try {
await action();
if (mounted) showToast(context, message);
@@ -341,8 +406,14 @@ class _SettingsPageState extends State<SettingsPage> {
title: Text(l.disableTitle),
content: Text(l.disableBody(Wording.thisDeviceInText)),
actions: [
- OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.cancel)),
- FilledButton(onPressed: () => Navigator.pop(ctx, true), child: Text(l.disable)),
+ OutlinedButton(
+ onPressed: () => Navigator.pop(ctx, false),
+ child: Text(l.cancel),
+ ),
+ FilledButton(
+ onPressed: () => Navigator.pop(ctx, true),
+ child: Text(l.disable),
+ ),
],
),
);
@@ -350,16 +421,74 @@ class _SettingsPageState extends State<SettingsPage> {
}
Future<void> _saveServer(AppState state, Config cfg) async {
+ if (_serverSaving) return;
final l = context.l10n;
final url = _serverController.text.trim();
// 留空就是不用服务器,只在局域网里同步
- if (url.isNotEmpty && !url.startsWith('ws://') && !url.startsWith('wss://')) {
+ if (url.isNotEmpty &&
+ !url.startsWith('ws://') &&
+ !url.startsWith('wss://')) {
showToast(context, l.urlMustBeWs, error: true);
return;
}
- setState(() => _serverDirty = false);
- _lastLoadedServer = url;
- await _update(state, cfg..signalingUrl = url, message: url.isEmpty ? l.serverCleared : l.serverUpdated);
+ final next = cfg.deepCopy()
+ ..signalingUrl = url
+ ..customSignalingUrl = url
+ ..serviceMode = url.isEmpty
+ ? ServiceMode.SERVICE_MODE_LAN
+ : ServiceMode.SERVICE_MODE_CUSTOM;
+ setState(() => _serverSaving = true);
+ try {
+ await state.updateConfig(next);
+ if (!mounted) return;
+ setState(() {
+ _serverDirty = false;
+ _lastLoadedServer = url;
+ });
+ showToast(context, url.isEmpty ? l.serverCleared : l.serverUpdated);
+ } catch (e) {
+ if (mounted) showToast(context, AppState.describeError(e), error: true);
+ } finally {
+ if (mounted) setState(() => _serverSaving = false);
+ }
+ }
+
+ Future<void> _setOfficial(AppState state, Config cfg, bool value) async {
+ if (value) {
+ final ok = await showDialog<bool>(
+ context: context,
+ builder: (ctx) => AlertDialog(
+ title: Text(context.l10n.officialEnableTitle),
+ content: Text(
+ '${context.l10n.officialPrivacy}${cfg.serviceMode == ServiceMode.SERVICE_MODE_CUSTOM ? '\n\n${context.l10n.officialSwitchConfirm}' : ''}',
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(ctx, false),
+ child: Text(context.l10n.cancel),
+ ),
+ FilledButton(
+ onPressed: () => Navigator.pop(ctx, true),
+ child: Text(context.l10n.useOfficialService),
+ ),
+ ],
+ ),
+ );
+ if (ok != true || !mounted) return;
+ }
+ setState(() => _serverSaving = true);
+ try {
+ final next = cfg.deepCopy()
+ ..serviceMode = (value
+ ? ServiceMode.SERVICE_MODE_OFFICIAL
+ : ServiceMode.SERVICE_MODE_LAN)
+ ..signalingUrl = '';
+ await state.updateConfig(next);
+ } catch (e) {
+ if (mounted) showToast(context, AppState.describeError(e), error: true);
+ } finally {
+ if (mounted) setState(() => _serverSaving = false);
+ }
}
/// macOS 打开「本地网络」设置面板;Windows 弹出 UAC,在防火墙里放行后台服务。
@@ -377,7 +506,11 @@ class _SettingsPageState extends State<SettingsPage> {
if (name.isEmpty) return;
setState(() => _nameDirty = false);
_lastLoadedName = name;
- await _update(state, cfg..deviceName = name, message: context.l10n.deviceNameUpdated);
+ await _update(
+ state,
+ cfg..deviceName = name,
+ message: context.l10n.deviceNameUpdated,
+ );
}
Future<void> _update(AppState state, Config next, {String? message}) async {
@@ -475,14 +608,18 @@ class _Dropdown<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
final p = context.palette;
- final current = items.firstWhere((e) => e.key == value, orElse: () => items.first);
+ final current = items.firstWhere(
+ (e) => e.key == value,
+ orElse: () => items.first,
+ );
return PopupMenuButton<T>(
tooltip: '',
initialValue: value,
position: PopupMenuPosition.under,
onSelected: onChanged,
itemBuilder: (_) => [
- for (final e in items) PopupMenuItem(value: e.key, height: 32, child: Text(e.value)),
+ for (final e in items)
+ PopupMenuItem(value: e.key, height: 32, child: Text(e.value)),
],
child: Container(
padding: const EdgeInsets.fromLTRB(10, 5, 8, 5),
diff --git a/ui/test/official_service_test.dart b/ui/test/official_service_test.dart
new file mode 100644
index 0000000..daf3112
--- /dev/null
+++ b/ui/test/official_service_test.dart
@@ -0,0 +1,171 @@
+import 'package:fixnum/fixnum.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:pasteferry_ui/app_state.dart';
+import 'package:pasteferry_ui/gen/pasteferry/v1/daemon.pb.dart';
+import 'package:pasteferry_ui/main.dart';
+import 'package:pasteferry_ui/pages/official_service_page.dart';
+import 'package:pasteferry_ui/pages/settings_page.dart';
+
+class OfficialTestState extends AppState {
+ bool failSave = false;
+ int saves = 0;
+ OfficialTestState({
+ bool official = false,
+ String language = 'zh-Hans',
+ String ack = '',
+ }) {
+ debugSeed(
+ status: Status(deviceId: 'abcdefghijklmnopqrstuvwxyz', lanEnabled: true),
+ config: Config(
+ serviceMode: official
+ ? ServiceMode.SERVICE_MODE_OFFICIAL
+ : ServiceMode.SERVICE_MODE_LAN,
+ language: language,
+ officialNoticeAck: ack,
+ ),
+ self: Device(id: 'abcdefghijklmnopqrstuvwxyz'),
+ );
+ }
+ @override
+ Future<void> updateConfig(Config next) async {
+ saves++;
+ if (failSave) throw StateError('save failed');
+ debugSeed(status: status!, config: next, self: self!);
+ }
+
+ @override
+ Future<void> acknowledgeOfficialNotice(String key) async =>
+ updateConfig(config!.deepCopy()..officialNoticeAck = key);
+ void usage(OfficialUsage u) =>
+ debugEvent(Event(statusChanged: status!.deepCopy()..officialUsage = u));
+}
+
+void main() {
+ testWidgets(
+ 'official navigation is opt-in and does not replace startup history',
+ (tester) async {
+ final state = OfficialTestState();
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ expect(find.text('官方服务'), findsNothing);
+ state.debugSeed(
+ status: state.status!,
+ config: state.config!.deepCopy()
+ ..serviceMode = ServiceMode.SERVICE_MODE_OFFICIAL,
+ self: state.self!,
+ );
+ await tester.pumpAndSettle();
+ expect(find.text('还没有记录'), findsOneWidget);
+ await tester.tap(find.text('官方服务').first);
+ await tester.pumpAndSettle();
+ expect(find.byType(OfficialServicePage), findsOneWidget);
+ expect(find.text('尚未申请中转,余额待核验'), findsWidgets);
+ expect(find.text('0 MB'), findsNothing);
+ state.debugSeed(
+ status: state.status!,
+ config: state.config!.deepCopy()
+ ..serviceMode = ServiceMode.SERVICE_MODE_LAN,
+ self: state.self!,
+ );
+ await tester.pumpAndSettle();
+ expect(find.byType(OfficialServicePage), findsNothing);
+ expect(find.byType(SettingsPage), findsOneWidget);
+ },
+ );
+ testWidgets(
+ 'custom address is saved explicitly and a failure preserves the draft',
+ (tester) async {
+ final state = OfficialTestState()..failSave = true;
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ await tester.tap(find.text('设置').first);
+ await tester.pumpAndSettle();
+ final input = find.byType(TextField).first;
+ await tester.enterText(input, 'wss://my.example/signal');
+ expect(state.saves, 0);
+ await tester.tap(find.text('保存并连接'));
+ await tester.pumpAndSettle();
+ expect(state.config!.signalingUrl, isEmpty);
+ expect(
+ tester.widget<TextField>(input).controller!.text,
+ 'wss://my.example/signal',
+ );
+ state.failSave = false;
+ await tester.tap(find.text('保存并连接'));
+ await tester.pumpAndSettle();
+ expect(state.config!.customSignalingUrl, 'wss://my.example/signal');
+ expect(state.config!.serviceMode, ServiceMode.SERVICE_MODE_CUSTOM);
+ },
+ );
+ testWidgets(
+ 'quota notice waits for foreground and acknowledgement survives restart',
+ (tester) async {
+ final state = OfficialTestState(official: true);
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
+ final u = OfficialUsage(
+ available: true,
+ day: '2026-10-16',
+ quotaGroup: 'bucket',
+ reason: 'quota_exhausted',
+ limitBytes: Int64(100000000),
+ );
+ state.usage(u);
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsNothing);
+ tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
+ await tester.pumpAndSettle();
+ expect(find.text('今日中转额度已用完'), findsOneWidget);
+ await tester.tap(find.text('知道了'));
+ await tester.pumpAndSettle();
+ expect(
+ state.config!.officialNoticeAck,
+ contains('bucket:2026-10-16:quota_exhausted'),
+ );
+ state.usage(u);
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsNothing);
+ final restarted = OfficialTestState(
+ official: true,
+ ack: state.config!.officialNoticeAck,
+ )..usage(u);
+ await tester.pumpWidget(
+ PasteFerryApp(key: const ValueKey('restart'), state: restarted),
+ );
+ await tester.pumpAndSettle();
+ expect(find.byType(AlertDialog), findsNothing);
+ },
+ );
+ for (final language in ['en', 'zh-Hans', 'zh-Hant-TW', 'zh-Hant-HK', 'ja']) {
+ testWidgets('official usage fits minimum window in $language', (
+ tester,
+ ) async {
+ tester.view.physicalSize = const Size(760, 560);
+ tester.view.devicePixelRatio = 1;
+ addTearDown(tester.view.resetPhysicalSize);
+ addTearDown(tester.view.resetDevicePixelRatio);
+ final state = OfficialTestState(official: true, language: language);
+ final now = DateTime.now().millisecondsSinceEpoch ~/ 1000;
+ state.usage(
+ OfficialUsage(
+ available: true,
+ day: '2026-10-16',
+ quotaGroup: 'bucket',
+ uploadBytes: Int64(50000000),
+ downloadBytes: Int64(40000000),
+ limitBytes: Int64(100000000),
+ remainingBytes: Int64(10000000),
+ resetAtUnix: Int64(now + 3600),
+ updatedAtUnix: Int64(now),
+ ),
+ );
+ await tester.pumpWidget(PasteFerryApp(state: state));
+ await tester.pumpAndSettle();
+ await tester.tap(find.byIcon(Icons.cloud_outlined).first);
+ await tester.pumpAndSettle();
+ expect(find.byType(OfficialServicePage), findsOneWidget);
+ expect(find.text('90 MB'), findsOneWidget);
+ expect(find.text('100 MB'), findsOneWidget);
+ expect(tester.takeException(), isNull);
+ });
+ }
+}
diff --git a/ui/tool/l10n/strings.py b/ui/tool/l10n/strings.py
index 636544d..58a210d 100644
--- a/ui/tool/l10n/strings.py
+++ b/ui/tool/l10n/strings.py
@@ -196,7 +196,7 @@ S = [
("server", "Server (optional)", "服务器(可选)", "サーバー(任意)", "伺服器(選用)", "伺服器(可選)"),
("serverFootnote", "Only needed to sync between different networks, such as home and office. Devices on the same network connect without it. The server only helps devices find each other and can't see what they send.", "只在不同网络之间同步时需要,比如家里和公司;同一网络里的设备不用服务器也能直接连上。服务器只负责让设备找到彼此,看不到传输的内容。", "家と会社のように、別々のネットワーク間で同期するときだけ必要です。同じネットワーク内のデバイスはサーバーなしで直接つながります。サーバーはデバイス同士を引き合わせるだけで、やり取りする内容は見えません。", "只在不同網路之間同步時需要,例如家裡和公司;同一個網路裡的裝置不用伺服器也能直接連上。伺服器只負責讓裝置找到彼此,看不到傳輸的內容。", "只在不同網絡之間同步時需要,例如家裏和公司;同一網絡裏的裝置不用伺服器也能直接連上。伺服器只負責讓裝置找到彼此,看不到傳輸的內容。"),
("signalingUrl", "Signaling server", "信令服务器地址", "シグナリングサーバー", "信令伺服器位址", "信令伺服器地址"),
- ("signalingUrlDesc", "Press Return to save. Leave it empty to sync on this network only.", "按回车保存。留空表示只在局域网里同步", "Enter で保存。空欄にするとこのネットワーク内だけで同期します", "按 Enter 儲存。留空表示只在區域網路裡同步", "按 Enter 儲存。留空表示只在區域網絡裏同步"),
+ ("signalingUrlDesc", "Click Save and connect or press Enter. Leave it empty to sync on this network only.", "点击“保存并连接”或按回车。留空表示只在局域网里同步", "「保存して接続」をクリックするか Enter を押します。空欄にするとこのネットワーク内だけで同期します", "點擊「儲存並連線」或按 Enter。留空表示只在區域網路裡同步", "點擊「儲存並連線」或按 Enter。留空表示只在區域網絡裏同步"),
("signalingUrlPlaceholder", "ws://server-address:8787/signal", "ws://服务器地址:8787/signal", "ws://サーバーアドレス:8787/signal", "ws://伺服器位址:8787/signal", "ws://伺服器地址:8787/signal"),
("publicStun", "Probe with public servers", "用公共服务器探测网络出口", "公開サーバーで出口を調べる", "用公共伺服器偵測網路出口", "用公共伺服器探測網絡出口"),
("publicStunDesc", "On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.", "公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP", "複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。", "在公司雙線路這類多出口網路裡,能找到更多可以直連的路徑。公共伺服器只會看到你的公用 IP", "在公司雙線這類多出口網絡裏,能找到更多可以直連的路徑。公共伺服器只會看到你的公網 IP"),
@@ -293,6 +293,34 @@ S = [
("svcDevBodyMac", "This is a development build without the background service. Run ./scripts/install-macos.sh in the source folder to install it.", "这是开发构建,App 里没有内置后台服务。在源码目录运行 ./scripts/install-macos.sh 安装它。", "開発ビルドのためバックグラウンドサービスが含まれていません。ソースフォルダで ./scripts/install-macos.sh を実行してインストールしてください。", "這是開發版本,App 裡沒有內建背景服務。在原始碼資料夾執行 ./scripts/install-macos.sh 安裝它。", "這是開發版本,App 裏沒有內建背景服務。在原始碼目錄執行 ./scripts/install-macos.sh 安裝它。"),
("svcLogPath", "Log: {path}", "运行日志:{path}", "ログ:{path}", "記錄檔:{path}", "執行日誌:{path}"),
("svcCanDisable", "You can turn background sync off anytime in Settings.", "随时可以在「设置」中停用后台同步。", "バックグラウンド同期は「設定」でいつでもオフにできます。", "隨時可以在「設定」中停用背景同步。", "隨時可以在「設定」中停用背景同步。"),
+ # Official gateway: opt-in access, relay-only quota and privacy.
+ ('officialService', 'Official service', '官方服务', '公式サービス', '官方服務', '官方服務'),
+ ('useOfficialService', 'Use official service', '使用官方服务', '公式サービスを使う', '使用官方服務', '使用官方服務'),
+ ('officialPrivacy', 'Connects to the official service only when enabled and records essential access statistics. Direct connections are tried first; relay access is requested only if they fail. Content, real device names and raw system identifiers are not uploaded.', '仅开启后连接官方服务并统计必要接入信息。先尝试直连,失败才申请中转;不上传内容、真实设备名或原始系统标识。', '有効にした場合のみ公式サービスに接続し、必要最小限の接続情報を記録します。まず直接接続を試み、失敗した場合のみ中継を申請します。内容、実際の端末名、元のシステム識別子は送信しません。', '僅開啟後連線官方服務並統計必要連線資訊。先嘗試直連,失敗才申請中繼;不傳送內容、真實裝置名稱或原始系統識別碼。', '只在啟用後連接官方服務並統計必要連線資料。先嘗試直連,失敗才申請中轉;不傳送內容、真實裝置名稱或原始系統識別碼。'),
+ ('officialEnableTitle', 'Enable official Internet service?', '启用官方公网服务?', '公式インターネットサービスを有効にしますか?', '啟用官方公網服務?', '啟用官方公網服務?'),
+ ('officialSwitchConfirm', 'This switches away from your custom server. Its saved address will be retained.', '这会切换当前自定义服务器,已保存的地址仍会保留。', '現在のカスタムサーバーから切り替えます。保存済みのアドレスは保持されます。', '這會切換目前的自訂伺服器,已儲存的位址仍會保留。', '這會切換目前的自訂伺服器,已儲存的地址仍會保留。'),
+ ('customServer', 'Custom server', '自定义服务器', 'カスタムサーバー', '自訂伺服器', '自訂伺服器'),
+ ('saveAndConnect', 'Save and connect', '保存并连接', '保存して接続', '儲存並連線', '儲存並連接'),
+ ('officialUnused', 'Relay not requested; allowance not yet verified', '尚未申请中转,余额待核验', '中継は未申請です。残量は未確認です', '尚未申請中繼,餘額待確認', '尚未申請中轉,餘額待確認'),
+ ('officialUnavailable', 'Usage is unavailable; existing data may be out of date', '用量暂不可用,已有数据可能过期', '使用量を取得できません。表示データは古い可能性があります', '用量暫時無法取得,現有資料可能過期', '用量暫時無法取得,現有資料可能過期'),
+ ('officialQuotaTitle', 'Daily relay allowance used up', '今日中转额度已用完', '本日の中継上限に達しました', '今日中繼額度已用完', '今日中轉額度已用完'),
+ ('officialQuotaBody', 'Official relay is paused until the daily reset at midnight Beijing time. LAN and direct Internet connections remain available. Failed transfers can be retried later.', '官方中转已暂停,北京时间零点重置。局域网和公网直连仍可使用;传输失败时可稍后重试。', '公式中継は北京時間の午前0時にリセットされるまで停止します。LANと直接接続は引き続き利用できます。失敗した転送は後で再試行できます。', '官方中繼已暫停,北京時間午夜重設。區域網路和公網直連仍可使用;傳輸失敗時可稍後重試。', '官方中轉已暫停,北京時間午夜重設。區域網絡和公網直連仍可使用;傳輸失敗時可稍後重試。'),
+ ('officialPeerQuota', 'The peer has no relay allowance left. Direct connections remain available.', '对端中转额度不足,直连仍可使用', '相手の中継残量がありません。直接接続は引き続き利用できます', '對方中繼額度不足,直連仍可使用', '對方中轉額度不足,直連仍可使用'),
+ ('officialPaused', 'Official relay is unavailable. Direct connections remain available.', '官方中转暂不可用,直连仍可使用', '公式中継は現在利用できません。直接接続は引き続き利用できます', '官方中繼暫時無法使用,直連仍可使用', '官方中轉暫時無法使用,直連仍可使用'),
+ ('officialViewUsage', 'View usage', '查看用量', '使用量を表示', '查看用量', '查看用量'),
+ ('officialAcknowledge', 'Got it', '知道了', '確認しました', '知道了', '知道了'),
+ ('officialToday', "Today's relay usage", '今日中转用量', '本日の中継使用量', '今日中繼用量', '今日中轉用量'),
+ ('officialUsed', 'Used', '已使用', '使用済み', '已使用', '已使用'),
+ ('officialRemaining', 'Remaining', '剩余额度', '残量', '剩餘額度', '剩餘額度'),
+ ('officialDailyLimit', 'Daily allowance', '每日额度', '1日の上限', '每日額度', '每日額度'),
+ ('officialUpload', 'Upload', '上传', 'アップロード', '上傳', '上傳'),
+ ('officialDownload', 'Download', '下载', 'ダウンロード', '下載', '下載'),
+ ('officialReset', 'Reset time (Beijing)', '重置时间(北京时间)', 'リセット時刻(北京時間)', '重設時間(北京時間)', '重設時間(北京時間)'),
+ ('officialUpdated', 'Last updated', '最后更新', '最終更新', '上次更新', '上次更新'),
+ ('officialDeviceID', 'Device ID', '设备 ID', '端末 ID', '裝置 ID', '裝置 ID'),
+ ('officialWarning', '90% of the daily relay allowance has been used. Direct connections do not consume it.', '今日中转额度已使用 90%,直连不消耗此额度。', '本日の中継上限の90%を使用しました。直接接続ではこの残量は消費しません。', '今日中繼額度已使用 90%,直連不消耗此額度。', '今日中轉額度已使用 90%,直連不消耗此額度。'),
+ ('officialAccounting', 'Upload and download combined, including encryption overhead. Only official relay usage is measured; direct content and traffic are not recorded.', '上下行合计,包含加密传输开销;只统计官方中转,不统计直连内容或流量。', '暗号化の通信量を含む送受信の合計です。公式中継のみ計測し、直接接続の内容や通信量は記録しません。', '上下行合計,包含加密傳輸開銷;僅統計官方中繼,不統計直連內容或流量。', '上下行合計,包含加密傳輸開銷;只統計官方中轉,不統計直連內容或流量。'),
+
]
# 数字类占位符的类型;其余都是字符串