mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
increase default timeout to ask for a rule
Explained here: https://github.com/gustavo-iniguez-goya/opensnitch/issues/28#issuecomment-637484501
This commit is contained in:
parent
36a11b4102
commit
78c0da83c0
4 changed files with 13 additions and 6 deletions
|
@ -199,8 +199,8 @@ func acceptOrDeny(packet *netfilter.Packet, con *conman.Connection) *rule.Rule {
|
|||
// UI client if connected and running
|
||||
r, connected = uiClient.Ask(con)
|
||||
if r == nil {
|
||||
log.Error("Invalid rule received, skipping")
|
||||
packet.SetVerdict(netfilter.NF_DROP)
|
||||
log.Error("Invalid rule received, applying default action")
|
||||
applyDefaultAction(packet)
|
||||
return nil
|
||||
}
|
||||
if connected {
|
||||
|
|
|
@ -83,6 +83,9 @@ func Deserialize(reply *protocol.Rule) *Rule {
|
|||
}
|
||||
|
||||
func (r *Rule) Serialize() *protocol.Rule {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
return &protocol.Rule{
|
||||
Name: string(r.Name),
|
||||
Enabled: bool(r.Enabled),
|
||||
|
|
|
@ -134,7 +134,7 @@ func (s *Statistics) onConnection(con *conman.Connection, match *rule.Rule, wasM
|
|||
s.RuleHits++
|
||||
}
|
||||
|
||||
if match.Action == rule.Allow {
|
||||
if wasMissed == false && match.Action == rule.Allow {
|
||||
s.Accepted++
|
||||
} else {
|
||||
s.Dropped++
|
||||
|
@ -155,6 +155,9 @@ func (s *Statistics) onConnection(con *conman.Connection, match *rule.Rule, wasM
|
|||
if nEvents == maxEvents {
|
||||
s.Events = s.Events[1:]
|
||||
}
|
||||
if wasMissed {
|
||||
return
|
||||
}
|
||||
s.Events = append(s.Events, NewEvent(con, match))
|
||||
}
|
||||
|
||||
|
|
|
@ -225,12 +225,13 @@ func (c *Client) Ask(con *conman.Connection) (*rule.Rule, bool) {
|
|||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
|
||||
// FIXME: if timeout is fired, the rule is not added to the list in the GUI
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*120)
|
||||
defer cancel()
|
||||
reply, err := c.client.AskRule(ctx, con.Serialize())
|
||||
if err != nil {
|
||||
log.Warning("Error while asking for rule: %s", err, con)
|
||||
return clientErrorRule, false
|
||||
log.Warning("Error while asking for rule: %s - %v", err, con)
|
||||
return nil, false
|
||||
}
|
||||
|
||||
return rule.Deserialize(reply), true
|
||||
|
|
Loading…
Add table
Reference in a new issue