optimize(udp)/fix(quicSniffer): optimize performance of udp and fix a potential panic of quic (#301)

This commit is contained in:
mzz
2023-11-15 14:32:57 +08:00
committed by GitHub
parent dedc716413
commit 25c047a766
33 changed files with 968 additions and 466 deletions

View File

@ -20,7 +20,7 @@ import (
"github.com/sirupsen/logrus"
)
var BadUpstreamFormatError = fmt.Errorf("bad upstream format")
var ErrBadUpstreamFormat = fmt.Errorf("bad upstream format")
type Dns struct {
log *logrus.Logger
@ -55,12 +55,12 @@ func New(dns *config.Dns, opt *NewOption) (s *Dns, err error) {
tag, link := common.GetTagFromLinkLikePlaintext(string(upstreamRaw))
if tag == "" {
return nil, fmt.Errorf("%w: '%v' has no tag", BadUpstreamFormatError, upstreamRaw)
return nil, fmt.Errorf("%w: '%v' has no tag", ErrBadUpstreamFormat, upstreamRaw)
}
var u *url.URL
u, err = url.Parse(link)
if err != nil {
return nil, fmt.Errorf("%w: %v", BadUpstreamFormatError, err)
return nil, fmt.Errorf("%w: %v", ErrBadUpstreamFormat, err)
}
r := &UpstreamResolver{
Raw: u,