k2hr3-api 1.0.42 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/k2hr3-init.sh.templ +4 -4
- package/dist/.gitkeep +0 -0
- package/dist/src/app.js +262 -0
- package/{bin → dist/src/bin}/run.sh +1 -1
- package/dist/src/bin/watcher.js +113 -0
- package/dist/src/bin/www.js +217 -0
- package/dist/src/lib/basicipcheck.js +392 -0
- package/dist/src/lib/cacerts.js +106 -0
- package/dist/src/lib/dbglogging.js +190 -0
- package/dist/src/lib/dummyuserapi.js +719 -0
- package/dist/src/lib/ipwatch.js +354 -0
- package/dist/src/lib/k2hr3acrutil.js +532 -0
- package/dist/src/lib/k2hr3apiutil.js +1444 -0
- package/dist/src/lib/k2hr3cliutil.js +183 -0
- package/dist/src/lib/k2hr3config.js +832 -0
- package/dist/src/lib/k2hr3cryptutil.js +258 -0
- package/dist/src/lib/k2hr3dkc.js +12121 -0
- package/dist/src/lib/k2hr3extdata.js +198 -0
- package/dist/src/lib/k2hr3keys.js +207 -0
- package/dist/src/lib/k2hr3resutil.js +111 -0
- package/dist/src/lib/k2hr3template.js +6546 -0
- package/dist/src/lib/k2hr3tokens.js +2643 -0
- package/dist/src/lib/k2hr3userdata.js +296 -0
- package/dist/src/lib/k8soidc.js +1000 -0
- package/dist/src/lib/openstackapiv2.js +695 -0
- package/dist/src/lib/openstackapiv3.js +932 -0
- package/dist/src/lib/openstackep.js +667 -0
- package/{tests/auto_common.js → dist/src/lib/types.js} +4 -38
- package/dist/src/routes/acr.js +704 -0
- package/dist/src/routes/debugVerify.js +294 -0
- package/dist/src/routes/extdata.js +219 -0
- package/dist/src/routes/list.js +264 -0
- package/dist/src/routes/policy.js +840 -0
- package/dist/src/routes/resource.js +1489 -0
- package/dist/src/routes/role.js +2627 -0
- package/dist/src/routes/service.js +908 -0
- package/dist/src/routes/tenant.js +1141 -0
- package/dist/src/routes/userTokens.js +482 -0
- package/dist/src/routes/userdata.js +212 -0
- package/dist/src/routes/version.js +103 -0
- package/package.json +152 -121
- package/ChangeLog +0 -378
- package/app.js +0 -292
- package/bin/watcher +0 -122
- package/bin/www +0 -180
- package/eslint.config.mjs +0 -68
- package/lib/basicipcheck.js +0 -376
- package/lib/cacerts.js +0 -71
- package/lib/dbglogging.js +0 -151
- package/lib/dummyuserapi.js +0 -766
- package/lib/ipwatch.js +0 -379
- package/lib/k2hr3acrutil.js +0 -516
- package/lib/k2hr3apiutil.js +0 -1494
- package/lib/k2hr3cliutil.js +0 -191
- package/lib/k2hr3config.js +0 -826
- package/lib/k2hr3cryptutil.js +0 -254
- package/lib/k2hr3dkc.js +0 -12632
- package/lib/k2hr3extdata.js +0 -198
- package/lib/k2hr3keys.js +0 -234
- package/lib/k2hr3resutil.js +0 -100
- package/lib/k2hr3template.js +0 -6925
- package/lib/k2hr3tokens.js +0 -2799
- package/lib/k2hr3userdata.js +0 -312
- package/lib/k8soidc.js +0 -1012
- package/lib/openstackapiv2.js +0 -764
- package/lib/openstackapiv3.js +0 -1032
- package/lib/openstackep.js +0 -553
- package/routes/acr.js +0 -738
- package/routes/debugVerify.js +0 -263
- package/routes/extdata.js +0 -232
- package/routes/list.js +0 -270
- package/routes/policy.js +0 -869
- package/routes/resource.js +0 -1441
- package/routes/role.js +0 -2664
- package/routes/service.js +0 -894
- package/routes/tenant.js +0 -1095
- package/routes/userTokens.js +0 -511
- package/routes/userdata.js +0 -218
- package/routes/version.js +0 -108
- package/templ/Dockerfile.templ +0 -71
- package/tests/auto_acr.js +0 -1101
- package/tests/auto_acr_spec.js +0 -79
- package/tests/auto_all_spec.js +0 -142
- package/tests/auto_control_subprocess.sh +0 -243
- package/tests/auto_extdata.js +0 -220
- package/tests/auto_extdata_spec.js +0 -79
- package/tests/auto_init_config_json.sh +0 -275
- package/tests/auto_k2hdkc_server.ini +0 -109
- package/tests/auto_k2hdkc_slave.ini +0 -83
- package/tests/auto_list.js +0 -439
- package/tests/auto_list_spec.js +0 -79
- package/tests/auto_policy.js +0 -1579
- package/tests/auto_policy_spec.js +0 -79
- package/tests/auto_resource.js +0 -10956
- package/tests/auto_resource_spec.js +0 -79
- package/tests/auto_role.js +0 -6150
- package/tests/auto_role_spec.js +0 -79
- package/tests/auto_service.js +0 -770
- package/tests/auto_service_spec.js +0 -79
- package/tests/auto_subprocesses.js +0 -114
- package/tests/auto_template.sh +0 -126
- package/tests/auto_tenant.js +0 -1100
- package/tests/auto_tenant_spec.js +0 -79
- package/tests/auto_token_util.js +0 -219
- package/tests/auto_userdata.js +0 -292
- package/tests/auto_userdata_spec.js +0 -79
- package/tests/auto_usertokens.js +0 -565
- package/tests/auto_usertokens_spec.js +0 -79
- package/tests/auto_version.js +0 -127
- package/tests/auto_version_spec.js +0 -79
- package/tests/auto_watcher.js +0 -157
- package/tests/auto_watcher_spec.js +0 -79
- package/tests/k2hdkc_test.data +0 -986
- package/tests/k2hdkc_test_load.sh +0 -255
- package/tests/k2hr3template_test.js +0 -187
- package/tests/k2hr3template_test.sh +0 -339
- package/tests/k2hr3template_test_async.js +0 -216
- package/tests/k2hr3template_test_template.result +0 -7117
- package/tests/k2hr3template_test_template.txt +0 -3608
- package/tests/k2hr3template_test_vars.js +0 -194
- package/tests/manual_acr_delete.js +0 -143
- package/tests/manual_acr_get.js +0 -297
- package/tests/manual_acr_postput.js +0 -215
- package/tests/manual_allusertenant_get.js +0 -113
- package/tests/manual_extdata_get.js +0 -191
- package/tests/manual_k2hr3keys_get.js +0 -84
- package/tests/manual_list_gethead.js +0 -230
- package/tests/manual_policy_delete.js +0 -132
- package/tests/manual_policy_gethead.js +0 -275
- package/tests/manual_policy_postput.js +0 -297
- package/tests/manual_resource_delete.js +0 -433
- package/tests/manual_resource_gethead.js +0 -423
- package/tests/manual_resource_postput.js +0 -487
- package/tests/manual_role_delete.js +0 -404
- package/tests/manual_role_gethead.js +0 -547
- package/tests/manual_role_postput.js +0 -544
- package/tests/manual_service_delete.js +0 -153
- package/tests/manual_service_gethead.js +0 -178
- package/tests/manual_service_postput.js +0 -348
- package/tests/manual_tenant_delete.js +0 -186
- package/tests/manual_tenant_gethead.js +0 -268
- package/tests/manual_tenant_postput.js +0 -293
- package/tests/manual_test.sh +0 -352
- package/tests/manual_userdata_get.js +0 -173
- package/tests/manual_usertoken_gethead.js +0 -136
- package/tests/manual_usertoken_postput.js +0 -310
- package/tests/manual_version_get.js +0 -127
- package/tests/run_local_test_k2hdkc.sh +0 -174
- package/tests/test.sh +0 -333
package/lib/ipwatch.js
DELETED
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* K2HR3 REST API
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
|
-
*
|
|
6
|
-
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
|
-
* common management information for the cloud.
|
|
8
|
-
* K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
9
|
-
* These are stored as roles, resources, policies in K2hdkc, and the
|
|
10
|
-
* client system can dynamically read and modify these information.
|
|
11
|
-
*
|
|
12
|
-
* For the full copyright and license information, please view
|
|
13
|
-
* the license file that was distributed with this source code.
|
|
14
|
-
*
|
|
15
|
-
* AUTHOR: Takeshi Nakatani
|
|
16
|
-
* CREATE: Tue Oct 23 2018
|
|
17
|
-
* REVISION:
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
var util = require('util');
|
|
24
|
-
var dateformat = require('dateformat');
|
|
25
|
-
|
|
26
|
-
var apiutil = require('./k2hr3apiutil');
|
|
27
|
-
var k2hr3 = require('./k2hr3dkc');
|
|
28
|
-
var r3Conf = require('./k2hr3config').r3ApiConfig;
|
|
29
|
-
var apiConf = new r3Conf();
|
|
30
|
-
var chkipconfigType = require('./k2hr3config').chkipType;
|
|
31
|
-
|
|
32
|
-
// Debug logging objects
|
|
33
|
-
var r3logger = require('./dbglogging');
|
|
34
|
-
|
|
35
|
-
//---------------------------------------------------------
|
|
36
|
-
// Checking IP Addresses configuration
|
|
37
|
-
//---------------------------------------------------------
|
|
38
|
-
var localchkipconfig = {
|
|
39
|
-
type: chkipconfigType.CHECKER_TYPE_LISTENER, // Listener / Function / Basic{Or|And} / NoCheck
|
|
40
|
-
funcmod: null, // Module name(path) for Function type
|
|
41
|
-
pendingsec: 864000, // Limit for removing IP which is not alive : 10 * 24 * 60 * 60 = 10 days
|
|
42
|
-
intervalms: 4320000, // Interval ms for checking IP address : 12 * 60 * 60 * 1000 = 12 hour
|
|
43
|
-
parallelcnt: 32, // Parallel processing count
|
|
44
|
-
command4: 'ping', // Basic IP address check use this command for IPv4 : ping command
|
|
45
|
-
command6: 'ping6', // Basic IP address check use this command for IPv6
|
|
46
|
-
params: '-c 1', // Common ping command parameters
|
|
47
|
-
timeoutparam: '-W', // Timeout parameter name for ping command
|
|
48
|
-
timeoutms: 5000 // Timeout millisecond for each checking : 5000ms
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
(function()
|
|
52
|
-
{
|
|
53
|
-
var chkipconfig = apiConf.getCheckIPConfig();
|
|
54
|
-
|
|
55
|
-
if(apiutil.isSafeEntity(chkipconfig)){
|
|
56
|
-
if(apiutil.compareCaseString(chkipconfig.type, chkipconfigType.CHECKER_TYPE_LISTENER)){
|
|
57
|
-
localchkipconfig.type = chkipconfigType.CHECKER_TYPE_LISTENER;
|
|
58
|
-
localchkipconfig.funcmod = null;
|
|
59
|
-
}else if(apiutil.compareCaseString(chkipconfig.type, chkipconfigType.CHECKER_TYPE_FUNCTION)){
|
|
60
|
-
if(apiutil.isSafeString(chkipconfig.funcmod)){
|
|
61
|
-
localchkipconfig.type = chkipconfigType.CHECKER_TYPE_FUNCTION;
|
|
62
|
-
localchkipconfig.funcmod = chkipconfig.funcmod;
|
|
63
|
-
}else{
|
|
64
|
-
r3logger.elog('config : chkipconfig.funcmod value is something wrong : ' + JSON.stringify(chkipconfig.funcmod));
|
|
65
|
-
localchkipconfig.type = chkipconfigType.CHECKER_TYPE_NOCHECK;
|
|
66
|
-
localchkipconfig.funcmod = null;
|
|
67
|
-
}
|
|
68
|
-
}else if(apiutil.compareCaseString(chkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_OR) || apiutil.compareCaseString(chkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_AND)){
|
|
69
|
-
localchkipconfig.type = apiutil.compareCaseString(chkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_OR) ? chkipconfigType.CHECKER_TYPE_BASIC_OR : chkipconfigType.CHECKER_TYPE_BASIC_AND;
|
|
70
|
-
localchkipconfig.funcmod = null;
|
|
71
|
-
|
|
72
|
-
if(apiutil.isSafeString(chkipconfig.command4)){
|
|
73
|
-
localchkipconfig.command4 = chkipconfig.command4;
|
|
74
|
-
}
|
|
75
|
-
if(apiutil.isSafeString(chkipconfig.command6)){
|
|
76
|
-
localchkipconfig.command6 = chkipconfig.command6;
|
|
77
|
-
}
|
|
78
|
-
if(apiutil.isSafeString(chkipconfig.params)){
|
|
79
|
-
localchkipconfig.params = chkipconfig.params;
|
|
80
|
-
}
|
|
81
|
-
if(apiutil.isSafeString(chkipconfig.timeoutparam)){
|
|
82
|
-
localchkipconfig.timeoutparam= chkipconfig.timeoutparam;
|
|
83
|
-
}
|
|
84
|
-
if(apiutil.isSafeEntity(chkipconfig.timeoutms) && !isNaN(chkipconfig.timeoutms)){
|
|
85
|
-
localchkipconfig.timeoutms = parseInt(chkipconfig.timeoutms);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}else if(apiutil.compareCaseString(chkipconfig.type, chkipconfigType.CHECKER_TYPE_NOCHECK)){
|
|
89
|
-
localchkipconfig.type = chkipconfigType.CHECKER_TYPE_NOCHECK;
|
|
90
|
-
localchkipconfig.funcmod = null;
|
|
91
|
-
}else if(apiutil.isSafeEntity(chkipconfig.type)){
|
|
92
|
-
r3logger.elog('config : chkipconfig.type value is something wrong : ' + JSON.stringify(chkipconfig.type));
|
|
93
|
-
localchkipconfig.type = chkipconfigType.CHECKER_TYPE_NOCHECK;
|
|
94
|
-
localchkipconfig.funcmod = null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if(apiutil.isSafeEntity(chkipconfig.pendingsec) && !isNaN(chkipconfig.pendingsec)){
|
|
98
|
-
localchkipconfig.pendingsec = chkipconfig.pendingsec;
|
|
99
|
-
}
|
|
100
|
-
if(apiutil.isSafeEntity(chkipconfig.intervalms) && !isNaN(chkipconfig.intervalms)){
|
|
101
|
-
localchkipconfig.intervalms = chkipconfig.intervalms;
|
|
102
|
-
}
|
|
103
|
-
if(apiutil.isSafeEntity(chkipconfig.parallelcnt) && !isNaN(chkipconfig.parallelcnt)){
|
|
104
|
-
localchkipconfig.parallelcnt = chkipconfig.parallelcnt;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}());
|
|
108
|
-
|
|
109
|
-
//---------------------------------------------------------
|
|
110
|
-
// Utilities: Check configuration
|
|
111
|
-
//---------------------------------------------------------
|
|
112
|
-
function rawGetType()
|
|
113
|
-
{
|
|
114
|
-
return localchkipconfig.type;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function rawIsListenerType()
|
|
118
|
-
{
|
|
119
|
-
return apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_LISTENER);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function rawIsBasicType()
|
|
123
|
-
{
|
|
124
|
-
return (apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_OR) || apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_AND));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function rawIsBasicOrType()
|
|
128
|
-
{
|
|
129
|
-
return apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_OR);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function rawIsBasicAndType()
|
|
133
|
-
{
|
|
134
|
-
return apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_BASIC_AND);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function rawIsFunctionType()
|
|
138
|
-
{
|
|
139
|
-
return apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_FUNCTION);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function rawIsNocheckType()
|
|
143
|
-
{
|
|
144
|
-
return apiutil.compareCaseString(localchkipconfig.type, chkipconfigType.CHECKER_TYPE_NOCHECK);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
//---------------------------------------------------------
|
|
148
|
-
// Watcher Logging
|
|
149
|
-
//---------------------------------------------------------
|
|
150
|
-
var loggingStream = null;
|
|
151
|
-
var loggingTimeForm = null;
|
|
152
|
-
|
|
153
|
-
(function()
|
|
154
|
-
{
|
|
155
|
-
var r3Conf = require('./k2hr3config').r3ApiConfig;
|
|
156
|
-
var apiConf = new r3Conf();
|
|
157
|
-
loggingStream = apiConf.getWatcherLoggingStream(__dirname + '/..');
|
|
158
|
-
loggingTimeForm = apiConf.getWatcherTimeFormat();
|
|
159
|
-
}());
|
|
160
|
-
|
|
161
|
-
function rawWatcherLogging()
|
|
162
|
-
{
|
|
163
|
-
loggingStream.write('[' + dateformat(new Date(), loggingTimeForm) + '] ' + util.format.apply(util, arguments) + '\n');
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
//---------------------------------------------------------
|
|
167
|
-
// Check Addresses Alive raw function
|
|
168
|
-
//---------------------------------------------------------
|
|
169
|
-
function rawWatchAddressesAliveEx(ipchecker, callback)
|
|
170
|
-
{
|
|
171
|
-
var _ipchecker = ipchecker;
|
|
172
|
-
var _callback = callback;
|
|
173
|
-
|
|
174
|
-
if(!apiutil.isSafeEntity(_callback) || 'function' !== typeof _callback){
|
|
175
|
-
r3logger.elog('callback is not function.');
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if(!apiutil.isSafeEntity(_ipchecker) || 'function' !== typeof _ipchecker){
|
|
179
|
-
_callback(true, new Error('ipchecker is not function')); // fatal
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
//
|
|
184
|
-
// make ip addresses list depending cuk
|
|
185
|
-
//
|
|
186
|
-
var targetres = k2hr3.getAllIpDatasByCuk(true); // Currently supports only openstack
|
|
187
|
-
if(!apiutil.isSafeEntity(targetres) && apiutil.isSafeEntity(targetres.error)){
|
|
188
|
-
_callback(false, new Error('failed getting IP addresses list depending cuk by ' + JSON.stringify(targetres.error)));
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
if(apiutil.isEmptyArray(targetres.data)){
|
|
192
|
-
_callback(false, new Error('There is no IP address depending cuk'));
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
//
|
|
197
|
-
// Check Addresses
|
|
198
|
-
//
|
|
199
|
-
ipchecker(targetres.data, localchkipconfig).then(function(res)
|
|
200
|
-
{
|
|
201
|
-
r3logger.dlog('after checking IP addresses : ' + JSON.stringify(res));
|
|
202
|
-
|
|
203
|
-
if(apiutil.isSafeEntity(res) && !apiutil.isSafeEntity(res.error)){
|
|
204
|
-
if(apiutil.isEmptyArray(res.data)){
|
|
205
|
-
_callback(false, new Error('There is no IP address depending cuk after checking, why...'));
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// remove/clear by result of checking
|
|
210
|
-
var result = k2hr3.removeIpAddressWithCuk(res.data, localchkipconfig.pendingsec, rawWatcherLogging);
|
|
211
|
-
if(result){
|
|
212
|
-
_callback(false, result);
|
|
213
|
-
}else{
|
|
214
|
-
// Succeed without error
|
|
215
|
-
_callback(false, null);
|
|
216
|
-
}
|
|
217
|
-
}else{
|
|
218
|
-
_callback(false, new Error('checking IP addresses returns error : ' + (apiutil.isSafeEntity(res) && apiutil.isSafeEntity(res.error) ? res.error.message : 'unknown')));
|
|
219
|
-
}
|
|
220
|
-
}).catch(function(error){
|
|
221
|
-
_callback(true, new Error('checking IP addresses returns fatal error : ' + error.message)); // fatal
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
//---------------------------------------------------------
|
|
226
|
-
// Addresses Alive Watcher
|
|
227
|
-
//---------------------------------------------------------
|
|
228
|
-
// This is watcher checking alive of IP addresses which are
|
|
229
|
-
// registered with CUK.
|
|
230
|
-
//
|
|
231
|
-
// This function uses Interval Loop, so that this is run as
|
|
232
|
-
// daemon process. The interval time is set in checkipconfig
|
|
233
|
-
// in config.
|
|
234
|
-
//
|
|
235
|
-
// The interval loop is getting all ip addresses with it's
|
|
236
|
-
// information from k2hdkc at first. Next this calls a function
|
|
237
|
-
// which is specified by configuration as checkipconfig in
|
|
238
|
-
// config files. Last this sets alive status and dead at time
|
|
239
|
-
// into k2hdkc for each IP addresses. Then if IP address is
|
|
240
|
-
// not alive and over pending time, it is removed from k2hdkc.
|
|
241
|
-
//
|
|
242
|
-
// The raw checker function can be specified by checkipconfig
|
|
243
|
-
// value, and default function is implemented by k2hr3. The
|
|
244
|
-
// default function checks IP address by checking DNS resolve
|
|
245
|
-
// and ping to it.
|
|
246
|
-
// The raw function name must be 'checkAddressesAlive'.
|
|
247
|
-
//
|
|
248
|
-
function rawWatchAddressesAlive(oneshotCB)
|
|
249
|
-
{
|
|
250
|
-
var _callback = oneshotCB;
|
|
251
|
-
|
|
252
|
-
//
|
|
253
|
-
// Load checkAddressesAlive function
|
|
254
|
-
//
|
|
255
|
-
var ipchecker = null;
|
|
256
|
-
try{
|
|
257
|
-
if(rawIsFunctionType()){
|
|
258
|
-
ipchecker = require(localchkipconfig.funcmod).checkAddressesAlive;
|
|
259
|
-
}else if(rawIsBasicType()){
|
|
260
|
-
ipchecker = require('./basicipcheck').checkAddressesAlive;
|
|
261
|
-
}else{
|
|
262
|
-
// Nothing to do with interval
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
if(!apiutil.isSafeEntity(ipchecker) || 'function' !== typeof ipchecker){
|
|
266
|
-
r3logger.elog('could not load checkAddressesAlive function in : ' + (rawIsBasicType() ? './basicipcheck' : localchkipconfig.funcmod));
|
|
267
|
-
return null;
|
|
268
|
-
}
|
|
269
|
-
}catch(error){
|
|
270
|
-
r3logger.elog('could not load module : ' + (rawIsBasicType() ? './basicipcheck' : localchkipconfig.funcmod), JSON.stringify(error));
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if(apiutil.isSafeEntity(_callback) && 'function' == typeof _callback){
|
|
275
|
-
//
|
|
276
|
-
// one shot
|
|
277
|
-
//
|
|
278
|
-
rawWatchAddressesAliveEx(ipchecker, function(is_fatal, error)
|
|
279
|
-
{
|
|
280
|
-
var result = true;
|
|
281
|
-
if(is_fatal){
|
|
282
|
-
r3logger.elog('Fatal error is occurred : ' + error.message);
|
|
283
|
-
result = false;
|
|
284
|
-
}else if(error){
|
|
285
|
-
r3logger.wlog('Finished with messsage : ' + error.message);
|
|
286
|
-
}else{
|
|
287
|
-
r3logger.dlog('Finished without any error messsage');
|
|
288
|
-
}
|
|
289
|
-
_callback(result);
|
|
290
|
-
});
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
//
|
|
295
|
-
// Set Interval
|
|
296
|
-
//
|
|
297
|
-
var isFatalError = false;
|
|
298
|
-
var isWorking = false;
|
|
299
|
-
var checkInterval = setInterval(function()
|
|
300
|
-
{
|
|
301
|
-
if(!isFatalError && !isWorking){
|
|
302
|
-
isWorking = true;
|
|
303
|
-
//
|
|
304
|
-
// Checking
|
|
305
|
-
//
|
|
306
|
-
rawWatchAddressesAliveEx(ipchecker, function(is_fatal, error)
|
|
307
|
-
{
|
|
308
|
-
isWorking = false;
|
|
309
|
-
|
|
310
|
-
if(is_fatal){
|
|
311
|
-
r3logger.elog('Fatal error is occurred : ' + error.message);
|
|
312
|
-
isFatalError = true;
|
|
313
|
-
}else if(error){
|
|
314
|
-
r3logger.dlog('Finished with messsage : ' + error.message);
|
|
315
|
-
}else{
|
|
316
|
-
r3logger.dlog('Finished without messsage');
|
|
317
|
-
}
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
|
-
}, localchkipconfig.intervalms);
|
|
321
|
-
|
|
322
|
-
return checkInterval;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
//---------------------------------------------------------
|
|
326
|
-
// Exports
|
|
327
|
-
//---------------------------------------------------------
|
|
328
|
-
exports.chkipType = chkipconfigType;
|
|
329
|
-
|
|
330
|
-
exports.chkipconfig = localchkipconfig;
|
|
331
|
-
|
|
332
|
-
exports.getType = function()
|
|
333
|
-
{
|
|
334
|
-
return rawGetType();
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
exports.isListenerType = function()
|
|
338
|
-
{
|
|
339
|
-
return rawIsListenerType();
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
exports.isBasicType = function()
|
|
343
|
-
{
|
|
344
|
-
return rawIsBasicType();
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
exports.isBasicOrType = function()
|
|
348
|
-
{
|
|
349
|
-
return rawIsBasicOrType();
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
exports.isBasicAndType = function()
|
|
353
|
-
{
|
|
354
|
-
return rawIsBasicAndType();
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
exports.isFunctionType = function()
|
|
358
|
-
{
|
|
359
|
-
return rawIsFunctionType();
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
exports.isNocheckType = function()
|
|
363
|
-
{
|
|
364
|
-
return rawIsNocheckType();
|
|
365
|
-
};
|
|
366
|
-
|
|
367
|
-
exports.watchAddressesAlive = function(oneshotCB)
|
|
368
|
-
{
|
|
369
|
-
return rawWatchAddressesAlive(oneshotCB);
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
/*
|
|
373
|
-
* Local variables:
|
|
374
|
-
* tab-width: 4
|
|
375
|
-
* c-basic-offset: 4
|
|
376
|
-
* End:
|
|
377
|
-
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
378
|
-
* vim<600: noexpandtab sw=4 ts=4
|
|
379
|
-
*/
|