Skip to content

Commit

Permalink
Merge pull request #2465 from freifunk-gluon/respondd-fastd-method
Browse files Browse the repository at this point in the history
gluon-mesh-vpn-fastd: Expose negotiated method
  • Loading branch information
blocktrron authored Jan 11, 2024
2 parents d9c6463 + 9fc4918 commit 5eb15ac
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion package/gluon-mesh-vpn-fastd/src/respondd.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static bool get_peer_connection(struct json_object **ret, struct json_object *co
if (!key)
return false;

struct json_object *peer, *connection, *established;
struct json_object *peer, *connection, *established, *method;
if (!json_object_object_get_ex(peers, key, &peer) ||
!json_object_object_get_ex(peer, "connection", &connection))
return false;
Expand All @@ -229,6 +229,10 @@ static bool get_peer_connection(struct json_object **ret, struct json_object *co
struct json_object *jso = json_object_new_double(established_time/1000.0);
json_object_set_serializer(jso, json_object_double_to_json_string, "%.3f", NULL);
json_object_object_add(*ret, "established", jso);

if (json_object_object_get_ex(connection, "method", &method)) {
json_object_object_add(*ret, "method", json_object_get(method));
}
}
else {
*ret = NULL;
Expand Down
8 changes: 5 additions & 3 deletions package/gluon-status-page/javascript/status-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@
tr.appendChild(th);

var td = document.createElement('td');
if (peer[1] && peer[1].established != null)
td.textContent = _['connected'] + ' (' + formats.time(peer[1].established) + ')';
else
if (peer[1] && peer[1].established != null) {
var method = peer[1].method ? ', ' + peer[1].method : '';
td.textContent = _['connected'] + ' (' + formats.time(peer[1].established) + method + ')';
} else {
td.textContent = _['not connected'];
}
tr.appendChild(td);

tbody.appendChild(tr);
Expand Down
2 changes: 1 addition & 1 deletion package/gluon-status-page/javascript/status-page.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5eb15ac

Please sign in to comment.