|
|
@ -23,6 +23,7 @@ import (
|
|
|
|
"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 @@ import (
|
|
|
|
// 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,
|
|
|
|