Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deleting of IPv6 route #75

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/controllers/zt.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,9 @@ exports.routes = async function(nwid, route, action) {

const network = await network_detail(nwid);
let routes = network.routes;
const target6 = new ipaddr.Address6(route.target);
if (target6.isValid()) {
const parts = route.target.split('/');
route.target = target6.canonicalForm() + '/' + parts[1];
}
route.target = canonicalTarget(route.target);

const route_to_del = routes.find(rt => rt.target === route.target);
const route_to_del = routes.find(rt => canonicalTarget(rt.target) === route.target);

if (!route_to_del) {
if (action === 'add') {
Expand Down Expand Up @@ -220,6 +216,15 @@ exports.routes = async function(nwid, route, action) {
}
}

function canonicalTarget(target) {
const target6 = new ipaddr.Address6(target);
if (target6.isValid()) {
const parts = target.split('/');
return target6.canonicalForm() + '/' + parts[1];
}
return target;
}

exports.network_object = async function(nwid, object) {
const options = await init_options();
options.method = 'POST';
Expand Down