mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-09 11:48:18 +00:00
style(node): tighten the comments and probe assertion from the QA pass
Two follow-ups on the preceding fixes, no behaviour change: - The sweep comment in inbound_node.go had grown to a contiguous six-line block, over the two-line maximum. The prefix rationale it carried is already stated by nodeSelectedTagSet itself and by 6f40a51d's message. - The probe cap test asserted only that an error came back, which cannot tell a size rejection from a transport failure or a success=false envelope. It now pins LastError to the decode rejection. Both remain red-first: neutralizing maxProbeBodyBytes still fails the probe test on the new assertion.
This commit is contained in:
@@ -173,8 +173,6 @@ func (s *InboundService) ReconcileNode(ctx context.Context, rt *runtime.Remote,
|
|||||||
// rest were never imported, so their absence from the local DB must not
|
// rest were never imported, so their absence from the local DB must not
|
||||||
// delete them from the node. Only a selected tag missing locally (the
|
// delete them from the node. Only a selected tag missing locally (the
|
||||||
// panel deleted it while the node was unreachable) may be swept.
|
// panel deleted it while the node was unreachable) may be swept.
|
||||||
// The node reports a panel-created inbound with its n<id>- prefix stripped,
|
|
||||||
// so the selected set must carry both forms or the sweep never matches.
|
|
||||||
selected := nodeSelectedTagSet(n)
|
selected := nodeSelectedTagSet(n)
|
||||||
for _, tag := range remoteTags {
|
for _, tag := range remoteTags {
|
||||||
if _, want := desiredTags[tag]; want {
|
if _, want := desiredTags[tag]; want {
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import (
|
|||||||
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A node answers the probe over a connection the master does not control in the
|
// An oversized status body must be rejected, not buffered whole by encoding/json.
|
||||||
// skip/pin TLS modes, so an oversized status body must be rejected rather than
|
|
||||||
// buffered whole by encoding/json.
|
|
||||||
func TestProbeRejectsOversizedStatusBody(t *testing.T) {
|
func TestProbeRejectsOversizedStatusBody(t *testing.T) {
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
@@ -41,7 +39,12 @@ func TestProbeRejectsOversizedStatusBody(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
svc := &NodeService{}
|
svc := &NodeService{}
|
||||||
if _, err := svc.Probe(context.Background(), n); err == nil {
|
patch, err := svc.Probe(context.Background(), n)
|
||||||
|
if err == nil {
|
||||||
t.Fatal("Probe accepted a 3 MiB status body, want an error")
|
t.Fatal("Probe accepted a 3 MiB status body, want an error")
|
||||||
}
|
}
|
||||||
|
// Pin the rejection to the capped decode, not a transport or envelope failure.
|
||||||
|
if !strings.HasPrefix(patch.LastError, "decode response: ") {
|
||||||
|
t.Fatalf("LastError = %q, want a \"decode response: \" rejection", patch.LastError)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user