Created
October 30, 2021 15:32
-
-
Save p4ulodi4s/72a5cdf94ae5c6d7a25556c62280a5e0 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
| #!/usr/bin/env node | |
| let https = require( "https" ); | |
| const token = "aqui coloca o token da api"; | |
| const options = { | |
| headers: { | |
| "X-Token": token | |
| } | |
| }; | |
| function pppoeLoginByMac( args, callback ) { | |
| const api = "https://url.da.api"; | |
| const query = api + args[0]; | |
| https.get( query, options, function(response) { | |
| let data = '' | |
| response.on('data', function( newData ){ | |
| data += newData | |
| }); | |
| response.on('end', function(){ | |
| const parsedData = JSON.parse(data); | |
| let auth = {}; | |
| if( parsedData.resultados && parsedData.resultados.length > 0 ) { | |
| auth = { | |
| username: parsedData.resultados[0].login, | |
| password: parsedData.resultados[0].senha | |
| }; | |
| } | |
| callback( null, auth ); | |
| }); | |
| }); | |
| } | |
| exports.pppoeLoginByMac = pppoeLoginByMac; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment