Skip to content

Commit 44b2590

Browse files
refactor: remove dead code
1 parent 29d30b8 commit 44b2590

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

jail/linux.go

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
// LinuxJail implements Jailer using Linux network namespaces
1818
type LinuxJail struct {
1919
logger *slog.Logger
20-
namespace string
2120
vethHostName string // Host-side veth interface name for iptables rules
2221
vethJailName string // Jail-side veth interface name for iptables rules
2322
commandEnv []string
@@ -33,7 +32,6 @@ type LinuxJail struct {
3332
func NewLinuxJail(config Config) (*LinuxJail, error) {
3433
return &LinuxJail{
3534
logger: config.Logger,
36-
namespace: newNamespaceName(),
3735
httpProxyPort: config.HttpProxyPort,
3836
configDir: config.ConfigDir,
3937
caCertPath: config.CACertPath,
@@ -63,7 +61,7 @@ func (l *LinuxJail) ConfigureBeforeCommandExecution() error {
6361

6462
// Command returns an exec.Cmd configured to run within the network namespace.
6563
func (l *LinuxJail) Command(command []string) *exec.Cmd {
66-
l.logger.Debug("Creating command with namespace", "namespace", l.namespace)
64+
l.logger.Debug("Creating command with namespace")
6765

6866
cmd := exec.Command(command[0], command[1:]...)
6967
cmd.Env = l.commandEnv
@@ -114,30 +112,6 @@ func (l *LinuxJail) Close() error {
114112
// Continue with other cleanup even if this fails
115113
}
116114

117-
// Clean up namespace-specific DNS config directory
118-
netnsEtc := fmt.Sprintf("/etc/netns/%s", l.namespace)
119-
err = os.RemoveAll(netnsEtc)
120-
if err != nil {
121-
l.logger.Warn("Failed to remove namespace DNS config", "dir", netnsEtc, "error", err)
122-
// Continue with other cleanup
123-
}
124-
125-
// Remove network namespace
126-
err = l.removeNamespace()
127-
if err != nil {
128-
return fmt.Errorf("failed to remove namespace: %v", err)
129-
}
130-
131-
return nil
132-
}
133-
134-
// removeNamespace removes the network namespace
135-
func (l *LinuxJail) removeNamespace() error {
136-
cmd := exec.Command("ip", "netns", "del", l.namespace)
137-
err := cmd.Run()
138-
if err != nil {
139-
return fmt.Errorf("failed to remove namespace: %v", err)
140-
}
141115
return nil
142116
}
143117

0 commit comments

Comments
 (0)