Loading build_list.js +48 −5 Original line number Diff line number Diff line const outputFile = "list/e_trackers.json" const ciJobToken = process.env.CI_JOB_TOKEN const ciApiV4Url = process.env.CI_API_V4_URL const giltabProjectId = "1183" const adawayUri = "https://adaway.org/hosts.txt" const exodusUri = "https://reports.exodus-privacy.eu.org/api/trackers" const https = require('https') const fs = require('fs') const url = require('url') //const process = require('process') function fetch(url) { Loading Loading @@ -60,7 +66,11 @@ fetch(adawayUri) console.log("DONE") }) .then(toto => { printTrackers() return printTrackers() }) .then(trackersJson => { //saveTrackersFile(trackersJson) uploadTrackers(trackersJson) }) .catch(err => { console.log(err) Loading Loading @@ -147,8 +157,41 @@ function toLevel2Domain(hostname) { } function printTrackers() { fs.writeFileSync(outputFile, JSON.stringify({ return JSON.stringify({ trackers: trackers, createdAt: new Date().toISOString() })) }) } function saveTrackersFile(trackersJson) { fs.writeFileSync(outputFile, trackersJson) } function uploadTrackers(trackersJson) { return new Promise((resolve, reject) => { const body = JSON.stringify({ content: trackersJson, branch: 'main', commit_message: `Update trackers list ; ${trackers.length} trackers` }) const urlComponents = url.parse(`${ciApiV4Url}/projects/${encodeURIComponent(giltabProjectId)}/repository/files/${encodeURIComponent(outputFile)}`) const options = { method: 'PUT', port: 443, hostname: urlComponents.hostname, path: urlComponents.path, headers: { 'PRIVATE-TOKEN': ciJobToken, 'Content-Type': 'application/json', 'Content-Length': body.length, } } const req = https.request(options, res => {}) req.on('error', reject) req.write(body) req.end() resolve() })} list/e_trackers.json +1 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
build_list.js +48 −5 Original line number Diff line number Diff line const outputFile = "list/e_trackers.json" const ciJobToken = process.env.CI_JOB_TOKEN const ciApiV4Url = process.env.CI_API_V4_URL const giltabProjectId = "1183" const adawayUri = "https://adaway.org/hosts.txt" const exodusUri = "https://reports.exodus-privacy.eu.org/api/trackers" const https = require('https') const fs = require('fs') const url = require('url') //const process = require('process') function fetch(url) { Loading Loading @@ -60,7 +66,11 @@ fetch(adawayUri) console.log("DONE") }) .then(toto => { printTrackers() return printTrackers() }) .then(trackersJson => { //saveTrackersFile(trackersJson) uploadTrackers(trackersJson) }) .catch(err => { console.log(err) Loading Loading @@ -147,8 +157,41 @@ function toLevel2Domain(hostname) { } function printTrackers() { fs.writeFileSync(outputFile, JSON.stringify({ return JSON.stringify({ trackers: trackers, createdAt: new Date().toISOString() })) }) } function saveTrackersFile(trackersJson) { fs.writeFileSync(outputFile, trackersJson) } function uploadTrackers(trackersJson) { return new Promise((resolve, reject) => { const body = JSON.stringify({ content: trackersJson, branch: 'main', commit_message: `Update trackers list ; ${trackers.length} trackers` }) const urlComponents = url.parse(`${ciApiV4Url}/projects/${encodeURIComponent(giltabProjectId)}/repository/files/${encodeURIComponent(outputFile)}`) const options = { method: 'PUT', port: 443, hostname: urlComponents.hostname, path: urlComponents.path, headers: { 'PRIVATE-TOKEN': ciJobToken, 'Content-Type': 'application/json', 'Content-Length': body.length, } } const req = https.request(options, res => {}) req.on('error', reject) req.write(body) req.end() resolve() })}