fix: исправить баги, sentinel-ошибки, устаревшие доки
Баги: - udprelay: errors.Is(DeadlineExceeded) вместо сравнения строк; короткий backoff в ветке lockout; обернуть DTLS-ошибку через %w - bondserver.copyBondToBackend: лимит pending-map в 1024 (паритет с bondclient) - srtpmimicry.RelayPacketConn: bufPool для горячего UDP-пути (паритет с listen.go) - vkauth.token.go: ручной солвер под ctx.WithTimeout(ctx, ...) вместо Background — нет утечки горутины при shutdown Гигиена: - sentinel-ошибки vkauth как var = errors.New(...); вызыватели используют errors.Is - убраны устаревшие комментарии этапов рефакторинга (Pion SPDX, "Package bond", internal/bond, удалённый файл заметок) - .gitignore: *.exe, *.so Тесты + lint проходят.
This commit is contained in:
1 parent
7e3369f478
commit
ed6825976a
18 files changed
+203
-448
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Package bond contains the wire format used by the VLESS bond multi-lane
|
||||
// Package bondframe contains the wire format used by the VLESS bond multi-lane
|
||||
// transport (hello + framed data/FIN). Both the client (initiator) and the
|
||||
// server (acceptor) speak the same encoding.
|
||||
package bondframe
|
||||
|
||||
@@ -19,8 +19,16 @@ func (r *RelayPacketConn) ReadFrom(b []byte) (int, net.Addr, error) {
|
||||
if r.Conn == nil {
|
||||
return r.Relay.ReadFrom(b)
|
||||
}
|
||||
buf := make([]byte, MaxWire(len(b)))
|
||||
n, addr, err := r.Relay.ReadFrom(buf)
|
||||
bp := bufPool.Get().(*[]byte) //nolint:errcheck // pool New always returns *[]byte
|
||||
buf := *bp
|
||||
need := MaxWire(len(b))
|
||||
if cap(buf) < need {
|
||||
buf = make([]byte, need)
|
||||
*bp = buf
|
||||
}
|
||||
defer bufPool.Put(bp)
|
||||
|
||||
n, addr, err := r.Relay.ReadFrom(buf[:cap(buf)])
|
||||
if err != nil {
|
||||
return 0, addr, err
|
||||
}
|
||||
@@ -35,7 +43,17 @@ func (r *RelayPacketConn) WriteTo(b []byte, _ net.Addr) (int, error) {
|
||||
if r.Conn == nil {
|
||||
return r.Relay.WriteTo(b, r.Peer)
|
||||
}
|
||||
out := make([]byte, MaxWire(len(b)))
|
||||
wireLen := MaxWire(len(b))
|
||||
|
||||
bp := bufPool.Get().(*[]byte) //nolint:errcheck // pool New always returns *[]byte
|
||||
out := *bp
|
||||
if cap(out) < wireLen {
|
||||
out = make([]byte, wireLen)
|
||||
*bp = out
|
||||
}
|
||||
out = out[:wireLen]
|
||||
defer bufPool.Put(bp)
|
||||
|
||||
n, err := r.Conn.WrapInto(out, b)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
||||
Reference in new issue
Block a user