I am trying to send socket requests in C++ to an onion link I am hosting with tor services and node.js. My node.js server is being hosted on port 8080.
When I try to send socket requests to localhost:8080, it works perfectly fine.
However, when I try to send them to my onion link, it does not work.
The library I am using to handle sockets is https://github.com/socketio/socket.io-client-cpp.
The C++ code:
sio::client h;
connection_listener l(h);
h.set_open_listener(std::bind(&connection_listener::on_connected, &l));
h.set_close_listener(std::bind(&connection_listener::on_close, &l,std::placeholders::_1));
h.set_fail_listener(std::bind(&connection_listener::on_fail, &l));
h.connect("http://myonionlink.onion:8080/");
// it fails to connect to the onion link, but works perfectly fine with http://localhost:8080/
Why is this not working for the onion link? Do onion links work differently in this case?
Is there any method I can use to achieve this?
I think problem in ".onion TLD is not in the Internet DNS root" from https://en.wikipedia.org/wiki/.onion, under the hood library performs attempt to resolve your URL in the raw IP address and fails on it because there is not appropriate record in DNS table.
Related
I am trying to write a c++ websocket server and have browser/chrome clients connect over websockets, for a multiplayer game. The websocket c++ library I'm using atm is websocketpp or websocket++. I wrote an app that allows clients to connect over ws and localhost, but when I add an ip for the address, connections don't occur at all. Now I think I have to use ssl and wss for ip connection? I tried it and there is some connection activity, but then the handshake times out. Could I be experiencing cross-orgin issues, or what, do i need ssl? I am new to websockets. Could the problem be my ssl certs I made with openssl? I can post code, or if you are familiar with a c++ library to do websockets, what is it? Is this even a possible thing to do?
There could be multiple reasons why it won't connect over ip.
The first is port forwarding. On a local network it's not necessary but running a server over a remote network, portforwarding has to be done. You can just run your server then use a simple port checker (there's many websites for them) to see if a connection can be established.
The other reason could be as you said ssl. If you are running your client on a web host, the host may require a connection to be made over ssl/wss for websockets. If your server isn't running a valid ssl certificate then this could prevent the client from connecting to your server. I know for exampe Github pages requires the server to be running wss or valid ssl certificates on the server side in order for a client connection to be established; however, if you use a custom domain name for Github pages then you can disable the need for ssl.
In order to get valid ssl certificates you would need to register a domain for your ip address then either buy certificates or use free certificates from zerossl or other distributors.
Here is a game I have written which connects to a c++ server which I'm running on my own machine with its own domain with valid ssl certificates and the client is running on github pages with a custom domain I have registered.
It's basically multiplayer minesweeper where the objective is to locate the flags rather than avoid them.
I'm trying to connect to a domain that seems to have Akamai tech.
I can't connect and nor does curl - but the browser does.
So I assume the IP address is not blocked.
Reading up - it seems that Akamai runs some algorithms and doesn't allow connections sometimes.
But since a web browser works (from same pc) - I assume it can be made to work.
Any tip?
Your question is quite wage. Akami WAF will not allow curl unless you have white-listed your IP address. Browser connect is just TCP connection on port 80, 443. Which http method did you try to access and is that method allowed? By default i believe only GET and POST are allowed.
I have a web application hosted on an external server. I would create a communication beetwen my home server and the web application.
I thought something like that:
my home server send its ip to the web application
the web application send data to the home server
my home server send back some data
I want to implemente a P2P communication between the WebApp and the home server
it would be bettere if the communication is encrypted
i dont want to use dynamic dns
Is there something to implement that?
There are several types of IP. It can be "grey" and "white".
"Grey" means that your computer can't be accesses through it.
"White" IP's can be accessed directly. Also there are dynamic IP's
that changes through the time. It all depends from the provider.
It's possible that you have "white dynamic" IP but it's pretty rare
for providers to do.
It's easier to connect to server because it
always have "white" permament IP.
TCP/IP already does most of the work. You just create tcp connection and it stays. You just think about sending data.
My suggestion for you is to create something like this:
Home server connects to WebApp
Home server requests some data and WebApp sends back data
Home server sends request containing data and server respondes that all is ok
So you have client-server model. And client always does only requests and server does only responses. And they do not switch. It's easier to maintain.
There is common technology of doing that and it includes encryption too.
You should use HTTPS protocol. Https will do all the encryption(and safely exchange keys too) you just worry about certificates(there are ways not to buy certificate but sign them by yourself. It's whole another topic)
So you will send https requests from your home server PC(client) and get responses from server(webApp).
As you write on Python you would find this answer helpful for you:
HTTPS request in Python
I've been researching around regarding the capabilities of having a client access a website and check their ping in a game (so far there seems to be no possible way using JS, however there may be a way with AJAX?). Without a website, the method to check ping would be using the command-line ping command to the server address through ICMP. Would it be possible to check the ping of a client to the game server with a website middle-man?
EDIT: If I do a php solution as described here: Pinging a server in php without the port?
could I do something like checking the ping of client to my website, then checking from my website to the game server and then predict the ping of the client?
You cannot really use ping command from js, but you can use AJAX call to some empty file on your server, to measure the response time:
var start = new Date().getTime();
$.ajax('http://your_server/empty_file')
.always(function( data ) {
console.log(new Date().getTime()-start);
});
EDIT: you can only 'ping' game server using this method if it has HTTP server running on it (you may need to set up headers to enable cross-domain requests for that). If both servers are on the same fast local network, there is no need to ping to both servers separately, the measurments are going to be the same.
I've just started studying Winsocks and I've a simple question for you: how can I determine if the connection to a server must take place over a HTTP or HTTPS connection?
Let's say I want to connect to randomsite.random, how can I know what kind of connection I need? I know that for HTTP I must connect to port 80, while for HTTPS is needed 443, but how can I determine WHEN is needed a HTTPS connection?
Thank you for the attention!
The same way a web browser decides: Based on the URL you are trying to load. In a web browser, the URL begins with http or https, which is used to determine whether an SSL connection should be used. This is also used to determine the port if no port number is specified in the URL.
Many sites offer both a secure and a non-secure version. Some offer only a secure version, but still run a non-secure server which issues a redirect to the URL of the secure version. If you implement following of redirects, you don't need to worry about which version to use: it will happen automatically.
This is usually a function of the site you are connecting to.
If the site requires a HTTPS connection, then if you connect over HTTP you will get a redirect response code with a HTTPS URL.
Firstly, it's not always port 80 and port 443. Secondly, you won't establish successful communication if you use the wrong communication protocol. As said in another answer, if you try to connect via HTTP to an HTTPS server, it will give you a redirect response code with an HTTPS URL.
Most of the time, you have this information before-hand!