Skip to content
Snippets Groups Projects
Commit 9c83a31e authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[*] Fixed conflict with master.

parents 94e46a61 d234e400
No related branches found
No related tags found
1 merge request!24Features 3398
Showing
with 103 additions and 55 deletions
cmake_minimum_required(VERSION 2.8)
if (SUPPORT_PYTHON_PLUGINS)
project(API_CellFrame C)
else()
......@@ -9,15 +10,16 @@ set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_C_STANDARD 11)
set(Python_ADDITIONAL_VERSIONS 3.7 3.6 3.5 3.4)
set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4)
find_package (PythonLibs REQUIRED)
include_directories(${PYTHON_INCLUDE_DIR} include/)
file(GLOB PYTHON_CELLFRAME_SRCS src/*.c)
file(GLOB PYTHON_CELLFRAME_SRCS CellFrame/*.c)
file(GLOB PYTHON_CELLFRAME_HEADERS include/*.h)
set(SUBMODULES_NO_BUILD ON)
if (NOT (SUPPORT_PYTHON_PLUGINS))
include(cellframe-sdk/cmake/OS_Detection.cmake)
add_subdirectory(cellframe-sdk)
endif()
......@@ -40,7 +42,9 @@ target_compile_options(dap_stream_ch_chain_net PRIVATE "-fpic" )
target_compile_options(dap_stream_ch_chain PRIVATE "-fpic" )
target_compile_options(dap_udp_server PRIVATE "-fpic" )
target_compile_options(dap_chain_net_srv PRIVATE "-fpic" )
target_compile_options(dap_chain_net_srv_vpn PRIVATE "-fpic" )
if(NOT WIN32)
target_compile_options(dap_chain_net_srv_vpn PRIVATE "-fpic" )
endif()
target_compile_options(dap_chain_gdb PRIVATE "-fpic" )
target_compile_options(dap_enc_server PRIVATE "-fpic")
target_compile_options(dap_http_server PRIVATE "-fpic")
......@@ -64,7 +68,7 @@ else()
SET( CPACK_PACKAGE_NAME "${PROJECT_NAME}")
SET( CPACK_PACKAGE_VERSION_MAJOR 0)
SET( CPACK_PACKAGE_VERSION_MINOR 9)
SET( CPACK_PACKAGE_VERSION_PATCH 12)
SET( CPACK_PACKAGE_VERSION_PATCH 14)
add_definitions("-DDAP_VERSION_MAJOR=\"${CPACK_PACKAGE_VERSION_MAJOR}\"")
add_definitions("-DDAP_VERSION_MINOR=\"${CPACK_PACKAGE_VERSION_MINOR}\"")
......@@ -101,8 +105,8 @@ else()
#python_extension_module(${PROJECT_NAME} LINKED_MODULES_VAR dap_crypto_python_module)
#python_extension_module(${PROJECT_NAME} LINKED_MODULES_VAR DapServerCore)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PROJECT_NAME})
install(FILES src/__init__.py DESTINATION ${PROJECT_NAME})
install(FILES src/PublicNetworks/* DESTINATION ${PROJECT_NAME})
install(FILES CellFrame/__init__.py DESTINATION ${PROJECT_NAME})
install(FILES CellFrame/PublicNetworks/* DESTINATION ${PROJECT_NAME})
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdap-python/libdap_python_module.so DESTINATION CellFrame/lib)
# install(TARGETS dap_python_module LIBRARY DESTINATION CellFrame)
# install(TARGETS dap_crypto_python_module LIBRARY DESTINATION CellFrame)
......@@ -132,7 +136,9 @@ target_compile_options(dap_stream_ch_chain_net PRIVATE "-fpic" )
target_compile_options(dap_stream_ch_chain PRIVATE "-fpic" )
target_compile_options(dap_udp_server PRIVATE "-fpic" )
target_compile_options(dap_chain_net_srv PRIVATE "-fpic" )
if (NOT WIN32)
target_compile_options(dap_chain_net_srv_vpn PRIVATE "-fpic" )
endif()
target_compile_options(dap_chain_gdb PRIVATE "-fpic" )
target_compile_options(dap_enc_server PRIVATE "-fpic")
target_compile_options(dap_http_server PRIVATE "-fpic")
......@@ -143,6 +149,9 @@ target_compile_options(dap_chain_cs_dag_poa PRIVATE "-fpic")
target_compile_options(dap_chain_cs_dag_pos PRIVATE "-fpic")
if (WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX ".pyd")
endif()
target_link_libraries(${PROJECT_NAME} cellframe-sdk dap_python_module
......
.
\ No newline at end of file
......@@ -67,7 +67,7 @@ def getJsonString(var_dir, dist_dir, node_role="full", poa_sign_cert=None,pos_si
"dag-pos":{
"tokens_hold": ["KELT","KEL"],
"tokens_hold_value": [1000000000,1000000000],
"confirmations_minumum": 3,
"confirmations_minumum": 1,
}
"files":{
"storage_dir":"{$var_dir}/lib/network/kelvin-testnet/pasma"
......
from .libCellFrame import *
File moved
......@@ -13,7 +13,7 @@ static bool s_init_http_enc = false;
static bool s_init_server_core = false;
static bool s_init_mempool = false;
static bool s_init_http_client_simple = false;
//static bool s_init_http_client_simple = false;
static bool s_init_wallet = false;
static bool s_init_cs_dag = false;
static bool s_init_cs_dag_poa = false;
......@@ -263,12 +263,13 @@ PyObject *python_cellframe_init(PyObject *self, PyObject *args){
return NULL;
}
s_init_mempool = true;
/*
} else if (strcmp(c_value, "HttpClientSimple") == 0){
// if (dap_http_client_simple_init() != 0){
// PyErr_SetString(CellFrame_error, "Failed to initialize HttpClientSimple module. ");
// return NULL;
// }
// s_init_http_client_simple = true;
if (dap_http_client_simple_init() != 0){
PyErr_SetString(CellFrame_error, "Failed to initialize HttpClientSimple module. ");
return NULL;
}
s_init_http_client_simple = true;*/
} else if (strcmp(c_value, "Wallet") == 0){
if (dap_chain_wallet_init() != 0){
PyErr_SetString(CellFrame_error, "Failed to initialize Wallet module. ");
......
File moved
File moved
File moved
File moved
File moved
# python-cellframe
## Prerequisites
To install, you must have Python3.7 including pip and a scikit-build.
sudo apt-get install pip3
If there is a problem on Debian buster
"unknown system group 'Debian-exim' in statoverride file; the system group got removed"
Use the following command to fix it
dpkg-statoverride --remove /etc/exim4/passwd.client
Now repeat sudo apt-get install pip3
## Build and Run tests:
To install, you must have Python3.7 and a scikit-build.
```
git clone https://gitlab.demlabs.net/cellframe/python-cellframe.git
cd python-cellframe
......@@ -28,9 +36,20 @@ sudo apt-get install libverto-dev
sudo apt-get install lldb-7
sudo apt-get install libmemcached-dev
sudo apt-get install libldb-dev
sudo apt-get install libtalloc-dev
sudo apt-get install libtevent-dev
sudo apt-get install libpython3-dev
sudo apt-get install traceroute
```
\ No newline at end of file
```
## Windows Build
First of all you need to install msys2. It provides 3 shells.
To install dependencies, run from MSYS shell:
```
pacman -S base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-file mingw-w64-x86_64-json-c mingw-w64-x86_64-python-pip
```
To start a build, run from MinGW 64bit shell (don't forget to change dir to python-cellframe repo):
```
python setup.py install
```
#!/usr/bin/python3
# CellFrame SDK.Python v0.9-4 Example Application #0
from CellFrame.libCellFrame import *
from CellFrame import *
import os
app_name = "MyChains"
......@@ -33,7 +33,7 @@ json_string = """{
"server": {
"enabled": true,
"listen_address": "0.0.0.0",
"listen_port_tcp": 8079
"listen_port_tcp": 8099
},
"conserver": {
"enabled": true,
......
......@@ -2,7 +2,7 @@
import sys
import os
from CellFrame.libCellFrame import *
from CellFrame import *
app_name="MyChains"
tmp_dir = os.getcwd() + "/tmp"
......
#!/usr/bin/python3
from CellFrame.libCellFrame import *
from CellFrame.libCellFrame import init, Cert,CryptoKeyType
from string import Template
import os
import sys
import MyAuthConf
import random
import string
# ---- Vars ----
# App name
appName = "MyAuth"
# Generate config
jsonCfg=MyAuthConf.getJsonString(appName,"CRITICAL")
jsonCfg = MyAuthConf.getJsonString(appName, "CRITICAL")
# Init SDK
try:
init( jsonCfg )
init(jsonCfg)
except json.decoder.JSONDecodeError as jex:
sys.stderr.write("load_json_config JSONdecode :%s" % jex)
exit(-1)
# Prepare to parse input arguments
counter=0
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
# Action Help
def help():
print("CA managment script usage: ")
print("")
print("To get this help")
print("\t"+cmdName+" [help]")
print("")
print("Generate <Root nodes number> certificates (5 by default)" +
"for selected <Algorythm> (\"sig_dil\" by default)")
print("\t"+cmdName+" init_root_ca [<Root nodes number>] [<Algorythm>] [<Restore string>]")
print("")
counter = 0
action = "help"
cmdName = ""
action_arg = {}
# Parse input arguments
for arg in sys.argv:
counter+=1
counter += 1
# Extract command name
if counter == 1:
cmdName = arg
......@@ -36,18 +58,8 @@ for arg in sys.argv:
if counter == 2:
action = arg
elif counter > 2:
action_arg[counter-2]=arg
action_arg[counter-2] = arg
# Process actions
# Action Help
def help():
print("CA managment script usage: ")
print("")
print("To get this help")
print("\t"+cmdName+" [help]")
print("")
print("Generate <Root nodes number> certificates (5 by default) for selected <Algorythm> (\"sig_dil\" by default)")
print("\t"+cmdName+" init_root_ca [<Root nodes number>] [<Algorythm>]")
print("")
if action == "help":
help()
# Action init root CAs
......@@ -55,26 +67,28 @@ elif action == "init_root_ca":
# Default params
rootCaNumber = 5
rootCaAlgoName = "sig_dil"
restoreString = randomString(12)
# Set default algo Dilithium
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_DILITHIUM
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_DILITHIUM()
# Read action args
if len(action_arg) > 0:
rootCaNumber = action_arg[1]
if len(action_arg) > 1:
rootCaAlgoName = action_arg[2]
if len(action_arg) > 2:
restoreString = action_arg[3]
# Parse algo name
if rootCaAlgoName == "sig_bliss":
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_BLISS
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_BLISS()
elif rootCaAlgoName == "sig_tesla":
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_TESLA
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_TESLA()
elif rootCaAlgoName == "sig_picnic":
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_PICNIC
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_PICNIC()
elif rootCaAlgoName == "sig_dil":
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_DILITHIUM
rootCaAlgo = CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_DILITHIUM()
else:
# Process error case
print("(!) Wrong algo name \""+rootCaAlgoName+"\", possible names: sig_bliss, sig_tesla, sig_picnic, sig_dil")
......@@ -82,7 +96,11 @@ elif action == "init_root_ca":
exit(-1)
# Create certs
print("Init root "+str(rootCaNumber)+" certificates with algo "+rootCaAlgoName)
print("Init root "+str(rootCaNumber)+" certificates with algo "
+ rootCaAlgoName)
print("Record somewhere the restore string(without braces): \""
+ restoreString+"\"")
for cur in range(int(rootCaNumber)):
certName = MyAuthConf.getNetworkName(appName,"_") +"_root_"+str(cur)
cert=Cert.generate( certName, rootCaAlgo,"fasdfsdf" )
cname = MyAuthConf.getNetworkName(appName, "_") + "_root_" + str(cur)
cert = Cert.generate(cname, rootCaAlgo, restoreString)
cert.save()
#!/usr/bin/python3
import sys
import os
from CellFrame.libCelLFrame import AppCli
from CellFrame.libCellFrame import AppCli
app_name="MyAuth"
tmp_dir = os.getcwd() + "/tmp"
......
from CellFrame.libCellFrame import *
def cmdUser(*argv):
def cmdUser(argv, strReply):
reply="user managment command:\n"
for arg in argv:
reply+=" arg"+str(arg)+"=\""+arg+"\"\n"
setReplyText(reply)
AppCliServer.setReplyText(reply, strReply)
def init():
AppCliServer.cmdItemCreate("user",cmdUser,"User managment command","""
......
......@@ -33,7 +33,7 @@ def getJsonString(app_name, log_level="DEBUG"):
"server": {
"enabled": true,
"listen_address": "0.0.0.0",
"listen_port_tcp": 8079
"listen_port_tcp": 8099
},
"conserver": {
"enabled": true,
......
......@@ -48,9 +48,10 @@ class CMakeBuild(build_ext):
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(
cfg.upper(),
extdir)]
if sys.maxsize > 2**32:
cmake_args += ['-A', 'x64']
build_args += ['--', '/m']
cmake_args += ['-G', 'MinGW Makefiles']
#if sys.maxsize > 2**32:
# cmake_args += ['-A', 'x64']
#build_args += ['--', '/m']
else:
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
build_args += ['--', '-j4']
......@@ -69,7 +70,7 @@ class CMakeBuild(build_ext):
setup(
name="CellFrame",
version="0.9-post12",
version="0.9-post14",
description="CellFrame SDK",
author='Demlabs (2007-2020)',
license="GNU GPLv3",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment