expose the connection kind to CustomClientAuthentication

Signed-off-by: R.I.Pienaar <rip@devco.net>
This commit is contained in:
R.I.Pienaar
2021-04-08 18:33:55 +02:00
parent c7f8296a85
commit f2d1a173db
2 changed files with 11 additions and 0 deletions

View File

@@ -47,6 +47,8 @@ type ClientAuthentication interface {
RegisterUser(*User)
// RemoteAddress expose the connection information of the client
RemoteAddress() net.Addr
// Kind indicates what type of connection this is matching defined constants like CLIENT, ROUTER, GATEWAY, LEAF etc
Kind() int
}
// NkeyUser is for multiple nkey based users

View File

@@ -643,6 +643,15 @@ func (c *client) reportErrRegisterAccount(acc *Account, err error) {
c.sendErr("Failed Account Registration")
}
// Kind returns the client kind and will be one of the defined constants like CLIENT, ROUTER, GATEWAY, LEAF
func (c *client) Kind() int {
c.mu.Lock()
kind := c.kind
c.mu.Unlock()
return kind
}
// registerWithAccount will register the given user with a specific
// account. This will change the subject namespace.
func (c *client) registerWithAccount(acc *Account) error {