Skip to content
Snippets Groups Projects
Commit bd4501da authored by Cédric Moreau's avatar Cédric Moreau
Browse files

udid2 format no more active by default - may be activated through --udid2 option

parent 47a700a3
Branches
Tags
No related merge requests found
var META_TS = "META:TS:[1-9][0-9]*"; var META_TS = "META:TS:[1-9][0-9]*";
var UDID2 = "udid2;c;([A-Z-]*);([A-Z-]*);(\\d{4}-\\d{2}-\\d{2});(e\\+\\d{2}\\.\\d{2}(\\+|-)\\d{3}\\.\\d{2});(\\d+)(;?)"; var UDID2 = "udid2;c;([A-Z-]*);([A-Z-]*);(\\d{4}-\\d{2}-\\d{2});(e\\+\\d{2}\\.\\d{2}(\\+|-)\\d{3}\\.\\d{2});(\\d+)(;?)";
var USER_ID = "[^: ]*";
var BASE58 = "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+"; var BASE58 = "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]+";
var PUBKEY = "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}"; var PUBKEY = "[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{43,44}";
var TIMESTAMP = "[1-9][0-9]*"; var TIMESTAMP = "[1-9][0-9]*";
...@@ -20,13 +21,14 @@ module.exports = { ...@@ -20,13 +21,14 @@ module.exports = {
INTEGER: /^\d+$/, INTEGER: /^\d+$/,
TIMESTAMP: exact(TIMESTAMP), TIMESTAMP: exact(TIMESTAMP),
USER_ID: exact(USER_ID), // Any format, by default
UDID2_FORMAT: exact(UDID2), UDID2_FORMAT: exact(UDID2),
BASE58: exact(BASE58), BASE58: exact(BASE58),
PUBLIC_KEY: exact(PUBKEY), PUBLIC_KEY: exact(PUBKEY),
SIG: exact(SIGNATURE), SIG: exact(SIGNATURE),
CERT: { CERT: {
SELF: { SELF: {
UID: exact("UID:" + UDID2), UID: exact("UID:" + USER_ID),
META: exact(META_TS) META: exact(META_TS)
}, },
OTHER: { OTHER: {
...@@ -35,7 +37,7 @@ module.exports = { ...@@ -35,7 +37,7 @@ module.exports = {
} }
}, },
IDENTITY: { IDENTITY: {
INLINE: exact(PUBKEY + ":" + SIGNATURE + ":" + TIMESTAMP + ":" + UDID2) INLINE: exact(PUBKEY + ":" + SIGNATURE + ":" + TIMESTAMP + ":" + USER_ID)
}, },
BLOCK: { BLOCK: {
JOINER: exact(PUBKEY + ":" + SIGNATURE + ":" + TIMESTAMP), JOINER: exact(PUBKEY + ":" + SIGNATURE + ":" + TIMESTAMP),
......
...@@ -64,7 +64,7 @@ function IdentityParser (onError) { ...@@ -64,7 +64,7 @@ function IdentityParser (onError) {
return "No pubkey found"; return "No pubkey found";
} }
if (!obj.uid) { if (!obj.uid) {
return "Cannot extract udid2"; return "Wrong user id format";
} }
if (!obj.time) { if (!obj.time) {
return "Cannot extract signature time"; return "Cannot extract signature time";
......
...@@ -56,7 +56,7 @@ function MembershipParser (onError) { ...@@ -56,7 +56,7 @@ function MembershipParser (onError) {
err = {code: codes['BAD_DATE'], message: "Incorrect Date field: must be a positive or zero integer"}; err = {code: codes['BAD_DATE'], message: "Incorrect Date field: must be a positive or zero integer"};
} }
if(!err){ if(!err){
if(obj.userid && !obj.userid.match(constants.UDID2_FORMAT)) if(obj.userid && !obj.userid.match(constants.USER_ID))
err = {code: codes['BAD_USERID'], message: "UserID must match udid2 format"}; err = {code: codes['BAD_USERID'], message: "UserID must match udid2 format"};
} }
if(!err){ if(!err){
......
...@@ -26,6 +26,7 @@ var ConfigurationSchema = new Schema({ ...@@ -26,6 +26,7 @@ var ConfigurationSchema = new Schema({
powDelay: {"type": Number, "default": 0}, // Delay before starting computation of a new block powDelay: {"type": Number, "default": 0}, // Delay before starting computation of a new block
participate: {"type": Boolean, "default": true}, // Participate to writing the keychain participate: {"type": Boolean, "default": true}, // Participate to writing the keychain
tsInterval: {"type": Number, "default": 30}, tsInterval: {"type": Number, "default": 30},
udid2: {"type": Boolean, "default": false},
}); });
ConfigurationSchema.virtual('createNext').get(function () { ConfigurationSchema.virtual('createNext').get(function () {
......
...@@ -14,6 +14,7 @@ var logger = require('../app/lib/logger')('ucoind'); ...@@ -14,6 +14,7 @@ var logger = require('../app/lib/logger')('ucoind');
var signature = require('../app/lib/signature'); var signature = require('../app/lib/signature');
var crypto = require('../app/lib/crypto'); var crypto = require('../app/lib/crypto');
var base58 = require('../app/lib/base58'); var base58 = require('../app/lib/base58');
var constants = require('../app/lib/constants');
var ucoin = require('./..'); var ucoin = require('./..');
function keys (val) { function keys (val) {
...@@ -52,6 +53,7 @@ program ...@@ -52,6 +53,7 @@ program
.option('--growth <number>', 'Universal Dividend %growth. Aka. \'c\' parameter in RMT') .option('--growth <number>', 'Universal Dividend %growth. Aka. \'c\' parameter in RMT')
.option('--ud0 <number>', 'Universal Dividend initial value') .option('--ud0 <number>', 'Universal Dividend initial value')
.option('--dt <number>', 'Number of seconds between two UD') .option('--dt <number>', 'Number of seconds between two UD')
.option('--udid2', 'Enable udid2 format for user id')
; ;
program program
...@@ -412,6 +414,11 @@ program ...@@ -412,6 +414,11 @@ program
.description('Start uCoin server using given --currency') .description('Start uCoin server using given --currency')
.action(service(ucoin.createPeerServer, function (server, conf) { .action(service(ucoin.createPeerServer, function (server, conf) {
if (conf.udid2) {
// UserID must match udid2 format
constants.USER_ID = constants.UDID2_FORMAT;
}
// server // server
// .pipe(router(server.PeeringService.cert.fingerprint, server.conn)) // .pipe(router(server.PeeringService.cert.fingerprint, server.conn))
// .pipe(multicaster()); // .pipe(multicaster());
...@@ -491,7 +498,8 @@ function overrideConf(conf) { ...@@ -491,7 +498,8 @@ function overrideConf(conf) {
tsInterval: program.tsInterval, tsInterval: program.tsInterval,
ud0: program.ud0, ud0: program.ud0,
c: program.growth, c: program.growth,
dt: program.dt dt: program.dt,
udid2: program.udid2
} }
}; };
...@@ -519,6 +527,7 @@ function overrideConf(conf) { ...@@ -519,6 +527,7 @@ function overrideConf(conf) {
if (cli.ucp.dt) conf.dt = cli.ucp.dt; if (cli.ucp.dt) conf.dt = cli.ucp.dt;
if (cli.ucp.c) conf.c = cli.ucp.c; if (cli.ucp.c) conf.c = cli.ucp.c;
if (cli.ucp.ud0) conf.ud0 = cli.ucp.ud0; if (cli.ucp.ud0) conf.ud0 = cli.ucp.ud0;
if (cli.ucp.udid2) conf.udid2 = cli.ucp.udid2;
// Specific internal settings // Specific internal settings
conf.createNext = true; conf.createNext = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment