1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-24 20:19:10 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Laurent Cozic
f98c693adf CLI v1.0.112 2018-07-25 17:51:13 +02:00
Laurent Cozic
6da80f3291 Trying to get proxy to work 2018-07-25 17:47:35 +02:00
9 changed files with 87 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "joplin",
"version": "1.0.110",
"version": "1.0.112",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -19,7 +19,7 @@
],
"owner": "Laurent Cozic"
},
"version": "1.0.110",
"version": "1.0.112",
"bin": {
"joplin": "./main.js"
},

View File

@@ -40,9 +40,9 @@
"integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4="
},
"acorn": {
"version": "5.6.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.6.2.tgz",
"integrity": "sha512-zUzo1E5dI2Ey8+82egfnttyMlMZ2y0D8xOCO3PNPPlYXpl8NZvF6Qk9L9BEtJs+43FqEmfBViDqc5d1ckRDguw=="
"version": "5.7.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz",
"integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ=="
},
"acorn-globals": {
"version": "4.1.0",
@@ -52,6 +52,14 @@
"acorn": "^5.0.0"
}
},
"agent-base": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.0.tgz",
"integrity": "sha512-c+R/U5X+2zz2+UCrCFv6odQzJdoqI+YecuhnAJLa1zYaMc13zPfwMwZrr91Pd1DYNo/yPRbiM4WVf9whgwFsIg==",
"requires": {
"es6-promisify": "^5.0.0"
}
},
"ajv": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.0.tgz",
@@ -1363,9 +1371,9 @@
"dev": true
},
"cssom": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.2.tgz",
"integrity": "sha1-uANhcMefB6kP8vFuIihAJ6JDhIs="
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.3.tgz",
"integrity": "sha512-pjE/I/NSp3iyeoxXN5QaoJpgzYUMj2dJHx9OSufoTliJLDx+kuOQaMCJW8OwvrKJswhXUHnHN6eUmUSETN0msg=="
},
"cssstyle": {
"version": "0.3.1",
@@ -2258,6 +2266,14 @@
"resolved": "https://registry.npmjs.org/es6-promise-pool/-/es6-promise-pool-2.5.0.tgz",
"integrity": "sha1-FHxhKza0fxBQJ/nSv1SlmKmdnMs="
},
"es6-promisify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
"requires": {
"es6-promise": "^4.0.3"
}
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
@@ -2265,9 +2281,9 @@
"dev": true
},
"escodegen": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.1.tgz",
"integrity": "sha512-6hTjO1NAWkHnDk3OqQ4YrCuwwmGHL9S3nPlzBOUG/R44rda3wLNrfvQ5fkSGjyhHFKM7ALPKcKGrwvCLe0lC7Q==",
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.10.0.tgz",
"integrity": "sha512-fjUOf8johsv23WuIKdNQU4P9t9jhQ4Qzx6pC2uW890OloK3Zs1ZAoCNpg/2larNF501jLl3UNy0kIRcF6VI22g==",
"requires": {
"esprima": "^3.1.3",
"estraverse": "^4.2.0",
@@ -3507,6 +3523,25 @@
"sshpk": "^1.7.0"
}
},
"https-proxy-agent": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz",
"integrity": "sha512-HPCTS1LW51bcyMYbxUIOO4HEOlQ1/1qRaFWcyxvwaqUS9TY88aoEuHUY33kuAh1YhVVaDQhLZsnPd+XNARWZlQ==",
"requires": {
"agent-base": "^4.1.0",
"debug": "^3.1.0"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"iconv-lite": {
"version": "0.4.19",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
@@ -3887,9 +3922,9 @@
"integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo="
},
"joplin-turndown": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/joplin-turndown/-/joplin-turndown-4.0.7.tgz",
"integrity": "sha512-dOUzNg0nt1Sgz5LO/6CvZmgGLk3q0BCelZ+CDTb/UOBn7reqUl7R0B4yAfiqDtO8p0/wzY/N87RzXeEawbPvFA==",
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/joplin-turndown/-/joplin-turndown-4.0.8.tgz",
"integrity": "sha512-RPZJSZEplVPL3UiJNkaKsFAG8bCGofsKIiH24s8/4qcy1xYnEufvg++rHm7rxi/0VCtpSkRBlWHSs1/srJZvoA==",
"requires": {
"jsdom": "^11.9.0"
}
@@ -4557,9 +4592,9 @@
"dev": true
},
"nwsapi": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.3.tgz",
"integrity": "sha512-zFJF9lOpg2+uicP0BQKOAfIOqeTp/p8PC669mewxgRkR1hGjne8BMUHk4wpRS9o5Z0icA5Nv04HmGkW31KfMKw=="
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.0.4.tgz",
"integrity": "sha512-Zt6HRR6RcJkuj5/N9zeE7FN6YitRW//hK2wTOwX274IBphbY3Zf5+yn5mZ9v/SzAOTMjQNxZf9KkmPLWn0cV4g=="
},
"oauth-sign": {
"version": "0.8.2",

View File

@@ -90,6 +90,7 @@
"fs-extra": "^5.0.0",
"highlight.js": "^9.12.0",
"html-entities": "^1.2.1",
"https-proxy-agent": "^2.2.1",
"image-type": "^3.0.0",
"joplin-turndown": "^4.0.8",
"joplin-turndown-plugin-gfm": "^1.0.7",

View File

@@ -2,6 +2,7 @@ const Setting = require('lib/models/Setting.js');
const SyncTargetRegistry = require('lib/SyncTargetRegistry');
const ObjectUtils = require('lib/ObjectUtils');
const { _ } = require('lib/locale.js');
const { shim } = require('lib/shim.js');
const shared = {}
@@ -17,7 +18,9 @@ shared.checkSyncConfig = async function(comp, settings) {
const SyncTargetClass = SyncTargetRegistry.classById(syncTargetId);
const options = Setting.subValues('sync.' + syncTargetId, settings);
comp.setState({ checkSyncConfigResult: 'checking' });
const previousTimeout = shim.setFetchTimeout(1000 * 5);
const result = await SyncTargetClass.checkConfig(ObjectUtils.convertValuesToFunctions(options));
shim.setFetchTimeout(previousTimeout);
comp.setState({ checkSyncConfigResult: result });
}

View File

@@ -19,7 +19,9 @@ async function tryAndRepeat(fn, count) {
while (true) {
try {
console.info('RRRRRRR');
const result = await fn();
console.info(result);
return result;
} catch (error) {
if (retryCount >= count) throw error;

View File

@@ -152,6 +152,7 @@ class Setting extends BaseModel {
'net.customCertificates': { value: '', type: Setting.TYPE_STRING, show: (settings) => { return [SyncTargetRegistry.nameToId('nextcloud'), SyncTargetRegistry.nameToId('webdav')].indexOf(settings['sync.target']) >= 0 }, public: true, appTypes: ['desktop', 'cli'], label: () => _('Custom TLS certificates'), description: () => _('Comma-separated list of paths to directories to load the certificates from, or path to individual cert files. For example: /my/cert_dir, /other/custom.pem. Note that if you make changes to the TLS settings, you must save your changes before clicking on "Check synchronisation configuration".') },
'net.ignoreTlsErrors': { value: false, type: Setting.TYPE_BOOL, show: (settings) => { return [SyncTargetRegistry.nameToId('nextcloud'), SyncTargetRegistry.nameToId('webdav')].indexOf(settings['sync.target']) >= 0 }, public: true, appTypes: ['desktop', 'cli'], label: () => _('Ignore TLS certificate errors') },
'net.proxy': { value: '', type: Setting.TYPE_STRING, public: true, appTypes: ['desktop', 'cli'], label: () => _('Proxy') },
};
return this.metadata_;

View File

@@ -7,8 +7,10 @@ const { setLocale, defaultLocale, closestSupportedLocale } = require('lib/locale
const { FsDriverNode } = require('lib/fs-driver-node.js');
const mimeUtils = require('lib/mime-utils.js').mime;
const Note = require('lib/models/Note.js');
const Setting = require('lib/models/Setting.js');
const Resource = require('lib/models/Resource.js');
const urlValidator = require('valid-url');
const HttpsProxyAgent = require('https-proxy-agent');
function shimInit() {
shim.fsDriver = () => { throw new Error('Not implemented') }
@@ -188,10 +190,27 @@ function shimInit() {
return new Buffer(data).toString('base64');
}
shim.addProxyAgent_ = (requestOptions) => {
if (requestOptions.agent) return requestOptions;
const proxy = Setting.value('net.proxy');
if (!proxy) return requestOptions;
requestOptions = Object.assign({}, requestOptions);
requestOptions.agent = new HttpsProxyAgent(proxy); // http://127.0.0.1:3128
return requestOptions;
}
shim.fetch = async function(url, options = null) {
const validatedUrl = urlValidator.isUri(url);
if (!validatedUrl) throw new Error('Not a valid URL: ' + url);
options = shim.addProxyAgent_(options);
if (shim.fetchTimeout()) options.timeout = shim.fetchTimeout();
console.info(options);
return shim.fetchWithRetry(() => {
return nodeFetch(url, options)
}, options);
@@ -221,7 +240,7 @@ function shimInit() {
};
}
const requestOptions = {
let requestOptions = {
protocol: url.protocol,
host: url.hostname,
port: url.port,
@@ -230,6 +249,8 @@ function shimInit() {
headers: headers,
};
requestOptions = shim.addProxyAgent_(requestOptions);
const doFetchOperation = async () => {
return new Promise((resolve, reject) => {
let file = null;

View File

@@ -120,6 +120,12 @@ shim.fetchWithRetry = async function(fetchFn, options = null) {
}
shim.fetch = () => { throw new Error('Not implemented'); }
shim.setFetchTimeout = (v) => {
const previousTimeout = shim.fetchTimeout_ ? shim.fetchTimeout_ : null;
shim.fetchTimeout_ = v;
return previousTimeout;
}
shim.fetchTimeout = () => { return shim.fetchTimeout_; }
shim.FormData = typeof FormData !== 'undefined' ? FormData : null;
shim.fsDriver = () => { throw new Error('Not implemented') }
shim.FileApiDriverLocal = null;