How to use HTTP_X_FORWARDED_FOR properly?

You can use this function to get proper client IP: public function getClientIP(){ if (array_key_exists(‘HTTP_X_FORWARDED_FOR’, $_SERVER)){ return $_SERVER[“HTTP_X_FORWARDED_FOR”]; }else if (array_key_exists(‘REMOTE_ADDR’, $_SERVER)) { return $_SERVER[“REMOTE_ADDR”]; }else if (array_key_exists(‘HTTP_CLIENT_IP’, $_SERVER)) { return $_SERVER[“HTTP_CLIENT_IP”]; } return ”; }

socket.error:[errno 99] cannot assign requested address and namespace in python

Stripping things down to basics this is what you would want to test with: import socket server = socket.socket() server.bind((“10.0.0.1”, 6677)) server.listen(4) client_socket, client_address = server.accept() print(client_address, “has connected”) while True: recvieved_data = client_socket.recv(1024) print(recvieved_data) This works assuming a few things: Your local IP address (on the server) is 10.0.0.1 (This video shows you how) … Read more

Get All IP Addresses on Machine

The DNS variants work across the network, but one DNS entry can have many IP addresses and one IP address can have many DNS entries. More importantly, an address needn’t be bound to a DNS entry at all. For the local machine try this:- foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces()) { Console.WriteLine(“Name: ” + netInterface.Name); Console.WriteLine(“Description: … Read more

How to check if an IP address is from a particular network/netmask in Java?

Option 1: Use spring-security-web‘s IpAddressMatcher. Unlike Apache Commons Net, it supports both ipv4 and ipv6. import org.springframework.security.web.util.matcher.IpAddressMatcher; … private void checkIpMatch() { matches(“192.168.2.1”, “192.168.2.1”); // true matches(“192.168.2.1”, “192.168.2.0/32”); // false matches(“192.168.2.5”, “192.168.2.0/24”); // true matches(“92.168.2.1”, “fe80:0:0:0:0:0:c0a8:1/120”); // false matches(“fe80:0:0:0:0:0:c0a8:11”, “fe80:0:0:0:0:0:c0a8:1/120”); // true matches(“fe80:0:0:0:0:0:c0a8:11”, “fe80:0:0:0:0:0:c0a8:1/128”); // false matches(“fe80:0:0:0:0:0:c0a8:11”, “192.168.2.0/32”); // false } private boolean matches(String ip, … Read more

UrlFetchApp request fails in Menu Functions but not in Custom Functions (connecting to external REST API)

When UrlFetchApp is used by the custom function and the script editor, I think that the difference is whether IPv6 is used, while the address of IPv4 is changed every run. In this case, the results of the script editor and custom menu are the same. I thought that this might be the reason of … Read more