Some code reorg

This commit is contained in:
yo
2022-04-24 16:55:33 +02:00
parent 43f26d099f
commit e4fc9c3a6c
4 changed files with 50 additions and 43 deletions

View File

@ -229,12 +229,6 @@ func prepareJailedZfsDatasets(jail *Jail) error {
return nil
}
type NatDesc struct {
Proto string
JailPort string
HostPort string
}
// tcp(80:8080),tcp(3300-3310:33060-33070)
func getNatForwardsArray(nat_forwards string, decompose_range bool) ([]NatDesc, error) {
var res []NatDesc
@ -282,24 +276,6 @@ func getNatForwardsArray(nat_forwards string, decompose_range bool) ([]NatDesc,
return res, nil
}
func enableRcKeyValue(rcconfpath string, key string, value string) error {
cmd := fmt.Sprintf("/usr/sbin/sysrc -f %s %s=%s", rcconfpath, key, value)
_, err := executeCommand(cmd)
if err != nil {
return err
}
return nil
}
func disableRcKey(rcconfpath string, key string) error {
cmd := fmt.Sprintf("/usr/sbin/sysrc -f %s -x %s", rcconfpath, key)
_, err := executeCommand(cmd)
if err != nil {
return err
}
return nil
}
/*****************************************************************************
* Enable or disables DHCP or accept_rtadv for interfaces declared with this
* option
@ -433,25 +409,6 @@ func getJailsInUseIPv4() ([]string, error) {
return ips, nil
}
func getHostInUseIPv4() ([]string, error) {
var ips []string
re := regexp.MustCompile(ifconfigipv4re)
out, err := executeCommand("/sbin/ifconfig")
if err != nil {
return ips, fmt.Errorf("ERROR executing \"/sbin/ifconfig\": %s", err)
}
for _, line := range strings.Split(out, "\n") {
if re.MatchString(line) {
ips = append(ips, re.FindStringSubmatch(line)[1])
}
}
return ips, nil
}
func genNatIpv4(jail *Jail) ([]string, error) {
var ippair []string