Add multi network dialing
This commit is contained in:
@@ -3,6 +3,7 @@ package option
|
||||
import (
|
||||
"strings"
|
||||
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-dns"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
F "github.com/sagernet/sing/common/format"
|
||||
@@ -150,3 +151,23 @@ func DNSQueryTypeToString(queryType uint16) string {
|
||||
}
|
||||
return F.ToString(queryType)
|
||||
}
|
||||
|
||||
type NetworkStrategy C.NetworkStrategy
|
||||
|
||||
func (n NetworkStrategy) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(C.NetworkStrategy(n).String())
|
||||
}
|
||||
|
||||
func (n *NetworkStrategy) UnmarshalJSON(content []byte) error {
|
||||
var value string
|
||||
err := json.Unmarshal(content, &value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
strategy, loaded := C.StringToNetworkStrategy[value]
|
||||
if !loaded {
|
||||
return E.New("unknown network strategy: ", value)
|
||||
}
|
||||
*n = NetworkStrategy(strategy)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user