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
410ac110
Commit
410ac110
authored
Sep 17, 2018
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'alpha-test' of
https://dev.nexpie.com/stack/vernemq
into alpha-test
parents
7cbbb0fb
36200e3c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
2 deletions
+45
-2
authhook/index.js
+2
-0
authhook/on_deliver.js
+5
-2
authhook/on_unsubscribe.js
+35
-0
files/vernemq.conf
+3
-0
No files found.
authhook/index.js
View file @
410ac110
...
@@ -13,6 +13,7 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
...
@@ -13,6 +13,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'
).
on_deliver
var
on_deliver
=
require
(
'./on_deliver'
).
on_deliver
var
signRole
=
require
(
'./checkClientRole'
).
signRole
var
signRole
=
require
(
'./checkClientRole'
).
signRole
var
on_unsubscribe
=
require
(
'./on_unsubscribe'
).
on_unsubscribe
const
server
=
restify
.
createServer
({
const
server
=
restify
.
createServer
({
name
:
'authhook'
,
name
:
'authhook'
,
...
@@ -39,6 +40,7 @@ server.post('/onsub', (req,res,next) => {
...
@@ -39,6 +40,7 @@ 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
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/signRole'
,
signRole
)
server
.
post
(
'/signRole'
,
signRole
)
...
...
authhook/on_deliver.js
View file @
410ac110
...
@@ -19,6 +19,7 @@ function hasGroup(topics) {
...
@@ -19,6 +19,7 @@ function hasGroup(topics) {
}
}
else
return
false
else
return
false
}
}
module
.
exports
.
hasGroup
=
hasGroup
function
beDesireTopic
(
topics
)
{
function
beDesireTopic
(
topics
)
{
if
(
hasGroup
(
topics
))
{
if
(
hasGroup
(
topics
))
{
...
@@ -26,8 +27,10 @@ function beDesireTopic(topics) {
...
@@ -26,8 +27,10 @@ function beDesireTopic(topics) {
}
}
else
return
topics
else
return
topics
}
}
module
.
exports
.
beDesireTopic
=
beDesireTopic
function
joinTopic
(
topics
)
{
function
joinTopic
(
topics
)
{
var
topic
=
topics
.
split
(
'/!'
)[
1
]
var
topic
=
topics
.
split
(
'/!'
)[
1
]
return
topics
.
split
(
'/!'
)[
0
]
+
topic
.
substring
(
topic
.
indexOf
(
'/'
),
topic
.
length
)
return
topics
.
split
(
'/!'
)[
0
]
+
topic
.
substring
(
topic
.
indexOf
(
'/'
),
topic
.
length
)
}
}
\ No newline at end of file
module
.
exports
.
joinTopic
=
joinTopic
\ No newline at end of file
authhook/on_unsubscribe.js
0 → 100644
View file @
410ac110
function
on_unsubscribe
(
req
,
res
,
next
)
{
console
.
log
(
'------on unsubscribe-------'
)
console
.
log
(
req
.
body
)
var
topic
=
req
.
body
.
topics
[
0
];
// checkRole
var
checkRealDB
=
require
(
'./checkClientRole'
).
checkRealDB
checkRealDB
(
req
.
body
.
username
,
(
err
,
decoded
)
=>
{
if
(
err
)
{
// Set Response
var
getGroupID
=
require
(
'./utils/getGroupID'
).
getGroupID
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
(
_id
)
=>
{
// get groupID
// console.log(_id)
var
_ftopic
=
require
(
'./utils/getTopic'
).
getTopic
(
topic
,
_id
)
// get topic where concat with groupID
var
response
=
{
"result"
:
"ok"
,
"topics"
:
[
_ftopic
]
}
console
.
log
(
response
)
res
.
send
(
response
);
})
}
else
{
console
.
log
(
decoded
)
if
(
decoded
.
role
===
'realtimedb'
)
{
var
response
=
{
'result'
:
'ok'
}
console
.
log
(
response
)
res
.
send
(
response
);
}
}
})
}
module
.
exports
.
on_unsubscribe
=
on_unsubscribe
\ No newline at end of file
files/vernemq.conf
View file @
410ac110
...
@@ -817,6 +817,9 @@ vmq_webhooks.webhook3.endpoint = http://localhost:40000/authpub
...
@@ -817,6 +817,9 @@ vmq_webhooks.webhook3.endpoint = http://localhost:40000/authpub
vmq_webhooks
.
webhook5
.
hook
=
on_deliver
vmq_webhooks
.
webhook5
.
hook
=
on_deliver
vmq_webhooks
.
webhook5
.
endpoint
=
http
://
localhost
:
40000
/
ondeliver
vmq_webhooks
.
webhook5
.
endpoint
=
http
://
localhost
:
40000
/
ondeliver
vmq_webhooks
.
webhook6
.
hook
=
on_unsubscribe
vmq_webhooks
.
webhook6
.
endpoint
=
http
://
localhost
:
40000
/
onunsub
## 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