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 ¶
- func SingboxBins() []string
- func SingboxCheck(t testing.TB, config []byte) bool
- func SingboxConfig(t testing.TB, outbound []byte) []byte
- func XrayBuild(t testing.TB, config []byte)
- func XrayBuildArray(t testing.TB, doc []byte) []map[string]json.RawMessage
- func XrayConfig(t testing.TB, outbound []byte) []byte
- func XraySecurity(t testing.TB, s *internet.StreamConfig) proto.Message
- func XrayStreams(t testing.TB, config []byte) []*internet.StreamConfig
- func XrayTransport(t testing.TB, s *internet.StreamConfig, name string) proto.Message
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
XrayTransport returns the typed settings of the named transport ("splithttp", "websocket", ...) or fails.
Types ¶
This section is empty.