|
|
@ -13,6 +13,7 @@ import (
|
|
|
|
"crypto/tls"
|
|
|
|
"crypto/tls"
|
|
|
|
"encoding/json"
|
|
|
|
"encoding/json"
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
@ -52,6 +53,8 @@ import (
|
|
|
|
"tailscale.com/version/distro"
|
|
|
|
"tailscale.com/version/distro"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func inTest() bool { return flag.Lookup("test.v") != nil }
|
|
|
|
|
|
|
|
|
|
|
|
var getLogTargetOnce struct {
|
|
|
|
var getLogTargetOnce struct {
|
|
|
|
sync.Once
|
|
|
|
sync.Once
|
|
|
|
v string // URL of logs server, or empty for default
|
|
|
|
v string // URL of logs server, or empty for default
|
|
|
@ -559,7 +562,7 @@ func NewWithConfigPath(collection, dir, cmdName string) *Policy {
|
|
|
|
conf.IncludeProcSequence = true
|
|
|
|
conf.IncludeProcSequence = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if envknob.NoLogsNoSupport() {
|
|
|
|
if envknob.NoLogsNoSupport() || inTest() {
|
|
|
|
log.Println("You have disabled logging. Tailscale will not be able to provide support.")
|
|
|
|
log.Println("You have disabled logging. Tailscale will not be able to provide support.")
|
|
|
|
conf.HTTPC = &http.Client{Transport: noopPretendSuccessTransport{}}
|
|
|
|
conf.HTTPC = &http.Client{Transport: noopPretendSuccessTransport{}}
|
|
|
|
} else if val := getLogTarget(); val != "" {
|
|
|
|
} else if val := getLogTarget(); val != "" {
|
|
|
@ -720,7 +723,10 @@ func DialContext(ctx context.Context, netw, addr string) (net.Conn, error) {
|
|
|
|
|
|
|
|
|
|
|
|
// NewLogtailTransport returns an HTTP Transport particularly suited to uploading
|
|
|
|
// NewLogtailTransport returns an HTTP Transport particularly suited to uploading
|
|
|
|
// logs to the given host name. See DialContext for details on how it works.
|
|
|
|
// logs to the given host name. See DialContext for details on how it works.
|
|
|
|
func NewLogtailTransport(host string) *http.Transport {
|
|
|
|
func NewLogtailTransport(host string) http.RoundTripper {
|
|
|
|
|
|
|
|
if inTest() {
|
|
|
|
|
|
|
|
return noopPretendSuccessTransport{}
|
|
|
|
|
|
|
|
}
|
|
|
|
// Start with a copy of http.DefaultTransport and tweak it a bit.
|
|
|
|
// Start with a copy of http.DefaultTransport and tweak it a bit.
|
|
|
|
tr := http.DefaultTransport.(*http.Transport).Clone()
|
|
|
|
tr := http.DefaultTransport.(*http.Transport).Clone()
|
|
|
|
|
|
|
|
|
|
|
|