Skip to content

Commit

Permalink
tmp debugs
Browse files Browse the repository at this point in the history
  • Loading branch information
zo-el committed Aug 1, 2024
1 parent 135bf80 commit b238dca
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions server/src/routes/zt_registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,24 @@ const addZeroTierMember = async (address, name, description) => {
const networkId = await SETTINGS.get('zerotier_network_id')
// deregister any old entries with the same name (holoport id) as the new entry, before creating new entries.
await clearOldStaleEntries(name, apiToken, networkId)
return fetch(`https://my.zerotier.com/api/network/${networkId}/member/${address}`, {
method: 'POST',
headers: { authorization: `Bearer ${apiToken}` },
body: JSON.stringify({
config: { authorized: true },
description: description,
name: name
try {
// todo: only for debugging remove asao
console.log(`Adding member ${name} with address ${address} to network-id: ${networkId}`)
let response = fetch(`https://my.zerotier.com/api/network/${networkId}/member/${address}`, {
method: 'POST',
headers: { authorization: `Bearer ${apiToken}` },
body: JSON.stringify({
config: { authorized: true },
description: description,
name: name
})
})
})
console.log("Member added successfully.", response);
return response
} catch (e) {
console.log("Error: ", e)
return e
}
}

/**
Expand All @@ -38,6 +47,7 @@ const clearOldStaleEntries = async (name, apiToken, networkId) => {
method: 'GET',
headers: { authorization: `Bearer ${apiToken}` }
})
console.log(`response: ${response}`)
let all_members = await response.json()
console.log(`Total number of members: ${all_members.length}`)
let old_members = all_members.filter(m => m.name === name);
Expand Down

0 comments on commit b238dca

Please sign in to comment.