2023-03-17 04:24:29 +00:00
|
|
|
package option
|
|
|
|
|
|
|
|
import (
|
2023-12-01 12:15:11 +00:00
|
|
|
"github.com/sagernet/sing/common/json"
|
2023-03-17 04:24:29 +00:00
|
|
|
"github.com/sagernet/sing/common/uot"
|
|
|
|
)
|
|
|
|
|
|
|
|
type _UDPOverTCPOptions struct {
|
|
|
|
Enabled bool `json:"enabled,omitempty"`
|
|
|
|
Version uint8 `json:"version,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type UDPOverTCPOptions _UDPOverTCPOptions
|
|
|
|
|
|
|
|
func (o UDPOverTCPOptions) MarshalJSON() ([]byte, error) {
|
|
|
|
switch o.Version {
|
|
|
|
case 0, uot.Version:
|
|
|
|
return json.Marshal(o.Enabled)
|
|
|
|
default:
|
|
|
|
return json.Marshal(_UDPOverTCPOptions(o))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *UDPOverTCPOptions) UnmarshalJSON(bytes []byte) error {
|
|
|
|
err := json.Unmarshal(bytes, &o.Enabled)
|
|
|
|
if err == nil {
|
|
|
|
return nil
|
|
|
|
}
|
2024-07-22 04:10:22 +00:00
|
|
|
return json.UnmarshalDisallowUnknownFields(bytes, (*_UDPOverTCPOptions)(o))
|
2023-03-17 04:24:29 +00:00
|
|
|
}
|