mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
Use logger.Logf consistently. It was used in most places.
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
c1917710ad
commit
a59dc5f155
@ -15,18 +15,19 @@
|
|||||||
|
|
||||||
"golang.org/x/crypto/curve25519"
|
"golang.org/x/crypto/curve25519"
|
||||||
"golang.org/x/crypto/nacl/box"
|
"golang.org/x/crypto/nacl/box"
|
||||||
|
"tailscale.com/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
serverKey [32]byte
|
serverKey [32]byte
|
||||||
privateKey [32]byte // TODO(crawshaw): make this wgcfg.PrivateKey?
|
privateKey [32]byte // TODO(crawshaw): make this wgcfg.PrivateKey?
|
||||||
publicKey [32]byte
|
publicKey [32]byte
|
||||||
logf func(format string, args ...interface{})
|
logf logger.Logf
|
||||||
netConn net.Conn
|
netConn net.Conn
|
||||||
conn *bufio.ReadWriter
|
conn *bufio.ReadWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(privateKey [32]byte, netConn net.Conn, conn *bufio.ReadWriter, logf func(format string, args ...interface{})) (*Client, error) {
|
func NewClient(privateKey [32]byte, netConn net.Conn, conn *bufio.ReadWriter, logf logger.Logf) (*Client, error) {
|
||||||
c := &Client{
|
c := &Client{
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
logf: logf,
|
logf: logf,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
"golang.org/x/crypto/curve25519"
|
"golang.org/x/crypto/curve25519"
|
||||||
"golang.org/x/crypto/nacl/box"
|
"golang.org/x/crypto/nacl/box"
|
||||||
|
"tailscale.com/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const magic = 0x44c55250 // "DERP" with a non-ASCII high-bit
|
const magic = 0x44c55250 // "DERP" with a non-ASCII high-bit
|
||||||
@ -44,14 +45,14 @@
|
|||||||
type Server struct {
|
type Server struct {
|
||||||
privateKey [32]byte // TODO(crawshaw): make this wgcfg.PrivateKey?
|
privateKey [32]byte // TODO(crawshaw): make this wgcfg.PrivateKey?
|
||||||
publicKey [32]byte
|
publicKey [32]byte
|
||||||
logf func(format string, args ...interface{})
|
logf logger.Logf
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
netConns map[net.Conn]chan struct{}
|
netConns map[net.Conn]chan struct{}
|
||||||
clients map[[32]byte]*client
|
clients map[[32]byte]*client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(privateKey [32]byte, logf func(format string, args ...interface{})) *Server {
|
func NewServer(privateKey [32]byte, logf logger.Logf) *Server {
|
||||||
s := &Server{
|
s := &Server{
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
logf: logf,
|
logf: logf,
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"tailscale.com/derp"
|
"tailscale.com/derp"
|
||||||
|
"tailscale.com/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is a DERP-over-HTTP client.
|
// Client is a DERP-over-HTTP client.
|
||||||
@ -32,7 +33,7 @@
|
|||||||
// Send/Recv will completely re-establish the connection.
|
// Send/Recv will completely re-establish the connection.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
privateKey [32]byte
|
privateKey [32]byte
|
||||||
logf func(format string, args ...interface{})
|
logf logger.Logf
|
||||||
closed chan struct{}
|
closed chan struct{}
|
||||||
url *url.URL
|
url *url.URL
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
@ -44,13 +45,13 @@ type Client struct {
|
|||||||
client *derp.Client
|
client *derp.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(privateKey [32]byte, serverURL string, logf func(format string, args ...interface{})) (c *Client, err error) {
|
func NewClient(privateKey [32]byte, serverURL string, logf logger.Logf) (*Client, error) {
|
||||||
u, err := url.Parse(serverURL)
|
u, err := url.Parse(serverURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("derphttp.NewClient: %v", err)
|
return nil, fmt.Errorf("derphttp.NewClient: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c = &Client{
|
c := &Client{
|
||||||
privateKey: privateKey,
|
privateKey: privateKey,
|
||||||
logf: logf,
|
logf: logf,
|
||||||
url: u,
|
url: u,
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"tailscale.com/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RusagePrefixLog(logf func(f string, argv ...interface{})) func(f string, argv ...interface{}) {
|
func RusagePrefixLog(logf logger.Logf) func(f string, argv ...interface{}) {
|
||||||
return func(f string, argv ...interface{}) {
|
return func(f string, argv ...interface{}) {
|
||||||
var m runtime.MemStats
|
var m runtime.MemStats
|
||||||
runtime.ReadMemStats(&m)
|
runtime.ReadMemStats(&m)
|
||||||
|
Loading…
Reference in New Issue
Block a user