mirror of
https://github.com/fatedier/frp.git
synced 2024-12-16 03:19:00 +08:00
26 lines
533 B
Go
26 lines
533 B
Go
|
package kcp
|
||
|
|
||
|
import (
|
||
|
"sync/atomic"
|
||
|
|
||
|
"github.com/pkg/errors"
|
||
|
"golang.org/x/net/ipv4"
|
||
|
)
|
||
|
|
||
|
func (s *UDPSession) defaultTx(txqueue []ipv4.Message) {
|
||
|
nbytes := 0
|
||
|
npkts := 0
|
||
|
for k := range txqueue {
|
||
|
if n, err := s.conn.WriteTo(txqueue[k].Buffers[0], txqueue[k].Addr); err == nil {
|
||
|
nbytes += n
|
||
|
npkts++
|
||
|
xmitBuf.Put(txqueue[k].Buffers[0])
|
||
|
} else {
|
||
|
s.notifyWriteError(errors.WithStack(err))
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
atomic.AddUint64(&DefaultSnmp.OutPkts, uint64(npkts))
|
||
|
atomic.AddUint64(&DefaultSnmp.OutBytes, uint64(nbytes))
|
||
|
}
|