mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-18 08:16:39 +00:00
Merge branch 'main' into feature/peer-approval
This commit is contained in:
@@ -290,11 +290,13 @@ func toPolicyResponse(account *server.Account, policy *server.Policy) *api.Polic
|
||||
Enabled: policy.Enabled,
|
||||
}
|
||||
for _, r := range policy.Rules {
|
||||
rID := r.ID
|
||||
rDescription := r.Description
|
||||
rule := api.PolicyRule{
|
||||
Id: &r.ID,
|
||||
Id: &rID,
|
||||
Name: r.Name,
|
||||
Enabled: r.Enabled,
|
||||
Description: &r.Description,
|
||||
Description: &rDescription,
|
||||
Bidirectional: r.Bidirectional,
|
||||
Protocol: api.PolicyRuleProtocol(r.Protocol),
|
||||
Action: api.PolicyRuleAction(r.Action),
|
||||
|
||||
@@ -390,14 +390,18 @@ func getMinMaxVersion(inputList []string) (string, string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
switch len(versions) {
|
||||
|
||||
targetIndex := 1
|
||||
l := len(versions)
|
||||
|
||||
switch l {
|
||||
case 0:
|
||||
return "", ""
|
||||
case 1:
|
||||
v := versions[0].String()
|
||||
case targetIndex:
|
||||
v := versions[targetIndex-1].String()
|
||||
return v, v
|
||||
default:
|
||||
sort.Sort(version.Collection(versions))
|
||||
return versions[0].String(), versions[len(versions)-1].String()
|
||||
return versions[targetIndex-1].String(), versions[l-1].String()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,6 +354,7 @@ func (am *DefaultAccountManager) AddPeer(setupKey, userID string, peer *nbpeer.P
|
||||
}
|
||||
|
||||
var ephemeral bool
|
||||
setupKeyName := ""
|
||||
if !addedByUser {
|
||||
// validate the setup key if adding with a key
|
||||
sk, err := account.FindSetupKey(upperKey)
|
||||
@@ -369,6 +370,7 @@ func (am *DefaultAccountManager) AddPeer(setupKey, userID string, peer *nbpeer.P
|
||||
opEvent.InitiatorID = sk.Id
|
||||
opEvent.Activity = activity.PeerAddedWithSetupKey
|
||||
ephemeral = sk.Ephemeral
|
||||
setupKeyName = sk.Name
|
||||
} else {
|
||||
opEvent.InitiatorID = userID
|
||||
opEvent.Activity = activity.PeerAddedByUser
|
||||
@@ -447,6 +449,9 @@ func (am *DefaultAccountManager) AddPeer(setupKey, userID string, peer *nbpeer.P
|
||||
|
||||
opEvent.TargetID = newPeer.ID
|
||||
opEvent.Meta = newPeer.EventMeta(am.GetDNSDomain())
|
||||
if !addedByUser {
|
||||
opEvent.Meta["setup_key_name"] = setupKeyName
|
||||
}
|
||||
|
||||
am.StoreEvent(opEvent.InitiatorID, opEvent.TargetID, opEvent.AccountID, opEvent.Activity, opEvent.Meta)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user