Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+29
-8
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package logpolicy manages the creation or reuse of logtail loggers,
|
||||
@@ -43,6 +43,7 @@ import (
|
||||
"tailscale.com/net/netknob"
|
||||
"tailscale.com/net/netmon"
|
||||
"tailscale.com/net/netns"
|
||||
"tailscale.com/net/netutil"
|
||||
"tailscale.com/net/netx"
|
||||
"tailscale.com/net/tlsdial"
|
||||
"tailscale.com/paths"
|
||||
@@ -53,13 +54,15 @@ import (
|
||||
"tailscale.com/util/eventbus"
|
||||
"tailscale.com/util/must"
|
||||
"tailscale.com/util/racebuild"
|
||||
"tailscale.com/util/syspolicy/pkey"
|
||||
"tailscale.com/util/syspolicy/policyclient"
|
||||
"tailscale.com/util/testenv"
|
||||
"tailscale.com/version"
|
||||
"tailscale.com/version/distro"
|
||||
)
|
||||
|
||||
// GetLogTarget is an optional hook to register a function
|
||||
// that returns the log target URL to be used by logpolicy.
|
||||
var GetLogTarget feature.Hook[func() string]
|
||||
|
||||
var getLogTargetOnce struct {
|
||||
sync.Once
|
||||
v string // URL of logs server, or empty for default
|
||||
@@ -67,8 +70,12 @@ var getLogTargetOnce struct {
|
||||
|
||||
func getLogTarget() string {
|
||||
getLogTargetOnce.Do(func() {
|
||||
envTarget, _ := os.LookupEnv("TS_LOG_TARGET")
|
||||
getLogTargetOnce.v, _ = policyclient.Get().GetString(pkey.LogTarget, envTarget)
|
||||
if f, ok := GetLogTarget.GetOk(); ok {
|
||||
getLogTargetOnce.v = f()
|
||||
}
|
||||
if getLogTargetOnce.v == "" {
|
||||
getLogTargetOnce.v, _ = os.LookupEnv("TS_LOG_TARGET")
|
||||
}
|
||||
})
|
||||
|
||||
return getLogTargetOnce.v
|
||||
@@ -539,7 +546,18 @@ func (opts Options) init(disableLogging bool) (*logtail.Config, *Policy) {
|
||||
// anyway, no need to add one.
|
||||
lflags = 0
|
||||
}
|
||||
console := log.New(stderrWriter{}, "", lflags)
|
||||
var conWriter io.Writer = stderrWriter{}
|
||||
if buildfeatures.HasSyslog {
|
||||
if f, ok := feature.HookLogSink.GetOk(); ok {
|
||||
if w := f(); w != nil {
|
||||
// Logs are being redirected elsewhere (e.g. to syslog,
|
||||
// which records its own timestamps).
|
||||
conWriter = w
|
||||
lflags = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
console := log.New(conWriter, "", lflags)
|
||||
|
||||
var earlyErrBuf bytes.Buffer
|
||||
earlyLogf := func(format string, a ...any) {
|
||||
@@ -669,7 +687,10 @@ func (opts Options) init(disableLogging bool) (*logtail.Config, *Policy) {
|
||||
logID := newc.PublicID.String()
|
||||
exe, _ := os.Executable()
|
||||
if strings.EqualFold(filepath.Base(exe), "tailscaled.exe") {
|
||||
diskLogf := filelogger.New("tailscale-service", logID, lw.Logf)
|
||||
// Alongside the log config: %ProgramData%\Tailscale\Logs for
|
||||
// the service, or %LocalAppData%\Tailscale\Logs for a tailscaled
|
||||
// run by a regular user. See LogsDir.
|
||||
diskLogf := filelogger.New(filepath.Join(opts.Dir, "Logs"), "tailscale-service", logID, lw.Logf)
|
||||
logOutput = logger.FuncWriter(diskLogf)
|
||||
}
|
||||
}
|
||||
@@ -878,7 +899,7 @@ func (opts TransportOptions) New() http.RoundTripper {
|
||||
opts.NetMon = netmon.NewStatic()
|
||||
}
|
||||
// Start with a copy of http.DefaultTransport and tweak it a bit.
|
||||
tr := http.DefaultTransport.(*http.Transport).Clone()
|
||||
tr := netutil.NewDefaultTransport()
|
||||
if opts.TLSClientConfig != nil {
|
||||
tr.TLSClientConfig = opts.TLSClientConfig.Clone()
|
||||
}
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
//go:build !ts_omit_syspolicy
|
||||
|
||||
package logpolicy
|
||||
|
||||
import _ "tailscale.com/feature/syspolicy"
|
||||
Reference in new issue
Block a user