Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/tailscale/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"fmt"
"io"
"log"
"net"
"net/url"
"os"
"runtime"
"strings"
Expand Down Expand Up @@ -164,6 +166,19 @@ For help on subcommands, add --help after: "mirage status --help".
}

localClient.Socket = rootArgs.socket

/*
if the Socket is like http://ip:port then we try to connect plain
http to a remote tailscaled for debug, without authentication
*/
parsedUrl, err := url.Parse(rootArgs.socket)
if err == nil {
localClient.Dial = func(ctx context.Context, network, addr string) (net.Conn, error) {
var d net.Dialer
return d.DialContext(ctx, "tcp", parsedUrl.Host)
}
}

rootfs.Visit(func(f *flag.Flag) {
if f.Name == "socket" {
localClient.UseSocketOnly = true
Expand Down
20 changes: 15 additions & 5 deletions mirageclient-win/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"tailscale.com/envknob"
"tailscale.com/ipn/ipnlocal"
"tailscale.com/ipn/ipnserver"
"tailscale.com/ipn/localapi"
"tailscale.com/ipn/store"
"tailscale.com/logtail/backoff"
"tailscale.com/net/dns"
Expand Down Expand Up @@ -214,6 +215,13 @@ func StartDaemon(ctx context.Context, logf logger.Logf, logID string) error { //
if err == nil {
logf("got LocalBackend in %v", time.Since(t0).Round(time.Millisecond))
srv.SetLocalBackend(lb)
if debugMux != nil {
lah := localapi.NewHandler(lb, logf, logPubID)
lah.PermitWrite = true
lah.PermitRead = true

debugMux.Handle("/", lah)
}
return
}
lbErr.Store(err) // before the following cancel
Expand Down Expand Up @@ -250,13 +258,15 @@ func getLocalBackend(ctx context.Context, logf logger.Logf, logid logid.PublicID
if _, ok := e.(wgengine.ResolvingEngine).GetResolver(); !ok {
panic("internal error: exit node resolver not wired up")
}
if debugMux != nil && debugPort > 0 && debugPort < 65536 {
if ig, ok := e.(wgengine.InternalsGetter); ok {
if _, mc, _, ok := ig.GetInternals(); ok {
debugMux.HandleFunc("/debug/magicsock", mc.ServeHTTPDebug)
if debugMode {
if debugMux != nil && debugPort > 0 && debugPort < 65536 {
if ig, ok := e.(wgengine.InternalsGetter); ok {
if _, mc, _, ok := ig.GetInternals(); ok {
debugMux.HandleFunc("/debug/magicsock", mc.ServeHTTPDebug)
}
}
go runDebugServer(debugMux, ":"+strconv.FormatInt(debugPort, 10))
}
go runDebugServer(debugMux, ":"+strconv.FormatInt(debugPort, 10))
}

ns, err := newNetstack(logf, dialer, e)
Expand Down
1 change: 1 addition & 0 deletions mirageclient-win/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const defaultServerCode = "ipv4.uk"
const socketPath = `\\.\pipe\ProtectedPrefix\Administrators\Mirage\miraged`
const enginePort = 0 //0 -动态端口机制
const debugPort = 54321 // 调试信息页面端口
const debugMode = false // 是否开启调试模式

var programPath string = filepath.Join(os.Getenv("ProgramData"), serviceName)

Expand Down