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

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

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

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

Loading…
Cancel
Save