So I am trying to create a p2p file sharing application in Golang. I am running a globally accessible server for the purpose of sharing IP addresses of 2 clients. When both the clients have each other's IP addresses, they can use hole punching to share the files.
But I am facing some problems in the hole punching part. When I send a request to server, the server is going to store the address of the client and it will later relay this address to other client. Problem is that the address being stored on the server is different than the address that is being is used for Hole punching. Suppose that address being stored on server is NATrouterIP1:PORT-A for first client and NATrouterIP2:PORT-B for the second. But when I am using the first client to send a message to second client, it shows that the message was sent from NATRouterIP1:PORT-C. PORT-A generally stays around 65000. But this PORT-C is 1024. For my application to work these ports should be same. Can someone explain what the issue is?
Github: https://github.com/killtheverse/go-send
Related
Currently I am developing an HTTP server and I am using the throttle (access limitation per minute) functionality of Laravel based on IP address.
However I am afraid that when a VPN and/or Proxy Server is used by different people the incoming request will show the same IP address. The rate limitation is included only to prevent dedicated DOS attacks and I don't want the user of my website to be blocked by rate limitation if they are using a VPN.
First of all, I don't have a solid understanding of how IP addresses are obtained and stored in the Request object. I assume it is included in the HTTP request header however I wasn't able to find it in Google Chrome's developer tool, "Network" tab. The developer tool only shows the destination address and not the source ip address in the "Request Header" session.
Next, I don't have a testing environment where I can test whether the IP address will be the same when sending by different machines using the same VPN, hence I have to ask the question here.
Any help would be appreciated.
will Requests coming from VPNs show the same IP address or not?
Yes, it will show up as the same IP address as this is the whole purpose of using a VPN service, to change the user IP address.
However, if you want to detect if a user is using VPN there are third-party services to help you with that https://ipinfo.io/
I know already about the web-sockets, and they are great, the problem with them is that they have to keep the connection open in order to be able to communicate.
I have a small system where from time to time the server has to update the status and notify the clients about that, and keeping the connection open from every client is not so optimal. At same time is very important that the update on the client side to be made just in time.
So my question is, if the server has a unique address does the client have a public temporary address where the server can send request? So when the client will connect to the server it will provide it's unique address and the server will cache it, and when there will be an update the server will send the request to that address?
I understand that there many problems as the address will constantly change, but this is already other question.
If client does not have a dedicated IP-address then it is not available from WAN unless it has an open connection with any node in it.
When client from local network sends request to a server it's (client's) router remembers client's local IP-address and port and translates it using NAT protocol to one of router's free ports and then sends data further with router's own 'IP-address of the sender' in IP protocol header and 'Sender's port' in TCP header. When router get's server's response it uses NAT table from it's memory to translate addresses back and deliver data to the client. Addresses are normally kept in NAT table while connection between server and client is open. So if there are no opened connections between server and local network client then server will not be able to connect with client because server does not know how to reach it.
You say you have a small system. Why then do you think that you will not have enough free ports at your server to work with websockets? If you just want to get updates from the server (not to both send and get data through a persistently opened connection) you'll probably find long polling or SSE more suitable. It is definitely easier to implement than websockets.
I am working on a small project to help me understand websockets better. I am making a simple browser game that connects to an ip via a websocket. There will be 3 ip addresses however I want to assign the user an ip and not have them able to modify it so they are unable to get on the same server as friends.
I will assign the ip based on how full the games are etc and this will be down via php. Currently although it connects to this ip, the user is able to use the console in a browser to modify the ip to one of the other ones.
I was thinking of sending a check number, so the web server sends this to the user along with the ip. It also sends it to the websocket server. Then when a user connects if the check number doesn't match it rejects the connection.
I'm new to websockets so I'm not sure if this would be easy to implement, so are there any easy solutions to this?
That seems to be the duty of other element, in particular the load balancer. How are you balancing the requests across those 3 servers? Does your load balancer support sticky sessions?
If not, probably you can record to which IP address the user connected first, and they if it connects to one of the other two later, you can return a HTTP 302 (Redirect) pointing to the server you want.
Cheers.
I am trying to develop a lan chat application. As I looked for the topic, I found that whatsapp, viber etc. use a server which controls all the traffic. The server tells the status of devices and manage all traffic etc. So, what am I trying to know is :
How the server gets the info of devices like, IP address, MAC address etc?
How the data is transferred from one client to server and then server to another client?
Which language should I use server side?
As shown in image, I want to connect two devices, A and B and interchange data between them.
Actually, I'm not sure data always through the server. From what I know, the client logs in at the server the first time it connects only. If client A wants to send a message to client B, it retrieves the IP corresponding to username_B from the server, then exchange of data is done directly between client.
What you should do is to develop a protocol to login at the server and register the client IP, and to retrieve an IP from a username.
For the routers between server and clients, I think it is out the server scope, you just need for NAT.
I used client and the client will create a connection to server via HornetQ and Netty
Each of 1 minute, server will send heart beat and client (who subscribered) will be received this message. In the message, I included the root IP of server
Everything will be OK if this server had only 1 network card (NIC).
But in the case, server have 2 or more network cards. I met issue.
In the message is received by client, the IP of server not right.
I used InetAddress.getLocalHost().getHostAddress() to get to root IP and I known it wrong in this case server had 2 NICs
So can you give me some advise, how I can get right IP here?
Some guys said we can refer "the socket being used for getting right IP". Do you know how we can get it?
First of all I don't understand why you need IP address, If you think of implementing heartbeat, its not required, If you have used org.hornetq.jms.client.HornetQJMSConnectionFactory It automatically does heartbeat check. And If you have two servers and want to differentiate between servers, use a clientId and send it in message header and while listening you can select message based on the clientId or other approach use sync jms calls.