@@ -20,7 +20,6 @@ import (
20
20
tuicCommon "github.com/metacubex/mihomo/transport/tuic/common"
21
21
22
22
"github.com/metacubex/quic-go"
23
- "github.com/metacubex/randv2"
24
23
"github.com/metacubex/sing-quic/hysteria2"
25
24
M "github.com/metacubex/sing/common/metadata"
26
25
)
@@ -186,30 +185,27 @@ func NewHysteria2(option Hysteria2Option) (*Hysteria2, error) {
186
185
}
187
186
188
187
var ranges utils.IntRanges [uint16 ]
189
- var serverAddress []string
188
+ var serverPorts []uint16
190
189
if option .Ports != "" {
191
190
ranges , err = utils.NewUnsignedRanges [uint16 ](option .Ports )
192
191
if err != nil {
193
192
return nil , err
194
193
}
195
194
ranges .Range (func (port uint16 ) bool {
196
- serverAddress = append (serverAddress , net . JoinHostPort ( option . Server , strconv . Itoa ( int ( port ))) )
195
+ serverPorts = append (serverPorts , port )
197
196
return true
198
197
})
199
- if len (serverAddress ) > 0 {
200
- clientOptions .ServerAddress = func (ctx context.Context ) (* net.UDPAddr , error ) {
201
- return resolveUDPAddr (ctx , "udp" , serverAddress [randv2 .IntN (len (serverAddress ))], C .NewDNSPrefer (option .IPVersion ))
202
- }
203
-
198
+ if len (serverPorts ) > 0 {
204
199
if option .HopInterval == 0 {
205
200
option .HopInterval = defaultHopInterval
206
201
} else if option .HopInterval < minHopInterval {
207
202
option .HopInterval = minHopInterval
208
203
}
209
204
clientOptions .HopInterval = time .Duration (option .HopInterval ) * time .Second
205
+ clientOptions .ServerPorts = serverPorts
210
206
}
211
207
}
212
- if option .Port == 0 && len (serverAddress ) == 0 {
208
+ if option .Port == 0 && len (serverPorts ) == 0 {
213
209
return nil , errors .New ("invalid port" )
214
210
}
215
211
0 commit comments