Fix config format output

This commit is contained in:
世界
2026-10-23 19:57:06 +08:00
parent b5a4fd174f
commit 755150a513
13 changed files with 19 additions and 35 deletions
+2 -2
View File
@@ -17004,10 +17004,10 @@
"User": {
"type": "object",
"properties": {
"Username": {
"username": {
"type": "string"
},
"Password": {
"password": {
"type": "string"
}
},
+1 -1
View File
@@ -45,7 +45,7 @@ require (
github.com/sagernet/netlink v0.0.0-20260814022025-64455d367bbf
github.com/sagernet/nftables v0.3.0-mod.4
github.com/sagernet/quic-go v0.61.0-sing-box-mod.12
github.com/sagernet/sing v0.9.7-0.20261023115459-9faf3c29ae9c
github.com/sagernet/sing v0.9.7-0.20261023115459-0678b21952a5
github.com/sagernet/sing-cloudflared v0.1.4-0.20261021152903-2d40d788fcf6
github.com/sagernet/sing-mux v0.3.10-0.20260929204512-caf09fe32475
github.com/sagernet/sing-openconnect v0.1.1-0.20260929151225-cbd68c45de58
+2 -2
View File
@@ -318,8 +318,8 @@ github.com/sagernet/nftables v0.3.0-mod.4 h1:vnOtcDYeSXv2e5RoRuGH0lrpttQFJ8iC4IC
github.com/sagernet/nftables v0.3.0-mod.4/go.mod h1:8kslHG4VvYNihcco+i6uxIX7qbT8A56T0y5q7U44ZaQ=
github.com/sagernet/quic-go v0.61.0-sing-box-mod.12 h1:9/USaaiONHFeqBePb+4C/A0MBM2dmxED49UGBpHLHS4=
github.com/sagernet/quic-go v0.61.0-sing-box-mod.12/go.mod h1:hmLC8GJPp+BrpBgrgJnacvI4fZGIhasuy1ROJJ8GR4E=
github.com/sagernet/sing v0.9.7-0.20261023115459-9faf3c29ae9c h1:wMpRBuv/lzJw/uVFucTMF7VWmHfV+m32fHILPWkzPoo=
github.com/sagernet/sing v0.9.7-0.20261023115459-9faf3c29ae9c/go.mod h1:K3Owt3xPhHugvlnlPPxZJ/exXdaJfEPOTNorGk4AXjo=
github.com/sagernet/sing v0.9.7-0.20261023115459-0678b21952a5 h1:CWi0GHLvGQlSAGPoSLJYhiTNN/2tjAdTBHHozl4p3gw=
github.com/sagernet/sing v0.9.7-0.20261023115459-0678b21952a5/go.mod h1:K3Owt3xPhHugvlnlPPxZJ/exXdaJfEPOTNorGk4AXjo=
github.com/sagernet/sing-cloudflared v0.1.4-0.20261021152903-2d40d788fcf6 h1:cedQ/AnIVZXNS0RbV5E6xXbLan7Qu8rOj7+B1kvb7fs=
github.com/sagernet/sing-cloudflared v0.1.4-0.20261021152903-2d40d788fcf6/go.mod h1:XEqEDYRCAYLaoPjZ1ifVWJg5iWAJHL2gOAXe/PM28Cg=
github.com/sagernet/sing-mux v0.3.10-0.20260929204512-caf09fe32475 h1:aG0DqHEOjax7DyfE1GTAXZotOg3QGVCz3/8rCSua2kg=
-3
View File
@@ -78,9 +78,6 @@ func (o Hysteria2Obfs) MarshalJSON() ([]byte, error) {
default:
return nil, E.New("unknown obfs type: ", o.Type)
}
if v == nil {
return json.Marshal(_Hysteria2Obfs(o))
}
return badjson.MarshallObjects(_Hysteria2Obfs(o), v)
}
+1 -1
View File
@@ -195,7 +195,7 @@ type OpenVPNPushOptions struct {
}
type OpenVPNPushDNSServerOptions struct {
Priority int `json:"priority"`
Priority int `json:"priority,omitempty"`
Addresses badoption.Listable[string] `json:"addresses"`
ResolveDomains badoption.Listable[string] `json:"resolve_domains,omitempty"`
DNSSEC string `json:"dnssec,omitempty" enum:"yes,optional,no"`
+1 -1
View File
@@ -182,7 +182,7 @@ type ServerOptionsWrapper interface {
type ServerOptions struct {
Server string `json:"server"`
ServerPort uint16 `json:"server_port"`
ServerPort uint16 `json:"server_port,omitempty"`
}
func (o ServerOptions) Build() M.Socksaddr {
-6
View File
@@ -48,9 +48,6 @@ func (r RuleAction) MarshalJSON() ([]byte, error) {
default:
return nil, E.New("unknown rule action: " + r.Action)
}
if v == nil {
return badjson.MarshallObjects(_RuleAction(r))
}
return badjson.MarshallObjects(_RuleAction(r), v)
}
@@ -124,9 +121,6 @@ func (r DNSRuleAction) MarshalJSON() ([]byte, error) {
default:
return nil, E.New("unknown DNS rule action: " + r.Action)
}
if v == nil {
return badjson.MarshallObjects(_DNSRuleAction(r))
}
return badjson.MarshallObjects(_DNSRuleAction(r), v)
}
+3 -3
View File
@@ -12,12 +12,12 @@ type ShadowsocksInboundOptions struct {
}
type ShadowsocksUser struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
Password string `json:"password"`
}
type ShadowsocksDestination struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
Password string `json:"password"`
ServerOptions
}
@@ -26,7 +26,7 @@ type ShadowsocksOutboundOptions struct {
DialerOptions
ServerOptions
Method string `json:"method" enum:"none,aes-128-gcm,aes-192-gcm,aes-256-gcm,chacha20-ietf-poly1305,xchacha20-ietf-poly1305,2022-blake3-aes-128-gcm,2022-blake3-aes-256-gcm,2022-blake3-chacha20-poly1305,aes-128-ctr,aes-192-ctr,aes-256-ctr,aes-128-cfb,aes-192-cfb,aes-256-cfb,rc4-md5,chacha20-ietf,xchacha20"`
Password string `json:"password"`
Password string `json:"password,omitempty"`
Plugin string `json:"plugin,omitempty"`
PluginOptions string `json:"plugin_opts,omitempty"`
Network NetworkList `json:"network,omitempty"`
+3 -10
View File
@@ -164,17 +164,10 @@ type _DERPSTUNListenOptions struct {
type DERPSTUNListenOptions _DERPSTUNListenOptions
func (d DERPSTUNListenOptions) MarshalJSON() ([]byte, error) {
portOptions := _DERPSTUNListenOptions{
Enabled: d.Enabled,
ListenOptions: ListenOptions{
ListenPort: d.ListenPort,
},
}
if _DERPSTUNListenOptions(d) == portOptions {
return json.Marshal(d.Enabled)
} else {
return json.Marshal(_DERPSTUNListenOptions(d))
if d.Enabled && d.ListenPort != 0 && d.ListenOptions == (ListenOptions{ListenPort: d.ListenPort}) {
return json.Marshal(d.ListenPort)
}
return json.Marshal(_DERPSTUNListenOptions(d))
}
func (d *DERPSTUNListenOptions) UnmarshalJSON(bytes []byte) error {
+1 -1
View File
@@ -11,7 +11,7 @@ type TrojanInboundOptions struct {
}
type TrojanUser struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
Password string `json:"password"`
}
+2 -2
View File
@@ -23,8 +23,8 @@ type _USBIPServerServiceOptions struct {
type USBIPServerServiceOptions _USBIPServerServiceOptions
func (o USBIPServerServiceOptions) MarshalJSON() ([]byte, error) {
if o.Options == nil {
return json.Marshal(_USBIPServerServiceOptions(o))
if o.Provider == USBIPProviderDefault {
o.Provider = ""
}
return badjson.MarshallObjects(_USBIPServerServiceOptions(o), o.Options)
}
+1 -1
View File
@@ -9,7 +9,7 @@ type VLESSInboundOptions struct {
}
type VLESSUser struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
UUID string `json:"uuid"`
Flow string `json:"flow,omitempty"`
}
+2 -2
View File
@@ -9,7 +9,7 @@ type VMessInboundOptions struct {
}
type VMessUser struct {
Name string `json:"name"`
Name string `json:"name,omitempty"`
UUID string `json:"uuid"`
AlterId int `json:"alterId,omitempty"`
}
@@ -18,7 +18,7 @@ type VMessOutboundOptions struct {
DialerOptions
ServerOptions
UUID string `json:"uuid"`
Security string `json:"security" enum:"auto,none,zero,aes-128-cfb,aes-128-gcm,chacha20-poly1305"`
Security string `json:"security,omitempty" enum:"auto,none,zero,aes-128-cfb,aes-128-gcm,chacha20-poly1305"`
AlterId int `json:"alter_id,omitempty"`
GlobalPadding bool `json:"global_padding,omitempty"`
AuthenticatedLength bool `json:"authenticated_length,omitempty"`