jsoncheck

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsoncheck lets the tests ask the real cores whether a client config they render is valid: Xray in process (xray-core's own config builder) and sing-box through its binary. Only tests import it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SingboxBins

func SingboxBins() []string

SingboxBins are the sing-box binaries to ask: SINGBOX_BIN (several paths separated by the OS path-list separator), or else every ~/.cache/mistgate-tests/sing-box-* the download step left there. Empty means the test is skipped, like the Mihomo core test without MIHOMO_BIN.

func SingboxCheck

func SingboxCheck(t testing.TB, config []byte) bool

SingboxCheck runs `sing-box check -c` for every binary and fails on the first refusal. It returns false when there is no binary (the caller skips).

func SingboxConfig

func SingboxConfig(t testing.TB, outbound []byte) []byte

SingboxConfig wraps one outbound fragment (no tag) into the smallest profile `sing-box check` accepts: the outbound tagged "proxy", a direct one and a final route.

func XrayBuild

func XrayBuild(t testing.TB, config []byte)

XrayBuild unmarshals a full config into xray-core's conf.Config and builds it, as `xray run` does before it starts anything. The core ignores unknown keys, so the outbound objects are also decoded with DisallowUnknownFields (stream settings, and the protocol settings object) to catch a misspelt key.

func XrayBuildArray

func XrayBuildArray(t testing.TB, doc []byte) []map[string]json.RawMessage

XrayBuildArray checks a whole Xray JSON subscription: a non-empty array in which every element is a complete config the core builds. `remarks` is the app's own key (the core does not know it), so it is dropped; every other key of the config, and every key of the outbounds, has to be one the core knows. It returns the elements.

func XrayConfig

func XrayConfig(t testing.TB, outbound []byte) []byte

XrayConfig wraps one outbound fragment (no tag) into the smallest config v2rayNG-style clients accept: a loopback socks inbound, the outbound tagged "proxy" and a routing section.

func XraySecurity

func XraySecurity(t testing.TB, s *internet.StreamConfig) proto.Message

XraySecurity returns the typed security settings (tls or reality config) or fails.

func XrayStreams

func XrayStreams(t testing.TB, config []byte) []*internet.StreamConfig

XrayStreams builds a full config and returns the stream settings of its outbounds, so a test can look at what reached the core (a key the core ignores shows up here as a zero value).

func XrayTransport

func XrayTransport(t testing.TB, s *internet.StreamConfig, name string) proto.Message

XrayTransport returns the typed settings of the named transport ("splithttp", "websocket", ...) or fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL