mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Add SetSessionGatekeeper
This allows you to define a function which determines whether a session connection (either incoming or outgoing) is allowed based on the public key.
This commit is contained in:
parent
d4a3b2bc76
commit
720a078a35
2 changed files with 35 additions and 76 deletions
|
@ -395,6 +395,18 @@ func (c *Core) GetNodeInfo(keyString, coordString string, nocache bool) (NodeInf
|
|||
return NodeInfoPayload{}, errors.New(fmt.Sprintf("getNodeInfo timeout: %s", keyString))
|
||||
}
|
||||
|
||||
// SetSessionGatekeeper allows you to configure a handler function for deciding
|
||||
// whether a session should be allowed or not. The default session firewall is
|
||||
// implemented in this way. The function receives the public key of the remote
|
||||
// side, and a boolean which is true if we initiated the session or false if we
|
||||
// received an incoming session request.
|
||||
func (c *Core) SetSessionGatekeeper(f func(pubkey *crypto.BoxPubKey, initiator bool) bool) {
|
||||
c.sessions.isAllowedMutex.Lock()
|
||||
defer c.sessions.isAllowedMutex.Unlock()
|
||||
|
||||
c.sessions.isAllowedHandler = f
|
||||
}
|
||||
|
||||
// SetLogger sets the output logger of the Yggdrasil node after startup. This
|
||||
// may be useful if you want to redirect the output later.
|
||||
func (c *Core) SetLogger(log *log.Logger) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue