MCPcopy
hub / github.com/WireGuard/wireguard-go / SendBuffers

Method SendBuffers

device/peer.go:116–145  ·  view source on GitHub ↗
(buffers [][]byte)

Source from the content-addressed store, hash-verified

114}
115
116func (peer *Peer) SendBuffers(buffers [][]byte) error {
117 peer.device.net.RLock()
118 defer peer.device.net.RUnlock()
119
120 if peer.device.isClosed() {
121 return nil
122 }
123
124 peer.endpoint.Lock()
125 endpoint := peer.endpoint.val
126 if endpoint == nil {
127 peer.endpoint.Unlock()
128 return errors.New("no known endpoint for peer")
129 }
130 if peer.endpoint.clearSrcOnTx {
131 endpoint.ClearSrc()
132 peer.endpoint.clearSrcOnTx = false
133 }
134 peer.endpoint.Unlock()
135
136 err := peer.device.net.bind.Send(buffers, endpoint)
137 if err == nil {
138 var totalLen uint64
139 for _, b := range buffers {
140 totalLen += uint64(len(b))
141 }
142 peer.txBytes.Add(totalLen)
143 }
144 return err
145}
146
147func (peer *Peer) String() string {
148 // The awful goo that follows is identical to:

Callers 3

SendHandshakeResponseMethod · 0.95

Calls 3

isClosedMethod · 0.80
ClearSrcMethod · 0.65
SendMethod · 0.65

Tested by

no test coverage detected