@@ -17,7 +17,6 @@ import (
1717 nberrors "github.com/netbirdio/netbird/client/errors"
1818 firewall "github.com/netbirdio/netbird/client/firewall/manager"
1919 "github.com/netbirdio/netbird/client/internal/acl/id"
20- "github.com/netbirdio/netbird/client/ssh"
2120 "github.com/netbirdio/netbird/management/domain"
2221 mgmProto "github.com/netbirdio/netbird/management/proto"
2322)
@@ -86,30 +85,8 @@ func (d *DefaultManager) ApplyFiltering(networkMap *mgmProto.NetworkMap, dnsRout
8685}
8786
8887func (d * DefaultManager ) applyPeerACLs (networkMap * mgmProto.NetworkMap ) {
89- rules , squashedProtocols := d .squashAcceptRules (networkMap )
88+ rules := d .squashAcceptRules (networkMap )
9089
91- enableSSH := networkMap .PeerConfig != nil &&
92- networkMap .PeerConfig .SshConfig != nil &&
93- networkMap .PeerConfig .SshConfig .SshEnabled
94- if _ , ok := squashedProtocols [mgmProto .RuleProtocol_ALL ]; ok {
95- enableSSH = enableSSH && ! ok
96- }
97- if _ , ok := squashedProtocols [mgmProto .RuleProtocol_TCP ]; ok {
98- enableSSH = enableSSH && ! ok
99- }
100-
101- // if TCP protocol rules not squashed and SSH enabled
102- // we add default firewall rule which accepts connection to any peer
103- // in the network by SSH (TCP 22 port).
104- if enableSSH {
105- rules = append (rules , & mgmProto.FirewallRule {
106- PeerIP : "0.0.0.0" ,
107- Direction : mgmProto .RuleDirection_IN ,
108- Action : mgmProto .RuleAction_ACCEPT ,
109- Protocol : mgmProto .RuleProtocol_TCP ,
110- Port : strconv .Itoa (ssh .DefaultSSHPort ),
111- })
112- }
11390
11491 // if we got empty rules list but management not set networkMap.FirewallRulesIsEmpty flag
11592 // we have old version of management without rules handling, we should allow all traffic
@@ -373,9 +350,7 @@ func (d *DefaultManager) getPeerRuleID(
373350//
374351// NOTE: It will not squash two rules for same protocol if one covers all peers in the network,
375352// but other has port definitions or has drop policy.
376- func (d * DefaultManager ) squashAcceptRules (
377- networkMap * mgmProto.NetworkMap ,
378- ) ([]* mgmProto.FirewallRule , map [mgmProto.RuleProtocol ]struct {}) {
353+ func (d * DefaultManager ) squashAcceptRules (networkMap * mgmProto.NetworkMap , ) []* mgmProto.FirewallRule {
379354 totalIPs := 0
380355 for _ , p := range append (networkMap .RemotePeers , networkMap .OfflinePeers ... ) {
381356 for range p .AllowedIps {
@@ -479,11 +454,11 @@ func (d *DefaultManager) squashAcceptRules(
479454
480455 // if all protocol was squashed everything is allow and we can ignore all other rules
481456 if _ , ok := squashedProtocols [mgmProto .RuleProtocol_ALL ]; ok {
482- return squashedRules , squashedProtocols
457+ return squashedRules
483458 }
484459
485460 if len (squashedRules ) == 0 {
486- return networkMap .FirewallRules , squashedProtocols
461+ return networkMap .FirewallRules
487462 }
488463
489464 var rules []* mgmProto.FirewallRule
@@ -500,7 +475,7 @@ func (d *DefaultManager) squashAcceptRules(
500475 rules = append (rules , r )
501476 }
502477
503- return append (rules , squashedRules ... ), squashedProtocols
478+ return append (rules , squashedRules ... )
504479}
505480
506481// getRuleGroupingSelector takes all rule properties except IP address to build selector
0 commit comments