Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libdap-chain-net-srv
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Commits
c7196e73
Unverified
Commit
c7196e73
authored
5 years ago
by
Dmitriy A. Gerasimov
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #4 from kelvinblockchain/feature-2272
Feature 2272
parents
70681d2b
68bb77e1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
dap_chain_net_srv_common.c
+14
-20
14 additions, 20 deletions
dap_chain_net_srv_common.c
dap_chain_net_srv_common.h
+2
-3
2 additions, 3 deletions
dap_chain_net_srv_common.h
with
17 additions
and
24 deletions
CMakeLists.txt
+
1
−
1
View file @
c7196e73
...
@@ -14,7 +14,7 @@ set(DAP_CHAIN_NET_SRV_HEADERS
...
@@ -14,7 +14,7 @@ set(DAP_CHAIN_NET_SRV_HEADERS
add_library
(
${
PROJECT_NAME
}
STATIC
${
DAP_CHAIN_NET_SRV_SRCS
}
${
DAP_CHAIN_NET_SRV_HEADERS
}
)
add_library
(
${
PROJECT_NAME
}
STATIC
${
DAP_CHAIN_NET_SRV_SRCS
}
${
DAP_CHAIN_NET_SRV_HEADERS
}
)
target_link_libraries
(
dap_chain_net_srv dap_core dap_crypto dap_chain dap_chain_crypto dap_chain_net
)
target_link_libraries
(
dap_chain_net_srv dap_core dap_crypto dap_chain dap_chain_crypto dap_chain_net
dap_server_http_db_auth
)
target_include_directories
(
dap_chain_net_srv INTERFACE .
)
target_include_directories
(
dap_chain_net_srv INTERFACE .
)
set
(
${
PROJECT_NAME
}
_DEFINITIONS CACHE INTERNAL
"
${
PROJECT_NAME
}
: Definitions"
FORCE
)
set
(
${
PROJECT_NAME
}
_DEFINITIONS CACHE INTERNAL
"
${
PROJECT_NAME
}
: Definitions"
FORCE
)
...
...
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_common.c
+
14
−
20
View file @
c7196e73
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include
"dap_chain_datum_tx_items.h"
#include
"dap_chain_datum_tx_items.h"
#include
"dap_chain_utxo.h"
#include
"dap_chain_utxo.h"
#include
"dap_stream.h"
#include
"dap_stream.h"
#include
"dap_server_http_db_auth.h"
/**
/**
* copy a_value_dst to a_uid_src
* copy a_value_dst to a_uid_src
...
@@ -72,14 +73,24 @@ void dap_chain_net_srv_abstract_set(dap_chain_net_srv_abstract_t *a_cond, uint8_
...
@@ -72,14 +73,24 @@ void dap_chain_net_srv_abstract_set(dap_chain_net_srv_abstract_t *a_cond, uint8_
/**
/**
*
*
*/
*/
uint64_t
dap_chain_net_srv_client_auth
(
char
*
a_addr_base58
,
uint8_t
*
a_sign
,
size_t
a_sign_size
,
uint64_t
dap_chain_net_srv_client_auth
(
const
char
*
a_service_key
,
const
dap_chain_net_srv_abstract_t
**
a_cond_out
)
const
dap_chain_net_srv_abstract_t
**
a_cond_out
)
{
{
dap_chain_addr_t
*
l_addr
=
(
a_addr_base58
)
?
dap_chain_str_to_addr
(
a_addr_base58
)
:
NULL
;
char
*
l_addr_base58
;
char
*
l_sign_hash_str
;
if
(
dap_server_http_db_auth_parse_service_key
(
a_service_key
,
&
l_addr_base58
,
&
l_sign_hash_str
))
{
return
0
;
}
if
(
!
dap_server_http_db_auth_check_key
(
l_addr_base58
,
l_sign_hash_str
))
{
// invalid signature
return
0
;
}
dap_chain_addr_t
*
l_addr
=
(
l_addr_base58
)
?
dap_chain_str_to_addr
(
l_addr_base58
)
:
NULL
;
dap_chain_tx_out_cond_t
*
l_tx_out_cond
=
NULL
;
dap_chain_tx_out_cond_t
*
l_tx_out_cond
=
NULL
;
dap_chain_sign_type_t
l_sig_type
;
dap_chain_sign_type_t
l_sig_type
;
if
(
l_addr
)
if
(
l_addr
)
memcpy
(
&
l_sig_type
,
&
l_addr
->
sig_type
,
sizeof
(
dap_chain_sign_type_t
));
memcpy
(
&
l_sig_type
,
&
l_addr
->
sig_type
,
sizeof
(
dap_chain_sign_type_t
));
// Search all value in transactions with l_addr in 'out_cond' item
// Search all value in transactions with l_addr in 'out_cond' item
uint64_t
l_value
=
dap_chain_utxo_tx_cache_get_out_cond_value
(
l_addr
,
&
l_tx_out_cond
);
uint64_t
l_value
=
dap_chain_utxo_tx_cache_get_out_cond_value
(
l_addr
,
&
l_tx_out_cond
);
DAP_DELETE
(
l_addr
);
DAP_DELETE
(
l_addr
);
...
@@ -92,23 +103,6 @@ uint64_t dap_chain_net_srv_client_auth(char *a_addr_base58, uint8_t *a_sign, siz
...
@@ -92,23 +103,6 @@ uint64_t dap_chain_net_srv_client_auth(char *a_addr_base58, uint8_t *a_sign, siz
uint8_t
*
l_cond
=
dap_chain_datum_tx_out_cond_item_get_cond
(
l_tx_out_cond
,
&
l_cond_size
);
uint8_t
*
l_cond
=
dap_chain_datum_tx_out_cond_item_get_cond
(
l_tx_out_cond
,
&
l_cond_size
);
uint8_t
*
l_pkey
=
dap_chain_datum_tx_out_cond_item_get_pkey
(
l_tx_out_cond
,
&
l_pkey_size
);
uint8_t
*
l_pkey
=
dap_chain_datum_tx_out_cond_item_get_pkey
(
l_tx_out_cond
,
&
l_pkey_size
);
// create l_chain_sign for check a_sign
dap_chain_sign_t
*
l_chain_sign
=
DAP_NEW_Z_SIZE
(
dap_chain_sign_t
,
sizeof
(
dap_chain_sign_t
)
+
a_sign_size
+
l_pkey_size
);
l_chain_sign
->
header
.
type
=
l_sig_type
;
l_chain_sign
->
header
.
sign_size
=
l_pkey_size
;
l_chain_sign
->
header
.
sign_pkey_size
=
l_pkey_size
;
// write serialized public key to dap_chain_sign_t
memcpy
(
l_chain_sign
->
pkey_n_sign
,
l_pkey
,
l_pkey_size
);
// write serialized signature to dap_chain_sign_t
memcpy
(
l_chain_sign
->
pkey_n_sign
+
l_pkey_size
,
a_sign
,
a_sign_size
);
// check signature
if
(
dap_chain_sign_verify
(
l_chain_sign
,
a_sign
,
a_sign_size
)
!=
1
)
{
// invalid signature
return
0
;
}
if
(
l_cond_size
!=
sizeof
(
dap_chain_net_srv_abstract_t
))
{
if
(
l_cond_size
!=
sizeof
(
dap_chain_net_srv_abstract_t
))
{
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
dap_chain_net_srv_common.h
+
2
−
3
View file @
c7196e73
...
@@ -68,7 +68,7 @@ typedef struct dap_chain_net_srv_abstract
...
@@ -68,7 +68,7 @@ typedef struct dap_chain_net_srv_abstract
struct
{
struct
{
int
bandwith
;
int
bandwith
;
int
abuse_resistant
;
int
abuse_resistant
;
in
t
limit_bytes
;
size_
t
limit_bytes
;
}
vpn
;
}
vpn
;
/*struct {
/*struct {
int value;
int value;
...
@@ -105,5 +105,4 @@ void dap_chain_net_srv_uid_set(dap_chain_net_srv_uid_t *a_uid_src, uint128_t a_v
...
@@ -105,5 +105,4 @@ void dap_chain_net_srv_uid_set(dap_chain_net_srv_uid_t *a_uid_src, uint128_t a_v
// generate new dap_chain_net_srv_uid_t
// generate new dap_chain_net_srv_uid_t
bool
dap_chain_net_srv_gen_uid
(
uint8_t
*
a_srv
,
size_t
a_srv_size
);
bool
dap_chain_net_srv_gen_uid
(
uint8_t
*
a_srv
,
size_t
a_srv_size
);
uint64_t
dap_chain_net_srv_client_auth
(
char
*
a_addr_base58
,
uint8_t
*
a_sign
,
size_t
a_sign_size
,
uint64_t
dap_chain_net_srv_client_auth
(
const
char
*
a_service_key
,
const
dap_chain_net_srv_abstract_t
**
a_cond_out
);
const
dap_chain_net_srv_abstract_t
**
a_cond_out
);
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