line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "perlbolt.h" |
2
|
|
|
|
|
|
|
#include "ingyINLINE.h" |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#include |
5
|
|
|
|
|
|
|
#include |
6
|
|
|
|
|
|
|
#include "connection.h" |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
static uint_fast8_t LOG_LEVEL = NEO4J_LOG_TRACE+1; |
9
|
|
|
|
|
|
|
static uint_fast32_t LOGGER_FLAGS = 0; |
10
|
|
|
|
|
|
|
|
11
|
0
|
|
|
|
|
|
void new_cxn_obj(cxn_obj_t **cxn_obj) { |
12
|
0
|
|
|
|
|
|
Newx(*cxn_obj, 1, cxn_obj_t); |
13
|
0
|
|
|
|
|
|
(*cxn_obj)->connection = (neo4j_connection_t *)NULL; |
14
|
0
|
|
|
|
|
|
(*cxn_obj)->connected = 0; |
15
|
0
|
|
|
|
|
|
(*cxn_obj)->errnum = 0; |
16
|
0
|
|
|
|
|
|
int major_version = 0; |
17
|
0
|
|
|
|
|
|
int minor_version = 0; |
18
|
0
|
|
|
|
|
|
(*cxn_obj)->strerror = ""; |
19
|
0
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
int set_log_level( const char* classname, const char* lvl ) |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
0
|
|
|
|
|
if(strcmp(lvl,"NONE")==0) |
24
|
|
|
|
|
|
|
{ |
25
|
0
|
|
|
|
|
|
LOG_LEVEL = NEO4J_LOG_TRACE+1; |
26
|
|
|
|
|
|
|
} |
27
|
0
|
0
|
|
|
|
|
if(strcmp(lvl,"ERROR")==0) |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
|
|
|
LOG_LEVEL = NEO4J_LOG_ERROR; |
30
|
|
|
|
|
|
|
} |
31
|
0
|
0
|
|
|
|
|
if(strcmp(lvl,"WARN")==0) |
32
|
|
|
|
|
|
|
{ |
33
|
0
|
|
|
|
|
|
LOG_LEVEL = NEO4J_LOG_WARN; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
0
|
|
|
|
|
if(strcmp(lvl,"INFO")==0) |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
|
|
|
LOG_LEVEL = NEO4J_LOG_INFO; |
38
|
|
|
|
|
|
|
} |
39
|
0
|
0
|
|
|
|
|
if(strcmp(lvl,"DEBUG")==0) |
40
|
|
|
|
|
|
|
{ |
41
|
0
|
|
|
|
|
|
LOG_LEVEL = NEO4J_LOG_DEBUG; |
42
|
|
|
|
|
|
|
} |
43
|
0
|
0
|
|
|
|
|
if(strcmp(lvl,"TRACE")==0) |
44
|
|
|
|
|
|
|
{ |
45
|
0
|
|
|
|
|
|
LOG_LEVEL = NEO4J_LOG_TRACE; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
return (int) LOG_LEVEL; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
SV* connect_ ( const char* classname, const char* neo4j_url, |
51
|
|
|
|
|
|
|
int timeout, bool encrypt, |
52
|
|
|
|
|
|
|
const char* tls_ca_dir, const char* tls_ca_file, |
53
|
|
|
|
|
|
|
const char* tls_pk_file, const char* tls_pk_pass ) |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
SV *cxn; |
56
|
|
|
|
|
|
|
SV *cxn_ref; |
57
|
|
|
|
|
|
|
cxn_obj_t *cxn_obj; |
58
|
|
|
|
|
|
|
char *climsg, *s; |
59
|
|
|
|
|
|
|
neo4j_config_t *config; |
60
|
0
|
|
|
|
|
|
new_cxn_obj(&cxn_obj); |
61
|
0
|
|
|
|
|
|
neo4j_client_init(); |
62
|
0
|
|
|
|
|
|
config = neo4j_new_config(); |
63
|
0
|
|
|
|
|
|
config->connect_timeout = (time_t) timeout; |
64
|
0
|
0
|
|
|
|
|
if (strlen(tls_ca_dir)) { |
65
|
0
|
|
|
|
|
|
ignore_unused_result(neo4j_config_set_TLS_ca_dir(config, tls_ca_dir)); |
66
|
|
|
|
|
|
|
} |
67
|
0
|
0
|
|
|
|
|
if (strlen(tls_ca_file)) { |
68
|
0
|
|
|
|
|
|
ignore_unused_result(neo4j_config_set_TLS_ca_file(config, tls_ca_file)); |
69
|
|
|
|
|
|
|
} |
70
|
0
|
0
|
|
|
|
|
if (strlen(tls_pk_file)) { |
71
|
0
|
|
|
|
|
|
ignore_unused_result(neo4j_config_set_TLS_private_key(config, tls_pk_file)); |
72
|
|
|
|
|
|
|
} |
73
|
0
|
0
|
|
|
|
|
if (strlen(tls_pk_pass)) { |
74
|
0
|
|
|
|
|
|
ignore_unused_result(neo4j_config_set_TLS_private_key_password(config, tls_pk_pass)); |
75
|
|
|
|
|
|
|
} |
76
|
0
|
0
|
|
|
|
|
if (LOG_LEVEL <= NEO4J_LOG_TRACE) |
77
|
|
|
|
|
|
|
{ |
78
|
0
|
|
|
|
|
|
neo4j_config_set_logger_provider(config, neo4j_std_logger_provider(stderr, LOG_LEVEL, LOGGER_FLAGS)); |
79
|
|
|
|
|
|
|
} |
80
|
0
|
0
|
|
|
|
|
cxn_obj->connection = neo4j_connect( neo4j_url, config, |
81
|
|
|
|
|
|
|
encrypt ? 0 : NEO4J_INSECURE ); |
82
|
0
|
0
|
|
|
|
|
if (cxn_obj->connection == NULL) { |
83
|
0
|
|
|
|
|
|
cxn_obj->errnum = errno; |
84
|
0
|
|
|
|
|
|
cxn_obj->connected = false; |
85
|
0
|
|
|
|
|
|
Newx(climsg, BUFLEN, char); |
86
|
0
|
|
|
|
|
|
cxn_obj->strerror = neo4j_strerror(errno, climsg, BUFLEN-1); |
87
|
|
|
|
|
|
|
} else { |
88
|
0
|
0
|
|
|
|
|
if ( encrypt && ! neo4j_connection_is_secure(cxn_obj->connection) ) { |
|
|
0
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
warn("Bolt connection not secure!"); |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
cxn_obj->major_version = cxn_obj->connection->version; |
92
|
0
|
|
|
|
|
|
cxn_obj->minor_version = cxn_obj->connection->minor_version; |
93
|
0
|
|
|
|
|
|
cxn_obj->connected = true; |
94
|
0
|
|
|
|
|
|
cxn_obj->strerror = ""; |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
|
cxn = newSViv((IV) cxn_obj); |
97
|
0
|
|
|
|
|
|
cxn_ref = newRV_noinc(cxn); |
98
|
0
|
|
|
|
|
|
sv_bless(cxn_ref, gv_stashpv(CXNCLASS, GV_ADD)); |
99
|
0
|
|
|
|
|
|
SvREADONLY_on(cxn); |
100
|
0
|
|
|
|
|
|
return cxn_ref; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
MODULE = Neo4j::Bolt PACKAGE = Neo4j::Bolt |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
SV * |
110
|
|
|
|
|
|
|
connect_ (classname, neo4j_url, timeout, encrypt, tls_ca_dir, tls_ca_file, tls_pk_file, tls_pk_pass) |
111
|
|
|
|
|
|
|
const char * classname |
112
|
|
|
|
|
|
|
const char * neo4j_url |
113
|
|
|
|
|
|
|
int timeout |
114
|
|
|
|
|
|
|
bool encrypt |
115
|
|
|
|
|
|
|
const char * tls_ca_dir |
116
|
|
|
|
|
|
|
const char * tls_ca_file |
117
|
|
|
|
|
|
|
const char * tls_pk_file |
118
|
|
|
|
|
|
|
const char * tls_pk_pass |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
int |
121
|
|
|
|
|
|
|
set_log_level (classname, lvl) |
122
|
|
|
|
|
|
|
const char* classname |
123
|
|
|
|
|
|
|
const char* lvl |
124
|
|
|
|
|
|
|
|