Fix string type
Some checks failed
Build / Calculate version (push) Has been cancelled
Build / Build binary (push) Has been cancelled
Build / Build binary-1 (push) Has been cancelled
Build / Build binary-2 (push) Has been cancelled
Build / Build binary-3 (push) Has been cancelled
Build / Build binary-4 (push) Has been cancelled
Build / Build binary-5 (push) Has been cancelled
Build / Build binary-6 (push) Has been cancelled
Build / Build binary-7 (push) Has been cancelled
Build / Build binary-8 (push) Has been cancelled
Build / Build binary-9 (push) Has been cancelled
Build / Build binary-10 (push) Has been cancelled
Build / Build binary-11 (push) Has been cancelled
Build / Build binary-12 (push) Has been cancelled
Build / Build binary-13 (push) Has been cancelled
Build / Build binary-14 (push) Has been cancelled
Build / Build binary-15 (push) Has been cancelled
Build / Build binary-16 (push) Has been cancelled
Build / Build binary-17 (push) Has been cancelled
Build / Build binary-18 (push) Has been cancelled
Build / Build binary-19 (push) Has been cancelled
Build / Build binary-20 (push) Has been cancelled
Build / Build binary-21 (push) Has been cancelled
Build / Build binary-22 (push) Has been cancelled
Build / Build binary-23 (push) Has been cancelled
Build / Build binary-24 (push) Has been cancelled
Build / Build binary-25 (push) Has been cancelled
Build / Build binary-26 (push) Has been cancelled
Build / Build binary-27 (push) Has been cancelled
Build / Build binary-28 (push) Has been cancelled
Build / Build binary-29 (push) Has been cancelled
Build / Build binary-30 (push) Has been cancelled
Build / Build binary-31 (push) Has been cancelled
Build / Build binary-32 (push) Has been cancelled
Build / Build binary-33 (push) Has been cancelled
Build / Build binary-34 (push) Has been cancelled
Build / Build binary-35 (push) Has been cancelled
Build / Build binary-36 (push) Has been cancelled
Build / Build binary-37 (push) Has been cancelled
Build / Build Darwin binaries (push) Has been cancelled
Build / Build Darwin binaries-1 (push) Has been cancelled
Build / Build Darwin binaries-2 (push) Has been cancelled
Build / Build Windows binaries (push) Has been cancelled
Build / Build Windows binaries-1 (push) Has been cancelled
Build / Build Windows binaries-2 (push) Has been cancelled
Build / Build Android library (386) (push) Has been cancelled
Build / Build Android library (amd64) (push) Has been cancelled
Build / Build Android library (arm) (push) Has been cancelled
Build / Build Android library (arm64) (push) Has been cancelled
Build / Build Android (other) (push) Has been cancelled
Build / Build Android (other-legacy) (push) Has been cancelled
Build / Publish Android (push) Has been cancelled
Build / Build Windows client (arm64) (push) Has been cancelled
Build / Build Windows client (x64) (push) Has been cancelled
Build / Build Windows client (x86) (push) Has been cancelled
Build / Build Linux client (arm64) (push) Has been cancelled
Build / Build Linux client (armv7l) (push) Has been cancelled
Build / Build Linux client (x64) (push) Has been cancelled
Build / Build Apple library (ios-arm64) (push) Has been cancelled
Build / Build Apple library (macos-amd64) (push) Has been cancelled
Build / Build Apple library (macos-arm64) (push) Has been cancelled
Build / Build Apple library (tvos-arm64) (push) Has been cancelled
Build / Build Apple release clients (push) Has been cancelled
Build / Build Apple release clients-1 (push) Has been cancelled
Build / Build Apple App Store clients (push) Has been cancelled
Build / Build Apple App Store clients-1 (push) Has been cancelled
Build / Build Apple App Store clients-2 (push) Has been cancelled
Build / Upload builds (push) Has been cancelled
Build / Cache GC (push) Has been cancelled

This commit is contained in:
世界 2026-07-25 22:57:06 +08:00
parent ea6965b726
commit f60f3728ce
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
7 changed files with 9 additions and 123 deletions

View file

@ -188,7 +188,7 @@ func newSTDClient(ctx context.Context, logger logger.ContextLogger, serverAddres
if len(certificate) > 0 {
certPool := x509.NewCertPool()
if !certPool.AppendCertsFromPEM(certificate) {
return nil, E.New("failed to parse certificate:\n\n", certificate)
return nil, E.New("failed to parse certificate:\n\n", string(certificate))
}
tlsConfig.RootCAs = certPool
}

View file

@ -289,7 +289,7 @@ func (c *STDServerConfig) certificateUpdated(path string) error {
for _, certPath := range c.clientCertificatePath {
content, err := filemanager.ReadFile(c.ctx, certPath)
if err != nil {
c.logger.Error(E.Cause(err, "reload certificate from ", c.clientCertificatePath))
c.logger.Error(E.Cause(err, "reload certificate from ", certPath))
continue
}
if !clientCertificateCA.AppendCertsFromPEM(content) {

View file

@ -260,7 +260,7 @@ func newUTLSClient(ctx context.Context, logger logger.ContextLogger, serverAddre
if len(certificate) > 0 {
certPool := x509.NewCertPool()
if !certPool.AppendCertsFromPEM(certificate) {
return nil, E.New("failed to parse certificate:\n\n", certificate)
return nil, E.New("failed to parse certificate:\n\n", string(certificate))
}
tlsConfig.RootCAs = certPool
}

View file

@ -1,114 +0,0 @@
package option
import (
"github.com/sagernet/sing-box/schema"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/json"
"github.com/sagernet/sing/common/json/badoption"
)
type OnDemandOptions struct {
Enabled bool `json:"enabled,omitempty"`
Rules []OnDemandRule `json:"rules,omitempty"`
}
type OnDemandRule struct {
Action *OnDemandRuleAction `json:"action,omitempty"`
DNSSearchDomainMatch badoption.Listable[string] `json:"dns_search_domain_match,omitempty"`
DNSServerAddressMatch badoption.Listable[string] `json:"dns_server_address_match,omitempty"`
InterfaceTypeMatch *OnDemandRuleInterfaceType `json:"interface_type_match,omitempty"`
SSIDMatch badoption.Listable[string] `json:"ssid_match,omitempty"`
ProbeURL string `json:"probe_url,omitempty"`
}
type OnDemandRuleAction int
func (r *OnDemandRuleAction) MarshalJSON() ([]byte, error) {
if r == nil {
return nil, nil
}
value := *r
var actionName string
switch value {
case 1:
actionName = "connect"
case 2:
actionName = "disconnect"
case 3:
actionName = "evaluate_connection"
default:
return nil, E.New("unknown action: ", value)
}
return json.Marshal(actionName)
}
func (r *OnDemandRuleAction) UnmarshalJSON(bytes []byte) error {
var actionName string
if err := json.Unmarshal(bytes, &actionName); err != nil {
return err
}
var actionValue int
switch actionName {
case "connect":
actionValue = 1
case "disconnect":
actionValue = 2
case "evaluate_connection":
actionValue = 3
case "ignore":
actionValue = 4
default:
return E.New("unknown action name: ", actionName)
}
*r = OnDemandRuleAction(actionValue)
return nil
}
func (r OnDemandRuleAction) DescribeSchema(builder schema.Builder) (*schema.Node, error) {
return schema.StringEnum("connect", "disconnect", "evaluate_connection", "ignore"), nil
}
type OnDemandRuleInterfaceType int
func (r *OnDemandRuleInterfaceType) MarshalJSON() ([]byte, error) {
if r == nil {
return nil, nil
}
value := *r
var interfaceTypeName string
switch value {
case 1:
interfaceTypeName = "any"
case 2:
interfaceTypeName = "wifi"
case 3:
interfaceTypeName = "cellular"
default:
return nil, E.New("unknown interface type: ", value)
}
return json.Marshal(interfaceTypeName)
}
func (r *OnDemandRuleInterfaceType) UnmarshalJSON(bytes []byte) error {
var interfaceTypeName string
if err := json.Unmarshal(bytes, &interfaceTypeName); err != nil {
return err
}
var interfaceTypeValue int
switch interfaceTypeName {
case "any":
interfaceTypeValue = 1
case "wifi":
interfaceTypeValue = 2
case "cellular":
interfaceTypeValue = 3
default:
return E.New("unknown interface type name: ", interfaceTypeName)
}
*r = OnDemandRuleInterfaceType(interfaceTypeValue)
return nil
}
func (r OnDemandRuleInterfaceType) DescribeSchema(builder schema.Builder) (*schema.Node, error) {
return schema.StringEnum("any", "wifi", "cellular"), nil
}

View file

@ -110,7 +110,7 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
for _, hostKey := range options.HostKey {
key, _, _, _, err := ssh.ParseAuthorizedKey([]byte(hostKey))
if err != nil {
return nil, E.New("parse host key ", key)
return nil, E.Cause(err, "parse host key: ", hostKey)
}
outbound.hostKey = append(outbound.hostKey, key)
}

View file

@ -116,7 +116,7 @@ func NewCertificateProvider(ctx context.Context, logger log.ContextLogger, tag s
case option.ACMEKeyTypeRSA4096:
keyType = certmagic.RSA4096
default:
return nil, E.New("unsupported ACME key type: ", options.KeyType)
return nil, E.New("unsupported ACME key type: ", string(options.KeyType))
}
config.KeySource = certmagic.StandardKeyGenerator{KeyType: keyType}
}
@ -231,13 +231,13 @@ func newDNSSolver(dnsOptions *option.ACMEProviderDNS01ChallengeOptions, logger *
return nil, nil
}
if dnsOptions.TTL < 0 {
return nil, E.New("invalid ACME DNS01 ttl: ", dnsOptions.TTL)
return nil, E.New("invalid ACME DNS01 ttl: ", dnsOptions.TTL.Build())
}
if dnsOptions.PropagationDelay < 0 {
return nil, E.New("invalid ACME DNS01 propagation_delay: ", dnsOptions.PropagationDelay)
return nil, E.New("invalid ACME DNS01 propagation_delay: ", dnsOptions.PropagationDelay.Build())
}
if dnsOptions.PropagationTimeout < -1 {
return nil, E.New("invalid ACME DNS01 propagation_timeout: ", dnsOptions.PropagationTimeout)
return nil, E.New("invalid ACME DNS01 propagation_timeout: ", dnsOptions.PropagationTimeout.Build())
}
solver := &certmagic.DNS01Solver{
DNSManager: certmagic.DNSManager{

View file

@ -338,7 +338,7 @@ func (s *Service) requestCertificate(ctx context.Context) ([]byte, []byte, *tls.
}
privateKey = ecKey
default:
return nil, nil, nil, nil, E.New("unsupported Cloudflare Origin CA request type: ", s.requestType)
return nil, nil, nil, nil, E.New("unsupported Cloudflare Origin CA request type: ", string(s.requestType))
}
privateKeyDER, err := x509.MarshalPKCS8PrivateKey(privateKey)
if err != nil {