mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-16 02:52:23 +08:00
Fix missing marshal for udp_timeout
This commit is contained in:
parent
3eed614dea
commit
f5bb5cf343
|
@ -145,12 +145,16 @@ type ListenOptions struct {
|
|||
|
||||
type UDPTimeoutCompat Duration
|
||||
|
||||
func (u *UDPTimeoutCompat) UnmarshalJSON(data []byte) error {
|
||||
func (c UDPTimeoutCompat) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal((time.Duration)(c).String())
|
||||
}
|
||||
|
||||
func (c *UDPTimeoutCompat) UnmarshalJSON(data []byte) error {
|
||||
var valueNumber int64
|
||||
err := json.Unmarshal(data, &valueNumber)
|
||||
if err == nil {
|
||||
*u = UDPTimeoutCompat(time.Second * time.Duration(valueNumber))
|
||||
*c = UDPTimeoutCompat(time.Second * time.Duration(valueNumber))
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(data, (*Duration)(u))
|
||||
return json.Unmarshal(data, (*Duration)(c))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user