* feat(api): sandbox default network limited egress Signed-off-by: Toma Puljak <toma.puljak@hotmail.com> * feat: egress network limiter Signed-off-by: Goran Draganic <goran@daytona.io> * feat(docs): added network limits docs Signed-off-by: Bruno Grbavac <bruno.grbavac@outlook.com> * fix(docs): added essential services list to firewall docs Signed-off-by: Bruno Grbavac <bruno.grbavac@outlook.com> --------- Signed-off-by: Toma Puljak <toma.puljak@hotmail.com> Signed-off-by: Goran Draganic <goran@daytona.io> Signed-off-by: Bruno Grbavac <bruno.grbavac@outlook.com> Co-authored-by: Toma Puljak <toma.puljak@hotmail.com> Co-authored-by: Bruno Grbavac <bruno.grbavac@outlook.com>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
// Copyright 2025 Daytona Platforms Inc.
|
|
// SPDX-License-Identifier: AGPL-3.0
|
|
|
|
package netrules
|
|
|
|
import "strings"
|
|
|
|
// DeleteNetworkRules completely removes network rules for a container
|
|
func (manager *NetRulesManager) DeleteNetworkRules(name string) error {
|
|
// Add prefix to chain name
|
|
chainName := formatChainName(name)
|
|
|
|
manager.mu.Lock()
|
|
defer manager.mu.Unlock()
|
|
|
|
// First unassign the rules from the container (atomic within the same mutex)
|
|
rules, err := manager.ipt.List("filter", "DOCKER-USER")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Find and remove rules that reference our chain
|
|
for _, rule := range rules {
|
|
if strings.Contains(rule, chainName) {
|
|
// Parse the rule to extract arguments
|
|
args, err := ParseRuleArguments(rule)
|
|
if err != nil {
|
|
// Skip malformed rules
|
|
continue
|
|
}
|
|
|
|
if err := manager.ipt.Delete("filter", "DOCKER-USER", args...); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
|
|
// Then delete the chain and all its rules
|
|
return manager.ipt.ClearAndDeleteChain("filter", chainName)
|
|
}
|