Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump braces from 3.0.2 to 3.0.3 in /client/web #1

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Prev Previous commit
Next Next commit
Export APIs
nekohasekai committed Nov 22, 2024
commit c54409144e619cfd8e8f8bc670d4d5eac8487bad
16 changes: 12 additions & 4 deletions ipn/ipnlocal/local.go
Original file line number Diff line number Diff line change
@@ -371,6 +371,10 @@ type LocalBackend struct {
// backend is healthy and captive portal detection is not required
// (sending false).
needsCaptiveDetection chan bool

cfg *wgcfg.Config
rcfg *router.Config
dcfg *dns.Config
}

// HealthTracker returns the health tracker for the backend.
@@ -486,10 +490,10 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo
}

netMon := sys.NetMon.Get()
b.sockstatLogger, err = sockstatlog.NewLogger(logpolicy.LogsDir(logf), logf, logID, netMon, sys.HealthTracker())
if err != nil {
log.Printf("error setting up sockstat logger: %v", err)
}
//b.sockstatLogger, err = sockstatlog.NewLogger(logpolicy.LogsDir(logf), logf, logID, netMon, sys.HealthTracker())
//if err != nil {
// log.Printf("error setting up sockstat logger: %v", err)
//}
// Enable sockstats logs only on non-mobile unstable builds
if version.IsUnstableBuild() && !version.IsMobile() && b.sockstatLogger != nil {
b.sockstatLogger.SetLoggingEnabled(true)
@@ -4261,6 +4265,10 @@ func (b *LocalBackend) authReconfig() {
}

b.initPeerAPIListener()

b.cfg = cfg
b.rcfg = rcfg
b.dcfg = dcfg
}

// shouldUseOneCGNATRoute reports whether we should prefer to make one big
18 changes: 18 additions & 0 deletions ipn/ipnlocal/local_export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ipnlocal

import (
"sync/atomic"

"github.com/sagernet/tailscale/net/dns"
"github.com/sagernet/tailscale/wgengine/filter"
"github.com/sagernet/tailscale/wgengine/router"
"github.com/sagernet/tailscale/wgengine/wgcfg"
)

func (b *LocalBackend) ExportFilter() *atomic.Pointer[filter.Filter] {
return &b.filterAtomic
}

func (b *LocalBackend) ExportConfig() (*wgcfg.Config, *dns.Config, *router.Config) {
return b.cfg, b.dcfg, b.rcfg
}
14 changes: 14 additions & 0 deletions tsnet/tsnet_export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package tsnet

import (
"github.com/sagernet/tailscale/ipn/ipnlocal"
"github.com/sagernet/tailscale/wgengine/netstack"
)

func (s *Server) ExportNetstack() *netstack.Impl {
return s.netstack
}

func (s *Server) ExportLocalBackend() *ipnlocal.LocalBackend {
return s.lb
}
10 changes: 10 additions & 0 deletions version/version_export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package version

import "github.com/sagernet/tailscale/types/lazy"

func SetVersion(version string) {
short = lazy.SyncValue[string]{}
short.MustSet(version)
long = lazy.SyncValue[string]{}
long.MustSet(version)
}
7 changes: 7 additions & 0 deletions wgengine/netstack/netstack_export.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package netstack

import "github.com/sagernet/gvisor/pkg/tcpip/stack"

func (ns *Impl) ExportIPStack() *stack.Stack {
return ns.ipstack
}