So today I came to this odd question. Lately I have been having many problems with my wireless connection and I wanted a fast way of enabling/disabling wireless and also block my MAC address and see how many devices are connected to my network etc.
So i thought that I might be able to make a kind of API of my router and just build my own app to access to it (I've already done this emulating the HTTP communication between client and router server). But It seems so unpractical that I've to be from server side reading the HTML responses from the internal server in the router.
Then I just thought that there should be a way to access directly to router info, just like the internal server does and even change the website inside.
I guess it depends on the router but just want to ask for ideas/suggestions on what is the best way to do this and if theres any protocol or a better way that I might be missing.
I know its a tricky question and maybe it shouldn't be in stackoverflow but I thought that any of you would have the knwoledge.
public String login() {
String routerUri = "http://192.168.1.1/login-login.cgi";
RestTemplate restTemplateLogin = new RestTemplate();
HttpHeaders headersLogin = new HttpHeaders();
headersLogin.add("Cookie", "_TESTCOOKIESUPPORT=1");
headersLogin.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("sessionKey", "blablvablalbalbla");
map.add("pass", "");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map,
headersLogin);
ResponseEntity<String> response = restTemplateLogin.postForEntity(routerUri, request, String.class);
String loginCookie = response.getHeaders().getFirst("Set-Cookie").split(";")[0].split("=")[1];
return loginCookie;
}
as you can see, by now I am accessing to this CGI asking the router for them directly, I'd be nice to see what's inside.
Router: Mitrastar gpt-2541GNAC
Thank you very much for your help!