dospin/net_freebsd.go

33 lines
725 B
Go
Raw Normal View History

2016-02-26 17:35:57 -06:00
/*
Copyright 2016 gtalent2@gmail.com
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
2016-02-14 23:38:28 -06:00
package main
import (
"bytes"
"log"
"os/exec"
"strconv"
)
2016-02-14 23:38:28 -06:00
func setupPortForward(ip, port string) {
}
2016-02-27 18:15:37 -06:00
func portUsageCount(ports ...int) int {
2016-02-28 01:05:30 -06:00
cmd := "/usr/bin/sockstat"
args := []string{"-4c"}
2016-02-27 18:15:37 -06:00
for _, v := range ports {
2016-02-28 01:05:30 -06:00
args = append(args, "-p")
args = append(args, strconv.Itoa(v))
2016-02-27 18:15:37 -06:00
}
2016-02-28 01:05:30 -06:00
out, err := exec.Command(cmd, args...).Output()
2016-02-27 18:15:37 -06:00
if err != nil {
2016-02-28 01:05:30 -06:00
log.Println("Port Usage Check: Could not run \""+cmd+"\":", err)
2016-02-27 18:15:37 -06:00
}
return bytes.Count(out, []byte{'\n'}) - 1
}