Add certificate store

This commit is contained in:
世界 2025-01-08 10:34:45 +08:00
parent 8b7c8dcdb4
commit 221c003ce0
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
30 changed files with 4786 additions and 32 deletions

36
option/certificate.go Normal file
View file

@ -0,0 +1,36 @@
package option
import (
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing/common/json"
"github.com/sagernet/sing/common/json/badoption"
)
type _CertificateOptions struct {
Store string `json:"store,omitempty"`
Certificate badoption.Listable[string] `json:"certificate,omitempty"`
CertificatePath badoption.Listable[string] `json:"certificate_path,omitempty"`
CertificateDirectoryPath badoption.Listable[string] `json:"certificate_directory_path,omitempty"`
}
type CertificateOptions _CertificateOptions
func (o CertificateOptions) MarshalJSON() ([]byte, error) {
switch o.Store {
case C.CertificateStoreSystem:
o.Store = ""
}
return json.Marshal((*_CertificateOptions)(&o))
}
func (o *CertificateOptions) UnmarshalJSON(data []byte) error {
err := json.Unmarshal(data, (*_CertificateOptions)(o))
if err != nil {
return err
}
switch o.Store {
case C.CertificateStoreSystem, "":
o.Store = C.CertificateStoreSystem
}
return nil
}