fix some misc problem found using browser to access API
This commit is contained in:
parent
00de23ded7
commit
72ff65e833
|
@ -60,6 +60,13 @@ module.exports.create = function (deps, conf) {
|
|||
}
|
||||
|
||||
function isAuthorized(req, res, fn) {
|
||||
// OPTIONS requests are only to determine if a particular request is allowed, and the
|
||||
// browser won't send the session header with this request, so don't try to authenticate.
|
||||
if (req.method === 'OPTIONS') {
|
||||
fn();
|
||||
return;
|
||||
}
|
||||
|
||||
var auth = jwt.decode((req.headers.authorization||'').replace(/^bearer\s+/i, ''));
|
||||
if (!auth) {
|
||||
res.statusCode = 401;
|
||||
|
|
|
@ -50,9 +50,8 @@ var moduleSchemas = {
|
|||
}
|
||||
|
||||
// the dns control modules for DDNS
|
||||
, dns_oauth3_org: {
|
||||
name: 'dns@oauth3.org'
|
||||
, type: 'object'
|
||||
, 'dns@oauth3.org': {
|
||||
type: 'object'
|
||||
, required: [ 'token_id' ]
|
||||
, properties: {
|
||||
token_id: { type: 'string' }
|
||||
|
@ -67,10 +66,6 @@ moduleSchemas.forward.properties.ports = { type: 'array', items: portSchema };
|
|||
|
||||
Object.keys(moduleSchemas).forEach(function (name) {
|
||||
var schema = moduleSchemas[name];
|
||||
if (schema.name) {
|
||||
name = schema.name;
|
||||
delete schema.name;
|
||||
}
|
||||
schema.id = '/modules/'+name;
|
||||
schema.required = ['id', 'type'].concat(schema.required || []);
|
||||
schema.properties.id = { type: 'string' };
|
||||
|
|
|
@ -265,8 +265,14 @@ module.exports.create = function (deps, conf) {
|
|||
}).filter(Boolean));
|
||||
}
|
||||
|
||||
recheckPubAddr();
|
||||
setInterval(recheckPubAddr, 5*60*1000);
|
||||
function check() {
|
||||
recheckPubAddr().catch(function (err) {
|
||||
console.error('failed to handle all actions needed for DDNS');
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
check();
|
||||
setInterval(check, 5*60*1000);
|
||||
|
||||
var curConf;
|
||||
function updateConf() {
|
||||
|
|
|
@ -50,10 +50,7 @@ module.exports.create = function (deps, config, netHandler) {
|
|||
return;
|
||||
}
|
||||
|
||||
process.nextTick(function () {
|
||||
socket.unshift(opts.firstChunk);
|
||||
});
|
||||
|
||||
writer.write(opts.firstChunk);
|
||||
socket.pipe(writer);
|
||||
writer.pipe(socket);
|
||||
|
||||
|
|
|
@ -1907,9 +1907,9 @@
|
|||
}
|
||||
},
|
||||
"socket-pair": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/socket-pair/-/socket-pair-1.0.1.tgz",
|
||||
"integrity": "sha1-mneFcEv9yOj2NxwodeyjIeMT/po=",
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/socket-pair/-/socket-pair-1.0.3.tgz",
|
||||
"integrity": "sha512-O1WJMNIPAAGCzzJi1Lk9K9adctKM4DukiUO6G6sQSs+CqEAZ5uGX86uIMDKygBZZr62YHDoOGH1rJShOzw6i9Q==",
|
||||
"requires": {
|
||||
"bluebird": "3.5.0"
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
"serve-static": "^1.10.0",
|
||||
"server-destroy": "^1.0.1",
|
||||
"sni": "^1.0.0",
|
||||
"socket-pair": "^1.0.1",
|
||||
"socket-pair": "^1.0.3",
|
||||
"socksv5": "0.0.6",
|
||||
"stunnel": "git+https://git.daplie.com/Daplie/node-tunnel-client.git#v1",
|
||||
"stunneld": "git+https://git.daplie.com/Daplie/node-tunnel-server.git#v1",
|
||||
|
|
Loading…
Reference in New Issue