pull/16/head v0.0.2
Bruce Leidl 9 years ago
parent 7f94d3189e
commit 2d4c127f4e

@ -4,21 +4,21 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/op/go-logging"
"io/ioutil"
"net"
"strconv"
"strings"
"github.com/subgraph/fw-daemon/Godeps/_workspace/src/github.com/op/go-logging"
)
var log = logging.MustGetLogger("proc")
func SetLogger(logger *logging.Logger) {
log = logger
}
var pcache = &pidCache{}
func LookupUDPSocketProcess(srcPort uint16) *ProcInfo {
ss := findUDPSocket(srcPort)
if ss == nil {
@ -63,7 +63,6 @@ func (sa *socketAddr) parse(s string) error {
return nil
}
func ParseIp(ip string) (net.IP, error) {
var result net.IP
dst, err := hex.DecodeString(ip)
@ -145,7 +144,7 @@ func readConntrack() ([]*ConnectionInfo, error) {
}
var result []*ConnectionInfo
lines := strings.Split(string(data), "\n")
for _,line := range(lines) {
for _, line := range lines {
ci, err := parseConntrackLine(line)
if err != nil {
return nil, err

@ -1,17 +1,16 @@
package proc
import (
"fmt"
"io/ioutil"
"os"
"path"
"strconv"
"fmt"
"strings"
"path"
"io/ioutil"
"sync"
"syscall"
)
type ProcInfo struct {
Uid int
Pid int

@ -1,11 +1,12 @@
package proc
import (
"net"
"errors"
"fmt"
"io/ioutil"
"strings"
"errors"
"net"
"strconv"
"strings"
)
type socketAddr struct {
@ -83,7 +84,6 @@ func (ss *socketStatus) parseLine(line string) error {
return nil
}
func getSocketLines(proto string) []string {
path := fmt.Sprintf("/proc/net/%s", proto)
data, err := ioutil.ReadFile(path)

Loading…
Cancel
Save