Compare commits

...
46 Commits
Author SHA1 Message Date
lxm 45994cc23f Merge pull request #1376 from hxy7yx/v2.5
delete transport_mode in modbus rtu
2023-07-05 18:21:51 +08:00
hxy7yx f360d34688 delete transport_mode in modbus rtu 2023-07-05 18:08:13 +08:00
lxm cae5c3f9c6 Merge pull request #1363 from hxy7yx/v2.5-2
optimization of password error reporting
2023-07-05 15:16:47 +08:00
lxm 68775233d3 Merge pull request #1375 from lixiumei123/v2.5
version:2.5.1
2023-07-03 21:00:15 +08:00
liyuxi 2d4ef2e81a version:2.5.1 2023-07-03 10:16:39 +00:00
lxm b1fc78632d Merge pull request #1371 from hxy7yx/v2.5
delete modbus rtu udp temporarily
2023-07-03 16:06:47 +08:00
lxm e52a3d8dd9 Merge pull request #1372 from lixiumei123/v2.5
delete file plugin
2023-07-03 16:01:30 +08:00
liyuxi 82e216c161 delete file plugin 2023-07-03 07:14:41 +00:00
hxy7yx 2cb2d81254 delete modbus rtu udp temporarily 2023-07-03 14:12:01 +08:00
fengzeroz 203acf54c8 Merge pull request #1360 from hxy7yx/v2.5
exclude license when downloading logs
2023-07-03 13:50:57 +08:00
hxy7yx 413cb7600f Merge branch 'v2.5' into v2.5-2 2023-06-28 13:48:01 +08:00
hxy7yx 8d57bbb252 optimization of password error reporting 2023-06-28 13:44:11 +08:00
eeff 3cecf258a3 Merge pull request #1358 from eeff/v2.5
Pick to fix(ekuiper): check setting host and port is available
2023-06-28 11:08:07 +08:00
hxy7yx eb5de62e46 exclude license when downloading logs 2023-06-28 09:49:21 +08:00
eeff 0fde678e1e fix(ekuiper): check setting host and port is available 2023-06-27 15:23:25 +08:00
fengzero 2b33aa933a improve(connection): donot close fd if tty read returns 0 2023-06-26 07:22:14 +00:00
fengzeroz 9d1c68a420 Merge pull request #1354 from eeff/v2.5
Pick to v2.5 fix(restful): template api handle NEU_ERR_PLUGIN_NAME_TOO_LONG
2023-06-25 16:33:37 +08:00
fengzeroz 5ee5b71dab Merge pull request #1352 from fengzeroz/v2.5
fix(connection): check result of recv
2023-06-25 16:30:49 +08:00
eeff 3de06119d0 fix(restful): template api handle NEU_ERR_PLUGIN_NAME_TOO_LONG 2023-06-25 10:30:30 +08:00
fengzero 7e4119de21 fix(connection): check result of recv 2023-06-21 08:55:47 +00:00
fengzeroz 40df46a0fc Merge pull request #1349 from fengzeroz/v2.5
fix(driver): delay write tag
2023-06-21 15:05:27 +08:00
fengzero eedf2a9819 fix(driver): delay write tag 2023-06-21 06:18:28 +00:00
fengzero 4472c2aeb1 Revert "fix(ekuiper): check ip address listenable"
This reverts commit 3fcbe3f7b7.
2023-06-16 10:47:06 +00:00
fengzeroz 872ac53c3f Merge pull request #1343 from fengzeroz/v2.5
chore(ci): ui version 2.5.0
2023-06-16 15:18:32 +08:00
fengzero a5fea3f2bb chore(ci): ui version 2.5.0 2023-06-16 07:03:11 +00:00
fengzeroz 1e0ed4be64 Merge pull request #1340 from hxy7yx/v2.5
Change the log-level 'info' to 'notice'
2023-06-16 11:05:15 +08:00
fengzeroz 0080cde80b Merge pull request #1337 from fengzeroz/v2.5
fix(connection): connection cannot be recovered when the line is abno…
2023-06-16 10:15:41 +08:00
hxy7yx 5cf6d23d43 Merge branch 'v2.5' into v2.5 2023-06-16 10:12:23 +08:00
hxy7yx caecaf67a6 Change the log-level 'info' to 'notice' 2023-06-16 10:11:44 +08:00
fengzero 8efdc08a32 fix(connection): connection cannot be recovered when the line is abnormal 2023-06-15 10:17:42 +00:00
fengzeroz 6d95a37651 Merge pull request #1335 from eeff/v2.5
Pick to v2.5 feat: remove neuronex sql schema
2023-06-15 15:32:40 +08:00
eeff 5a0a6206cf feat(restful): remove ekuiper http api 2023-06-15 15:30:02 +08:00
eeff 4035de49ca feat: remove neuronex sql schema 2023-06-15 15:13:13 +08:00
eeff e379386249 Merge pull request #1333 from eeff/v2.5
Pick to v2.5 fix(restful): check node name length in node update request
2023-06-15 14:45:40 +08:00
eeff c003332911 fix(restful): check node name length in node update request 2023-06-15 14:29:19 +08:00
eeff 4c38f80618 Merge pull request #1331 from eeff/v2.5
Pick to v2.5 fix: make template request more robust
2023-06-15 14:28:56 +08:00
eeff 2d0e36d596 fix: make template request more robust 2023-06-15 11:07:40 +08:00
eeff b9945c458e fix: neu_url_decode return value on buffer overflow 2023-06-15 11:07:40 +08:00
fengzeroz 614b949354 Merge pull request #1330 from hxy7yx/v2.5
update error codes in ft
2023-06-15 10:30:20 +08:00
fengzeroz 134dffee48 Merge pull request #1325 from eeff/v2.5
fix(ekuiper): check ip address listenable
2023-06-15 09:49:13 +08:00
hxy7yx 820265dfc3 update error codes in ft 2023-06-14 18:02:03 +08:00
eeff 3fcbe3f7b7 fix(ekuiper): check ip address listenable 2023-06-14 17:36:52 +08:00
fengzeroz ee6e962aa6 Merge pull request #1324 from fengzeroz/v2.5
chore(ci): branch v2.5
2023-06-14 13:28:58 +08:00
fengzero a7bf4a85e5 chore(ci): branch v2.5 2023-06-14 05:28:11 +00:00
fengzeroz 10df7590ca Merge pull request #1323 from fengzeroz/v2.5
version: 2.5.0
2023-06-14 13:23:48 +08:00
fengzero c31db4b5db version: 2.5.0 2023-06-14 05:21:06 +00:00
32 changed files with 605 additions and 672 deletions
+3 -3
View File
@@ -8,9 +8,9 @@ on:
- published
env:
VERSION: 2.4.0
UI_VERSION: 2.4.0
BRANCH: main
VERSION: 2.5.1
UI_VERSION: 2.5.1
BRANCH: v2.5
jobs:
cross-build:
-1
View File
@@ -156,7 +156,6 @@ add_subdirectory(plugins/modbus)
add_subdirectory(plugins/mqtt)
add_subdirectory(plugins/ekuiper)
add_subdirectory(plugins/monitor)
add_subdirectory(plugins/file)
add_subdirectory(simulator)
+1 -2
View File
@@ -5,7 +5,6 @@
"libplugin-monitor.so",
"libplugin-modbus-tcp.so",
"libplugin-modbus-rtu.so",
"libplugin-modbus-qh-tcp.so",
"libplugin-file.so"
"libplugin-modbus-qh-tcp.so"
]
}
+13
View File
@@ -59,6 +59,19 @@ Get APP node, it should be success.
Check Response Status ${res} 200
Node Should Exist ${res}[nodes] mqtt-node
Update node name to empty string, it should fail.
${res} = Update Node modbus-node ${EMPTY}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_NODE_NAME_EMPTY}
Update node name to excessive long string, it should fail.
${name} = Evaluate 'a'*200
${res} = Update Node modbus-node ${name}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_NODE_NAME_TOO_LONG}
Update driver node name, it should fail if the node does not exist
${res} = Update Node modbus-node-nonexistent mqtt-node
+7 -2
View File
@@ -6,10 +6,15 @@ Suite Setup Start Neuronx
Suite Teardown Stop Neuronx
*** Test Cases ***
login with invalid username and password, it should return failure
login with invalid username, it should return failure
POST /api/v2/login {"name":"admin1", "pass": "0000"}
Integer response status 401
Integer $.error ${NEU_ERR_INVALID_USER_OR_PASSWORD}
Integer $.error ${NEU_ERR_INVALID_USER}
login with invalid password, it should return failure
POST /api/v2/login {"name":"admin", "pass": "2333"}
Integer response status 401
Integer $.error ${NEU_ERR_INVALID_PASSWORD}
login with username and password, it should return success
POST /api/v2/login {"name":"admin", "pass": "0000"}
+7
View File
@@ -16,6 +16,10 @@ ${NEU_ERR_FILE_NOT_EXIST} 1011
${NEU_ERR_INVALID_PASSWORD_LEN} 1012
${NEU_ERR_DUPLICATE_PASSWORD} 1013
${NEU_ERR_COMMAND_EXECUTION_FAILED} 1014
${NEU_ERR_IP_ADDRESS_INVALID} 1015
${NEU_ERR_IP_ADDRESS_IN_USE} 1016
${NEU_ERR_INVALID_USER} 1017
${NEU_ERR_INVALID_PASSWORD} 1018
${NEU_ERR_NODE_EXIST} 2002
${NEU_ERR_NODE_NOT_EXIST} 2003
@@ -27,7 +31,10 @@ ${NEU_ERR_NODE_NOT_RUNNING} 2008
${NEU_ERR_NODE_IS_STOPED} 2009
${NEU_ERR_NODE_NAME_TOO_LONG} 2010
${NEU_ERR_NODE_NOT_ALLOW_DELETE} 2011
${NEU_ERR_NODE_NOT_ALLOW_SUBSCRIBE} 2012
${NEU_ERR_NODE_NOT_ALLOW_UPDATE} 2013
${NEU_ERR_NODE_NOT_ALLOW_MAP} 2014
${NEU_ERR_NODE_NAME_EMPTY} 2015
${NEU_ERR_GROUP_ALREADY_SUBSCRIBED} 2101
${NEU_ERR_GROUP_NOT_SUBSCRIBE} 2102
+216
View File
@@ -44,6 +44,14 @@ Create a template with too long name, it should fail.
[Teardown] Del Template ${g_long_str}
Create a template with too long plugin name, it should fail.
${res} = Add Template ${g_template} ${g_long_str} ${g_groups}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PLUGIN_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Create a template having no group, it should success.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
@@ -126,12 +134,26 @@ Create a template with singleton plugin, it should fail.
[Teardown] Del Template ${g_template}
Create a template with north plugin, it should fail.
${res} = Add Template ${g_template} MQTT ${g_empty}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PLUGIN_NOT_SUPPORT_TEMPLATE}
[Teardown] Del Template ${g_template}
Get nonexistent template, it should fail.
${res} = Get Template ${g_template}
Check Response Status ${res} 404
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NOT_FOUND}
Get a template using too long name query parameter, it should fail.
${res} = Get Template ${g_long_str}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PARAM_IS_WRONG}
Get an existent template having no groups, it should success.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
@@ -186,6 +208,12 @@ Delete a nonexistent template, it should fail.
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NOT_FOUND}
Delete a template using too long name query parameter, it should fail.
${res} = Del Template ${g_long_str}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PARAM_IS_WRONG}
Delete an existent template, it should success.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
@@ -311,6 +339,18 @@ Add group with invalid interval to existing template, it should fail.
[Teardown] Del Template ${g_template}
Add group using too long template name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Add Template Group ${g_long_str} ${g_group1}[name] ${2000}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Add group with too long name to existing template, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
@@ -346,6 +386,18 @@ Get groups from nonexistent template, it should fail.
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NOT_FOUND}
Get groups using too long name query parameter, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Get Template Groups ${g_long_str}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PARAM_IS_WRONG}
[Teardown] Del Template ${g_template}
Get groups when there are no groups, it should return empty result.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
@@ -379,6 +431,30 @@ Update group interval when template does not exist, it should fail.
[Teardown] Del Template ${g_template}
Update group using too long template name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Put Template Group ${g_long_str} ${g_group1}[name] ${2000}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Update group using too long group name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Put Template Group ${g_template} ${g_long_str} ${2000}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_GROUP_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Update group interval when group does not exist, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_empty}
Check Response Status ${res} 200
@@ -438,6 +514,30 @@ Delete nonexistent group from existent template, it should fail.
[Teardown] Del Template ${g_template}
Delete group using too long template name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Del Template Group ${g_long_str} ${g_group1}[name]
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Delete group using too long group name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Del Template Group ${g_template} ${g_long_str}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_GROUP_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Delete group from existent template, it should success.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
@@ -526,6 +626,26 @@ Add tag with conflicting name to existing template group, it should fail.
[Teardown] Del Template ${g_template}
Add tag using too long template name in request, it should fail.
Add Template And One Group ${g_template} ${g_plugin} ${g_group1}[name] ${g_group1}[interval]
${res} = Add Template Tags ${g_long_str} ${g_group1}[name] ${g_tag1}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Add tag using too long group name in request, it should fail.
Add Template And One Group ${g_template} ${g_plugin} ${g_group1}[name] ${g_group1}[interval]
${res} = Add Template Tags ${g_template} ${g_long_str} ${g_tag1}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_GROUP_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Add tag with too long name to existing template group, it should fail.
Add Template And One Group ${g_template} ${g_plugin} ${g_group1}[name] ${g_group1}[interval]
@@ -601,6 +721,30 @@ Get tags from nonexistent template group, it should fail.
[Teardown] Del Template ${g_template}
Get tags using too long template name query parameter, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Get Template Tags ${g_long_str} ${g_group1}[name]
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PARAM_IS_WRONG}
[Teardown] Del Template ${g_template}
Get tags using too long group name query parameter, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Get Template Tags ${g_template} ${g_long_str}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PARAM_IS_WRONG}
[Teardown] Del Template ${g_template}
Get tags when there are none from existent template group, it should return empty result.
Add Template And One Group ${g_template} ${g_plugin} ${g_group1}[name] ${g_group1}[interval]
@@ -623,6 +767,18 @@ Get tags from existent template group, it should return the tags.
[Teardown] Del Template ${g_template}
Get tags using too long tag name query parameter, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Grep Template Tags ${g_template} ${g_group1}[name] ${g_long_str}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_PARAM_IS_WRONG}
[Teardown] Del Template ${g_template}
Get tags by name pattern when there is no match, it should return empty result.
Add Template And One Group ${g_template} ${g_plugin} ${g_group1}[name] ${g_group1}[interval]
@@ -688,6 +844,30 @@ Update tag when template tag does not exist, it should fail.
[Teardown] Del Template ${g_template}
Update tag using too long template name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Put Template Tags ${g_long_str} ${g_group1}[name] ${g_tag1}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Update tag using too long group name in request, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Put Template Tags ${g_template} ${g_long_str} ${g_tag1}
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_GROUP_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Update tag name to invalid value, it should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
@@ -786,6 +966,42 @@ Delete tag when template tag does not exist, it trivially success.
[Teardown] Del Template ${g_template}
Delete tag using too long template name in request, it should should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Del Template Tags ${g_long_str} ${g_group1}[name] ${g_tag1}[name]
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TEMPLATE_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Delete tag using too long group name in request, it should should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Del Template Tags ${g_template} ${g_long_str} ${g_tag1}[name]
Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_GROUP_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Delete tag using too long tag name in request, it should should fail.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
Check Error Code ${res} ${NEU_ERR_SUCCESS}
${res} = Del Template Tags ${g_template} ${g_group1}[name] ${g_tag1}[name] ${g_long_str}
#Check Response Status ${res} 400
Check Error Code ${res} ${NEU_ERR_TAG_NAME_TOO_LONG}
[Teardown] Del Template ${g_template}
Delete one tag, it should keep other tags untouched.
${res} = Add Template ${g_template} ${g_plugin} ${g_groups}
Check Response Status ${res} 200
+5
View File
@@ -45,6 +45,10 @@ typedef enum {
NEU_ERR_INVALID_PASSWORD_LEN = 1012,
NEU_ERR_DUPLICATE_PASSWORD = 1013,
NEU_ERR_COMMAND_EXECUTION_FAILED = 1014,
NEU_ERR_IP_ADDRESS_INVALID = 1015,
NEU_ERR_IP_ADDRESS_IN_USE = 1016,
NEU_ERR_INVALID_USER = 1017,
NEU_ERR_INVALID_PASSWORD = 1018,
NEU_ERR_NODE_EXIST = 2002,
NEU_ERR_NODE_NOT_EXIST = 2003,
@@ -59,6 +63,7 @@ typedef enum {
NEU_ERR_NODE_NOT_ALLOW_SUBSCRIBE = 2012,
NEU_ERR_NODE_NOT_ALLOW_UPDATE = 2013,
NEU_ERR_NODE_NOT_ALLOW_MAP = 2014,
NEU_ERR_NODE_NAME_EMPTY = 2015,
NEU_ERR_GROUP_ALREADY_SUBSCRIBED = 2101,
NEU_ERR_GROUP_NOT_SUBSCRIBE = 2102,
+1 -1
View File
@@ -95,7 +95,7 @@ inline static const char *neu_type_string(neu_type_e type)
return "";
}
#define NEU_VALUE_SIZE 512
#define NEU_VALUE_SIZE 128
typedef union {
bool boolean;
int8_t i8;
@@ -1,27 +0,0 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2023 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
BEGIN TRANSACTION;
-- default data-stream-processing node for neuronex
INSERT
OR REPLACE INTO nodes (name, type, state, plugin_name)
VALUES
('data-stream-processing', 2, 1, 'eKuiper');
COMMIT;
@@ -1,45 +0,0 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2023 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
BEGIN TRANSACTION;
-- Update default data-stream-processing node setting when
-- the data-stream-processing node exists and is at init state.
-- The init state implies the user has not provide any setting yet.
INSERT INTO
settings (node_name, setting)
SELECT
name,
'{"params":{"host":"0.0.0.0","port":7081}}'
FROM
nodes
WHERE
name = 'data-stream-processing'
and state = 1;
-- Update default data-stream-processing node to running state when
-- the data-stream-processing node exists and is at init state.
UPDATE
nodes
SET
state = 3
where
name = 'data-stream-processing'
and state = 1;
COMMIT;
+1 -1
View File
@@ -28,7 +28,7 @@ FROM nodes
WHERE
settings.node_name = nodes.name
AND JSON_EXTRACT(json(setting), '$.params.transport_mode') IS NULL
AND (nodes.plugin_name='modbus-qh-tcp' OR nodes.plugin_name='modbus-plus-tcp' OR nodes.plugin_name='modbus-rtu' OR nodes.plugin_name='modbus-tcp' OR nodes.plugin_name='Modbus TCP' OR nodes.plugin_name='Modbus RTU' OR nodes.plugin_name='Modbus TCP QH');
AND (nodes.plugin_name='modbus-qh-tcp' OR nodes.plugin_name='modbus-plus-tcp' OR nodes.plugin_name='modbus-tcp' OR nodes.plugin_name='Modbus TCP' OR nodes.plugin_name='Modbus TCP QH');
UPDATE settings
SET setting = JSON_SET(json(setting), '$.params.connection_mode', 0)
+58 -1
View File
@@ -17,6 +17,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include "errcodes.h"
#include "neuron.h"
#include "utils/asprintf.h"
@@ -99,6 +103,7 @@ static int ekuiper_plugin_uninit(neu_plugin_t *plugin)
{
int rv = 0;
nng_close(plugin->sock);
nng_aio_free(plugin->recv_aio);
nng_mtx_free(plugin->mtx);
free(plugin->host);
@@ -127,7 +132,14 @@ static int ekuiper_plugin_start(neu_plugin_t *plugin)
if ((rv = nng_listen(plugin->sock, url, NULL, 0)) != 0) {
plog_error(plugin, "nng_listen: %s", nng_strerror(rv));
nng_close(plugin->sock);
return NEU_ERR_EINTERNAL;
if (NNG_EADDRINVAL == rv) {
rv = NEU_ERR_IP_ADDRESS_INVALID;
} else if (NNG_EADDRINUSE == rv) {
rv = NEU_ERR_IP_ADDRESS_IN_USE;
} else {
rv = NEU_ERR_EINTERNAL;
}
return rv;
}
nng_recv_aio(plugin->sock, plugin->recv_aio);
@@ -163,6 +175,12 @@ static int parse_config(neu_plugin_t *plugin, const char *setting,
goto error;
}
struct in_addr addr;
if (0 == inet_aton(host.v.val_str, &addr)) {
plog_error(plugin, "inet_aton fail: %s", host.v.val_str);
goto error;
}
// port, required
if (0 == port.v.val_int || port.v.val_int > 65535) {
plog_error(plugin, "setting invalid port: %" PRIi64, port.v.val_int);
@@ -182,6 +200,41 @@ error:
return -1;
}
static inline int check_url_listenable(neu_plugin_t *plugin, const char *url,
const char *host, uint16_t port)
{
if (NULL != plugin->host && // already configured and
port == plugin->port && // port is the same, then if
(0 == strcmp(plugin->host, host) // 1. host is the same
|| 0 == strcmp("0.0.0.0", host) // 2. to bind to any address
|| 0 == strcmp("0.0.0.0", plugin->host) // 3. bound to any address
)) {
// early return, no need check url is listenable
return 0;
}
nng_socket sock = NNG_SOCKET_INITIALIZER;
int rv = nng_pair0_open(&sock);
if (0 != rv) {
plog_error(plugin, "nng_pair0_open: %s", nng_strerror(rv));
return NEU_ERR_EINTERNAL;
}
if (0 != (rv = nng_listen(sock, url, NULL, 0))) {
plog_error(plugin, "nng_listen: %s", nng_strerror(rv));
if (NNG_EADDRINVAL == rv) {
rv = NEU_ERR_IP_ADDRESS_INVALID;
} else if (NNG_EADDRINUSE == rv) {
rv = NEU_ERR_IP_ADDRESS_IN_USE;
} else {
rv = NEU_ERR_EINTERNAL;
}
}
nng_close(sock);
return rv;
}
static int ekuiper_plugin_config(neu_plugin_t *plugin, const char *setting)
{
int rv = 0;
@@ -201,6 +254,10 @@ static int ekuiper_plugin_config(neu_plugin_t *plugin, const char *setting)
goto error;
}
if (0 != (rv = check_url_listenable(plugin, url, host, port))) {
goto error;
}
plog_notice(plugin, "config success");
free(plugin->host);
-11
View File
@@ -1,11 +0,0 @@
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/plugins")
set(CMAKE_BUILD_RPATH ./)
file(COPY ${CMAKE_SOURCE_DIR}/plugins/file/file.json DESTINATION ${CMAKE_BINARY_DIR}/plugins/schema/)
set(PLUGIN_NAME plugin-file)
set(PLUGIN_SOURCES file_plugin.c file_req.c)
add_library(${PLUGIN_NAME} SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/neuron)
target_sources(${PLUGIN_NAME} PRIVATE ${PLUGIN_SOURCES})
target_link_libraries(${PLUGIN_NAME} neuron-base)
-22
View File
@@ -1,22 +0,0 @@
{
"tag_regex": [
{
"type": 13,
"regex": ""
}
],
"group_interval": 1000,
"file_length": {
"name": "File Max Length",
"name_zh": "文件最大长度",
"description": "",
"description_zh": "",
"attribute": "required",
"type": "int",
"default": 512,
"valid": {
"min": 1,
"max": 512
}
}
}
-173
View File
@@ -1,173 +0,0 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include "file_req.h"
static neu_plugin_t *driver_open(void);
static int driver_close(neu_plugin_t *plugin);
static int driver_init(neu_plugin_t *plugin);
static int driver_uninit(neu_plugin_t *plugin);
static int driver_start(neu_plugin_t *plugin);
static int driver_stop(neu_plugin_t *plugin);
static int driver_config(neu_plugin_t *plugin, const char *config);
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data);
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag);
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
static const neu_plugin_intf_funs_t plugin_intf_funs = {
.open = driver_open,
.close = driver_close,
.init = driver_init,
.uninit = driver_uninit,
.start = driver_start,
.stop = driver_stop,
.setting = driver_config,
.request = driver_request,
.driver.validate_tag = driver_validate_tag,
.driver.group_timer = driver_group_timer,
.driver.write_tag = driver_write,
};
const neu_plugin_module_t neu_plugin_module = {
.version = NEURON_PLUGIN_VER_1_0,
.schema = "file",
.module_name = "File",
.module_descr = "The plugin is used to read and write files.",
.module_descr_zh = "该插件用于读写文件。",
.intf_funs = &plugin_intf_funs,
.kind = NEU_PLUGIN_KIND_SYSTEM,
.type = NEU_NA_TYPE_DRIVER,
.display = true,
.single = false,
};
static neu_plugin_t *driver_open(void)
{
neu_plugin_t *plugin = calloc(1, sizeof(neu_plugin_t));
neu_plugin_common_init(&plugin->common);
return plugin;
}
static int driver_close(neu_plugin_t *plugin)
{
plog_notice(plugin, "close and free `%s` plugin success",
plugin->common.name);
free(plugin);
return 0;
}
static int driver_init(neu_plugin_t *plugin)
{
plugin->events = neu_event_new();
plog_notice(plugin, "initialize `%s` plugin success", plugin->common.name);
return 0;
}
static int driver_uninit(neu_plugin_t *plugin)
{
neu_event_close(plugin->events);
plog_notice(plugin, "uninitialize `%s` plugin success",
plugin->common.name);
return 0;
}
static int driver_start(neu_plugin_t *plugin)
{
plugin->common.link_state = NEU_NODE_LINK_STATE_CONNECTED;
plog_notice(plugin, "start `%s` plugin success", plugin->common.name);
return 0;
}
static int driver_stop(neu_plugin_t *plugin)
{
plugin->common.link_state = NEU_NODE_LINK_STATE_DISCONNECTED;
plog_notice(plugin, "stop `%s` plugin success", plugin->common.name);
return 0;
}
static int driver_config(neu_plugin_t *plugin, const char *config)
{
char * err_param = NULL;
neu_json_elem_t file_length = { .name = "file_length", .t = NEU_JSON_INT };
int ret = neu_parse_param((char *) config, &err_param, 1, &file_length);
if (ret != 0) {
plog_error(plugin, "config:%s, decode error: %s", config, err_param);
free(err_param);
return -1;
}
plugin->file_length = file_length.v.val_int;
plugin->common.link_state = NEU_NODE_LINK_STATE_CONNECTED;
return 0;
}
static int driver_request(neu_plugin_t *plugin, neu_reqresp_head_t *head,
void *data)
{
(void) plugin;
(void) head;
(void) data;
return 0;
}
static int driver_validate_tag(neu_plugin_t *plugin, neu_datatag_t *tag)
{
plog_notice(plugin, "validate tag success, name:%s, address:%s, type:%d ",
tag->name, tag->address, tag->type);
return 0;
}
static int driver_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
return file_group_timer(plugin, group);
}
static int driver_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
int ret = file_write(plugin, req, tag, value);
plog_notice(plugin,
"write response, ret: %d, tag_name: %s, type: %d, address: %s",
ret, tag->name, tag->type, tag->address);
return ret;
}
-165
View File
@@ -1,165 +0,0 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include "file_req.h"
struct file_group_data {
UT_array *tags;
char * group;
};
static void plugin_group_free(neu_plugin_group_t *pgp);
int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group)
{
neu_adapter_update_metric_cb_t update_metric =
plugin->common.adapter_callbacks->update_metric;
int64_t rtt = NEU_METRIC_LAST_RTT_MS_MAX;
struct file_group_data *gd = NULL;
int length = plugin->file_length;
if (group->user_data == NULL) {
gd = calloc(1, sizeof(struct file_group_data));
group->user_data = gd;
group->group_free = plugin_group_free;
utarray_new(gd->tags, &ut_ptr_icd);
gd->group = strdup(group->group_name);
}
utarray_foreach(group->tags, neu_datatag_t *, tag)
{
FILE * f = NULL;
struct stat st = { 0 };
char * buf = calloc(1, length);
neu_dvalue_t dvalue = { 0 };
if (stat(tag->address, &st) != 0) {
dvalue.type = NEU_TYPE_ERROR;
dvalue.value.i32 = NEU_ERR_FILE_NOT_EXIST;
goto dvalue_result;
}
if ((f = fopen(tag->address, "rb+")) == NULL) {
nlog_warn("fail open to read and write file: %s", tag->address);
dvalue.type = NEU_TYPE_ERROR;
dvalue.value.i32 = NEU_ERR_FILE_OPEN_FAILURE;
goto dvalue_result;
}
fseek(f, 0, SEEK_END);
int size = ftell(f);
if (size >= length) {
nlog_warn(
"the file length exceeds the set value, file: %s, length: %d",
tag->address, size);
dvalue.type = NEU_TYPE_ERROR;
dvalue.value.i32 = NEU_ERR_STRING_TOO_LONG;
fclose(f);
goto dvalue_result;
}
fseek(f, 0, SEEK_SET);
int ret = fread(buf, sizeof(char), length, f);
if (ret == 0) {
nlog_warn("read file failed:%s", tag->address);
dvalue.type = NEU_TYPE_ERROR;
dvalue.value.i32 = NEU_ERR_FILE_READ_FAILURE;
fclose(f);
goto dvalue_result;
} else if (ret >= NEU_VALUE_SIZE) {
nlog_warn("the file length exceeds the maximum, file: %s, ret: %d",
tag->address, ret);
dvalue.type = NEU_TYPE_ERROR;
dvalue.value.i32 = NEU_ERR_STRING_TOO_LONG;
fclose(f);
goto dvalue_result;
}
dvalue.type = NEU_TYPE_STRING;
strncpy(dvalue.value.str, buf, strlen(buf));
rtt = 1;
fclose(f);
dvalue_result:
plugin->common.adapter_callbacks->driver.update(
plugin->common.adapter, group->group_name, tag->name, dvalue);
free(buf);
}
update_metric(plugin->common.adapter, NEU_METRIC_LAST_RTT_MS, rtt, NULL);
return 0;
}
static void plugin_group_free(neu_plugin_group_t *pgp)
{
struct file_group_data *gd = (struct file_group_data *) pgp->user_data;
utarray_foreach(gd->tags, neu_datatag_t **, tag) { free(*tag); }
utarray_free(gd->tags);
free(gd->group);
free(gd);
}
int file_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value)
{
FILE *fp = NULL;
int ret = 0;
int length = strlen(value.str);
if (length >= NEU_VALUE_SIZE) {
nlog_warn("write file exceeds the maximum value, file: %s, length: %d",
tag->address, length);
ret = NEU_ERR_STRING_TOO_LONG;
goto dvalue_result;
}
fp = fopen(tag->address, "w");
if (0 == fwrite(value.str, sizeof(char), strlen(value.str), fp)) {
nlog_warn("write file failed: %s", tag->address);
ret = NEU_ERR_FILE_WRITE_FAILURE;
fclose(fp);
goto dvalue_result;
}
fclose(fp);
neu_datatag_string_ltoh(value.str, strlen(value.str));
dvalue_result:
plugin->common.adapter_callbacks->driver.write_response(
plugin->common.adapter, req, ret);
return 0;
}
-37
View File
@@ -1,37 +0,0 @@
/**
* NEURON IIoT System for Industry 4.0
* Copyright (C) 2020-2022 EMQ Technologies Co., Ltd All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#ifndef _NEU_M_PLUGIN_file_REQ_H_
#define _NEU_M_PLUGIN_file_REQ_H_
#include <neuron.h>
struct neu_plugin {
neu_plugin_common_t common;
neu_events_t *events;
int file_length;
};
int file_group_timer(neu_plugin_t *plugin, neu_plugin_group_t *group);
int file_write(neu_plugin_t *plugin, void *req, neu_datatag_t *tag,
neu_value_u value);
#endif
-29
View File
@@ -327,31 +327,6 @@
"value": 1
}
},
"transport_mode": {
"name": "Transport Mode",
"name_zh": "传输模式",
"description": "TCP transfer or UDP transfer",
"description_zh": "TCP 传输或 UDP 传输",
"attribute": "required",
"type": "map",
"default": 0,
"valid": {
"map": [
{
"key": "TCP",
"value": 0
},
{
"key": "UDP",
"value": 1
}
]
},
"condition": {
"field": "link",
"value": 1
}
},
"connection_mode": {
"name": "Connection Mode",
"name_zh": "连接模式",
@@ -375,10 +350,6 @@
"condition": {
"field": "link",
"value": 1
},
"condition": {
"field": "transport_mode",
"value": 0
}
}
}
+22 -32
View File
@@ -148,10 +148,9 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
neu_json_elem_t timeout = { .name = "timeout", .t = NEU_JSON_INT };
neu_json_elem_t interval = { .name = "interval", .t = NEU_JSON_INT };
neu_json_elem_t mode = { .name = "connection_mode", .t = NEU_JSON_INT };
neu_json_elem_t tmode = { .name = "transport_mode", .t = NEU_JSON_INT };
neu_json_elem_t host = { .name = "host", .t = NEU_JSON_STR };
neu_json_elem_t port = { .name = "port", .t = NEU_JSON_INT };
neu_json_elem_t mode = { .name = "connection_mode", .t = NEU_JSON_INT };
neu_json_elem_t host = { .name = "host", .t = NEU_JSON_STR };
neu_json_elem_t port = { .name = "port", .t = NEU_JSON_INT };
neu_json_elem_t device = { .name = "device", .t = NEU_JSON_STR };
neu_json_elem_t stop = { .name = "stop", .t = NEU_JSON_INT };
@@ -184,8 +183,8 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
ret = neu_parse_param((char *) config, &err_param, 5, &device, &stop,
&parity, &baud, &data);
} else {
ret = neu_parse_param((char *) config, &err_param, 4, &mode, &host,
&port, &tmode);
ret = neu_parse_param((char *) config, &err_param, 3, &mode, &host,
&port);
}
if (ret != 0) {
@@ -223,33 +222,24 @@ static int driver_config(neu_plugin_t *plugin, const char *config)
device.v.val_str, baud.v.val_int, data.v.val_int,
parity.v.val_int, stop.v.val_int);
} else {
if (tmode.v.val_int == 1) {
param.type = NEU_CONN_UDP;
param.params.udp.timeout = 3000;
param.params.udp.src_ip = "0.0.0.0";
param.params.udp.src_port = 0;
param.params.udp.dst_ip = host.v.val_str;
param.params.udp.dst_port = port.v.val_int;
plugin->is_server = false;
} else {
if (mode.v.val_int == 1) {
param.type = NEU_CONN_TCP_SERVER;
param.params.tcp_server.ip = host.v.val_str;
param.params.tcp_server.port = port.v.val_int;
param.params.tcp_server.start_listen = modbus_tcp_server_listen;
param.params.tcp_server.stop_listen = modbus_tcp_server_stop;
param.params.tcp_server.timeout = timeout.v.val_int;
param.params.tcp_server.max_link = 1;
plugin->is_server = true;
}
if (mode.v.val_int == 0) {
param.type = NEU_CONN_TCP_CLIENT;
param.params.tcp_client.ip = host.v.val_str;
param.params.tcp_client.port = port.v.val_int;
param.params.tcp_client.timeout = timeout.v.val_int;
plugin->is_server = false;
}
if (mode.v.val_int == 1) {
param.type = NEU_CONN_TCP_SERVER;
param.params.tcp_server.ip = host.v.val_str;
param.params.tcp_server.port = port.v.val_int;
param.params.tcp_server.start_listen = modbus_tcp_server_listen;
param.params.tcp_server.stop_listen = modbus_tcp_server_stop;
param.params.tcp_server.timeout = timeout.v.val_int;
param.params.tcp_server.max_link = 1;
plugin->is_server = true;
}
if (mode.v.val_int == 0) {
param.type = NEU_CONN_TCP_CLIENT;
param.params.tcp_client.ip = host.v.val_str;
param.params.tcp_client.port = port.v.val_int;
param.params.tcp_client.timeout = timeout.v.val_int;
plugin->is_server = false;
}
plog_notice(plugin,
"config: host: %s, port: %" PRId64 ", mode: %" PRId64 "",
host.v.val_str, port.v.val_int, mode.v.val_int);
+36 -15
View File
@@ -62,26 +62,47 @@ void handle_add_adapter(nng_aio *aio)
})
}
void handle_update_adapter(nng_aio *aio)
static inline int send_node_update_req(nng_aio * aio,
neu_json_update_node_req_t *req)
{
neu_plugin_t *plugin = neu_rest_get_plugin();
int len = strlen(req->name);
if (NEU_NODE_NAME_LEN <= len) {
return NEU_ERR_NODE_NAME_TOO_LONG;
}
len = strlen(req->new_name);
if (NEU_NODE_NAME_LEN <= len) {
return NEU_ERR_NODE_NAME_TOO_LONG;
} else if (0 == len) {
return NEU_ERR_NODE_NAME_EMPTY;
}
neu_req_update_node_t cmd = { 0 };
strcpy(cmd.node, req->name);
strcpy(cmd.new_name, req->new_name);
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_UPDATE_NODE,
};
if (0 != neu_plugin_op(plugin, header, &cmd)) {
return NEU_ERR_IS_BUSY;
}
return 0;
}
void handle_update_adapter(nng_aio *aio)
{
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
aio, neu_json_update_node_req_t, neu_json_decode_update_node_req, {
int ret = 0;
neu_reqresp_head_t header = { 0 };
neu_req_update_node_t cmd = { 0 };
header.ctx = aio;
header.type = NEU_REQ_UPDATE_NODE;
strcpy(cmd.node, req->name);
strcpy(cmd.new_name, req->new_name);
ret = neu_plugin_op(plugin, header, &cmd);
if (ret != 0) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
});
int ret = send_node_update_req(aio, req);
if (0 != ret) {
NEU_JSON_RESPONSE_ERROR(
ret, { neu_http_response(aio, ret, result_error); });
}
})
}
-6
View File
@@ -152,12 +152,6 @@ static struct neu_http_handler rest_handlers[] = {
.url = "/",
.value.path = "/web",
},
{
.method = NEU_HTTP_METHOD_UNDEFINE,
.type = NEU_HTTP_HANDLER_PROXY,
.url = "/api/v2/ekuiper",
.value.dst_url = "http://127.0.0.1:9081",
},
{
.method = NEU_HTTP_METHOD_POST,
.type = NEU_HTTP_HANDLER_FUNCTION,
+2 -1
View File
@@ -63,7 +63,8 @@ void handle_logs_files(nng_aio *aio)
rv = system("rm -rf /tmp/neuron_debug.tar.gz");
nlog_warn("remove old neuron_debug.tar.gz, rv: %d", rv);
/* tar the neuron directory */
rv = system("tar -zcvf /tmp/neuron_debug.tar.gz ../neuron");
rv = system("tar -zcvf /tmp/neuron_debug.tar.gz "
"--exclude='persistence/neuron.lic' ../neuron");
if (rv == -1) {
nlog_error("failed to create neuron_debug.tar.gz, rv: %d", rv);
NEU_JSON_RESPONSE_ERROR(NEU_ERR_COMMAND_EXECUTION_FAILED, {
+4 -4
View File
@@ -58,7 +58,7 @@ void handle_login(nng_aio *aio)
if (NULL == user) {
nlog_error("could not find user `%s`", req->name);
NEU_JSON_RESPONSE_ERROR(NEU_ERR_INVALID_USER_OR_PASSWORD, {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_INVALID_USER, {
neu_http_response(aio, error_code.error, result_error);
});
} else if (pass_len < NEU_USER_PASSWORD_MIN_LEN ||
@@ -90,7 +90,7 @@ void handle_login(nng_aio *aio)
free(result);
} else {
nlog_error("user `%s` password check fail", req->name);
NEU_JSON_RESPONSE_ERROR(NEU_ERR_INVALID_USER_OR_PASSWORD, {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_INVALID_PASSWORD, {
neu_http_response(aio, error_code.error, result_error);
});
}
@@ -114,10 +114,10 @@ void handle_password(nng_aio *aio)
rv = NEU_ERR_INVALID_PASSWORD_LEN;
} else if (NULL == (user = neu_load_user(req->name))) {
nlog_error("could not find user `%s`", req->name);
rv = NEU_ERR_INVALID_USER_OR_PASSWORD;
rv = NEU_ERR_INVALID_USER;
} else if (!neu_user_check_password(user, req->old_pass)) {
nlog_error("user `%s` password check fail", req->name);
rv = NEU_ERR_INVALID_USER_OR_PASSWORD;
rv = NEU_ERR_INVALID_PASSWORD;
} else if (0 !=
(rv = neu_user_update_password(user, req->new_pass))) {
nlog_error("user `%s` update password fail", req->name);
+158 -77
View File
@@ -170,15 +170,22 @@ void handle_del_template(nng_aio *aio)
NEU_VALIDATE_JWT(aio);
neu_req_del_template_t cmd = { 0 };
int ret = neu_http_get_param_str(aio, "name", cmd.name, sizeof(cmd.name));
// optional parameter
if (-2 != ret && (ret <= 0 || sizeof(cmd.name) <= (size_t) ret)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, NEU_ERR_PARAM_IS_WRONG, result_error);
});
return;
}
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_DEL_TEMPLATE,
};
neu_req_del_template_t cmd = { 0 };
neu_http_get_param_str(aio, "name", cmd.name, sizeof(cmd.name));
if (0 != neu_plugin_op(plugin, header, &cmd)) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
@@ -197,10 +204,19 @@ void handle_get_template(nng_aio *aio)
};
neu_req_get_template_t cmd = { 0 };
if (neu_http_get_param_str(aio, "name", cmd.name, sizeof(cmd.name)) <= 0) {
int ret = neu_http_get_param_str(aio, "name", cmd.name, sizeof(cmd.name));
if (0 < ret && (size_t) ret < sizeof(cmd.name)) {
// valid name parameter provided
header.type = NEU_REQ_GET_TEMPLATE;
} else if (-2 == ret) {
// no name parameter
header.type = NEU_REQ_GET_TEMPLATES;
} else {
header.type = NEU_REQ_GET_TEMPLATE;
// invalid name parameter
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, NEU_ERR_PARAM_IS_WRONG, result_error);
});
return;
}
if (0 != neu_plugin_op(plugin, header, &cmd)) {
@@ -327,16 +343,24 @@ send_template_mod_group_req(nng_aio *aio, neu_reqresp_type_e type,
{
neu_plugin_t *plugin = neu_rest_get_plugin();
neu_reqresp_head_t header = {
.ctx = aio,
.type = type,
};
if (strlen(req->tmpl) >= NEU_TEMPLATE_NAME_LEN) {
return NEU_ERR_TEMPLATE_NAME_TOO_LONG;
} else if (strlen(req->group) >= NEU_GROUP_NAME_LEN) {
return NEU_ERR_GROUP_NAME_TOO_LONG;
} else if (req->interval < NEU_GROUP_INTERVAL_LIMIT) {
return NEU_ERR_GROUP_PARAMETER_INVALID;
}
neu_req_add_template_group_t cmd = { 0 };
strcpy(cmd.tmpl, req->tmpl);
strcpy(cmd.group, req->group);
cmd.interval = req->interval;
neu_reqresp_head_t header = {
.ctx = aio,
.type = type,
};
if (0 != neu_plugin_op(plugin, header, &cmd)) {
return NEU_ERR_IS_BUSY;
}
@@ -350,22 +374,10 @@ static inline void process_mod_template_group(nng_aio * aio,
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
aio, neu_json_template_mod_group_req_t,
neu_json_decode_template_mod_group_req, {
if (strlen(req->group) >= NEU_GROUP_NAME_LEN) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_GROUP_NAME_TOO_LONG, {
neu_http_response(aio, NEU_ERR_GROUP_NAME_TOO_LONG,
result_error);
});
} else if (req->interval < NEU_GROUP_INTERVAL_LIMIT) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_GROUP_PARAMETER_INVALID, {
neu_http_response(aio, NEU_ERR_GROUP_PARAMETER_INVALID,
result_error);
});
} else {
int ret = send_template_mod_group_req(aio, type, req);
if (ret != 0) {
NEU_JSON_RESPONSE_ERROR(
ret, { neu_http_response(aio, ret, result_error); });
}
int ret = send_template_mod_group_req(aio, type, req);
if (ret != 0) {
NEU_JSON_RESPONSE_ERROR(
ret, { neu_http_response(aio, ret, result_error); });
}
})
}
@@ -380,23 +392,43 @@ void handle_update_template_group(nng_aio *aio)
process_mod_template_group(aio, NEU_REQ_UPDATE_TEMPLATE_GROUP);
}
void handle_del_template_group(nng_aio *aio)
static inline int
send_template_del_group_req(nng_aio * aio,
neu_json_template_del_group_req_t *req)
{
neu_plugin_t *plugin = neu_rest_get_plugin();
if (strlen(req->tmpl) >= NEU_TEMPLATE_NAME_LEN) {
return NEU_ERR_TEMPLATE_NAME_TOO_LONG;
}
if (strlen(req->group) >= NEU_GROUP_NAME_LEN) {
return NEU_ERR_GROUP_NAME_TOO_LONG;
}
neu_req_add_template_tag_t cmd = { 0 };
strcpy(cmd.tmpl, req->tmpl);
strcpy(cmd.group, req->group);
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_DEL_TEMPLATE_GROUP,
};
if (0 != neu_plugin_op(plugin, header, &cmd)) {
return NEU_ERR_IS_BUSY;
}
return 0;
}
void handle_del_template_group(nng_aio *aio)
{
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
aio, neu_json_template_del_group_req_t,
neu_json_decode_template_del_group_req, {
neu_reqresp_head_t header = { 0 };
header.ctx = aio;
header.type = NEU_REQ_DEL_TEMPLATE_GROUP;
neu_req_add_template_group_t cmd = { 0 };
strcpy(cmd.tmpl, req->tmpl);
strcpy(cmd.group, req->group);
if (0 != neu_plugin_op(plugin, header, &cmd)) {
int ret = NEU_ERR_IS_BUSY;
int ret = send_template_del_group_req(aio, req);
if (0 != ret) {
NEU_JSON_RESPONSE_ERROR(
ret, { neu_http_response(aio, ret, result_error); });
}
@@ -406,15 +438,16 @@ void handle_del_template_group(nng_aio *aio)
static int send_template_mod_tags_req(nng_aio *aio, neu_reqresp_type_e type,
neu_json_template_mod_tags_req_t *req)
{
int ret = 0;
neu_plugin_t *plugin = neu_rest_get_plugin();
int ret = 0;
int i = 0;
if (strlen(req->tmpl) >= NEU_TEMPLATE_NAME_LEN) {
return NEU_ERR_TEMPLATE_NAME_TOO_LONG;
}
neu_reqresp_head_t header = {
.ctx = aio,
.type = type,
};
if (strlen(req->group) >= NEU_GROUP_NAME_LEN) {
return NEU_ERR_GROUP_NAME_TOO_LONG;
}
neu_req_add_template_tag_t cmd = { 0 };
strcpy(cmd.tmpl, req->tmpl);
@@ -425,7 +458,7 @@ static int send_template_mod_tags_req(nng_aio *aio, neu_reqresp_type_e type,
return NEU_ERR_EINTERNAL;
}
for (i = 0; i < req->n_tag; i++) {
for (int i = 0; i < req->n_tag; i++) {
cmd.n_tag += 1;
if (0 != (ret = set_tag_by_json(&cmd.tags[i], &req->tags[i]))) {
neu_req_add_template_tag_fini(&cmd);
@@ -433,6 +466,11 @@ static int send_template_mod_tags_req(nng_aio *aio, neu_reqresp_type_e type,
}
}
neu_reqresp_head_t header = {
.ctx = aio,
.type = type,
};
if (0 != neu_plugin_op(plugin, header, &cmd)) {
neu_req_add_template_tag_fini(&cmd);
return NEU_ERR_IS_BUSY;
@@ -447,26 +485,38 @@ static int send_template_del_tags_req(nng_aio * aio,
int ret = 0;
neu_plugin_t *plugin = neu_rest_get_plugin();
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_DEL_TEMPLATE_TAG,
};
if (strlen(req->tmpl) >= NEU_TEMPLATE_NAME_LEN) {
return NEU_ERR_TEMPLATE_NAME_TOO_LONG;
}
if (strlen(req->group) >= NEU_GROUP_NAME_LEN) {
return NEU_ERR_GROUP_NAME_TOO_LONG;
}
neu_req_del_template_tag_t cmd = { 0 };
strcpy(cmd.tmpl, req->tmpl);
strcpy(cmd.group, req->group);
cmd.n_tag = req->n_tags;
cmd.tags = calloc(req->n_tags, sizeof(char *));
cmd.tags = calloc(req->n_tags, sizeof(char *));
if (NULL == cmd.tags) {
return NEU_ERR_EINTERNAL;
}
for (int i = 0; i < req->n_tags; i++) {
if (strlen(req->tags[i]) >= NEU_TAG_NAME_LEN) {
neu_req_del_template_tag_fini(&cmd);
return NEU_ERR_TAG_NAME_TOO_LONG;
}
cmd.tags[i] = req->tags[i];
req->tags[i] = NULL; // ownership moved
cmd.n_tag += 1;
}
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_DEL_TEMPLATE_TAG,
};
if (ret != neu_plugin_op(plugin, header, &cmd)) {
neu_req_del_template_tag_fini(&cmd);
ret = NEU_ERR_IS_BUSY;
@@ -530,44 +580,74 @@ void handle_get_template_tags(nng_aio *aio)
neu_req_get_template_tag_t cmd = { 0 };
if (neu_http_get_param_str(aio, "template", cmd.tmpl, sizeof(cmd.tmpl)) <=
0 ||
neu_http_get_param_str(aio, "group", cmd.group, sizeof(cmd.group)) <=
0) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, NEU_ERR_PARAM_IS_WRONG, result_error);
})
return;
ret = neu_http_get_param_str(aio, "template", cmd.tmpl, sizeof(cmd.tmpl));
// required parameter
if (ret <= 0 || sizeof(cmd.tmpl) <= (size_t) ret) {
ret = NEU_ERR_PARAM_IS_WRONG;
goto end;
}
// optional
neu_http_get_param_str(aio, "name", cmd.name, sizeof(cmd.name));
ret = neu_http_get_param_str(aio, "group", cmd.group, sizeof(cmd.group));
// required parameter
if (ret <= 0 || sizeof(cmd.tmpl) <= (size_t) ret) {
ret = NEU_ERR_PARAM_IS_WRONG;
goto end;
}
ret = neu_http_get_param_str(aio, "name", cmd.name, sizeof(cmd.name));
// optional parameter
if (-2 != ret && (ret <= 0 || sizeof(cmd.name) <= (size_t) ret)) {
ret = NEU_ERR_PARAM_IS_WRONG;
goto end;
}
ret = neu_plugin_op(plugin, header, &cmd);
if (ret != 0) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_IS_BUSY, {
neu_http_response(aio, NEU_ERR_IS_BUSY, result_error);
});
if (0 != ret) {
ret = NEU_ERR_IS_BUSY;
}
end:
if (0 != ret) {
NEU_JSON_RESPONSE_ERROR(ret,
{ neu_http_response(aio, ret, result_error); });
}
}
static inline int send_template_inst_req(nng_aio * aio,
neu_json_template_inst_req_t *req)
{
neu_plugin_t *plugin = neu_rest_get_plugin();
if (strlen(req->name) >= NEU_TEMPLATE_NAME_LEN) {
return NEU_ERR_TEMPLATE_NAME_TOO_LONG;
}
if (strlen(req->node) >= NEU_NODE_NAME_LEN) {
return NEU_ERR_PLUGIN_NAME_TOO_LONG;
}
neu_req_inst_template_t cmd = { 0 };
strncpy(cmd.tmpl, req->name, sizeof(cmd.tmpl));
strncpy(cmd.node, req->node, sizeof(cmd.node));
neu_reqresp_head_t header = {
.ctx = aio,
.type = NEU_REQ_INST_TEMPLATE,
};
if (0 != neu_plugin_op(plugin, header, &cmd)) {
return NEU_ERR_IS_BUSY;
}
return 0;
}
void handle_instantiate_template(nng_aio *aio)
{
NEU_PROCESS_HTTP_REQUEST_VALIDATE_JWT(
aio, neu_json_template_inst_req_t, neu_json_decode_template_inst_req, {
neu_plugin_t *plugin = neu_rest_get_plugin();
neu_reqresp_head_t header = { 0 };
header.ctx = aio;
header.type = NEU_REQ_INST_TEMPLATE;
neu_req_inst_template_t cmd = { 0 };
strncpy(cmd.tmpl, req->name, sizeof(cmd.tmpl));
strncpy(cmd.node, req->node, sizeof(cmd.node));
int ret = neu_plugin_op(plugin, header, &cmd);
int ret = send_template_inst_req(aio, req);
if (0 != ret) {
ret = NEU_ERR_IS_BUSY;
NEU_JSON_RESPONSE_ERROR(
ret, { neu_http_response(aio, ret, result_error); });
}
@@ -587,7 +667,8 @@ void handle_get_template_group(nng_aio *aio)
neu_req_get_template_group_t cmd = { 0 };
int ret = neu_http_get_param_str(aio, "name", cmd.tmpl, sizeof(cmd.tmpl));
if (ret <= 0 || (size_t) ret >= sizeof(cmd.tmpl)) {
// required parameter
if (ret <= 0 || sizeof(cmd.tmpl) <= (size_t) ret) {
NEU_JSON_RESPONSE_ERROR(NEU_ERR_PARAM_IS_WRONG, {
neu_http_response(aio, NEU_ERR_PARAM_IS_WRONG, result_error);
});
+21 -1
View File
@@ -57,6 +57,7 @@ typedef struct group {
neu_event_timer_t *report;
neu_event_timer_t *read;
neu_event_timer_t *write;
neu_plugin_group_t grp;
neu_adapter_driver_t *driver;
@@ -75,6 +76,7 @@ struct neu_adapter_driver {
static int report_callback(void *usr_data);
static int read_callback(void *usr_data);
static int write_callback(void *usr_data);
static void read_group(int64_t timestamp, int64_t timeout,
neu_driver_cache_t *cache, const char *group,
UT_array *tags, neu_resp_tag_value_t *datas);
@@ -197,6 +199,7 @@ int neu_adapter_driver_uninit(neu_adapter_driver_t *driver)
neu_adapter_del_timer((neu_adapter_t *) driver, el->report);
neu_event_del_timer(driver->driver_events, el->read);
neu_event_del_timer(driver->driver_events, el->write);
if (el->grp.group_free != NULL) {
el->grp.group_free(&el->grp);
}
@@ -625,6 +628,11 @@ int neu_adapter_driver_add_group(neu_adapter_driver_t *driver, const char *name,
param.cb = read_callback;
find->read = neu_event_add_timer(driver->driver_events, param);
param.second = 0;
param.millisecond = 100;
param.cb = write_callback;
find->write = neu_event_add_timer(driver->driver_events, param);
REGISTER_GROUP_METRIC(&driver->adapter, find->name,
NEU_METRIC_GROUP_TAGS_TOTAL,
neu_group_tag_size(find->group));
@@ -683,6 +691,7 @@ int neu_adapter_driver_del_group(neu_adapter_driver_t *driver, const char *name)
neu_adapter_del_timer((neu_adapter_t *) driver, find->report);
neu_event_del_timer(driver->driver_events, find->read);
neu_event_del_timer(driver->driver_events, find->write);
if (find->grp.group_free != NULL) {
find->grp.group_free(&find->grp);
}
@@ -1069,7 +1078,7 @@ static void group_change(void *arg, int64_t timestamp, UT_array *static_tags,
timestamp);
}
static int read_callback(void *usr_data)
static int write_callback(void *usr_data)
{
group_t * group = (group_t *) usr_data;
neu_node_running_state_e state = group->driver->adapter.state;
@@ -1098,6 +1107,17 @@ static int read_callback(void *usr_data)
utarray_clear(group->wt_tags);
pthread_mutex_unlock(&group->wt_mtx);
return 0;
}
static int read_callback(void *usr_data)
{
group_t * group = (group_t *) usr_data;
neu_node_running_state_e state = group->driver->adapter.state;
if (state != NEU_NODE_RUNNING_STATE_RUNNING) {
return 0;
}
if (neu_group_is_change(group->group, group->timestamp)) {
neu_group_change_test(group->group, group->timestamp, (void *) group,
group_change);
+3 -3
View File
@@ -61,7 +61,7 @@ const char *usage_text =
" -d, --daemon run as daemon process\n"
" -h, --help show this help message\n"
" --log log to the stdout\n"
" --log_level <LEVEL> default log level(DEBUG,INFO)\n"
" --log_level <LEVEL> default log level(DEBUG,NOTICE)\n"
" --reset-password reset dashboard to use default password\n"
" --restart <POLICY> restart policy to apply when neuron daemon terminates,\n"
" - never, never restart (default)\n"
@@ -254,8 +254,8 @@ void neu_cli_args_init(neu_cli_args_t *args, int argc, char *argv[])
if (strcmp(log_level, "DEBUG") == 0) {
default_log_level = ZLOG_LEVEL_DEBUG;
}
if (strcmp(log_level, "INFO") == 0) {
default_log_level = ZLOG_LEVEL_INFO;
if (strcmp(log_level, "NOTICE") == 0) {
default_log_level = ZLOG_LEVEL_NOTICE;
}
free(log_level);
}
+28 -10
View File
@@ -47,6 +47,7 @@ struct neu_conn {
void * data;
bool is_connected;
bool stop;
bool connection_ok;
neu_conn_callback connected;
neu_conn_callback disconnected;
@@ -341,8 +342,14 @@ ssize_t neu_conn_send(neu_conn_t *conn, uint8_t *buf, ssize_t len)
conn->fd, len, ret, strerror(errno), errno);
}
if (ret == -1 && errno != EAGAIN) {
conn_disconnect(conn);
if (ret == -1) {
if (errno != EAGAIN) {
conn_disconnect(conn);
} else {
if (conn->connection_ok == true) {
conn_disconnect(conn);
}
}
}
if (ret > 0 && conn->callback_trigger == false) {
@@ -353,6 +360,7 @@ ssize_t neu_conn_send(neu_conn_t *conn, uint8_t *buf, ssize_t len)
if (ret > 0) {
conn->state.send_bytes += ret;
conn->connection_ok = true;
}
pthread_mutex_unlock(&conn->mtx);
@@ -399,14 +407,23 @@ ssize_t neu_conn_recv(neu_conn_t *conn, uint8_t *buf, ssize_t len)
}
break;
}
if (ret <= 0) {
zlog_error(
conn->param.log,
"conn fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d), type:%d",
conn->fd, len, ret, strerror(errno), errno, conn->param.type);
if (errno == EPIPE || (ret == 0 && errno != 0)) {
if (conn->param.type == NEU_CONN_TTY_CLIENT) {
if (ret == -1) {
zlog_error(
conn->param.log,
"tty conn fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d)",
conn->fd, len, ret, strerror(errno), errno);
conn_disconnect(conn);
}
} else {
if (ret <= 0) {
zlog_error(conn->param.log,
"conn fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d)",
conn->fd, len, ret, strerror(errno), errno);
if (ret == 0 || (ret == -1 && errno != EAGAIN)) {
conn_disconnect(conn);
}
}
}
pthread_mutex_unlock(&conn->mtx);
@@ -507,7 +524,7 @@ ssize_t neu_conn_udp_recvfrom(neu_conn_t *conn, uint8_t *buf, ssize_t len,
zlog_error(conn->param.log,
"conn udp fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d)",
conn->fd, len, ret, strerror(errno), errno);
if (errno == EPIPE || (ret == 0 && errno != 0)) {
if (ret == 0 || (ret == -1 && errno != EAGAIN)) {
conn_disconnect(conn);
}
}
@@ -995,7 +1012,8 @@ static void conn_connect(neu_conn_t *conn)
static void conn_disconnect(neu_conn_t *conn)
{
conn->is_connected = false;
conn->is_connected = false;
conn->connection_ok = false;
if (conn->callback_trigger == true) {
conn->disconnected(conn->data, conn->fd);
conn->callback_trigger = false;
+6 -1
View File
@@ -167,6 +167,11 @@ int neu_manager_add_template(neu_manager_t *manager, const char *name,
return NEU_ERR_EINTERNAL;
}
if (NEU_NA_TYPE_DRIVER != plug_inst->module->type) {
free_plugin_instance(plug_inst);
return NEU_ERR_PLUGIN_NOT_SUPPORT_TEMPLATE;
}
neu_template_t *tmpl = neu_template_new(name, plugin);
if (NULL == tmpl) {
free_plugin_instance(plug_inst);
@@ -521,7 +526,7 @@ int neu_manager_instantiate_template(neu_manager_t * manager,
neu_adapter_driver_t *driver = (neu_adapter_driver_t *) adapter;
if (adapter->module->type != NEU_NA_TYPE_DRIVER) {
ret = NEU_ERR_GROUP_NOT_ALLOW;
ret = NEU_ERR_PLUGIN_NOT_SUPPORT_TEMPLATE;
goto end;
}
+7 -1
View File
@@ -77,7 +77,7 @@ ssize_t neu_url_decode(const char *s, size_t len, char *buf, size_t size)
}
buf[j++] = c;
}
buf[(j < size) ? j : --j] = '\0';
buf[(j < size) ? j : j - 1] = '\0';
return j;
}
@@ -317,10 +317,14 @@ int neu_http_response(nng_aio *aio, neu_err_code_e code, char *content)
case NEU_ERR_NEED_TOKEN:
case NEU_ERR_DECODE_TOKEN:
case NEU_ERR_INVALID_USER_OR_PASSWORD:
case NEU_ERR_INVALID_USER:
case NEU_ERR_INVALID_PASSWORD:
status = NNG_HTTP_STATUS_UNAUTHORIZED;
break;
case NEU_ERR_BODY_IS_WRONG:
case NEU_ERR_PARAM_IS_WRONG:
case NEU_ERR_IP_ADDRESS_INVALID:
case NEU_ERR_IP_ADDRESS_IN_USE:
case NEU_ERR_NODE_SETTING_INVALID:
case NEU_ERR_NODE_NOT_ALLOW_UPDATE:
case NEU_ERR_NODE_NOT_ALLOW_SUBSCRIBE:
@@ -332,10 +336,12 @@ int neu_http_response(nng_aio *aio, neu_err_code_e code, char *content)
case NEU_ERR_LIBRARY_FAILED_TO_OPEN:
case NEU_ERR_LIBRARY_MODULE_INVALID:
case NEU_ERR_NODE_NAME_TOO_LONG:
case NEU_ERR_NODE_NAME_EMPTY:
case NEU_ERR_GROUP_NAME_TOO_LONG:
case NEU_ERR_INVALID_PASSWORD_LEN:
case NEU_ERR_DUPLICATE_PASSWORD:
case NEU_ERR_TEMPLATE_NAME_TOO_LONG:
case NEU_ERR_PLUGIN_NAME_TOO_LONG:
case NEU_ERR_PLUGIN_NOT_SUPPORT_TEMPLATE:
status = NNG_HTTP_STATUS_BAD_REQUEST;
break;
+5
View File
@@ -113,6 +113,11 @@ TEST(HTTPTest, http_get_param_str)
EXPECT_EQ(ret, 3);
EXPECT_EQ(0, strcmp("组", buf));
nng_http_req_set_uri(req, "/?group=%E7%BB%84");
ret = neu_http_get_param_str(aio, "group", buf, 3);
EXPECT_EQ(ret, 3);
EXPECT_EQ(0, strncmp("组", buf, 2));
nng_aio_free(aio);
nng_http_req_free(req);
nng_url_free(url);
+1 -1
View File
@@ -1 +1 @@
2.4.0
2.5.1