Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Sep 5, 2023
1 parent 69c9547 commit 4bdfde3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Dockerfile.tailscale-HEAD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ RUN apt-get update \

RUN useradd --shell=/bin/bash --create-home ssh-it-user

RUN git clone https://github.com/tailscale/tailscale.git
# RUN git clone https://github.com/tailscale/tailscale.git
COPY tailscale /go/tailscale

WORKDIR /go/tailscale

Expand Down
5 changes: 4 additions & 1 deletion hscontrol/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ import (
"tailscale.com/tailcfg"
"tailscale.com/types/dnstype"
"tailscale.com/types/key"

Check failure on line 52 in hscontrol/app.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gci`-ed with --skip-generated -s standard,default (gci)
_ "net/http/pprof"

Check failure on line 53 in hscontrol/app.go

View workflow job for this annotation

GitHub Actions / golangci-lint

G108: Profiling endpoint is automatically exposed on /debug/pprof (gosec)
)

var (
Expand Down Expand Up @@ -93,7 +95,7 @@ type Headscale struct {
shutdownChan chan struct{}
pollNetMapStreamWG sync.WaitGroup

pollStreamOpenMu sync.Mutex
// pollStreamOpenMu sync.Mutex
}

func NewHeadscale(cfg *types.Config) (*Headscale, error) {
Expand Down Expand Up @@ -439,6 +441,7 @@ func (h *Headscale) ensureUnixSocketIsAbsent() error {

func (h *Headscale) createRouter(grpcMux *runtime.ServeMux) *mux.Router {
router := mux.NewRouter()
router.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)

router.HandleFunc(ts2021UpgradePath, h.NoiseUpgradeHandler).Methods(http.MethodPost)

Expand Down
6 changes: 6 additions & 0 deletions hscontrol/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ func (h *Headscale) handleRegister(
isNoise bool,
) {
now := time.Now().UTC()
log.Trace().Msg("STEP 2")
machine, err := h.db.GetMachineByAnyKey(machineKey, registerRequest.NodeKey, registerRequest.OldNodeKey)
log.Trace().Msg("STEP 3")
if errors.Is(err, gorm.ErrRecordNotFound) {
log.Trace().Msg("STEP 4")
// If the machine has AuthKey set, handle registration via PreAuthKeys
if registerRequest.Auth.AuthKey != "" {
log.Trace().Msg("STEP 5")
h.handleAuthKey(writer, registerRequest, machineKey, isNoise)

return
Expand Down Expand Up @@ -236,7 +240,9 @@ func (h *Headscale) handleAuthKey(
Msgf("Processing auth key for %s", registerRequest.Hostinfo.Hostname)
resp := tailcfg.RegisterResponse{}

log.Trace().Msg("STEP 5")
pak, err := h.db.ValidatePreAuthKey(registerRequest.Auth.AuthKey)
log.Trace().Msg("STEP 6")
if err != nil {
log.Error().
Caller().
Expand Down
3 changes: 3 additions & 0 deletions hscontrol/auth_noise.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func (ns *noiseServer) NoiseRegistrationHandler(

log.Trace().
Any("headers", req.Header).
Caller().
Msg("Headers")

body, _ := io.ReadAll(req.Body)
Expand All @@ -40,5 +41,7 @@ func (ns *noiseServer) NoiseRegistrationHandler(

ns.nodeKey = registerRequest.NodeKey

log.Trace().Msg("STEP 1")

ns.headscale.handleRegister(writer, req, registerRequest, ns.conn.Peer(), true)
}
6 changes: 3 additions & 3 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (h *Headscale) handlePoll(
// following updates missing
var updateChan chan types.StateUpdate
if mapRequest.Stream {
h.pollStreamOpenMu.Lock()
// h.pollStreamOpenMu.Lock()
h.pollNetMapStreamWG.Add(1)
defer h.pollNetMapStreamWG.Done()

Expand Down Expand Up @@ -233,6 +233,8 @@ func (h *Headscale) handlePoll(
return
}

// h.pollStreamOpenMu.Unlock()

// Send the client an update to make sure we send an initial mapresponse
_, err = writer.Write(mapResp)
if err != nil {
Expand All @@ -254,8 +256,6 @@ func (h *Headscale) handlePoll(
ctx, cancel := context.WithCancel(ctx)
defer cancel()

h.pollStreamOpenMu.Unlock()

for {
logInfo("Waiting for update on stream channel")
select {
Expand Down
1 change: 1 addition & 0 deletions hscontrol/poll_noise.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func (ns *noiseServer) NoisePollNetMapHandler(

log.Trace().
Any("headers", req.Header).
Caller().
Msg("Headers")

body, _ := io.ReadAll(req.Body)
Expand Down
2 changes: 1 addition & 1 deletion integration/tsic/tsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func (t *TailscaleInContainer) Login(
)
}

if _, _, err := t.Execute(command); err != nil {
if _, _, err := t.Execute(command, dockertestutil.ExecuteCommandTimeout(60*time.Second)); err != nil {

Check failure on line 364 in integration/tsic/tsic.go

View workflow job for this annotation

GitHub Actions / golangci-lint

mnd: Magic number: 60, in <argument> detected (gomnd)
return fmt.Errorf(
"%s failed to join tailscale client (%s): %w",
t.hostname,
Expand Down

0 comments on commit 4bdfde3

Please sign in to comment.