Add support for backfillips
This commit is contained in:
parent
4fb45c41bd
commit
bdba6db42d
|
@ -14,12 +14,10 @@ function renameNode(nodeId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPKA(username) {
|
function createPKA(username) {
|
||||||
console.log(username);
|
|
||||||
var url = `${username}/pakcreate`;
|
var url = `${username}/pakcreate`;
|
||||||
var ephemereal = $("#ephemereal").is(":checked");
|
var ephemereal = $("#ephemereal").is(":checked");
|
||||||
var reusable = $("#reusable").is(":checked");
|
var reusable = $("#reusable").is(":checked");
|
||||||
var expiration = $("#expiration").val();
|
var expiration = $("#expiration").val();
|
||||||
console.log(expiration);
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -65,3 +63,29 @@ function toggleExpired(obj) {
|
||||||
$(".pka-expired").addClass("pka-hide");
|
$(".pka-expired").addClass("pka-hide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function backfillips(obj) {
|
||||||
|
var url = "backfillips";
|
||||||
|
var button = $(obj);
|
||||||
|
var original = button.html();
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
method: "POST",
|
||||||
|
dataType: "json",
|
||||||
|
contentType: "application/json; charset=utf-8",
|
||||||
|
xhrFields: {
|
||||||
|
withCredentials: true,
|
||||||
|
},
|
||||||
|
data: {},
|
||||||
|
success: function (data) {
|
||||||
|
if (data.length) {
|
||||||
|
button.html("Updated");
|
||||||
|
} else {
|
||||||
|
button.html("Done");
|
||||||
|
}
|
||||||
|
setTimeout(function () {
|
||||||
|
button.html(original);
|
||||||
|
}, 500);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="row data justify-content-between">
|
||||||
|
<div class="col col-4">
|
||||||
<h3>nodes</h3>
|
<h3>nodes</h3>
|
||||||
|
</div>
|
||||||
|
<div class="col col-2">
|
||||||
|
<span data-toggle="tooltip" data-placement="right" title="Recheck all IP addresses of all nodes">
|
||||||
|
<button type="button" class="btn btn-outline-primary btn-sm" onClick="backfillips(this);">Backfill IP addresses</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<p></p>
|
<p></p>
|
||||||
<table id="nodes" class="display" style="width:100%">
|
<table id="nodes" class="display" style="width:100%">
|
||||||
|
|
|
@ -9,6 +9,7 @@ from flask import jsonify
|
||||||
from hsapi_client import Node, User, Route, PreAuthKey
|
from hsapi_client import Node, User, Route, PreAuthKey
|
||||||
from hsapi_client.preauthkeys import (v1CreatePreAuthKeyRequest,
|
from hsapi_client.preauthkeys import (v1CreatePreAuthKeyRequest,
|
||||||
v1ExpirePreAuthKeyRequest)
|
v1ExpirePreAuthKeyRequest)
|
||||||
|
from hsapi_client.nodes import v1BackfillNodeIPsResponse
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
|
@ -104,3 +105,10 @@ def expirePKA(userName: str, key: str):
|
||||||
|
|
||||||
PreAuthKey().expire(req)
|
PreAuthKey().expire(req)
|
||||||
return redirect(url_for('main.user', userName=userName))
|
return redirect(url_for('main.user', userName=userName))
|
||||||
|
|
||||||
|
|
||||||
|
@rest_blueprint.route('/backfillips', methods=['POST'])
|
||||||
|
@auth.authorize_admins('default')
|
||||||
|
def backfillips():
|
||||||
|
response = Node().backfillips()
|
||||||
|
return jsonify(response.changes)
|
||||||
|
|
|
@ -452,13 +452,13 @@ files = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hsapi-client"
|
name = "hsapi-client"
|
||||||
version = "0.9.6"
|
version = "0.9.7"
|
||||||
description = "Headscale API client"
|
description = "Headscale API client"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "<4.0,>=3.11"
|
python-versions = "<4.0,>=3.11"
|
||||||
files = [
|
files = [
|
||||||
{file = "hsapi_client-0.9.6-py3-none-any.whl", hash = "sha256:441cd219a2384f66511b8cca21224171b4e6753d16d364d984eb9887aa686a6c"},
|
{file = "hsapi_client-0.9.7-py3-none-any.whl", hash = "sha256:6cd8ac2a787112a02d7d5d3e029ceba0749844806b20b3c27247393cccd53def"},
|
||||||
{file = "hsapi_client-0.9.6.tar.gz", hash = "sha256:b6a4183fb9cdf95b0e864eec5b79ea18843e25379f928c4770b68e4f1ce8334b"},
|
{file = "hsapi_client-0.9.7.tar.gz", hash = "sha256:7a6bf7cb533a4f0431c322bc292f09559eb27b37177ea2101a6ea559dc0c9e47"},
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "hsman"
|
name = "hsman"
|
||||||
version = "0.9.15"
|
version = "0.9.16"
|
||||||
description = "Flask Admin webui for Headscale"
|
description = "Flask Admin webui for Headscale"
|
||||||
authors = ["Andrea Mistrali <andrea@mistrali.pw>"]
|
authors = ["Andrea Mistrali <andrea@mistrali.pw>"]
|
||||||
license = "BSD"
|
license = "BSD"
|
||||||
|
|
Loading…
Reference in New Issue