diff --git a/README.md b/README.md index d9dbab8..743d7db 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,25 @@ To start you need to  As a mayor, you have to understand what you are doing, your numeric reputation is in the game. Always check sources before downloading any things. For dev use town name: **dev** and nation name :**ants**  +**Machine:** + +**use a sudoer user and execute command line $, for security reason, do not use apxuser replace it by something not common ( not as admin, mayor,… use your nickname or pseudo)** + +```plaintext +$ sudo apt update +$ sudo apt upgrade +$ sudo useradd -s /bin/bash -m -d /home/{apxuser} -c "{apxuser}" {apxuser} +$ sudo passwd {apxuser} +$ sudo usermod -aG sudo {apxuser} +$ sudo visudo +# add the next line in the file +$ {apxuser} ALL=(ALL) NOPASSWD: ALL +# exit and save +$ su {apxuser} +``` + +For Production + ### Network:  FOR DEV:  you can just use local http:/dev-ants @@ -88,7 +107,7 @@ You need a domain name, to get a free one [http://ydns.io](http://ydns.io) creat # Into your production machine $ crontab -e # add a line at the end to update your IP in case you have a dynamic WAN IP -1,6,11,16,21,26,31,36,41,46,51,56 * * * * sleep 38 ; wget --no-check-certificate -O - https://ydns.io/hosts/update/Tl7FDQAETmQre312edztgsIUy >> /tmp/apxtri_ydns.io.log 2>&1 & +1,6,11,16,21,26,31,36,41,46,51,56 * * * * sleep 38 ; wget --no-check-certificate -O - https://ydns.io/hosts/update/Tl7FDQAETmQre312edztgsIUy >> /tmp/apxtri_ydns.io.log 2>&1 $ ip -4 address # to get your (local) LAN IP of your server ``` @@ -98,19 +117,7 @@ This allow public access from internet to your DMZ local server.  Think to use ### Machine:  -use a sudoer user and execute command line $, for security reason, do not use apxuser replace it by something not common ( not as admin, mayor,… use your nickname or pseudo) - ```plaintext -$ sudo apt update -$ sudo apt upgrade -$ useradd -s /bin/bash -m -d /home/{apxuser} -c "{apxuser}" {apxuser} -$ passwd {apxuser} -$ sudo usermod -aG sudo {apxuser} -$ sudo visudo -# add the next line in the file -$ {apxuser} ALL=(ALL) NOPASSWD: ALL -# exit and save -$ su {apxuser} $ sudo apt install git vim libcap2-bin p7zip-full p7zip-rar curl nginx # Install last nvm** (check website to get latest v0.xx from https://github.com/nvm-sh/nvm) $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash @@ -126,7 +133,7 @@ $ yarn --version # Find a non existing town to join to an existing nation see https://apxtri.crabedance.com $ mkdir ~/apxtowns # if it does not exist $ mkdir ~/apxtowns/{town}-{nation} - +$ sudo chown {apxuser}:root /etc/nginx/nginx.conf ################################# # For dev ####################### ################################# diff --git a/models/Checkjson.js b/models/Checkjson.js index d476370..544aa48 100755 --- a/models/Checkjson.js +++ b/models/Checkjson.js @@ -100,7 +100,7 @@ Checkjson.schema.properties.format = { "idn-hostname": / /, ipv4: /^([0–9]{1,3}.){3}.([0–9]{1,3})$/, ipv6: /^((([0–9A-Fa-f]{1,4}:){7}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}:[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){5}:([0–9A-Fa-f]{1,4}:)?[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){4}:([0–9A-Fa-f]{1,4}:){0,2}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){3}:([0–9A-Fa-f]{1,4}:){0,3}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){2}:([0–9A-Fa-f]{1,4}:){0,4}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(([0–9A-Fa-f]{1,4}:){0,5}:((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(::([0–9A-Fa-f]{1,4}:){0,5}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|([0–9A-Fa-f]{1,4}::([0–9A-Fa-f]{1,4}:){0,5}[0–9A-Fa-f]{1,4})|(::([0–9A-Fa-f]{1,4}:){0,6}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){1,7}:))$/, - telephonefr: /^0[1-9][0-9]{9}$/, + telephonefr: /^0[1-9][0-9]{8}$/, telephoneinter: /^\+*(\d{3})*[0-9,\-]{8,}/, password: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&.])[A-Za-z\d$@$!%*?&.{}:|\s]{8,}/, diff --git a/models/Notifications.js b/models/Notifications.js index 57cd58a..03dea3c 100644 --- a/models/Notifications.js +++ b/models/Notifications.js @@ -35,6 +35,7 @@ Notifications.get = (alias, tribeId) => { */ Notifications.registertolist = (key, typekey, tribe, mlist, srckey, uuid) => { key = key.toLowerCase(); + typekey= (typekey=="telephone")? "telephonefr":typekey; if (!Checkjson.testformat(key, typekey)) return { status: 400, diff --git a/routes/notifications.js b/routes/notifications.js index aa50406..5059b7f 100644 --- a/routes/notifications.js +++ b/routes/notifications.js @@ -66,8 +66,9 @@ router.post("/registeranonymous",checkHeaders,(req,res)=>{ if (!req.body.typekey || !['email','telephone'].includes(req.body.typekey) ){ return res.status(406).json({status:406,ref:"Notifications",msg:"typekeyunknown",data:{typekey:req.body.typekey}}) } + const key= (req.body.contactpoint)?req.body.contactpoint:req.body[req.body.typekey]; result= Notifications.registertolist( - req.body[req.body.typekey], + key, req.body.typekey, req.body.tribe, req.body.mlist,