YunClient ip address

Hello :-)

I need a way to find out the ip address of a client sending a AJAX request to my Yun sketch. I've read the doc but I didn't find anything that can help me.

I want the allow or deny a Yun Client to execute a command in the sketch depending its ip address. If it's not possible, is there a way to configure the OpenWRT web server to allow or deny access to a page or directory depending the client ip address ?

Thanks for your help :-)

Bert

void process(YunClient client) {

  // On lit la commande
  String command = client.readStringUntil('/');

bgauvreau: ::::SNIP:::: If it's not possible, is there a way to configure the OpenWRT web server to allow or deny access to a page or directory depending the client ip address ?

@bgauvreau, typically on Apache-style webservers access control can be done with .htaccess. The webserver on Yun is the same as the one with OpenWrt. It is called uhttpd. Basic authentication is available via name and password.

Basic Authentication (httpd.conf) http://wiki.openwrt.org/doc/uci/uhttpd#basic_authentication_httpdconf

If this does not serve your purpose, you can write a CGI to check your clients' IP. You can use Perl, Python, and Lua is the default for OpenWRT (and Yun). There are also various libraries available (such as IPsec - which allows and denies access on a per IP basis). And, of course, you can put your private data on a different port via uhttpd.

Given further thought you can also use: SEE ALSO: firewall http://wiki.openwrt.org/doc/uci/firewall netfilter http://wiki.openwrt.org/doc/howto/netfilter

NOTE: if the library list is useful, I would appreciate any feedback - especially any need improvements.

Jesse

Hi Jesse, Thank you for your help ! Amont the links, the one for uhttpd is the more revelent. I Will do a port redirection depending the ip address of the client.

Havé a Nice day :)