diff --git a/.config b/.config new file mode 100644 index 0000000..a66b0d8 --- /dev/null +++ b/.config @@ -0,0 +1,3 @@ +SERVER_PWD= +BROWSER=firefox +PORT=7130 diff --git a/README.md b/README.md index 0115093..f823965 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,23 @@ -# Standard_Operations - Standard operations required for FLO Crypto, Blockchain API, Supernode WS, IndexedDB -This template contains standard operations that can be used for the following: -1. FLO Globals -2. FLO Crypto Operations -3. FLO Blockchain API Operations -4. FLO SuperNode Websocket Operations -5. compact IndexedDB Operations +# SuperNodeStorage +FLO Supernode Storage is a Cloud Storage progam for FLO Dapps -## FLO Globals -`floGlobals` object contains the global variables and constants required for the operations. Make sure to add this object before any other scripts. -`floGlobals` contains the following properties : -1. `blockchain` : Indicates the blockchain (`"FLO"` or `"FLO_TEST"`). -2. `apiURL` : Indicates the URL for blockchain API calls. -3. `adminID` : Indicates the master admin FLO ID for the project. -4. `sendAmt` : Indicates the default flo amount to be sent while sending transactions into the blockchain -5. `fee` : Indicates the default fee amount to be deduced while sending transactions into the blockchain -6. `supernodes` : Holder for the supernode list. Can be updated in runtime while retriving data from blockchain using API. Stored in the Object format, +## Installation +1. Download or clone the [repo](https://github.com/ranchimall/SuperNodeStorage): - { - : { - uri : - ...(otherProperties) - } - ...(Other Supernodes) - } + git clone https://github.com/ranchimall/SuperNodeStorage +2. Add a strong in `.config` file +3. Change other configurations (if needed) +4. Host and publish the domain name or IP with port -## FLO Crypto Operations -`floCrypto` operations can be used to perform blockchain-cryptography methods. `floCrypto` operations are synchronized and return a value. Contains the following Operations. -#### Generate New FLO ID pair - floCrypto.generateNewID() - `generateNewID` generates a new flo ID and returns private-key, public-key and floID +## Usage +1. Start the app using the following command in terminal. The server WSS will be started and the supernode html-js will be opened in the browser. -#### Calculate Public Key Hex -`getPubKeyHex` returns public-key from given private-key - floCrypto.getPubKeyHex(privateKey) -1. privateKey - private key in WIF format (Hex) + ./start_supernode.sh +2. (Only for first time login) Enter the and when prompted -#### Calculate FLO ID - floCrypto.getFloIDfromPubkeyHex(publicKey) -`getFloIDfromPubkeyHex` returns flo-ID from public-key -1. publicKey - public key hex value +The Supernode storage will automatically start -#### Verify Private Key - floCrypto.verifyPrivKey(privateKey, pubKey_floID, *isfloID) -`verifyPrivKey` verify the private-key for the given public-key or flo-ID -1. privateKey - private key in WIF format (Hex) -2. pubKey_floID - public Key or flo ID -3. isfloID - boolean value (true - compare as flo ID, false - compare as public key) (optional, default is true) +NOTE: The and will be stored securedly in IndexedDB of the browser -#### Validate FLO ID - floCrypto.validateAddr(floID) -`validateAddr` check if the given Address is valid or not -1. floID - flo ID to validate - -#### Data Encryption - floCrypto.encryptData(data, publicKey) -`encryptData` encrypts the given data using public-key -1. data - data to encrypt -2. publicKey - public key of the recipient - -#### Data Decryption - floCrypto.decryptData(data, privateKey) -`decryptData` decrypts the given data using private-key -1. data - encrypted data to decrypt (Object that was returned from encryptData) -2. privateKey - private key of the recipient - -#### Sign Data - floCrypto.signData(data, privateKey) -`signData` signs the data using the private key -1. data - data to sign -2. privateKey - private key of the signer - -#### Verify Signature - floCrypto.decryptData(data, signature, publicKey) -`decryptData` verifies signatue of the data using public-key -1. data - data of the given signature -2. signature - signature of the data -3. publicKey - public key of the signer +NOTE: Users may add `start_supernode` to bootup process to automatically start the supernode during boot up diff --git a/index.html b/app/index.html similarity index 100% rename from index.html rename to app/index.html diff --git a/app/supernodeWSS.bin b/app/supernodeWSS.bin new file mode 100755 index 0000000..d620c0a Binary files /dev/null and b/app/supernodeWSS.bin differ diff --git a/start_supernode.sh b/start_supernode.sh new file mode 100755 index 0000000..c1b126e --- /dev/null +++ b/start_supernode.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +current_date=$(date) +echo "$current_date : Starting Supernode" >> logs/app.log + +#Read configurations +IFS="=" +while read -r var value +do +export "$var"="${value}" +done < .config + +#Start the app +echo $current_date >> logs/server.log +app/supernodeWSS.bin $PORT $SERVER_PWD >> logs/server.log & +echo $current_date >> logs/browser.log +$BROWSER app/index.html >> logs/browser.log & +wait + diff --git a/supernodeWSS b/supernodeWSS deleted file mode 100755 index 5b551a6..0000000 Binary files a/supernodeWSS and /dev/null differ diff --git a/util/websocket.c b/util/websocket.c index eb63899..db6f7b2 100644 --- a/util/websocket.c +++ b/util/websocket.c @@ -6,9 +6,8 @@ #include "mongoose.h" static sig_atomic_t s_signal_received = 0; -static const char *s_http_port = "7130"; static struct mg_serve_http_opts s_http_server_opts; -static char server_pwd[100]; +static char *s_http_port, *server_pwd; static struct mg_connection *supernode_client = NULL; static void signal_handler(int sig_num) { @@ -145,12 +144,8 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { int main(int argc, char** argv) { - if(argc<=1){ - printf("Enter server password : "); - scanf("%s",server_pwd); - } - else - strcpy(server_pwd,argv[1]); + s_http_port = argv[1]; + server_pwd = argv[2]; struct mg_mgr mgr; struct mg_connection *nc; @@ -164,7 +159,7 @@ int main(int argc, char** argv) { nc = mg_bind(&mgr, s_http_port, ev_handler); mg_set_protocol_http_websocket(nc); - s_http_server_opts.document_root = "."; // Serve current directory + s_http_server_opts.document_root = "app/"; // Serve current directory s_http_server_opts.enable_directory_listing = "no"; printf("Started on port %s\n", s_http_port);