@@ -38,9 +38,51 @@ type Hysteria2InboundRealm struct {
3838 STUNDomainResolver * DomainResolveOptions `json:"stun_domain_resolver,omitempty"`
3939}
4040
41- type Hysteria2Obfs struct {
42- Type string `json:"type,omitempty"`
43- Password string `json:"password,omitempty"`
41+ type Hysteria2ObfsGecko struct {
42+ MinPacketSize int `json:"min_packet_size,omitempty"`
43+ MaxPacketSize int `json:"max_packet_size,omitempty"`
44+ }
45+
46+ type _Hysteria2Obfs struct {
47+ Type string `json:"type,omitempty"`
48+ Password string `json:"password,omitempty"`
49+ GeckoOptions Hysteria2ObfsGecko `json:"-"`
50+ }
51+
52+ type Hysteria2Obfs _Hysteria2Obfs
53+
54+ func (o Hysteria2Obfs ) MarshalJSON () ([]byte , error ) {
55+ var v any
56+ switch o .Type {
57+ case C .Hysteria2ObfsTypeSalamander :
58+ case C .Hysteria2ObfsTypeGecko :
59+ v = o .GeckoOptions
60+ default :
61+ return nil , E .New ("unknown obfs type: " , o .Type )
62+ }
63+ if v == nil {
64+ return json .Marshal ((_Hysteria2Obfs )(o ))
65+ }
66+ return badjson .MarshallObjects ((_Hysteria2Obfs )(o ), v )
67+ }
68+
69+ func (o * Hysteria2Obfs ) UnmarshalJSON (bytes []byte ) error {
70+ err := json .Unmarshal (bytes , (* _Hysteria2Obfs )(o ))
71+ if err != nil {
72+ return err
73+ }
74+ var v any
75+ switch o .Type {
76+ case C .Hysteria2ObfsTypeSalamander :
77+ case C .Hysteria2ObfsTypeGecko :
78+ v = & o .GeckoOptions
79+ default :
80+ return E .New ("unknown obfs type: " , o .Type )
81+ }
82+ if v == nil {
83+ return nil
84+ }
85+ return badjson .UnmarshallExcluded (bytes , (* _Hysteria2Obfs )(o ), v )
4486}
4587
4688type Hysteria2User struct {
0 commit comments