From ff242e6e618ee53ebcd7251f9c26ff721c7a03b4 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 12 Mar 2016 15:33:23 +0100 Subject: Initial import. --- .gitignore | 1 + TODO | 3 + build-openwrt-dev.sh | 408 ++++++++++++++++++++ build-openwrt.sh | 426 +++++++++++++++++++++ maj/00-generer-le-fichier-de-mise-a-jour.png | Bin 0 -> 97552 bytes maj/01-adresse-routeur.png | Bin 0 -> 10805 bytes maj/02-auth-routeur.png | Bin 0 -> 25005 bytes maj/03-interface-admin.png | Bin 0 -> 68652 bytes maj/04-menu-system-firmware-upgrade.png | Bin 0 -> 13320 bytes maj/05-formulaire-upgrade.png | Bin 0 -> 81985 bytes maj/06-selection-fichier-firmware.png | Bin 0 -> 69482 bytes maj/07-verif-nom-fichier-firmware.png | Bin 0 -> 18115 bytes maj/08-confirmation-upgrade.png | Bin 0 -> 12303 bytes maj/09-flash-en-cours.png | Bin 0 -> 8762 bytes maj/10-redemarrage-en-cours.png | Bin 0 -> 8933 bytes maj/11-fin-du-redemarrage.png | Bin 0 -> 16384 bytes maj/12-eventuel-probleme-de-chargement-de-page.png | Bin 0 -> 50361 bytes maj/13-page-authentification-openwrt.png | Bin 0 -> 36992 bytes maj/config.default.php | 3 + maj/doc.html | 121 ++++++ maj/gen-dev.php | 162 ++++++++ maj/gen.php | 162 ++++++++ maj/index.php | 139 +++++++ maj/main.css | 99 +++++ maj/main.js | 200 ++++++++++ maj/print.css | 17 + 26 files changed, 1741 insertions(+) create mode 100644 .gitignore create mode 100644 TODO create mode 100755 build-openwrt-dev.sh create mode 100755 build-openwrt.sh create mode 100644 maj/00-generer-le-fichier-de-mise-a-jour.png create mode 100644 maj/01-adresse-routeur.png create mode 100644 maj/02-auth-routeur.png create mode 100644 maj/03-interface-admin.png create mode 100644 maj/04-menu-system-firmware-upgrade.png create mode 100644 maj/05-formulaire-upgrade.png create mode 100644 maj/06-selection-fichier-firmware.png create mode 100644 maj/07-verif-nom-fichier-firmware.png create mode 100644 maj/08-confirmation-upgrade.png create mode 100644 maj/09-flash-en-cours.png create mode 100644 maj/10-redemarrage-en-cours.png create mode 100644 maj/11-fin-du-redemarrage.png create mode 100644 maj/12-eventuel-probleme-de-chargement-de-page.png create mode 100644 maj/13-page-authentification-openwrt.png create mode 100644 maj/config.default.php create mode 100644 maj/doc.html create mode 100644 maj/gen-dev.php create mode 100644 maj/gen.php create mode 100644 maj/index.php create mode 100644 maj/main.css create mode 100644 maj/main.js create mode 100644 maj/print.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f34591c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +maj/config.php diff --git a/TODO b/TODO new file mode 100644 index 0000000..608fbd6 --- /dev/null +++ b/TODO @@ -0,0 +1,3 @@ + + * Router hostname customziation ? + * Unrecognized IP if comming from IPv6 diff --git a/build-openwrt-dev.sh b/build-openwrt-dev.sh new file mode 100755 index 0000000..79ea750 --- /dev/null +++ b/build-openwrt-dev.sh @@ -0,0 +1,408 @@ +#!/bin/bash +# +# Work derived from ./quick_740n_ttn_bb.sh (Laurent Guerby ) +# +# Copyright 2016 Ludovic Pouzenc +# +# CHD OpenWRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CHD OpenWRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CHD OpenWRT. If not, see . +# +echo -n "$0 - " ; date + +# Directories and source file URL +BUILD_DIR=${BUILD_DIR:-./build} +CACHE_DIR=${CACHE_DIR:-.} +ORIG_TARBALL=OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64.tar.bz2 +ORIG_URL=http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/$ORIG_TARBALL +PACKAGES="luci luci-mod-admin-full ip" # Base packages +PACKAGES="$PACKAGES luci-i18n-base-en luci-i18n-firewall-en luci-i18n-base-fr luci-i18n-firewall-fr" # internationnalisation +PACKAGES="$PACKAGES miniupnpd luci-app-upnp luci-i18n-upnp-fr" # Extra packages +PACKAGES="$PACKAGES kmod-ledtrig-default-on kmod-ledtrig-netdev kmod-ledtrig-timer kmod-ledtrig-usbdev kmod-leds-gpio" # Additionnal kernel modules +PACKAGES="$PACKAGES -kmod-ppp -kmod-pppoe -kmod-pppox" # Unusefull kernel modules +PACKAGES="$PACKAGES -luci-proto-ppp -ppp -ppp-mod-pppoe -odhcp6c" # Unusefull packages + +# Argument parsing +if [ $# -lt 8 -o $# -gt 9 ] +then echo "Usage: $0 [wanip4addr]" + exit 1 +fi + +dnslist="185.131.40.1 fe80::31" + +profile=$1 +case "$profile" in + TLWR740|TLWR841) + ;; + *) echo "Unsupported profile '$profile', should be TLWR740 or TLWR841" + exit 2 + ;; +esac + +ip4pub=$2 +case "$ip4pub" in + 185.131.40.*) ;; + 185.131.41.*) ;; + *) echo "Unknown Ip4 $ip4pub"; exit 3;; +esac + +lanip4addr=$3 +ip6prefix=$4 +wanip6addr=${ip6prefix}1/56 +lanip6addr=${ip6prefix%%0::}1::1/64 +wanip6ll=$(echo $ip6prefix | sed -e 's#.*:\(....:....\)::$#fe80::\1/64#') + +if [ '$1$' = "${5:0:3}" ] +then root_password=$5 +else root_password=$(mkpasswd -5 "$5") +fi + +wireless_ssid=$6 +wireless_key=$7 +case $8 in + -1) wireless_disabled=1; wireless_txpower=10 ;; + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16) wireless_disabled=0; wireless_txpower=$8 ;; + *) echo "Unknown txpower '$8'"; exit 4 ;; +esac + +wanip4addr=${9:-'no-nat'} +case "$wanip4addr" in + 172.16.20.*|172.16.21.*) wanip4mask=255.255.0.0; wanip4gw=172.16.0.254 ;; + *) wanip4addr=$ip4pub; wanip4mask=255.255.254.0; wanip4gw=185.131.40.1 ;; +esac + +wanip6gw=fe80::31 + +cat < extra_files/etc/dropbear/authorized_keys < extra_files/etc/shadow < extra_files/etc/rc.local < extra_files/etc/config/network < extra_files/etc/config/wireless < extra_files/etc/config/dhcp < extra_files/etc/config/dropbear < extra_files/etc/config/firewall < extra_files/etc/config/upnpd < extra_files/etc/hotplug.d/button/01onoff <<"EOF" +#!/bin/sh + +[ "$BUTTON" = "wps" ] && [ "$ACTION" = "pressed" ] && { + SW=$(uci get wireless.@wifi-device[0].disabled) + [ $SW == '0' ] && uci set wireless.@wifi-device[0].disabled=1 + [ $SW == '0' ] || uci set wireless.@wifi-device[0].disabled=0 + wifi +} +EOF + +####################### +# Build Openwrt image # +####################### + +# Bug fix for RC3 (make clean forget things) +#if [ -d $BUILD_DIR/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/tmp ] +#then rm -r $BUILD_DIR/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/tmp +#fi + +make clean +make image PROFILE=$profile PACKAGES="$PACKAGES" FILES="extra_files/" +res=$? + +echo +if [ $res -eq 0 ] +then echo "Image ready: " + ls -la bin/ar71xx/openwrt-*-ar71xx-generic-tl-*-v[49]-squashfs-* + echo +else echo "Something went wrong, sorry" +fi + +echo -n "$0 - " ; date +exit $res diff --git a/build-openwrt.sh b/build-openwrt.sh new file mode 100755 index 0000000..1442359 --- /dev/null +++ b/build-openwrt.sh @@ -0,0 +1,426 @@ +#!/bin/bash +# +# Work derived from ./quick_740n_ttn_bb.sh (Laurent Guerby ) +# +# Copyright 2016 Ludovic Pouzenc +# +# CHD OpenWRT is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# CHD OpenWRT is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with CHD OpenWRT. If not, see . +# +echo -n "$0 - " ; date + +# Directories and source file URL +BUILD_DIR=${BUILD_DIR:-./build} +CACHE_DIR=${CACHE_DIR:-.} +ORIG_TARBALL=OpenWrt-ImageBuilder-15.05-ar71xx-generic.Linux-x86_64.tar.bz2 +ORIG_URL=http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/$ORIG_TARBALL +PACKAGES="luci luci-mod-admin-full ip" # Base packages +PACKAGES="$PACKAGES luci-i18n-base-en luci-i18n-firewall-en luci-i18n-base-fr luci-i18n-firewall-fr" # internationnalisation +PACKAGES="$PACKAGES miniupnpd luci-app-upnp luci-i18n-upnp-fr" # Extra packages +PACKAGES="$PACKAGES kmod-ledtrig-default-on kmod-ledtrig-netdev kmod-ledtrig-timer kmod-ledtrig-usbdev kmod-leds-gpio" # Additionnal kernel modules +PACKAGES="$PACKAGES -kmod-ppp -kmod-pppoe -kmod-pppox" # Unusefull kernel modules +PACKAGES="$PACKAGES -luci-proto-ppp -ppp -ppp-mod-pppoe -odhcp6c" # Unusefull packages + +# Argument parsing +if [ $# -lt 8 -o $# -gt 9 ] +then echo "Usage: $0 [wanip4addr]" + exit 1 +fi + +dnslist="185.131.40.1 fe80::31" + +profile=$1 +case "$profile" in + TLWR740|TLWR841) + ;; + *) echo "Unsupported profile '$profile', should be TLWR740 or TLWR841" + exit 2 + ;; +esac + +ip4pub=$2 +case "$ip4pub" in + 185.131.40.*) ;; + 185.131.41.*) ;; + *) echo "Unknown Ip4 $ip4pub"; exit 3;; +esac + +lanip4addr=$3 +ip6prefix=$4 +wanip6addr=${ip6prefix}1/56 +lanip6addr=${ip6prefix%%0::}1::1/64 +wanip6ll=$(echo $ip6prefix | sed -e 's#.*:\(....:....\)::$#fe80::\1/64#') + +if [ '$1$' = "${5:0:3}" ] +then root_password=$5 +else root_password=$(mkpasswd -5 "$5") +fi + +wireless_ssid=$6 +wireless_key=$7 +case $8 in + -1) wireless_disabled=1; wireless_txpower=10 ;; + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16) wireless_disabled=0; wireless_txpower=$8 ;; + *) echo "Unknown txpower '$8'"; exit 4 ;; +esac + +wanip4addr=${9:-'no-nat'} +case "$wanip4addr" in + 172.16.20.*|172.16.21.*) wanip4mask=255.255.0.0; wanip4gw=172.16.0.254 ;; + *) wanip4addr=$ip4pub; wanip4mask=255.255.254.0; wanip4gw=185.131.40.1 ;; +esac + +wanip6gw=fe80::31 + +cat < repositories.conf <<"EOT" +## Place your custom repositories here, they must match the architecture and version. +# src/gz chaos_calmer http://downloads.openwrt.org/chaos_calmer/15.05/ar71xx/generic/packages +# src custom file:///usr/src/openwrt/bin/ar71xx/packages + +## Remote package repositories +src/gz chaos_calmer_base http://localhost/openwrt/chaos_calmer/15.05/ar71xx/generic/packages/base +src/gz chaos_calmer_luci http://localhost/openwrt/chaos_calmer/15.05/ar71xx/generic/packages/luci +src/gz chaos_calmer_packages http://localhost/openwrt/chaos_calmer/15.05/ar71xx/generic/packages/packages +src/gz chaos_calmer_routing http://localhost/openwrt/chaos_calmer/15.05/ar71xx/generic/packages/routing +src/gz chaos_calmer_telephony http://localhost/openwrt/chaos_calmer/15.05/ar71xx/generic/packages/telephony +src/gz chaos_calmer_management http://localhost/openwrt/chaos_calmer/15.05/ar71xx/generic/packages/management + +## This is the local package repository, do not remove! +src imagebuilder file:packages +EOT + +cat > extra_files/etc/dropbear/authorized_keys < extra_files/etc/shadow < extra_files/etc/rc.local < extra_files/etc/config/network < extra_files/etc/config/wireless < extra_files/etc/config/dhcp < extra_files/etc/config/dropbear < extra_files/etc/config/firewall < extra_files/etc/config/upnpd < extra_files/etc/hotplug.d/button/01onoff <<"EOF" +#!/bin/sh + +[ "$BUTTON" = "wps" ] && [ "$ACTION" = "pressed" ] && { + SW=$(uci get wireless.@wifi-device[0].disabled) + [ $SW == '0' ] && uci set wireless.@wifi-device[0].disabled=1 + [ $SW == '0' ] || uci set wireless.@wifi-device[0].disabled=0 + wifi +} +EOF + +####################### +# Build Openwrt image # +####################### + +# Bug fix for RC3 (make clean forget things) +#if [ -d $BUILD_DIR/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/tmp ] +#then rm -r $BUILD_DIR/build_dir/target-mips_34kc_uClibc-0.9.33.2/linux-ar71xx_generic/tmp +#fi + +make clean +make image PROFILE=$profile PACKAGES="$PACKAGES" FILES="extra_files/" +res=$? + +echo +if [ $res -eq 0 ] +then echo "Image ready: " + ls -la bin/ar71xx/openwrt-*-ar71xx-generic-tl-*-v[49]-squashfs-* + echo +else echo "Something went wrong, sorry" +fi + +echo -n "$0 - " ; date +exit $res diff --git a/maj/00-generer-le-fichier-de-mise-a-jour.png b/maj/00-generer-le-fichier-de-mise-a-jour.png new file mode 100644 index 0000000..9bf2450 Binary files /dev/null and b/maj/00-generer-le-fichier-de-mise-a-jour.png differ diff --git a/maj/01-adresse-routeur.png b/maj/01-adresse-routeur.png new file mode 100644 index 0000000..95e86b5 Binary files /dev/null and b/maj/01-adresse-routeur.png differ diff --git a/maj/02-auth-routeur.png b/maj/02-auth-routeur.png new file mode 100644 index 0000000..50ed3fc Binary files /dev/null and b/maj/02-auth-routeur.png differ diff --git a/maj/03-interface-admin.png b/maj/03-interface-admin.png new file mode 100644 index 0000000..6184797 Binary files /dev/null and b/maj/03-interface-admin.png differ diff --git a/maj/04-menu-system-firmware-upgrade.png b/maj/04-menu-system-firmware-upgrade.png new file mode 100644 index 0000000..89898a6 Binary files /dev/null and b/maj/04-menu-system-firmware-upgrade.png differ diff --git a/maj/05-formulaire-upgrade.png b/maj/05-formulaire-upgrade.png new file mode 100644 index 0000000..88f3997 Binary files /dev/null and b/maj/05-formulaire-upgrade.png differ diff --git a/maj/06-selection-fichier-firmware.png b/maj/06-selection-fichier-firmware.png new file mode 100644 index 0000000..ceceb1d Binary files /dev/null and b/maj/06-selection-fichier-firmware.png differ diff --git a/maj/07-verif-nom-fichier-firmware.png b/maj/07-verif-nom-fichier-firmware.png new file mode 100644 index 0000000..9f01dc9 Binary files /dev/null and b/maj/07-verif-nom-fichier-firmware.png differ diff --git a/maj/08-confirmation-upgrade.png b/maj/08-confirmation-upgrade.png new file mode 100644 index 0000000..1a6c63e Binary files /dev/null and b/maj/08-confirmation-upgrade.png differ diff --git a/maj/09-flash-en-cours.png b/maj/09-flash-en-cours.png new file mode 100644 index 0000000..8acb268 Binary files /dev/null and b/maj/09-flash-en-cours.png differ diff --git a/maj/10-redemarrage-en-cours.png b/maj/10-redemarrage-en-cours.png new file mode 100644 index 0000000..c528198 Binary files /dev/null and b/maj/10-redemarrage-en-cours.png differ diff --git a/maj/11-fin-du-redemarrage.png b/maj/11-fin-du-redemarrage.png new file mode 100644 index 0000000..0e19a32 Binary files /dev/null and b/maj/11-fin-du-redemarrage.png differ diff --git a/maj/12-eventuel-probleme-de-chargement-de-page.png b/maj/12-eventuel-probleme-de-chargement-de-page.png new file mode 100644 index 0000000..1c46271 Binary files /dev/null and b/maj/12-eventuel-probleme-de-chargement-de-page.png differ diff --git a/maj/13-page-authentification-openwrt.png b/maj/13-page-authentification-openwrt.png new file mode 100644 index 0000000..8eeb057 Binary files /dev/null and b/maj/13-page-authentification-openwrt.png differ diff --git a/maj/config.default.php b/maj/config.default.php new file mode 100644 index 0000000..657ab12 --- /dev/null +++ b/maj/config.default.php @@ -0,0 +1,3 @@ + + + + + +Procédure à suivre + + + + +

Procédure de mise à jour votre routeur TP-Link

+

Je dois faire ça moi ?

+

Cette mise à jour est destinée à tous les adhérents de Comminges Haut Débit qui utilisent le petit routeur blanc TP-LINK fourni par l'association. Nous en avons besoin pour la suite des améliorations de notre réseau. +Nous avons prévu un outil qui permette à chacun d'être autonome.

+

Aucune compétence informatique particulière n'est requise ; essayez par vous même, on épaulera si besoin. Si vous êtes perdus, téléphonez au 05 33 00 33 36 (plutôt le soir). +Si vous n'êtes pas à l'aise avec l'utilisation de plusieurs fenêtres en même temps, vous pouvez imprimer cette procédure (je ne dis pas ça parce qu'on a quelques antennes sur la cellulose). +

+ +

Cette mise à jour va permettre :

+
    +
  • de corriger les problèmes connus avec le Wifi de maison (déconnections aléatoires)
  • +
  • de simplifier le déploiement des futures mises à jour (nous pourrons les automatiser)
  • +
  • de permettre des modifiations dans le fonctionnement de notre réseau (suppression du NAT)
  • +
+ +

C'est compris, mais comment faire ?

+ +

Il faut dérouler cette procédure depuis la connexion internet Comminges Haut Débit, et de préférence avec un ordinateur relié au routeur par un câble réseau. Utilisez le navigateur Mozilla Firefox (on a moins testé avec les autres).

+ + + +

1. Remplir un formulaire pour choisir les mots de passe de votre routeur

+

Le formulaire est disponible ici : http://moniteur.chd.sx/maj.
+(ce lien s'ouvrira dans une nouvelle fenêtre ou onglet)

+

+Vous avez là deux mots de passes à choisir, et à saisir deux fois chacun : +

    +
  • Le premier est le mot de passe WiFi pour connecter des ordinateurs portables ou tablettes
  • +
  • Le second vous permettra d'accéder à la configuration de votre routeur si vous en avez besoin
  • +
+ +Astuce : Si vous renseignez le même nom de réseau WiFi (SSID) et le même mot de passe qu'actuellement (cf étiquette sur le routeur), alors les ordinateurs qui se sont déjà connectés chez vous ne demanderont rien à la prochaine connexion. Sinon, il faudra leur indiquer le nouveau nom du réseau ou le nouveau mot de passe. + +

2. Télécharger le fichier de mise à jour

+ +

Une fois le formulaire rempli, cliquez sur le bouton "Générer le fichier de mise à jour". Il se grisera, il faudra patienter entre 20 secondes et une minute. Une boite de dialogue apparaîtra, choisissez "Enregistrer" comme illustré ci-dessous.

+00-generer-le-fichier-de-mise-a-jour +

Une fois ce fichier sauvegardé sur votre ordinateur, vous pouvez à présent fermer la page du formulaire.

+ +

3. Se connecter à votre routeur

+

Remarque : D'origine, le nom d'utilisateur est admin et le mot de passe par défaut est admin.

+

Première méthode : vous pouvez cliquer simplement sur ce lien : http://192.168.1.1 et vous devriez arriver directement sur la page verte TP-Link. (dans ce cas, sautez à l'étape 4) +

+

Deuxième méthode : ouvrez une nouvelle fenêtre ou onglet dans votre navigateur, et saisissez l'adresse LAN de votre routeur comme illustré.

+ +01-adresse-routeur.png +

Si cela ne fonctionne pas, il est possible que votre routeur ait une adresse différente. Les adhérents anciens ou ayant eu des soucis avec le routeur peuvent avoir l'adresse 192.168.0.1 et non pas 192.168.1.1. +

+02-auth-routeur.png + +

Les deux méthodes vous permettent d'arriver la page d'accueil du routeur, comme illustré ci-dessous.
+(Certes ça parle patois, mais promis, il n'y a pas besoin de déchiffrer)

+03-interface-admin.png + +

4. Lui indiquer le fichier mise à jour

+ +

Dans la page d'accueil du routeur, dans le menu sur la gauche, cliquez sur "System Tools" puis "Firmware Upgrade". Vous obtiendrez la page illustrée ci-dessous. +

+05-formulaire-upgrade.png +

Vérifiez dans cette page qu'en face de Hardware version, il y ait écrit WR740N v4 ou bien WR841N v9. Si ce n'est pas le cas, contactez-nous car cette mise à jour n'est pas compatible avec votre routeur, nous vous en confierons un autre.

+ +

Cliquez sur le bouton "Parcourir...", puis sélectionnez le fichier que vous avez téléchargé tout à l'heure depuis le formulaire. Son nom est mise-a-jour-routeur-TLWRxxxxx.bin. Si vous ne savez pas dans quel dossier il est, il s'est probablement rangé automatiquement dans votre dossier Téléchargements. Une fois sélectionné, cliquez sur Ouvrir.

+ +06-selection-fichier-firmware.png + +

Vérifiez sur le nom du fichier à droite du bouton Parcourir est bien mise-a-jour-routeur-TLWRxxxxx.bin puis cliquez sur le bouton "Upgrade" et confirmez avec le bouton OK.

+07-verif-nom-fichier-firmware.png
+08-confirmation-upgrade.png + +

5. Attendre 1 minute et se connecter au nouveau logiciel du routeur

+

Il n'y a aucune intervention de votre part pendant cette étape. Voici les illustrations de ce qui devrait se passer.

+ +09-flash-en-cours.png
+10-redemarrage-en-cours.png
+11-fin-du-redemarrage.png + +

6. Vérifier que tout fonctionne chez vous

+ +

Il se peut que juste après la mise à jour vous ayez un message d'erreur comme celui-ci :

+12-eventuel-probleme-de-chargement-de-page.png + +

Pas de panique, votre ordinateur n'a peut-être pas encore accroché le réseau.

+
    +
  • Attendre quelques secondes et cliquez réessayer
  • +
  • Si c'est pas mieux, débrancher le câble réseau au niveau de l'ordinateur pendant 10 secondes, rebrancher, attendre 30 secondes, cliquez réessayer
  • +
  • Si vous avez personnalisé l'adresse LAN dans le formulaire, votre navigateur n'a pas la bonne adresse, remplacez-la et validez par Entrée
  • +
  • Essayez une recherche sur votre moteur de recherche favori pour vérifier que vous avez accès à internet
  • +
+ +

Le routeur devrait afficher maintenant la page de connexion de OpenWRT. Vous pouvez visiter l'interface d'administration du routeur avec le mot de passe que vous avez choisi ou fermer cette fenêtre.

+ +13-page-authentification-openwrt.png + +

Vérifiez que tous vos équipements ont accès à internet. Certains peuvent avoir besoin d'être rébranché puis rebranché au réseau, ou bien seront en attente du mot de passe WiFi.

+ + +

Si quelque chose c'est mal passé, contactez-nous, comme indiqué en haut de cette page.

+ + diff --git a/maj/gen-dev.php b/maj/gen-dev.php new file mode 100644 index 0000000..5226813 --- /dev/null +++ b/maj/gen-dev.php @@ -0,0 +1,162 @@ + + * + * CHD OpenWRT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD OpenWRT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD OpenWRT. If not, see . +**/ + +function validate($regex, $index, $message, &$errors) { + if (isset($_POST[$index]) && 1 === preg_match($regex, $_POST[$index])) { + return true; + } + if (is_array($errors)) $errors[$index] = $message . ' (' . (isset($_POST[$index])?$_POST[$index]:'vide') . ')'; + return false; +} + +function checksame($index1, $index2, $message, &$errors) { + if ( + isset($_POST[$index1]) + && isset($_POST[$index2]) + && ($_POST[$index1] === $_POST[$index2]) + ) { + return true; + } + $errors[$index] = $message; + return false; +} +$pattern_ipv4_optionnal='/(^|((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4})$/'; +$pattern_ipv4='/((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$/'; +$pattern_ipv6='/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\z/i'; +$pattern_pass6='/^[^\']{6,64}$/u'; +$pattern_pass8='/^[^\']{8,64}$/u'; +$pattern_ssid='/^[\w._-]{1,32}$/'; +$pattern_iden='/^[\w._-]*$/'; +$pattern_rev='/^\d[\d.]*$/'; +$pattern_int='/^-?\d+$/'; + +$errors=array(); +$ignore=NULL; +$res = validate($pattern_iden, 'profile', 'Profil matériel du routeur incorrect', $errors); +$res &= validate($pattern_rev, 'revision', 'Révision matérielle du routeur incorrecte', $errors); +$res &= validate($pattern_ipv4, 'ip4pub', 'Adresse IPv4 publique du routeur incorrecte', $errors); +$res &= validate($pattern_ipv4_optionnal, 'ip4wan', 'Adresse IPv4 WAN du routeur incorrecte', $errors); +$res &= validate($pattern_ipv4, 'ip4lan', 'Adresse IPv4 LAN du routeur incorrecte', $errors); +$res &= validate($pattern_ipv6, 'ip6prefix', 'Préfixe IPv6 du routeur incorrect', $errors); +//$res &= validate($pattern_ipv6, 'ip6wanll', 'Adresse IPv6 WAN Link Local incorrecte', $errors); +$res &= validate($pattern_pass6, 'pwd1', 'Mot de passe du routeur incorrect', $errors); +$res &= validate($pattern_pass6, 'pwd2', 'Mot de passe du routeur incorrect', $ignore); +$res &= validate($pattern_ssid, 'ssid', 'Nom du réseau WiFi (SSID) incorrect', $errors); +$res &= validate($pattern_pass8, 'key1', 'Mot de passe du WiFi incorrect', $errors); +$res &= validate($pattern_pass8, 'key2', 'Mot de passe du WiFi incorrect', $ignore); +$res &= validate($pattern_int, 'txpower', 'Puissance d\'émission WiFi incorrecte', $errors); +$res &= checksame('pwd1', 'pwd2', 'Les mots de passes ne correspondent pas', $errors); +$res &= checksame('key1', 'key2', 'Les mots de passes ne correspondent pas', $errors); + +switch ($_POST['profile']) { + case 'TLWR740': + switch($_POST['revision']) { + case '4': + $profile='TLWR740'; + $revision='4'; + $user_filename='mise-a-jour-routeur-TLWR740v4.bin'; + $gen_filename='bin/ar71xx/openwrt-15.05-ar71xx-generic-tl-wr740n-v4-squashfs-factory.bin'; + break; + default: + $errors['revision'] = 'Routeur non supporté (' . (isset($_POST['revision'])?$_POST[$index]:'vide') . ')'; + $res = false; + } + break; + case 'TLWR841': + switch($_POST['revision']) { + case '9': + $profile='TLWR841'; + $revision='9'; + //$user_filename='wr841nv9_wr841ndv9_en_3_16_9_up(150310).bin'; + $user_filename='mise-a-jour-routeur-TLWR841v9.bin'; + $gen_filename='bin/ar71xx/openwrt-15.05-ar71xx-generic-tl-wr841n-v9-squashfs-factory.bin'; + break; + default: + $errors['revision'] = 'Routeur non supporté (' . (isset($_POST['revision'])?$_POST[$index]:'vide') . ')'; + $res = false; + } + break; + default: + $errors['profile'] = 'Routeur non supporté (' . (isset($_POST[$index])?$_POST['profile']:'vide') . ')'; + $res = false; + +} + +if ( !$res ) { + echo "\n\n\n\n\n\n

Oops, une erreur s'est produite

Il y a un problème avec les renseignements fournis
    \n"; + foreach ($errors as $k=>$v) { + echo "
  • $v
  • \n"; + } + echo '
'."
\n\n\n"; + exit(); +} + +// Prevent escapeshellarg to eat UTF-8 non ASCII chars +setlocale(LC_CTYPE, "fr_FR.UTF-8"); + +$basepath='/var/cache/build-openwrt-dev'; +$scriptfile='build-openwrt-dev.sh'; +$lockfile='/run/lock/build-openwrt-dev.lock'; + + +// Escape everything and build command-line +$ip4pub=escapeshellarg($_POST['ip4pub']); +$lanip4addr=escapeshellarg($_POST['ip4lan']); +$ip6prefix=escapeshellarg($_POST['ip6prefix']); +//$wanip6ll=escapeshellarg($_POST['ip6wanll']); +$root_passwd=escapeshellarg($_POST['pwd1']); +$wireless_ssid=escapeshellarg($_POST['ssid']); +$wireless_key=escapeshellarg($_POST['key1']); +$wireless_txpower=escapeshellarg($_POST['txpower']); +$wanip4addr=escapeshellarg($_POST['ip4wan']); + +# build-openwrt [ip4wan] +$command=escapeshellcmd($scriptfile); +$command .= " $profile $ip4pub $lanip4addr $ip6prefix $root_passwd $wireless_ssid $wireless_key $wireless_txpower $wanip4addr 2>&1"; + +// Prevent multiple parallel executions of the generation part +$fh=fopen($lockfile, 'w+'); +if ( ! is_resource($fh) ) { + echo "PROBLEM opening lock file\n"; + exit(); +} + +if ( ! flock($fh, LOCK_EX) ) { + echo "PROBLEM acquiring lock file\n"; + exit(); +} + +putenv("CACHE_DIR=$basepath/"); +putenv("BUILD_DIR=$basepath/build/"); +exec($command, $output, $return_val); + +// Dump script output in /tmp for troobleshooting +file_put_contents(tempnam('/tmp' , $scriptfile.'_'), array($command, "\n", print_r($output,true), "\n",$return_val,"\n")); + +if ( $return_val === 0 ) { + header('Content-Type: application/octet-stream'); + header("Content-Disposition: attachment; filename=$user_filename"); + readfile("$basepath/build/$gen_filename"); +} else { + echo "
\n$command\n\n";
+	echo join($output, "\n") . "\n\n";
+	echo "Command return value : "; var_dump($return_val);
+}
+
+fclose($fh);
+
diff --git a/maj/gen.php b/maj/gen.php
new file mode 100644
index 0000000..700150a
--- /dev/null
+++ b/maj/gen.php
@@ -0,0 +1,162 @@
+
+ * 
+ *  CHD OpenWRT is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ * 
+ *  CHD OpenWRT is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ * 
+ *  You should have received a copy of the GNU General Public License
+ *  along with CHD OpenWRT.  If not, see .
+**/
+
+function validate($regex, $index, $message, &$errors) {     
+	if (isset($_POST[$index]) && 1 === preg_match($regex, $_POST[$index])) {
+		return true;            
+	}
+	if (is_array($errors)) $errors[$index] = $message . ' (' . (isset($_POST[$index])?$_POST[$index]:'vide') . ')';
+	return false; 
+}
+
+function checksame($index1, $index2, $message, &$errors) {     
+	if (
+		isset($_POST[$index1])
+		&& isset($_POST[$index2])
+		&& ($_POST[$index1] === $_POST[$index2])
+	) {
+		return true;            
+	}
+	$errors[$index] = $message; 
+	return false;
+}
+$pattern_ipv4_optionnal='/(^|((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4})$/';
+$pattern_ipv4='/((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$/';
+$pattern_ipv6='/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\z/i';
+$pattern_pass6='/^[^\']{6,64}$/u';
+$pattern_pass8='/^[^\']{8,64}$/u';
+$pattern_ssid='/^[\w._-]{1,32}$/';
+$pattern_iden='/^[\w._-]*$/';
+$pattern_rev='/^\d[\d.]*$/';
+$pattern_int='/^-?\d+$/';
+
+$errors=array();
+$ignore=NULL;
+$res = validate($pattern_iden, 'profile', 'Profil matériel du routeur incorrect', $errors);
+$res &= validate($pattern_rev, 'revision', 'Révision matérielle du routeur incorrecte', $errors);
+$res &= validate($pattern_ipv4, 'ip4pub', 'Adresse IPv4 publique du routeur incorrecte', $errors);
+$res &= validate($pattern_ipv4_optionnal, 'ip4wan', 'Adresse IPv4 WAN du routeur incorrecte', $errors);
+$res &= validate($pattern_ipv4, 'ip4lan', 'Adresse IPv4 LAN du routeur incorrecte', $errors);
+$res &= validate($pattern_ipv6, 'ip6prefix', 'Préfixe IPv6 du routeur incorrect', $errors);
+//$res &= validate($pattern_ipv6, 'ip6wanll', 'Adresse IPv6 WAN Link Local incorrecte', $errors);
+$res &= validate($pattern_pass6, 'pwd1', 'Mot de passe du routeur incorrect', $errors);
+$res &= validate($pattern_pass6, 'pwd2', 'Mot de passe du routeur incorrect', $ignore);
+$res &= validate($pattern_ssid, 'ssid', 'Nom du réseau WiFi (SSID) incorrect', $errors);
+$res &= validate($pattern_pass8, 'key1', 'Mot de passe du WiFi incorrect', $errors);
+$res &= validate($pattern_pass8, 'key2', 'Mot de passe du WiFi incorrect', $ignore);
+$res &= validate($pattern_int, 'txpower', 'Puissance d\'émission WiFi incorrecte', $errors);
+$res &= checksame('pwd1', 'pwd2', 'Les mots de passes ne correspondent pas', $errors);
+$res &= checksame('key1', 'key2', 'Les mots de passes ne correspondent pas', $errors);
+
+switch ($_POST['profile']) {
+	case 'TLWR740':
+		switch($_POST['revision']) {
+			case '4':
+				$profile='TLWR740';
+				$revision='4';
+				$user_filename='mise-a-jour-routeur-TLWR740v4.bin';
+				$gen_filename='bin/ar71xx/openwrt-15.05-ar71xx-generic-tl-wr740n-v4-squashfs-factory.bin';
+				break;
+			default:
+				$errors['revision'] = 'Routeur non supporté (' . (isset($_POST['revision'])?$_POST[$index]:'vide') . ')';
+				$res = false;
+		}
+		break;
+	case 'TLWR841':
+		switch($_POST['revision']) {
+			case '9':
+				$profile='TLWR841';
+				$revision='9';
+				//$user_filename='wr841nv9_wr841ndv9_en_3_16_9_up(150310).bin';
+				$user_filename='mise-a-jour-routeur-TLWR841v9.bin';
+				$gen_filename='bin/ar71xx/openwrt-15.05-ar71xx-generic-tl-wr841n-v9-squashfs-factory.bin';
+				break;
+			default:
+				$errors['revision'] = 'Routeur non supporté (' . (isset($_POST['revision'])?$_POST[$index]:'vide') . ')';
+				$res = false;
+		}
+		break;
+	default:
+		$errors['profile'] = 'Routeur non supporté (' . (isset($_POST[$index])?$_POST['profile']:'vide') . ')';
+		$res = false;
+
+}
+
+if ( !$res ) {
+	echo "\n\n\n\n\n\n

Oops, une erreur s'est produite

Il y a un problème avec les renseignements fournis
    \n"; + foreach ($errors as $k=>$v) { + echo "
  • $v
  • \n"; + } + echo '
'."
\n\n\n"; + exit(); +} + +// Prevent escapeshellarg to eat UTF-8 non ASCII chars +setlocale(LC_CTYPE, "fr_FR.UTF-8"); + +$basepath='/var/cache/build-openwrt'; +$scriptfile='build-openwrt.sh'; +$lockfile='/run/lock/build-openwrt.lock'; + + +// Escape everything and build command-line +$ip4pub=escapeshellarg($_POST['ip4pub']); +$lanip4addr=escapeshellarg($_POST['ip4lan']); +$ip6prefix=escapeshellarg($_POST['ip6prefix']); +//$wanip6ll=escapeshellarg($_POST['ip6wanll']); +$root_passwd=escapeshellarg($_POST['pwd1']); +$wireless_ssid=escapeshellarg($_POST['ssid']); +$wireless_key=escapeshellarg($_POST['key1']); +$wireless_txpower=escapeshellarg($_POST['txpower']); +$wanip4addr=escapeshellarg($_POST['ip4wan']); + +# build-openwrt [ip4wan] +$command=escapeshellcmd($scriptfile); +$command .= " $profile $ip4pub $lanip4addr $ip6prefix $root_passwd $wireless_ssid $wireless_key $wireless_txpower $wanip4addr 2>&1"; + +// Prevent multiple parallel executions of the generation part +$fh=fopen($lockfile, 'w+'); +if ( ! is_resource($fh) ) { + echo "PROBLEM opening lock file\n"; + exit(); +} + +if ( ! flock($fh, LOCK_EX) ) { + echo "PROBLEM acquiring lock file\n"; + exit(); +} + +putenv("CACHE_DIR=$basepath/"); +putenv("BUILD_DIR=$basepath/build/"); +exec($command, $output, $return_val); + +// Dump script output in /tmp for troobleshooting +file_put_contents(tempnam('/tmp' , $scriptfile.'_'), array($command, "\n", print_r($output,true), "\n",$return_val,"\n")); + +if ( $return_val === 0 ) { + header('Content-Type: application/octet-stream'); + header("Content-Disposition: attachment; filename=$user_filename"); + readfile("$basepath/build/$gen_filename"); +} else { + echo "
\n$command\n\n";
+	echo join($output, "\n") . "\n\n";
+	echo "Command return value : "; var_dump($return_val);
+}
+
+fclose($fh);
+
diff --git a/maj/index.php b/maj/index.php
new file mode 100644
index 0000000..f9ed143
--- /dev/null
+++ b/maj/index.php
@@ -0,0 +1,139 @@
+
+ * 
+ *  CHD OpenWRT is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ * 
+ *  CHD OpenWRT is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ * 
+ *  You should have received a copy of the GNU General Public License
+ *  along with CHD OpenWRT.  If not, see .
+**/
+
+require_once('config.php');
+?>
+
+
+
+	
+	
+	Mise à jour du routeur
+	
+
+
+
+
+Erreur : L'adresse publique $ip4pub n'est pas reconnue\n";
+		exit();
+	}
+
+	$rest = file_get_contents($CONF_API_BASE_URL . "/gen_firm.php?ip4pub=".urlencode($ip4pub), false, NULL, 0, 256);
+	if ( $rest === FALSE ) {
+		echo "
Erreur : Pb webservice
\n"; + exit(); + } + + $result = json_decode($rest); + if ( !array_key_exists("initiales", $result) ) { + echo "
Erreur : Pb retour webservice
\n"; + exit(); + } + $ip4wan = $result->ip4wan; + $ip6prefix = $result->ip6prefix; + $constructeur = $result->constructeur; + $modele = $result->modele; + $profile = $result->profile; + $revision = $result->revision; + $adt_initiales = $result->initiales; + + $action=array_key_exists('dev', $_GET)?"gen-dev.php":"gen.php"; +?> +
+
+
+ Paramètres du réseau WiFi de maison + + + + + + + + + + + + + + + + + +
DésactivéMoyenFort
+
+
+
+ Administration du routeur + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
    +
  • Utilisez ce formulaire depuis votre propre connexion internet CHD ;
  • +
  • Réutilisez les anciens paramètres WiFi si vous souhaitez éviter de devoir retapper le mot de passe sur vos équipements WiFi ;
  • +
  • Changez le mot de passe d'administration (initialement : admin) ;
  • +
+
+
+
+ + diff --git a/maj/main.css b/maj/main.css new file mode 100644 index 0000000..8d23e8f --- /dev/null +++ b/maj/main.css @@ -0,0 +1,99 @@ +/** + * Copyright 2016 Ludovic Pouzenc + * + * CHD OpenWRT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD OpenWRT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD OpenWRT. If not, see . +**/ + +body { + font-family: Verdana,Arial,Helvetica,sans-serif; + font-size: 14px; + line-height: 1.5; +} + +fieldset { + border: 2px solid #E0D8B7; + background: none repeat scroll 0% 0% #fcfaf0; + color: #000; + margin: 1em 0px; + padding: 10px; +} + +.fieldset { + padding: 0 10px; +} + +legend { + padding: 1px 8px; + border: 2px solid #E0D8B7; + border-radius: 6px / 12px; + box-shadow: none; + background: none repeat scroll 0% 0% #FFF; + font-size: 14px; + color: #5E5223; +} + +fieldset label { + font-size: 12px; +} + +fieldset label, .label { + float: left; + clear: left; + padding-right: 0.5em; + width: 14.5em; + text-align: right; + font-size: 100%; + color: #333; +} + +form span { + display: block; + margin: 0px 0px 0px 15em; + padding: 0px 0px 4px 4px; +} + +input:required:invalid, input:focus:invalid, textarea:required:invalid, textarea:focus:invalid { + background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAT1JREFUeNpi/P//PwMpgImBRMACY/x7/uDX39sXt/67cMoDyOVgMjBjYFbV/8kkqcCBrIER5KS/967s+rmkXxzI5wJiRSBm/v8P7NTfHHFFl5mVdIzhGv4+u///x+xmuAlcdXPB9KeqeLgYd3bDU2ZpRRmwH4DOeAI07QXIRKipYPD35184/nn17CO4p/+cOfjl76+/X4GYAYThGn7/g+Mfh/ZZwjUA/aABpJVhpv6+dQUjZP78Z0YEK7OezS2gwltg64GmfTu6i+HL+mUMP34wgvGvL78ZOEysf8M1sGgZvQIqfA1SDAL8iUUMPIFRQLf+AmMQ4DQ0vYYSrL9vXDz2sq9LFsiX4dLRA0t8OX0SHKzi5bXf2HUMBVA0gN356N7p7xdOS3w5fAgcfNxWtn+BJi9gVVBOQfYPQIABABvRq3BwGT3OAAAAAElFTkSuQmCC'); + background-position: right top; + background-repeat: no-repeat; + box-shadow: none; +} + +fieldset input, fieldset textarea, fieldset select { + padding: 2px 4px; + border: 1px solid #ccc; + border-radius: 2px; + background: none repeat scroll 0% 0% #fff; + line-height: 1.1; + font-family: inherit; + font-size: 1.1em; + margin: 0; +} + +input[type="submit"], input[type="reset"], input[type="button"] { + padding: 2px 6px; + border: 1px solid #b5bbc4; + background: linear-gradient(to bottom, #fff, #dae6f1) repeat scroll 0% 0% #f7fafc; + font-size: 100%; + color: #333; +} + +img { + border: 2em #ccc solid; + margin:1em 0 1em 3em; +} + +span.tt { + font-family:'Lucida Console', monospace; +} diff --git a/maj/main.js b/maj/main.js new file mode 100644 index 0000000..a880b92 --- /dev/null +++ b/maj/main.js @@ -0,0 +1,200 @@ +/** + * Copyright 2016 Ludovic Pouzenc + * + * CHD OpenWRT is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * CHD OpenWRT is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CHD OpenWRT. If not, see . +**/ + +/* +document.onreadystatechange = function () { + console.log("document.onreadystatechange"); +}; + +document.onunload = function () { + console.log("document.onunload"); + for(var i=0; i<1000000000; i++) {} +};*/ + +document.addEventListener("DOMContentLoaded", function() { + console.log("DOMContentLoaded"); + + // HTML5 form validation + var supports_input_validity = function() { var i = document.createElement("input"); return "setCustomValidity" in i; } + + if(supports_input_validity()) { + var pwd1Input = document.getElementById("field_pwd1"); + var pwd2Input = document.getElementById("field_pwd2"); + var key1Input = document.getElementById("field_key1"); + var key2Input = document.getElementById("field_key2"); + + pwd2Input.addEventListener("keyup", function() { + this.setCustomValidity( + (this.value!=pwd1Input.value)?pwd2Input.title:"" + )}, false); + + key2Input.addEventListener("keyup", function() { + this.setCustomValidity( + (this.value!=key1Input.value)?key2Input.title:"" + )}, false); + } + + /* Range slider value update + var txpower = document.getElementById("field_txpower"); + var txpowerText = document.getElementById("field_txpower_text"); + txpower.addEventListener("change", function(e) { + txpowerText.value=txpower.value + " dB"; + }, true); + */ + var btn_gen = document.getElementById("btn_gen"); + btn_gen.value="Générer le fichier de mise à jour"; + + // Additionnal form validation (on submit) + var checkForm = function(e) { + + if (this.pwd1.value != this.pwd2.value) { + this.pwd1.focus(); + e.preventDefault(); + return; + } + if (this.key1.value != this.key2.value) { + this.key1.focus(); + e.preventDefault(); + return; + } + // Safari needs this one too + if (!e.target.checkValidity()) { + e.preventDefault(); + return; + } + // Form will pass, disable the form button to prevent multiple clicks + var btn_gen = document.getElementById("btn_gen"); + btn_gen.value="Patientez puis sauvez le fichier"; + btn_gen.disabled=true; + btn_gen.style.color="gray"; + }; + var form_main = document.getElementById("form_main"); + form_main.addEventListener("submit", checkForm, true); + + // Guess of current LAN gateway + var field_ip4lan = document.getElementById("field_ip4lan"); + getIPs(function(ip){ + console.log(ip); + var res = ip.match(/^192\.168\.\d+/); + if ( res ) { + // Dumb guess of gateway IP + field_ip4lan.value = res + ".1"; + } + }); + +}, false); + + +window.addEventListener('unload', function(event) { + console.log('unload'); + + // Revert submit button to inital state if history.go(-1) was used + var btn_gen = document.getElementById("btn_gen"); + btn_gen.value="Générer le fichier de mise à jour"; + btn_gen.disabled=false; + btn_gen.style.color="black"; + +}); + + +// LAN IPs detection +function getIPs(callback){ + var ip_dups = {}; + + //compatibility for firefox and chrome + var RTCPeerConnection = window.RTCPeerConnection + || window.mozRTCPeerConnection + || window.webkitRTCPeerConnection; + var useWebKit = !!window.webkitRTCPeerConnection; + + if(!RTCPeerConnection){ + return; // The following code pops JS errors on Safari + } + + //bypass naive webrtc blocking using an iframe + if(!RTCPeerConnection){ + //NOTE: you need to have an iframe in the page right above the script tag + // + // + //