Skip to content

Commit

Permalink
Version 0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
GeiserX committed Jul 4, 2019
0 parents commit 80598ae
Show file tree
Hide file tree
Showing 21 changed files with 10,444 additions and 0 deletions.
Empty file added .Rhistory
Empty file.
3 changes: 3 additions & 0 deletions AutoRun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/Rscript
Rscript -e 'shiny::runApp(appDir = "/home/tecnico/WebApp", launch.browser = FALSE, port = 8081, host = "127.0.0.1")'

Empty file added FAQ/.Rhistory
Empty file.
Binary file added FAQ/FAQ-1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions FAQ/FAQ.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: 'FAQ: Frequently Asked Questions'
author: "Sergio Fernández Rubio @ Electrónica Martínez"
date: "2/6/2015"
output: html_document
---

## Para qué sirve la aplicación web

La aplicación web sirve para sincronizar las bases de datos del **XGEST** contra las bases de datos **RADIUS Manager PPPoE** y **RADIUS Manager HotSpot**. Adicionalmente, podemos incluir la MAC del router para su autoconfiguración automática vía **DHCP66**.

![](FAQ-1-1.png)

## Uso de la aplicación web sincronizadora

En este apartado explicaremos el uso y la funcionalidad de esta aplicación web

#### Cómo usar la aplicación

1) Introducimos el **código de cliente**. Lo que hará la aplicación será **extraer información sobre el código de cliente escrito en la base de datos del XGEST**, así que es importante que sea correcto, puesto que si no, revertir el proceso es algo tedioso. Si el usuario no existe en el XGEST, la aplicación hará un _crash_ parcial, pudiendo recargar la WebApp directamente desde el navegador sin ninguna complicación.

2) Introducimos el **número de conexión**. Por lo general, se escogerá _Sin extensión_ para nuevos clientes. Si se escoge una conexión superior _(-2, -3, -4...)_, se creará una conexión adicional con un usuario PPPoE diferente, siempre con la misma contraseña.
Adicionalmente, se creará un usuario nuevo al RADIUS HotSpot si se escoge _Sin extensión_. Si elegimos alguna conexión diferente a la de _Sin extensión_, se añadirá ese número elegido como conexiones simultáneas vía HotSpot, es decir, que un cliente podrá usar **X conexiones simultáneas** conectándose a los WiFi Hotspot proporcionados por esta empresa con diferentes dispositivos. La velocidad será de **3 MB** en **cada** conexión. La contraseña será el número de móvil, o el fijo en su defecto.

3) Seleccionamos **la velocidad contratada** para la conexión por cable.

4) Si decidimos añadir una **MAC**, se creará el archivo de configuración asociado, en la que el router se configurará automáticamente. Los archivos se envían al servidor _X.X.X.X_.

5) El campo de Notas se añadirá únicamente al campo de notas de RADIUS Manager. La contraseña en texto plano se añade automáticamente, no hace falta incluirla.

6) Por último, seleccionamos **Sincronizar todo** para que todo se ejecute y se sincronice. El botón que vemos de _Descarga_ es por si, tras conectar el router, el Router no se autoconfigurara, por lo que le introduciremos el archivo manualmente. Importante: Este botón de Descarga **sólo** funciona tras haberle dado a **Sincronizar todo**.

## ¿Y si ya existe el cliente/MAC en...

* **Radius Manager**: No se creará, lo único que hará será extraer los datos para la contraseña PPPoE. Sí que se creará si elegimos una conexión que no exista

* **Radius HotSpot**: No se creará, no importa si tiene un número diferente de conexión. Simplemente actualizará el "Simultaneous-Use" para ponerle el número de conexiones igual al número de conexión que tenga

* **TFTP Server**: Aunque exista el archivo MAC en la base de datos, sobreescribirá siempre el archivo de configuración.

_Nota_: Se puede usar este servicio como creador de archivos de configuración MAC aunque el cliente ya exista en las demás bases de datos

## Instalación/Update de los programas/servicios

Para nueva instalación,

1) Instalar R: Como depende mucho del sistema y está en constante evolución, lo mejor es buscar en [google](http://lmgtfy.com/?q=R+ubuntu+install).

2) Instalar RStudio versión SERVER: La página oficial [aquí](http://www.rstudio.com/products/RStudio/#Server).

3) Instalar los paquetes necesarios para la WebApp: Dentro de RStudio (se inicia en el puerto 8787 por defecto) escribir:

> install.packages(c("shiny", "RMySQL", "digest", "stringr"))
Para hacer un update de los paquetes que se utilizan se utiliza, en consola, la siguiente instrucción:

> update.packages()
Para iniciar en el crontab en cada reboot, la instrucción es la siguiente:

> @reboot R -e 'shiny::runApp(appDir = "/home/tecnico/WebApp", launch.browser = FALSE, port = 8080, host = "0.0.0.0")'
## Troubleshooting

La mayor fuente de información se dará en los logs He incluido cada paso que da la aplicación junto a la hora. Si se congela la aplicación, lo más fácil será reiniciar el servidor, puesto que la WebApp se inicia automáticamente al iniciar el servidor.

Los logs se encuentran en _"/var/log/shiny-server.log"_ pero no comprenden la totalidad de la WebApp. Para ver todos los logs en modo muy verboso, comentar las líneas escritas en crontab, reiniciar el servidor, y iniciar manualmente desde dentro de RStudio con la sentencia. El log se borra cada vez que se pulsa al botón de _Sincronizar todo_.

> shiny::runApp(appDir = "/home/tecnico/WebApp", launch.browser = FALSE, port = 8080, host = "0.0.0.0")
Si el servidor es incapaz de llegar a los servidores del XGEST o ambos RADIUS la aplicación se detendrá por donde haya ocurrido el error. Primeramente llama al RADIUS Manager para obtener la lista de servicios disponibles. Luego llama al XGEST para obtener la información acerca del usuario. Luego llama de nuevo al RADIUS Manager para actualizarlo/extraer información. Luego al RADIUS HotSpot, y por último al servidor TFTP.

Sólo se permite tener un servidor Shiny activo. Por tanto si escribimos la sentencia que hemos escrito más arriba, dará un error.

Si el error se encuentra en la parte de la creación del archivo de configuración, puede ser por un fallo al comunicarse con el _X.X.X.X_, o también puede ser por error de la aplicación, al no reconocer el archivo recién creado. Esto último se soluciona reiniciando el servidor.
292 changes: 292 additions & 0 deletions FAQ/FAQ.html

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (c) Twitter Inc

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 18 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Router Express

Auto-configuration services development for Ethernet, ADSL and Voice client routers, using DHCP66 and TR069 standards

Development of TR069 and DHCP66 autoconfiguration services for all the entire network of an ISP properly anonymized. Creation of a WebApp based on R with scripts on Python that gives complete Internet access for a new client. It signs in a new client in the Ticket's database and in two Radius servers, picking up all the data from the principal Management software that the company uses.

[Project presented as a Final Project at University in 2015]http://repositorio.upct.es/xmlui/handle/10317/5245

All the project documentation is in Spanish due to the inability of some team members to read it in English.

## Author

* **Sergio Fernández** - *Creator* - [DrumSergio](https://github.com/DrumSergio)

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

111 changes: 111 additions & 0 deletions Scripts-Varios.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#########################################################################
### Cambiar parámetro en todos los Tenda vía archivo de configuración ###
#########################################################################

setwd("/media/tftpSRV/")
dirs <- dir(pattern = ".cfg$")

for(i in 42:length(dirs)){
archivo <<- scan(dirs[i], what = character(), skip = 0, sep = "\n")
id <- pmatch('rm_web_ip=', archivo)
archivo[id] <- "rm_web_ip=X.X.X.X"
write(archivo, paste0("/home/tecnico/WebApp/archivos-samba/", dirs[i]))
system(sprintf("smbclient -U dhcp66 //Y.Y.Y.Y/tftpSRV t1l2cm3r -c \"put %s %s\"", paste0("/home/tecnico/WebApp/archivos-samba/", dirs[i]), dirs[i]))
}

#################################
### Cambiar parámetro vía WEB ### (código python)
#################################

# import csv, os, signal
#
# def signal_handler(signum, frame):
# raise Exception("Timed out!")
#
# signal.signal(signal.SIGALRM, signal_handler)
# signal.alarm(12) #segundos
#
# c = csv.reader(open("/home/tecnico/Descargas/a.csv"))
# clist = list(c)
# for i in range(106,len(clist)):
# print i
# print clist[i][1]
# try:
# os.system('python /home/tecnico/Escritorio/tendaWEB.py ' + clist[i][1])
# except Exception, msg:
# print "Timed out!"


# # -*- coding: utf-8 -*-
# from selenium import webdriver
# from selenium.webdriver.common.by import By
# from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.support.ui import Select
# from selenium.common.exceptions import NoSuchElementException
# from selenium.common.exceptions import NoAlertPresentException
# import unittest, time, re
# import sys
#
# class TendaWEB(unittest.TestCase):
# def setUp(self):
# self.driver = webdriver.Firefox()
# self.driver.implicitly_wait(30)
# self.base_url = "http://%s:8080" % (self.IP)
# self.verificationErrors = []
# self.accept_next_alert = True
#
# def test_tenda_w_e_b(self):
# driver = self.driver
# driver.get(self.base_url + "/login.asp")
# driver.find_element_by_name("Password").clear()
# driver.find_element_by_name("Password").send_keys("PASSWORD")
# driver.find_element_by_link_text("OK").click()
# time.sleep(2)
# driver.find_element_by_link_text("Advanced").click()
# time.sleep(2)
# driver.find_element_by_css_selector("span.nav-text").click()
# time.sleep(2)
# driver.find_element_by_link_text("Remote Web Management").click()
# driver.switch_to_frame(driver.find_element_by_tag_name("iframe")) #iframe
# driver.find_element_by_id("RMsIP1").clear()
# driver.find_element_by_id("RMsIP1").send_keys("X.X.X.X")
# driver.find_element_by_css_selector("input.btn").click()
# driver.switch_to_default_content()
# driver.find_element_by_css_selector("#advance > span.nav-text").click()
# time.sleep(2)
# driver.find_element_by_link_text("DNS Settings").click()
# driver.switch_to_frame(driver.find_element_by_tag_name("iframe")) #iframe
# if driver.find_element_by_name("DNSEN").is_selected():
# driver.find_element_by_name("DNSEN").click()
# driver.find_element_by_css_selector("input.btn").click()
#
# def is_element_present(self, how, what):
# try: self.driver.find_element(by=how, value=what)
# except NoSuchElementException, e: return False
# return True
#
# def is_alert_present(self):
# try: self.driver.switch_to_alert()
# except NoAlertPresentException, e: return False
# return True
#
# def close_alert_and_get_its_text(self):
# try:
# alert = self.driver.switch_to_alert()
# alert_text = alert.text
# if self.accept_next_alert:
# alert.accept()
# else:
# alert.dismiss()
# return alert_text
# finally: self.accept_next_alert = True
#
# def tearDown(self):
# self.driver.quit()
# self.assertEqual([], self.verificationErrors)
#
# if __name__ == "__main__":
# if len(sys.argv) > 1:
# TendaWEB.IP = sys.argv.pop()
# unittest.main()

Loading

0 comments on commit 80598ae

Please sign in to comment.