Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vernemq
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stack
vernemq
Commits
7a00be97
Commit
7a00be97
authored
Nov 05, 2018
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://dev.nexpie.com/stack/vernemq
parents
d640c8a9
6dd889b8
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
8 deletions
+43
-8
authhook/auth_on_publish.js
+6
-1
authhook/auth_on_register.js
+1
-1
authhook/auth_on_subscribe.js
+6
-0
authhook/config/custom-environment-variables.json
+3
-1
authhook/config/default.json
+2
-1
authhook/config/local-dev.json
+4
-3
authhook/index.js
+5
-1
authhook/on_offline.js
+10
-0
files/vernemq.conf
+6
-0
No files found.
authhook/auth_on_publish.js
View file @
7a00be97
...
@@ -39,6 +39,7 @@ module.exports = function (options = {}) {
...
@@ -39,6 +39,7 @@ module.exports = function (options = {}) {
var
output
=
{};
var
output
=
{};
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
if
(
group
)
{
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'pub'
,
group
,
req
.
body
.
client_id
,
output
);
// get topic where concat with groupID
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'pub'
,
group
,
req
.
body
.
client_id
,
output
);
// get topic where concat with groupID
response
=
{
response
=
{
'result'
:
'ok'
,
'result'
:
'ok'
,
...
@@ -58,7 +59,11 @@ module.exports = function (options = {}) {
...
@@ -58,7 +59,11 @@ module.exports = function (options = {}) {
}
}
res
.
send
(
response
);
res
.
send
(
response
);
next
();
next
();
}
else
{
res
.
send
({
"result"
:
"no"
});
next
();
}
});
});
}
}
}
}
...
...
authhook/auth_on_register.js
View file @
7a00be97
...
@@ -27,7 +27,7 @@ function authCheck(client_id, token, password, callback) {
...
@@ -27,7 +27,7 @@ function authCheck(client_id, token, password, callback) {
}
}
else
{
else
{
//
console.log('token :' + token)
console
.
log
(
'token :'
+
token
)
seneca
.
act
(
'ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'
+
token
,
function
(
err
,
res
)
{
seneca
.
act
(
'ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'
+
token
,
function
(
err
,
res
)
{
// console.log('result : ' + util.inspect(res.result, false, null, true))
// console.log('result : ' + util.inspect(res.result, false, null, true))
if
(
res
.
result
)
{
if
(
res
.
result
)
{
...
...
authhook/auth_on_subscribe.js
View file @
7a00be97
...
@@ -37,6 +37,7 @@ module.exports = function (options = {}) {
...
@@ -37,6 +37,7 @@ module.exports = function (options = {}) {
var
GGID
=
require
(
'./utils/getGroupID'
);
var
GGID
=
require
(
'./utils/getGroupID'
);
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
if
(
group
)
{
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'sub'
,
group
,
req
.
body
.
client_id
)
// get topic where concat with groupID
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'sub'
,
group
,
req
.
body
.
client_id
)
// get topic where concat with groupID
var
_topic
=
[{
// setTopic for response
var
_topic
=
[{
// setTopic for response
'topic'
:
_ftopic
,
'topic'
:
_ftopic
,
...
@@ -53,6 +54,11 @@ module.exports = function (options = {}) {
...
@@ -53,6 +54,11 @@ module.exports = function (options = {}) {
res
.
send
(
response
);
res
.
send
(
response
);
next
();
next
();
}
else
{
res
.
send
({
"result"
:
"no"
});
next
();
}
});
});
}
}
}
}
...
...
authhook/config/custom-environment-variables.json
View file @
7a00be97
...
@@ -13,5 +13,6 @@
...
@@ -13,5 +13,6 @@
"auth_on_subscribe_debug"
:
"AUTH_ON_SUBSCRIBE_DEBUG"
,
"auth_on_subscribe_debug"
:
"AUTH_ON_SUBSCRIBE_DEBUG"
,
"on_publish_debug"
:
"ON_PUBLISH_DEBUG"
,
"on_publish_debug"
:
"ON_PUBLISH_DEBUG"
,
"on_deliver_debug"
:
"ON_DELIVER_DEBUG"
,
"on_deliver_debug"
:
"ON_DELIVER_DEBUG"
,
"on_unsubscribe_debug"
:
"ON_UNSUBSCRIBE_DEBUG"
"on_unsubscribe_debug"
:
"ON_UNSUBSCRIBE_DEBUG"
,
"on_offline_debug"
:
"ON_OFFLINE_DEBUG"
}
}
\ No newline at end of file
authhook/config/default.json
View file @
7a00be97
...
@@ -7,5 +7,6 @@
...
@@ -7,5 +7,6 @@
"auth_on_subscribe_debug"
:
false
,
"auth_on_subscribe_debug"
:
false
,
"on_publish_debug"
:
false
,
"on_publish_debug"
:
false
,
"on_deliver_debug"
:
false
,
"on_deliver_debug"
:
false
,
"on_unsubscribe_debug"
:
false
"on_unsubscribe_debug"
:
false
,
"on_offline_debug"
:
false
}
}
authhook/config/local-dev.json
View file @
7a00be97
{
{
"device_registry_host"
:
"
localhost
"
,
"device_registry_host"
:
"
alpha.nexpie.io
"
,
"device_registry_port"
:
8990
,
"device_registry_port"
:
8990
,
"token_registry_host"
:
"
localhost
"
,
"token_registry_host"
:
"
alpha.nexpie.io
"
,
"token_registry_port"
:
8790
,
"token_registry_port"
:
8790
,
"auth_on_register_debug"
:
true
,
"auth_on_register_debug"
:
true
,
...
@@ -10,5 +10,6 @@
...
@@ -10,5 +10,6 @@
"auth_on_subscribe_debug"
:
true
,
"auth_on_subscribe_debug"
:
true
,
"on_publish_debug"
:
true
,
"on_publish_debug"
:
true
,
"on_deliver_debug"
:
true
,
"on_deliver_debug"
:
true
,
"on_unsubscribe_debug"
:
true
"on_unsubscribe_debug"
:
true
,
"on_offline_debug"
:
true
}
}
authhook/index.js
View file @
7a00be97
...
@@ -7,6 +7,7 @@ var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
...
@@ -7,6 +7,7 @@ var auth_on_subscribe_debug = config.get('auth_on_subscribe_debug');
var
on_publish_debug
=
config
.
get
(
'on_publish_debug'
);
var
on_publish_debug
=
config
.
get
(
'on_publish_debug'
);
var
on_deliver_debug
=
config
.
get
(
'on_deliver_debug'
);
var
on_deliver_debug
=
config
.
get
(
'on_deliver_debug'
);
var
on_unsubscribe_debug
=
config
.
get
(
'on_unsubscribe_debug'
);
var
on_unsubscribe_debug
=
config
.
get
(
'on_unsubscribe_debug'
);
var
on_offline_debug
=
config
.
get
(
'on_offline_debug'
);
var
restify
=
require
(
'restify'
);
var
restify
=
require
(
'restify'
);
var
auth_on_register
=
require
(
'./auth_on_register'
)({
debug
:
auth_on_register_debug
});
var
auth_on_register
=
require
(
'./auth_on_register'
)({
debug
:
auth_on_register_debug
});
...
@@ -15,6 +16,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
...
@@ -15,6 +16,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
on_publish_debug
});
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
on_publish_debug
});
var
on_deliver
=
require
(
'./on_deliver'
)({
debug
:
on_deliver_debug
});
var
on_deliver
=
require
(
'./on_deliver'
)({
debug
:
on_deliver_debug
});
var
on_unsubscribe
=
require
(
'./on_unsubscribe'
)({
debug
:
on_unsubscribe_debug
});
var
on_unsubscribe
=
require
(
'./on_unsubscribe'
)({
debug
:
on_unsubscribe_debug
});
var
on_offline
=
require
(
'./on_offline'
)({
debug
:
on_offline_debug
});
const
server
=
restify
.
createServer
({
const
server
=
restify
.
createServer
({
name
:
'authhook'
,
name
:
'authhook'
,
...
@@ -37,13 +39,15 @@ server.get('/about', function (req, res, next) {
...
@@ -37,13 +39,15 @@ server.get('/about', function (req, res, next) {
server
.
post
(
'/authreg'
,
auth_on_register
);
server
.
post
(
'/authreg'
,
auth_on_register
);
server
.
post
(
'/authpub'
,
auth_on_publish
);
server
.
post
(
'/authpub'
,
auth_on_publish
);
server
.
post
(
'/authsub'
,
auth_on_subscribe
);
server
.
post
(
'/authsub'
,
auth_on_subscribe
);
server
.
post
(
'/onsub'
,
(
req
,
res
,
next
)
=>
{
server
.
post
(
'/onsub'
,
(
req
,
res
,
next
)
=>
{
console
.
log
(
req
.
body
)
console
.
log
(
req
.
body
)
res
.
send
(
''
)
res
.
send
(
''
)
})
})
server
.
post
(
'/onunsub'
,
on_unsubscribe
)
server
.
post
(
'/onunsub'
,
on_unsubscribe
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/onoff'
,
on_offline
)
server
.
post
(
'/ongone'
,
on_offline
)
server
.
listen
(
port
,
function
()
{
server
.
listen
(
port
,
function
()
{
console
.
log
(
'%s listening at %s'
,
server
.
name
,
server
.
url
);
console
.
log
(
'%s listening at %s'
,
server
.
name
,
server
.
url
);
...
...
authhook/on_offline.js
0 → 100644
View file @
7a00be97
module
.
exports
=
function
(
options
=
{})
{
return
function
(
req
,
res
,
next
)
{
doRedis
()
}
function
doRedis
()
{
}
}
\ No newline at end of file
files/vernemq.conf
View file @
7a00be97
...
@@ -820,6 +820,12 @@ vmq_webhooks.webhook5.endpoint = http://localhost:40000/ondeliver
...
@@ -820,6 +820,12 @@ vmq_webhooks.webhook5.endpoint = http://localhost:40000/ondeliver
vmq_webhooks
.
webhook6
.
hook
=
on_unsubscribe
vmq_webhooks
.
webhook6
.
hook
=
on_unsubscribe
vmq_webhooks
.
webhook6
.
endpoint
=
http
://
localhost
:
40000
/
onunsub
vmq_webhooks
.
webhook6
.
endpoint
=
http
://
localhost
:
40000
/
onunsub
vmq_webhooks
.
webhook7
.
hook
=
on_client_offline
vmq_webhooks
.
webhook7
.
endpoint
=
http
://
localhost
:
40000
/
onoff
vmq_webhooks
.
webhook8
.
hook
=
on_client_gone
vmq_webhooks
.
webhook8
.
endpoint
=
http
://
localhost
:
40000
/
ongone
## Specify the address and port of the bridge to connect to. Several
## Specify the address and port of the bridge to connect to. Several
## bridges can configured by using different bridge names (e.g. br0). If the
## bridges can configured by using different bridge names (e.g. br0). If the
## connection supports SSL encryption bridge.ssl.<name> can be used.
## connection supports SSL encryption bridge.ssl.<name> can be used.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment