Skip to content

Instantly share code, notes, and snippets.

@guilhermewebdev
Last active February 22, 2021 19:35
Show Gist options
  • Save guilhermewebdev/030fdd76d77639be00c17e831cc1244b to your computer and use it in GitHub Desktop.
Save guilhermewebdev/030fdd76d77639be00c17e831cc1244b to your computer and use it in GitHub Desktop.
Encontra um ip com a conexão
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