netty localhost - client-server

In netty, what is the best way to find the connected client is in localhost?
Note: e.getChannel().getRemoteAddress() gives ip address like 127.0.0.1:5555
but i can not be sure that localhost is set to that ip address.
Thanks.

Note that this isn't a Netty question.
If you want to determine that the remote address is really remote (i.e. from another host) you can try to look up the NetworkInterface using the IP address, and if you get null, it is really remote.
NetworkInterface ni = NetworkInterface.getByInetAddress(e.getChannel().getRemoteAddress().getAddress());
if (ni == null)
// remote client

Related

How to identify proxy protocol from IP and Port?

Say I have a list of proxies - I pull out of one of these proxies. It's nothing but ip and port. From a programming level, you need to know the protocol to use such as socks5, socks5h, http, https... etc etc. Is there a way to retrieve what kind of protocol a proxy uses from the information given?
If you are using Node.js you can try check-proxy library, though it does much more than just checking protocol.
Your proxy server identify the port number for example 6080,9180,etc so you can easily identify the proxy server.
Your id address also private or public you can use 'proxy server ip address' that automatically create a virtual proxy network.
Example: Your private ip address is 172.16.10.158 you can use proxy server, your ip address will be 136.56.89.210. You can use public ip ex 125.124.85.69 change in to 179.68.36.49.

How to get the IP address of a connected WebSocket-client?

I'm currently working on a ABAP Push Channel server to WebSocket client connection and I need the IP-address of the client in order to identify whether this client is the one I want to send the message to. In my scenario there could be multiple WebSocket connections.
Now there is the ssi_websocket_table table and the ssi_websocket_table_row row with the the field caller_ip, however this gives me the IP address of the DNS-Server of the network I'm connected to, and I expected the IP address of my local PC since the WebSocket-client is running on this machine.
Is there any other way to get the clients IP address from an active WebSocket connection in ABAP?
P.S. Looking at all the table entries, it shows the correct IP when using a different server configuration, as soon as I know why that's the case I will report back.
As pointed out by vwegert it makes no sense to use the IP to tell the WebSockets apart, I think it would probably be better to use an ID for each WebSocket connection instead.
You could get the IP from the WebSocket server context which gets the IP header apparently from the opening HTTP handshake for the connection:
DATA(lo_context) = i_context. " IF_APC_WSP_SERVER_CONTEXT type
DATA(lo_request) = lo_context->get_initial_request( ).
" initialize G_CONTEXT_ID_FIELD for PCP_SET_CONTEXT_FIELDS
DATA(lv_id) = lo_request->get_header_field( if_http_header_fields_sap=>remote_addr ).
the sample is taken from the SAP standard class CL_APC_WS_EXT_ABAP_ONLINE_COMM, ON_MESSAGE method.

Node.js EADDRNOTAVAIL can't access via external IP

app = require('http').createServer()
app.listen(5000, '75.113.126.31')
Error: listen EADDRNOTAVAIL
People say this error means I'm trying to listen on an IP address that I don't own. But that is my external IP address according to google.
Also, if I omit my IP, it only works when I visit localhost:5000 and 127.0.0.1:5000, visiting 75.113.126.31:5000 doesn't work, even though people say node should listen there too when I don't give a 2nd argument to listen. I also tried listening on IP 0.0.0.0 with no luck accessing it through external IP.
What are the possible causes? I disabled Windows firewall but that didn't help.
Your external IP and your computer's network address often have almost nothing in common. In fact it would be very unusual if they did match.
Normally you bind to 0.0.0.0 if you want your service to be available remotely.
It's also worth noting that if you have some kind of router or firewall you'll need to configure port mapping to get port 5000 to route to your local IP correctly.
ipconfig should show you your actual IP address.
You should also be aware that some routers don't handle mapping internal traffic back to a local IP. Many do, so it's not always a problem, but if it doesn't work that might be the case.
The error message you are getting is correct. I'm going to assume you are on a computer behind a router. That ip address Google is reporting is the ip address assigned to your router not your computer, i.e your computer doesn't own it. You can prove this by running the command ipconfig in a cmd prompt, finding out your eth/wifi ip address, and using that in your app.listen (it'll probably start with 192 or 10), it should work. If you want to make your app public an easier way might be to just forward the port 5000 from your router the computer running the node app. Hope this helps!

How to get Actual IPAddr from DDNS hostname

I am using Dyndns service for my PC. This allows me to get my PC's current Wan IPAddr from my ISP.
say I can use below WinForm app code to get the IPAddr by passing in this hostname example : Marina.dyndns.biz
public static void DoGetHostEntry(string hostname)
{
IPHostEntry host;
host = Dns.GetHostEntry(hostname);
Console.WriteLine("GetHostEntry({0}) returns:", hostname);
foreach (IPAddress ip in host.AddressList)
{
Console.WriteLine(" {0}", ip);
}
}
My PC link to a router which uses local ISP service.
Q1. Is this returned Wan IPaddr refered to my Router's External IPAddr ?
Q2. What if I have fixed an IPAddr for the PC say 192.168.1.90? then what is the returned IPAddr refered to?
Q3. How do I do in Windows Phone 7.1 Mango version to get my PC's IPAddr with above code?
Thanks
A while back I used a similar service however it installed itself as a service and used to monitor the network for changes. The way it should work is by making calls to its server and checking the ip request is coming from.
The router itself has the WAN and internally uses LAN IPs to then do a NAT for comms over WAN.
The WAP IP is the external router IP that is given out by the ISP
When you do a Dns.GetHostEntry(hostname) you will get 192.168.1.90 which is the LAN IP of you PC.. not the WAN IP.. WAN ip is accessible to Dyndns but not to our code / OS itself directly.
You can't access / scan for IP address for other devices from #WP&

My client/server program created in vb6(winsock) dont work on WAN but perfectly works n LAN Why?

I've created a simple client/server program with the help of winsock in vb6. It perfectly works on LAN but the problem is it doesn't work on WAN. All ports are already open, Firewall is already Off, I have dynamic IP so I used No-ip to get named IP address.
One more think I want to ask is , is it important to open port on both client and server? For eg- I've created the program on port 50505 and on the client computer the port is open but is it important to open 50505 on server also??
Here is my project.
If anyone could find the problem please let me know. I would appreciate a lot
Okay, first make sure that in the client side program that the Localport is not set to anything because Windows will assign it one, but the RemotePort is set to 50505. On the server side, the RemotePort is set to nothing, and the LocalPort is set to 50505.
Next you need to make sure your server has a static IP on your network.
So if your router's LAN IP is 192.168.1.1 you need to set your server's to
something like 192.168.1.50, just make sure that it doesn't get put in the range or the
DHCP server (That's the server that gives each computer a IP address from the router).
Next you need to setup your router for "Port forwarding". Be default your router had no idea what to do with data that the internet sends to it. You have to setup the router to forward any data from port 50505 to your server on your network.
While this seams really long and drawn out, it shouldn't take more than 5-10 min's to setup.
Good luck!
You need to configure the router that the server is behind to forward connections on that port to the computer running the server.
Otherwise, the client will not be able to connect to the server.

Resources