Restrict access to web server when using modem PPP conection

Ismael
Posts: 20
Joined: Thu Mar 05, 2020 7:35 am

Restrict access to web server when using modem PPP conection

Postby Ismael » Tue Dec 01, 2020 10:07 am

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.

Ismael
Posts: 20
Joined: Thu Mar 05, 2020 7:35 am

Re: Restrict access to web server when using modem PPP conection

Postby Ismael » Mon Feb 22, 2021 7:54 am

Any idea about if this is possible?
Thanks

Ismael
Posts: 20
Joined: Thu Mar 05, 2020 7:35 am

Re: Restrict access to web server when using modem PPP conection

Postby Ismael » Thu Mar 11, 2021 11:27 am

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:

Code: Select all

int socket_desc = httpd_req_to_sockfd(req);
Then, I tried to get interface name with lwip_getsockopt option but always return a 106 errno code (ETOOMANYREFS):

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);
	}
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

Who is online

Users browsing this forum: No registered users and 111 guests