pull/41/head
xSmurf 8 years ago
parent f750840b23
commit 2e6f98e410

@ -28,7 +28,7 @@ func (ob *dbusObject) isEnabled() (bool, error) {
func (ob *dbusObject) listRules() ([]sgfw.DbusRule, error) { func (ob *dbusObject) listRules() ([]sgfw.DbusRule, error) {
rules := []sgfw.DbusRule{} rules := []sgfw.DbusRule{}
err := ob.Call("com.subgraph.Firewall.ListRules", 0).Store(&rules); err := ob.Call("com.subgraph.Firewall.ListRules", 0).Store(&rules)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -111,9 +111,9 @@ func (rr *ruleRow) update() {
func getVerbText(rule *sgfw.DbusRule) string { func getVerbText(rule *sgfw.DbusRule) string {
if sgfw.RuleAction(rule.Verb) == sgfw.RULE_ACTION_ALLOW { if sgfw.RuleAction(rule.Verb) == sgfw.RULE_ACTION_ALLOW {
return sgfw.RuleActionString[sgfw.RULE_ACTION_ALLOW]+ ":" return sgfw.RuleActionString[sgfw.RULE_ACTION_ALLOW] + ":"
} }
return sgfw.RuleActionString[sgfw.RULE_ACTION_DENY]+ ":" return sgfw.RuleActionString[sgfw.RULE_ACTION_DENY] + ":"
} }
func getTargetText(rule *sgfw.DbusRule) string { func getTargetText(rule *sgfw.DbusRule) string {

@ -6,7 +6,7 @@ import (
const ( const (
STR_REDACTED = "[redacted]" STR_REDACTED = "[redacted]"
STR_UNKNOWN = "[uknown]" STR_UNKNOWN = "[uknown]"
) )
type RuleAction uint16 type RuleAction uint16
@ -16,14 +16,14 @@ const (
RULE_ACTION_ALLOW RULE_ACTION_ALLOW
) )
var RuleActionString = map[RuleAction]string { var RuleActionString = map[RuleAction]string{
RULE_ACTION_DENY: "DENY", RULE_ACTION_DENY: "DENY",
RULE_ACTION_ALLOW: "ALLOW", RULE_ACTION_ALLOW: "ALLOW",
} }
var RuleActionValue = map[string]RuleAction { var RuleActionValue = map[string]RuleAction{
"DENY": RULE_ACTION_DENY, "DENY": RULE_ACTION_DENY,
"ALLOW": RULE_ACTION_ALLOW, "ALLOW": RULE_ACTION_ALLOW,
} }
type RuleMode uint16 type RuleMode uint16
@ -34,39 +34,38 @@ const (
RULE_MODE_SYSTEM RULE_MODE_SYSTEM
) )
var RuleModeString = map[RuleMode]string { var RuleModeString = map[RuleMode]string{
RULE_MODE_SESSION: "SESSION", RULE_MODE_SESSION: "SESSION",
RULE_MODE_PERMANENT: "PERMANENT", RULE_MODE_PERMANENT: "PERMANENT",
RULE_MODE_SYSTEM: "SYSTEM", RULE_MODE_SYSTEM: "SYSTEM",
} }
var RuleModeValue = map[string]RuleMode { var RuleModeValue = map[string]RuleMode{
"SESSION": RULE_MODE_SESSION, "SESSION": RULE_MODE_SESSION,
"PERMANENT": RULE_MODE_PERMANENT, "PERMANENT": RULE_MODE_PERMANENT,
"SYSTEM": RULE_MODE_SYSTEM, "SYSTEM": RULE_MODE_SYSTEM,
} }
type FilterScope uint16 type FilterScope uint16
const ( const (
APPLY_ONCE FilterScope = iota APPLY_ONCE FilterScope = iota
APPLY_SESSION APPLY_SESSION
APPLY_FOREVER APPLY_FOREVER
) )
var FilterScopeString = map[FilterScope]string { var FilterScopeString = map[FilterScope]string{
APPLY_ONCE: "ONCE", APPLY_ONCE: "ONCE",
APPLY_SESSION: "SESSION", APPLY_SESSION: "SESSION",
APPLY_FOREVER: "FOREVER", APPLY_FOREVER: "FOREVER",
} }
var FilterScopeValue = map[string]FilterScope { var FilterScopeValue = map[string]FilterScope{
"ONCE": APPLY_ONCE, "ONCE": APPLY_ONCE,
"SESSION": APPLY_SESSION, "SESSION": APPLY_SESSION,
"FOREVER": APPLY_FOREVER, "FOREVER": APPLY_FOREVER,
} }
func GetFilterScopeString(scope FilterScope) string { func GetFilterScopeString(scope FilterScope) string {
if val, ok := FilterScopeString[scope]; ok { if val, ok := FilterScopeString[scope]; ok {
return val return val
@ -91,14 +90,14 @@ const (
) )
var FilterResultString = map[FilterResult]string{ var FilterResultString = map[FilterResult]string{
FILTER_DENY: "DENY", FILTER_DENY: "DENY",
FILTER_ALLOW: "ALLOW", FILTER_ALLOW: "ALLOW",
FILTER_PROMPT: "PROMPT", FILTER_PROMPT: "PROMPT",
} }
var FilterResultValue = map[string]FilterResult { var FilterResultValue = map[string]FilterResult{
"DENY": FILTER_DENY, "DENY": FILTER_DENY,
"ALLOW": FILTER_ALLOW, "ALLOW": FILTER_ALLOW,
"PROMPT": FILTER_PROMPT, "PROMPT": FILTER_PROMPT,
} }

@ -247,7 +247,7 @@ func printPacket(pkt *nfqueue.Packet, hostname string, pinfo *procsnitch.Info) s
if name == "" { if name == "" {
name = pkt.Dst.String() name = pkt.Dst.String()
} }
if (pinfo == nil) { if pinfo == nil {
return fmt.Sprintf("(%s %s:%d -> %s:%d)", proto, pkt.Src, pkt.SrcPort, name, pkt.DstPort) return fmt.Sprintf("(%s %s:%d -> %s:%d)", proto, pkt.Src, pkt.SrcPort, name, pkt.DstPort)
} else { } else {
return fmt.Sprintf("%s %s %s:%d -> %s:%d", pinfo.ExePath, proto, pkt.Src, pkt.SrcPort, name, pkt.DstPort) return fmt.Sprintf("%s %s %s:%d -> %s:%d", pinfo.ExePath, proto, pkt.Src, pkt.SrcPort, name, pkt.DstPort)

Loading…
Cancel
Save