Created
October 30, 2021 01:33
-
-
Save p4ulodi4s/bdfd94df19a5401ebeb9493c8b407412 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Realiza a configuração inicial para dispositivos da TP-Link. | |
| Se o dispositivo estiver com a tag NOT_PROVISION o script não será executado. | |
| Se o usuário do PPPOE estiver correto, o script não será executado. | |
| */ | |
| const now = Date.now(); | |
| const notProvision = declare("Tags.NOT_PROVISION", {value: 1}); | |
| if (notProvision.value !== undefined) { | |
| return; | |
| } | |
| const mac = declare( "InternetGatewayDevice.LANDevice.1.LANEthernetInterfaceConfig.1.MACAddress", {value: 1}).value[0]; | |
| let auth = ext( "sistema", 'pppoeLoginByMac', mac ); | |
| if( !auth || !auth.username || !auth.password ) { | |
| const hotspotMessage = "Identificado um reset do dispositivo " + | |
| mac + ". Os dados de login não foram encontrados no sistema"; | |
| ext( "message", "sendEmail", "colocar email aqui", "TR069 - ERRO", hotspotMessage ); | |
| return; | |
| } | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.*", {path: now}); //refresh | |
| const username = declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username", {value: 1} ); | |
| if( username && username.value && username.value.length > 1 && auth.username == username.value[0] ) { | |
| return; | |
| } | |
| // configura o PPPOE com o usuario encontrado | |
| createPPPOEConnection( auth ); | |
| const ProvisionMessage = "Identificado um reset do dispositivo " + | |
| mac + ". " + "O sistema configurou o PPPOE com o usuario " + auth.username; | |
| ext( "message", "sendEmail", "colocar email aqui", "TR069 - EQUIPAMENTO PROVISIONADO", ProvisionMessage ); | |
| function createPPPOEConnection( auth ) { | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.*.Enable", {path: now, value: now}, {value: false}); | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*", null, {path: 1}); | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.*", {path: now}); //refresh | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.ConnectionType", {value: now}, {value: "IP_Routed"}); | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Enable", {value: now}, {value: true}); | |
| declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username", {value: now}, {value: auth.username}); | |
| declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Password", {value: now}, {value: auth.password}); | |
| declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPAuthenticationProtocol", {value: now}, {value: "AUTO_AUTH"}); | |
| } | |
| /* | |
| function createCWMP() { | |
| declare("InternetGatewayDevice.ManagementServer.URL", {value: now}, {value: "http://ip do servidor:7547"}); | |
| declare("InternetGatewayDevice.ManagementServer.EnableCWMP", {value: now}, {value: true}); | |
| declare("InternetGatewayDevice.ManagementServer.PeriodicInformEnable", {value: now}, {value: true}); | |
| declare("InternetGatewayDevice.ManagementServer.PeriodicInformInterval", {value: now}, {value: 5}); | |
| } | |
| */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment