mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Optional peer authentication, if non-empty then incoming TCP and all UDP peers must match one of these box keys
This commit is contained in:
parent
5962d009a5
commit
6026e0a014
6 changed files with 45 additions and 7 deletions
|
@ -30,9 +30,10 @@ import "math"
|
|||
//import "fmt"
|
||||
|
||||
type peers struct {
|
||||
core *Core
|
||||
mutex sync.Mutex // Synchronize writes to atomic
|
||||
ports atomic.Value //map[Port]*peer, use CoW semantics
|
||||
core *Core
|
||||
authBoxPubs map[boxPubKey]struct{}
|
||||
mutex sync.Mutex // Synchronize writes to atomic
|
||||
ports atomic.Value //map[Port]*peer, use CoW semantics
|
||||
//ports map[Port]*peer
|
||||
}
|
||||
|
||||
|
@ -41,6 +42,12 @@ func (ps *peers) init(c *Core) {
|
|||
defer ps.mutex.Unlock()
|
||||
ps.putPorts(make(map[switchPort]*peer))
|
||||
ps.core = c
|
||||
ps.authBoxPubs = make(map[boxPubKey]struct{})
|
||||
}
|
||||
|
||||
func (ps *peers) isAuthBoxPub(box *boxPubKey) bool {
|
||||
_, isIn := ps.authBoxPubs[*box]
|
||||
return isIn || len(ps.authBoxPubs) == 0
|
||||
}
|
||||
|
||||
func (ps *peers) getPorts() map[switchPort]*peer {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue