mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-01-31 13:16:53 +00:00
36 lines
1 KiB
Go
36 lines
1 KiB
Go
|
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 {
|
||
|
if err := json.Unmarshal(data, (*_CertificateOptions)(o)); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
switch o.Store {
|
||
|
case C.CertificateStoreSystem, "":
|
||
|
o.Store = C.CertificateStoreSystem
|
||
|
}
|
||
|
return nil
|
||
|
}
|