chiark / gitweb /
Implement `keepalive' site option, to try to keep link always up.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 12 Sep 2015 15:17:51 +0000 (16:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 12 Sep 2015 15:18:45 +0000 (16:18 +0100)
README
debian/changelog
site.c

diff --git a/README b/README
index a01156c6d8a9491c12dfa7c946631c930d313f11..98ddec8793a49b7e0ea149bc808ed4dc123719b6 100644 (file)
--- a/README
+++ b/README
@@ -390,7 +390,7 @@ site: dict argument
     [half key-lifetime, or key-lifetime minus 5 mins (mobile: 12 hours),
      whichever is longer].
   keepalive (bool): if True then attempt always to keep a valid session key.
-    Not actually currently implemented. [false]
+    [false]
   log-events (string list): types of events to log for this site
     unexpected: unexpected key setup packets (may be late retransmissions)
     setup-init: start of attempt to setup a session key
index 95d45541ab9ad6864cdf7cf015188be7ea4a8462..d3be600bec498aa89056dcb648212335226997e3 100644 (file)
@@ -1,3 +1,9 @@
+secnet (0.4.1~~) unstable; urgency=medium
+
+  * Implement `keepalive' site option, to try to keep link always up.
+
+ --
+
 secnet (0.4.0) unstable; urgency=low
 
   Debugging improvements:
diff --git a/site.c b/site.c
index 70cc3166231df1cd1bcccf3943d6f3b87ef98c0f..db78d5f4ed27001d300951fa77784597096169ba 100644 (file)
--- a/site.c
+++ b/site.c
@@ -296,6 +296,7 @@ struct site {
 /* configuration information */
     string_t localname;
     string_t remotename;
+    bool_t keepalive;
     bool_t local_mobile, peer_mobile; /* Mobile client support */
     int32_t transport_peers_max;
     string_t tunname; /* localname<->remotename by default, used in logs */
@@ -1429,6 +1430,9 @@ static void enter_state_run(struct site *st)
     memset(st->dhsecret,0,st->dh->len);
     memset(st->sharedsecret,0,st->sharedsecretlen);
     set_link_quality(st);
+
+    if (st->keepalive && !current_valid(st))
+       initiate_key_setup(st, "keepalive", 0);
 }
 
 static bool_t ensure_resolving(struct site *st)
@@ -1967,6 +1971,8 @@ static list_t *site_apply(closure_t *self, struct cloc loc, dict_t *context,
     st->localname=dict_read_string(dict, "local-name", True, "site", loc);
     st->remotename=dict_read_string(dict, "name", True, "site", loc);
 
+    st->keepalive=dict_read_bool(dict,"keepalive",False,"site",loc,False);
+
     st->peer_mobile=dict_read_bool(dict,"mobile",False,"site",loc,False);
     st->local_mobile=
        dict_read_bool(dict,"local-mobile",False,"site",loc,False);