mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-13 03:34:43 +00:00
logtail, net/portmapper, wgengine/magicsock: use fmt.Appendf
Fixes #5206 Change-Id: I490bb92e774ce7c044040537e2cd864fcf1dbe5a Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
4aa88bc2c0
commit
c378a9900c
@ -5,7 +5,6 @@
|
|||||||
package logtail
|
package logtail
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
@ -51,9 +50,7 @@ func (m *memBuffer) TryReadLine() ([]byte, error) {
|
|||||||
case ent := <-m.pending:
|
case ent := <-m.pending:
|
||||||
if ent.dropCount > 0 {
|
if ent.dropCount > 0 {
|
||||||
m.next = ent.msg
|
m.next = ent.msg
|
||||||
buf := new(bytes.Buffer)
|
return fmt.Appendf(nil, "----------- %d logs dropped ----------", ent.dropCount), nil
|
||||||
fmt.Fprintf(buf, "----------- %d logs dropped ----------", ent.dropCount)
|
|
||||||
return buf.Bytes(), nil
|
|
||||||
}
|
}
|
||||||
return ent.msg, nil
|
return ent.msg, nil
|
||||||
default:
|
default:
|
||||||
|
@ -270,7 +270,7 @@ func (l *Logger) drainPending(scratch []byte) (res []byte) {
|
|||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
break
|
break
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
b = []byte(fmt.Sprintf("reading ringbuffer: %v", err))
|
b = fmt.Appendf(nil, "reading ringbuffer: %v", err)
|
||||||
batchDone = true
|
batchDone = true
|
||||||
} else if b == nil {
|
} else if b == nil {
|
||||||
if entries > 0 {
|
if entries > 0 {
|
||||||
|
@ -143,7 +143,7 @@ func (d *TestIGD) serveUPnPDiscovery() {
|
|||||||
pkt := buf[:n]
|
pkt := buf[:n]
|
||||||
if bytes.Equal(pkt, uPnPPacket) { // a super lazy "parse"
|
if bytes.Equal(pkt, uPnPPacket) { // a super lazy "parse"
|
||||||
d.inc(&d.counters.numUPnPDiscoRecv)
|
d.inc(&d.counters.numUPnPDiscoRecv)
|
||||||
resPkt := []byte(fmt.Sprintf("HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=120\r\nST: urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\nUSN: uuid:bee7052b-49e8-3597-b545-55a1e38ac11::urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\nEXT:\r\nSERVER: Tailscale-Test/1.0 UPnP/1.1 MiniUPnPd/2.2.1\r\nLOCATION: %s\r\nOPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n01-NLS: 1627958564\r\nBOOTID.UPNP.ORG: 1627958564\r\nCONFIGID.UPNP.ORG: 1337\r\n\r\n", d.ts.URL+"/rootDesc.xml"))
|
resPkt := fmt.Appendf(nil, "HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=120\r\nST: urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\nUSN: uuid:bee7052b-49e8-3597-b545-55a1e38ac11::urn:schemas-upnp-org:device:InternetGatewayDevice:1\r\nEXT:\r\nSERVER: Tailscale-Test/1.0 UPnP/1.1 MiniUPnPd/2.2.1\r\nLOCATION: %s\r\nOPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n01-NLS: 1627958564\r\nBOOTID.UPNP.ORG: 1627958564\r\nCONFIGID.UPNP.ORG: 1337\r\n\r\n", d.ts.URL+"/rootDesc.xml")
|
||||||
if d.doUPnP {
|
if d.doUPnP {
|
||||||
_, err = d.upnpConn.WriteTo(resPkt, src)
|
_, err = d.upnpConn.WriteTo(resPkt, src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -811,7 +811,7 @@ func (c *Conn) pickDERPFallback() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h := fnv.New64()
|
h := fnv.New64()
|
||||||
h.Write([]byte(fmt.Sprintf("%p/%d", c, processStartUnixNano))) // arbitrary
|
fmt.Fprintf(h, "%p/%d", c, processStartUnixNano) // arbitrary
|
||||||
return ids[rand.New(rand.NewSource(int64(h.Sum64()))).Intn(len(ids))]
|
return ids[rand.New(rand.NewSource(int64(h.Sum64()))).Intn(len(ids))]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user