fix: remove an agent's forward rules with the agent (0.0.4)
Deleting a machine left its forward rules behind: the host ports stayed bound and "busy" with no page to remove them from. The rules, their listeners and ufw rules now go with the agent, and rules orphaned by older versions are dropped on start. A host port equal to the direct tunnel port gets its own message.
This commit is contained in:
1 parent
328ade651c
commit
f3cb7701f2
4 files changed
+29
-7
No files matched your search
@@ -161,6 +161,12 @@ func (s *Server) restoreForwards() {
|
||||
return
|
||||
}
|
||||
for _, r := range rules {
|
||||
// Rules of an agent deleted by an older version: drop them.
|
||||
if a, err := s.db.GetAgent(r.AgentID); err == nil && a == nil {
|
||||
log.Printf("forward rule %d: agent %s is gone, removing", r.ID, r.AgentID)
|
||||
s.removeForward(r.ID)
|
||||
continue
|
||||
}
|
||||
if err := s.fwd.open(r); err != nil {
|
||||
log.Printf("restore forward rule %d (%s:%d): %v", r.ID, r.ListenAddr, r.HostPort, err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user