Enforce NoLogsNoSupport
This commit is contained in:
@@ -456,7 +456,7 @@ var crashOnUnexpected = RegisterOptBool("TS_DEBUG_CRASH_ON_UNEXPECTED")
|
||||
// NoLogsNoSupport reports whether the client's opted out of log uploads and
|
||||
// technical support.
|
||||
func NoLogsNoSupport() bool {
|
||||
return Bool("TS_NO_LOGS_NO_SUPPORT")
|
||||
return true
|
||||
}
|
||||
|
||||
var allowRemoteUpdate = RegisterBool("TS_ALLOW_ADMIN_CONSOLE_REMOTE_UPDATE")
|
||||
|
||||
@@ -629,8 +629,8 @@ func (opts Options) init(disableLogging bool) (*logtail.Config, *Policy) {
|
||||
}
|
||||
|
||||
if disableLogging {
|
||||
opts.Logf("You have disabled logging. Tailscale will not be able to provide support.")
|
||||
conf.HTTPC = &http.Client{Transport: noopPretendSuccessTransport{}}
|
||||
opts.Logf("Tailscale logging is disabled by sing-box. Tailscale will not be able to provide support.")
|
||||
conf.HTTPC = &http.Client{Transport: NoopPretendSuccessTransport{}}
|
||||
} else {
|
||||
// Only attach an on-disk filch buffer if we are going to be sending logs.
|
||||
// No reason to persist them locally just to drop them later.
|
||||
@@ -871,7 +871,7 @@ type TransportOptions struct {
|
||||
// to the given host name. See [DialContext] for details on how it works.
|
||||
func (opts TransportOptions) New() http.RoundTripper {
|
||||
if testenv.InTest() || envknob.NoLogsNoSupport() {
|
||||
return noopPretendSuccessTransport{}
|
||||
return NoopPretendSuccessTransport{}
|
||||
}
|
||||
if opts.NetMon == nil {
|
||||
opts.NetMon = netmon.NewStatic()
|
||||
@@ -935,9 +935,9 @@ func goVersion() string {
|
||||
return v
|
||||
}
|
||||
|
||||
type noopPretendSuccessTransport struct{}
|
||||
type NoopPretendSuccessTransport struct{}
|
||||
|
||||
func (noopPretendSuccessTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
func (NoopPretendSuccessTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
io.Copy(io.Discard, req.Body)
|
||||
req.Body.Close()
|
||||
return &http.Response{
|
||||
|
||||
@@ -772,6 +772,10 @@ func (s *Server) startLogger(closePool *closeOnErrorPool, health *health.Tracker
|
||||
HTTPC: &http.Client{Transport: logpolicy.NewLogtailTransport(logtail.DefaultHost, s.netMon, health, tsLogf)},
|
||||
MetricsDelta: clientmetric.EncodeLogTailMetricsDelta,
|
||||
}
|
||||
if envknob.NoLogsNoSupport() || testenv.InTest() {
|
||||
s.Logf("Tailscale logging is disabled by sing-box. Tailscale will not be able to provide support.")
|
||||
c.HTTPC = &http.Client{Transport: logpolicy.NoopPretendSuccessTransport{}}
|
||||
}
|
||||
s.logtail = logtail.NewLogger(c, tsLogf)
|
||||
closePool.addFunc(func() { s.logtail.Shutdown(context.Background()) })
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user