Skip to content

Commit

Permalink
address code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
klizhentas committed Jun 8, 2016
1 parent 2773a68 commit 84c12af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/auth/tun.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (

// dialRetryInterval specifies the time interval tun client waits to retry
// dialing the same auth server
const dialRetryInterval = time.Duration(time.Millisecond * 50)
const dialRetryInterval = time.Duration(time.Second)

// AuthTunnel listens on TCP/IP socket and accepts SSH connections. It then establishes
// an SSH tunnell which HTTP requests travel over. In other words, the Auth Service API
Expand Down
41 changes: 17 additions & 24 deletions lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,41 +332,35 @@ func (process *TeleportProcess) initAuthService(authority auth.Authority) error
auth.SetLimiter(limiter),
)
if err != nil {
utils.Consolef(cfg.Console, "[PROXY] Error: %v", err)
utils.Consolef(cfg.Console, "[AUTH] Error: %v", err)
return trace.Wrap(err)
}
if err := authTunnel.Start(); err != nil {
if askedToExit {
log.Infof("[PROXY] Auth Tunnel exited")
log.Infof("[AUTH] Auth Tunnel exited")
return nil
}
utils.Consolef(cfg.Console, "[PROXY] Error: %v", err)
utils.Consolef(cfg.Console, "[AUTH] Error: %v", err)
return trace.Wrap(err)
}
return nil
})

// Heart beat auth server presence, this is not the best place for this
// logic, consolidate it into auth package later
storage := utils.NewFileAddrStorage(
filepath.Join(process.Config.DataDir, "authservers.json"))
process.RegisterFunc(func() error {
// Heart beat auth server presence, this is not the best place for this
// logic, consolidate it into auth package later
connector, err := process.connectToAuthService(teleport.RoleAdmin)
if err != nil {
return trace.Wrap(err)
}
// External integrations rely on this event:
process.BroadcastEvent(Event{Name: AuthIdentityEvent, Payload: connector})
process.onExit(func(payload interface{}) {
connector.Client.Close()
})
return nil
})

authUser := identity.Cert.ValidPrincipals[0]
authClient, err := auth.NewTunClient(
string(teleport.RoleAuth),
process.Config.AuthServers,
authUser,
[]ssh.AuthMethod{ssh.PublicKeys(identity.KeySigner)},
auth.TunClientStorage(storage),
)
// success?
if err != nil {
return trace.Wrap(err)
}
process.BroadcastEvent(Event{Name: AuthIdentityEvent, Payload: &Connector{
Identity: identity,
Client: authClient,
}})
process.RegisterFunc(func() error {
srv := services.Server{
ID: process.Config.HostUUID,
Expand Down Expand Up @@ -409,7 +403,6 @@ func (process *TeleportProcess) initAuthService(authority auth.Authority) error
process.onExit(func(payload interface{}) {
askedToExit = true
authTunnel.Close()
authClient.Close()
log.Infof("[AUTH] auth service exited")
})
return nil
Expand Down

0 comments on commit 84c12af

Please sign in to comment.