Hello,
I've developing a device that could connect to a server using Wifi, Ethernet or Modem( in PPP mode).
Inside the device there is a simple HTTP (HTTPS in the future) that could be accessible from all three interphases. Due to I'm using >4.X version, netif abstraction make this very easy to implement but in some cases I want to restrict access over one interphase (in 95% of cases it will be over modem to reduce cost of internet data rates).
Is it possible? How can i do it?
Could I bind HTTP server socket only in Wifi and Ethernet?
Thanks.
Restrict access to web server when using modem PPP conection
Re: Restrict access to web server when using modem PPP conection
Any idea about if this is possible?
Thanks
Thanks
Re: Restrict access to web server when using modem PPP conection
Due to from netif layer this issue seems that has no answer, I have been trying to solve it internally from the Web server handlers.
To get socket information I'm using this code:
Then, I tried to get interface name with lwip_getsockopt option but always return a 106 errno code (ETOOMANYREFS):
Is this function available from the LWIP stack?
Because this didn't work, I tried to get where socket is binded with option lwip_getsockname but always return rare data.
Do someone have any other idea?
Thanks
To get socket information I'm using this code:
Code: Select all
int socket_desc = httpd_req_to_sockfd(req);
Code: Select all
struct ifreq ifr;
socklen_t ifr_len = sizeof(struct ifreq);
ret = lwip_getsockopt(socket_desc, SOL_SOCKET, SO_BINDTODEVICE, (void*)&ifr, &ifr_len);
if (ret < 0) {
ESP_LOGE(TAG, "Unable to bind socket to specified interface: errno %d", errno);
return ESP_OK;
}else{
ESP_LOGW(TAG, "Interface name: %s", ifr.ifr_name);
}
Because this didn't work, I tried to get where socket is binded with option lwip_getsockname but always return rare data.
Do someone have any other idea?
Thanks
Who is online
Users browsing this forum: No registered users and 240 guests