Last active
February 22, 2021 19:35
-
-
Save guilhermewebdev/030fdd76d77639be00c17e831cc1244b to your computer and use it in GitHub Desktop.
Encontra um ip com a conexão
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
const initialIP = 0 | |
const endIP = 255 | |
const testConnection = async () => { | |
try { | |
const response = await api.get("/api/connection ", { | |
headers: { | |
"X-Api-Key": "<api-key>", | |
"Content-Type": "application/json", | |
}, | |
}); | |
return response.status; | |
} catch(reason){ | |
return reason.response.status; | |
} | |
}; | |
const findIP = async () => { | |
for(let currentIP; currentIP <= endIP; currentIP++){ | |
const host = `10.100.0.${atual}`; | |
const response = await testConnection(host); | |
if(response == 200){ | |
return host; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment