mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
SYNC: anonymized cloud instance
This commit is contained in:
committed by
Diflow
parent
94ca613201
commit
d3c937569b
@@ -216,7 +216,7 @@ async function updateCloudFiles(isRefresh) {
|
||||
{
|
||||
headers: {
|
||||
...getLicenseHttpHeaders(),
|
||||
...(await getCloudSigninHeaders()),
|
||||
...(await getCloudInstanceHeaders()),
|
||||
'x-app-version': currentVersion.version,
|
||||
},
|
||||
}
|
||||
@@ -300,6 +300,17 @@ async function callCloudApiGet(endpoint, signinHolder = null, additionalHeaders
|
||||
return resp.data;
|
||||
}
|
||||
|
||||
async function getCloudInstanceHeaders() {
|
||||
if (!(await fs.exists(path.join(datadir(), 'cloud-instance.txt')))) {
|
||||
const newInstanceId = crypto.randomUUID();
|
||||
await fs.writeFile(path.join(datadir(), 'cloud-instance.txt'), newInstanceId);
|
||||
}
|
||||
const instanceId = await fs.readFile(path.join(datadir(), 'cloud-instance.txt'), 'utf-8');
|
||||
return {
|
||||
'x-cloud-instance': instanceId,
|
||||
};
|
||||
}
|
||||
|
||||
async function callCloudApiPost(endpoint, body, signinHolder = null) {
|
||||
if (!signinHolder) {
|
||||
signinHolder = await getCloudSigninHolder();
|
||||
|
||||
Reference in New Issue
Block a user