mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-28 04:00:57 +00:00
Some checks are pending
CI / go-test (push) Waiting to run
CI / codegen (push) Waiting to run
CI / govulncheck (push) Waiting to run
CI / race (push) Waiting to run
CI / fuzz-smoke (push) Waiting to run
CI / frontend (push) Waiting to run
CodeQL Advanced / Analyze (go) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run
Release 3X-UI / Publish rolling dev release (push) Blocked by required conditions
Replace the static reality-targets list with a server-side TLS 1.3 probe that checks TLS 1.3 + HTTP/2 + X25519 + a trusted certificate. - Single-domain validate auto-fills target and serverNames from the cert SAN - Discovery scans an IP/CIDR without SNI to find new targets from their certificates, deduped and ranked by feasibility then latency, private-IP guarded via netsafe - New endpoints scanRealityTarget and scanRealityTargets with RealityScanResult, plus openapigen and api-docs entries - Add scanner strings to all 13 locales - Replace deprecated AntD Alert message prop with title across the panel
145 lines
3.2 KiB
Go
145 lines
3.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
func main() {
|
|
root := flag.String("root", ".", "repository root containing internal/database/model and internal/web/entity")
|
|
outDir := flag.String("out", "frontend/src/generated", "output directory relative to root")
|
|
flag.Parse()
|
|
|
|
if err := run(*root, *outDir); err != nil {
|
|
fmt.Fprintln(os.Stderr, "openapigen:", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(root, outDir string) error {
|
|
requests := []packageRequest{
|
|
{
|
|
Path: resolveRel(root, "internal/database/model"),
|
|
StructAllow: setOf(
|
|
"User",
|
|
"Inbound",
|
|
"FallbackParentInfo",
|
|
"OutboundTraffics",
|
|
"InboundClientIps",
|
|
"ApiToken",
|
|
"HistoryOfSeeders",
|
|
"Setting",
|
|
"Node",
|
|
"ClientReverse",
|
|
"Client",
|
|
"ClientRecord",
|
|
"ClientInbound",
|
|
"InboundFallback",
|
|
"Host",
|
|
),
|
|
AliasAllow: setOf("Protocol"),
|
|
Overrides: map[string][]walkOverride{
|
|
"Inbound": {
|
|
{Field: "Settings", Kind: KindAny},
|
|
{Field: "StreamSettings", Kind: KindAny},
|
|
{Field: "Sniffing", Kind: KindAny},
|
|
},
|
|
"ClientRecord": {
|
|
{Field: "Reverse", Kind: KindAny},
|
|
},
|
|
"InboundClientIps": {
|
|
{Field: "Ips", Kind: KindAny},
|
|
},
|
|
"Host": {
|
|
{Field: "MuxParams", Kind: KindAny},
|
|
{Field: "SockoptParams", Kind: KindAny},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
Path: resolveRel(root, "internal/web/entity"),
|
|
StructAllow: setOf(
|
|
"Msg",
|
|
"AllSetting",
|
|
"AllSettingView",
|
|
),
|
|
},
|
|
{
|
|
Path: resolveRel(root, "internal/xray"),
|
|
StructAllow: setOf(
|
|
"ClientTraffic",
|
|
),
|
|
},
|
|
{
|
|
Path: resolveRel(root, "internal/web/service"),
|
|
StructAllow: setOf(
|
|
"InboundOption",
|
|
"ProbeResultUI",
|
|
"RealityScanResult",
|
|
),
|
|
},
|
|
{
|
|
Path: resolveRel(root, "internal/web/service/panel"),
|
|
StructAllow: setOf("ApiTokenView"),
|
|
},
|
|
}
|
|
|
|
schemas, aliases, err := walkPackages(requests)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
schemas = flattenEmbedded(schemas)
|
|
|
|
if len(schemas) == 0 {
|
|
return fmt.Errorf("no schemas produced; nothing to write")
|
|
}
|
|
|
|
target := filepath.Join(root, outDir)
|
|
if err := os.MkdirAll(target, 0o755); err != nil {
|
|
return err
|
|
}
|
|
|
|
zodBuf := &bytes.Buffer{}
|
|
if err := emitZod(zodBuf, schemas, aliases); err != nil {
|
|
return err
|
|
}
|
|
typesBuf := &bytes.Buffer{}
|
|
if err := emitTypes(typesBuf, schemas, aliases); err != nil {
|
|
return err
|
|
}
|
|
examplesBuf := &bytes.Buffer{}
|
|
if err := emitExamples(examplesBuf, schemas, aliases); err != nil {
|
|
return err
|
|
}
|
|
schemasBuf := &bytes.Buffer{}
|
|
if err := emitJSONSchema(schemasBuf, schemas, aliases); err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(target, "zod.ts"), zodBuf.Bytes(), 0o644); err != nil {
|
|
return err
|
|
}
|
|
if err := os.WriteFile(filepath.Join(target, "types.ts"), typesBuf.Bytes(), 0o644); err != nil {
|
|
return err
|
|
}
|
|
if err := os.WriteFile(filepath.Join(target, "examples.ts"), examplesBuf.Bytes(), 0o644); err != nil {
|
|
return err
|
|
}
|
|
if err := os.WriteFile(filepath.Join(target, "schemas.ts"), schemasBuf.Bytes(), 0o644); err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("openapigen: wrote %d schemas to %s\n", len(schemas), target)
|
|
return nil
|
|
}
|
|
|
|
func setOf(names ...string) map[string]bool {
|
|
m := make(map[string]bool, len(names))
|
|
for _, n := range names {
|
|
m[n] = true
|
|
}
|
|
return m
|
|
}
|