Import code, preparing for release

This commit is contained in:
Cuong Manh Le
2022-12-12 21:24:20 +07:00
committed by Cuong Manh Le
parent cef3cc497e
commit 91d60d2a64
22 changed files with 2545 additions and 1 deletions

25
cmd/ctrld/os_linux.go Normal file
View File

@@ -0,0 +1,25 @@
package main
import (
"os/exec"
)
// allocate loopback ip
// sudo ip a add 127.0.0.2/24 dev lo
func allocateIP(ip string) error {
cmd := exec.Command("ip", "a", "add", ip+"/24", "dev", "lo")
if err := cmd.Run(); err != nil {
mainLog.Error().Err(err).Msg("allocateIP failed")
return err
}
return nil
}
func deAllocateIP(ip string) error {
cmd := exec.Command("ip", "a", "del", ip+"/24", "dev", "lo")
if err := cmd.Run(); err != nil {
mainLog.Error().Err(err).Msg("deAllocateIP failed")
return err
}
return nil
}