Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-net-srv-vpn
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
cellframe
libdap-chain-net-srv-vpn
Commits
b0b3f91b
Commit
b0b3f91b
authored
5 years ago
by
Dmitriy A. Gerasimov
Browse files
Options
Downloads
Patches
Plain Diff
[*] Fixed
parent
d66084d6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dap_chain_net_srv_vpn_cdb_server_list.c
+29
-32
29 additions, 32 deletions
dap_chain_net_srv_vpn_cdb_server_list.c
with
29 additions
and
32 deletions
dap_chain_net_srv_vpn_cdb_server_list.c
+
29
−
32
View file @
b0b3f91b
...
@@ -59,13 +59,14 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg);
...
@@ -59,13 +59,14 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg);
int
dap_chain_net_srv_vpn_cdb_server_list_init
()
int
dap_chain_net_srv_vpn_cdb_server_list_init
()
{
{
char
**
l_cdb_networks
;
char
**
l_cdb_networks
;
size_t
l_cdb_networks_
size
=
0
;
size_t
l_cdb_networks_
count
=
0
;
log_it
(
L_NOTICE
,
"Initialized Server List Module"
);
log_it
(
L_NOTICE
,
"Initialized Server List Module"
);
l_cdb_networks
=
dap_config_get_array_str
(
g_config
,
"cdb"
,
"networks"
,
&
l_cdb_networks_
size
);
l_cdb_networks
=
dap_config_get_array_str
(
g_config
,
"cdb"
,
"networks"
,
&
l_cdb_networks_
count
);
if
(
l_cdb_networks_size
){
if
(
l_cdb_networks_count
){
s_cdb_net
=
DAP_NEW_Z_SIZE
(
dap_chain_net_t
*
,
sizeof
(
dap_chain_net_t
*
)
*
l_cdb_networks_size
);
s_cdb_net
=
DAP_NEW_Z_SIZE
(
dap_chain_net_t
*
,
sizeof
(
dap_chain_net_t
*
)
*
l_cdb_networks_count
);
for
(
size_t
i
=
0
;
i
<
l_cdb_networks_size
;
i
++
)
{
s_cdb_net_count
=
l_cdb_networks_count
;
for
(
size_t
i
=
0
;
i
<
l_cdb_networks_count
;
i
++
)
{
s_cdb_net
[
i
]
=
dap_chain_net_by_name
(
l_cdb_networks
[
i
]
);
s_cdb_net
[
i
]
=
dap_chain_net_by_name
(
l_cdb_networks
[
i
]
);
if
(
s_cdb_net
[
i
]
)
if
(
s_cdb_net
[
i
]
)
log_it
(
L_INFO
,
"Added
\"
%s
\"
network for server list fetchs"
,
l_cdb_networks
[
i
]);
log_it
(
L_INFO
,
"Added
\"
%s
\"
network for server list fetchs"
,
l_cdb_networks
[
i
]);
...
@@ -97,41 +98,37 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg)
...
@@ -97,41 +98,37 @@ static void s_http_simple_proc(dap_http_simple_t *a_http_simple, void *a_arg)
size_t
l_orders_count
=
0
;
size_t
l_orders_count
=
0
;
dap_chain_net_srv_price_unit_uid_t
l_unit_uid
=
{{
0
}};
dap_chain_net_srv_price_unit_uid_t
l_unit_uid
=
{{
0
}};
dap_chain_net_srv_uid_t
l_srv_uid
=
{
.
uint64
=
DAP_CHAIN_NET_SRV_VPN_ID
};
dap_chain_net_srv_uid_t
l_srv_uid
=
{
.
uint64
=
DAP_CHAIN_NET_SRV_VPN_ID
};
dap_chain_net_srv_order_find_all_by
(
l_net
,
SERV_DIR_SELL
,
l_srv_uid
,
SERV_CLASS_PERMANENT
,
l_unit_uid
,
NULL
,
0
,
0
,
&
l_orders
,
&
l_orders_count
);
dap_chain_net_srv_order_find_all_by
(
l_net
,
SERV_DIR_SELL
,
l_srv_uid
,
SERV_CLASS_PERMANENT
,
l_unit_uid
,
log_it
(
L_DEBUG
,
"Found %sd orders in
\"
%s
\"
network"
,
l_orders_count
,
l_net
->
pub
.
name
);
NULL
,
0
,
0
,
&
l_orders
,
&
l_orders_count
);
log_it
(
L_DEBUG
,
"Found %zd orders in
\"
%s
\"
network"
,
l_orders_count
,
l_net
->
pub
.
name
);
for
(
size_t
j
=
0
;
j
<
l_orders_count
;
j
++
)
{
for
(
size_t
j
=
0
;
j
<
l_orders_count
;
j
++
)
{
dap_chain_node_info_t
*
l_node_info
=
dap_chain_node_info_read
(
l_net
,
&
l_orders
[
j
].
node_addr
);
dap_chain_node_info_t
*
l_node_info
=
dap_chain_node_info_read
(
l_net
,
&
l_orders
[
j
].
node_addr
);
if
(
l_node_info
){
if
(
l_node_info
){
char
l_node_ext_ipv4_str
[
INET_ADDRSTRLEN
]
=
{
0
};
char
l_node_ext_ipv4_str
[
INET_ADDRSTRLEN
]
=
{
0
};
char
l_node_ext_ipv6_str
[
INET6_ADDRSTRLEN
]
=
{
0
};
char
l_node_ext_ipv6_str
[
INET6_ADDRSTRLEN
]
=
{
0
};
inet_ntop
(
AF_INET
,
&
l_node_info
->
hdr
.
ext_addr_v4
,
l_node_ext_ipv4_str
,
sizeof
(
l_node_ext_ipv4_str
));
if
(
l_node_info
->
hdr
.
ext_addr_v4
.
s_addr
)
inet_ntop
(
AF_INET6
,
&
l_node_info
->
hdr
.
ext_addr_v6
,
l_node_ext_ipv6_str
,
sizeof
(
l_node_ext_ipv6_str
));
inet_ntop
(
AF_INET
,
&
l_node_info
->
hdr
.
ext_addr_v4
,
l_node_ext_ipv4_str
,
sizeof
(
l_node_ext_ipv4_str
));
if
(
*
((
uint128_t
*
)
l_node_info
->
hdr
.
ext_addr_v6
.
__in6_u
.
__u6_addr8
)
)
dap_http_simple_reply_f
(
a_http_simple
,
inet_ntop
(
AF_INET6
,
&
l_node_info
->
hdr
.
ext_addr_v6
,
l_node_ext_ipv6_str
,
sizeof
(
l_node_ext_ipv6_str
));
" {
\n
"
"
\"
Location
\"
:
\"
NETHERLANDS
\"
,
\n
"
dap_http_simple_reply_f
(
a_http_simple
,
" {
\n
"
);
"
\"
Name
\"
:
\"
%s.Cell-%s.%sd
\"
,
\n
"
"
\"
Address
\"
:
\"
%s
\"
,
\n
"
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Location
\"
:
\"
NETHERLANDS
\"
,
\n
"
);
"
\"
Address6
\"
:
\"
%s
\"
,
\n
"
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Name
\"
:
\"
%s.Cell-%lu.%zd
\"
,
\n
"
,
l_net
->
pub
.
name
,
l_node_info
->
hdr
.
cell_id
.
uint64
,
j
);
"
\"
Port
\"
:%hu,
\n
"
if
(
l_node_ext_ipv4_str
[
0
]
)
"
\"
Description
\"
:
\"
%s
\"
,
\n
"
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Address
\"
:
\"
%s
\"
,
\n
"
,
l_node_ext_ipv4_str
);
"
\"
Price
\"
:%lu,
\n
"
if
(
l_node_ext_ipv6_str
[
0
]
)
"
\"
PriceUnits
\"
:%u,
\n
"
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Address6
\"
:
\"
%s
\"
,
\n
"
,
l_node_ext_ipv6_str
);
"
\"
PriceToken
\"
:
\"
%s
\"\n
"
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Port
\"
:%hu,
\n
"
,
l_node_info
->
hdr
.
ext_port
);
" },
\n
"
,
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Ext
\"
:
\"
%s
\"
,
\n
"
,
l_orders
[
j
].
ext
);
l_net
->
pub
.
name
,
l_node_info
->
hdr
.
cell_id
.
uint64
,
j
,
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
Price
\"
:%lu,
\n
"
,
l_orders
[
j
].
price
);
l_node_ext_ipv4_str
,
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
PriceUnits
\"
:%u,
\n
"
,
l_orders
[
j
].
price_unit
.
uint32
);
l_node_ext_ipv6_str
,
dap_http_simple_reply_f
(
a_http_simple
,
"
\"
PriceToken
\"
:
\"
%s
\"\n
"
,
l_orders
[
j
].
price_ticker
);
l_node_info
->
hdr
.
ext_port
,
dap_http_simple_reply_f
(
a_http_simple
,
" },
\n
"
);
l_orders
[
j
].
ext
,
l_orders
[
j
].
price
,
l_orders
[
j
].
price_unit
.
uint32
,
l_orders
[
j
].
price_ticker
);
}
else
}
else
log_it
(
L_WARNING
,
"Order %
s
d in
\"
%s
\"
network issued by node without ext_ipv4 field"
);
log_it
(
L_WARNING
,
"Order %
z
d in
\"
%s
\"
network issued by node without ext_ipv4 field"
,
j
,
l_net
->
pub
.
name
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment