I have a server and an android app. My server want to request a destination but with the IP of the android device that my app is running on. So I need to proxy the requests (relay them) in my app so the destination could see the client's IP but the server. You can see my explanation in the picture:
How can I do this in my app?
Yes this could be done but not just with relays; you also need to port forwarding mechanism in between. Here is how I would try to do this:
Local portforward the requests of the server onto a dedicated port on your android device and then from their call the Destination server via your relay mechanism which could be fulfilled very succicntly by LittleProxy like solution.
Related
I am using Xamarin Forms to build an Android app. The data that the app will consume is stored on our server in a SQL database on our local network. I am using a C# Web API service (served by IIS) to connect the app to the server. All traffic will be inside our local network.
Currently the Web API is being served by IP address on port 90 - this was the only way I could get the emulator to be able to connect to the server, as no luck accessing it by name. I can fire up a browser on my development machine and load up http://10.1.1.15:90/api/Controller and I get back the data I was expecting.
I have also done a networkaccess check for access to 10.1.1.15 on port 90 using Powershell from my machine, which comes back Fine.
I use James Montemagno's Connectivity package to check for network access in the app - this returns true if I check for the IP address. It returns true if I check for the IP address on port 80. However it returns false if I check for the IP address on port 90. How can I get this to access the server on port 90? (BTW it will also need to access other services on port 91 and 92).
The android device was set up by default with a proxy. I toild it not to use the proxy and then it worked
I'm debugging an API on my home development environment with the IP range 192.168.0.0-255.
I'm in Australia (relevant for reasons below), the API's written in PHP, and I'm running Apache.
My server IP = 192.168.0.20
My router is configured to forward HTTP requests to this IP.
My router's internal IP is 192.168.0.1 and external IP is, for this example, 123.123.123.123
For the following cases:
Laptop, all browsers, over wi-fi
Android tablet, all browsers, over wifi
Android phone, using Internet browser, over wifi
the server detects $_SERVER['REMOTE_ADDR'] = 123.123.123.123.
The latency is effectively zero and no caching occurs. So far, all as expected.
However, when I submit the same query from an Android mobile phone (assigned the IP of 192.168.0.10) in Chrome over the same wi-fi connection, the server detects:
$_SERVER['HTTP_X_FORWARDED_FOR']: 123.123.123.123
$_SERVER['HTTP_FORWARDED']: 123.123.123.123
$_SERVER['REMOTE_ADDR'] : 66.249.84.217`
The 'REMOTE_ADDR' also takes on the values 66.249.84.223 and 66.249.84.229
There is a delay of ~400ms and my API is being cached - hence not returning correct/latest values.
Relevant parts of HTTP header:
Forwarded: for=123.123.123.123
Scheme: http
Via: 1.1 Chrome-Compression-Proxy
I see 66.249.84.0-255 belongs to Google, and understand why compression may often be useful in mobile context. But in my case I'd rather avoid the extra latency of a round-world-trip.
When I run the same queries over HTTPS, no re-routing through Googles's servers occurs.
Is there any way to avoid Chrome mobile re-routing my packets?
Your request is, presumably, being routed through Google's Data Compression Proxy.
Since Google does not try to hijack your SSL certificates, no such rerouting is being done for SSL connections.
On the client side, a user can simply disable this in settings with Settings > Bandwidth Management > Reduce data usage.
On the server side, it's too late to "undo" the routing, though you can indicate with a Cache-Control: no-transform header that you don't want your response transcoded.
From the Google Developer Docs:
As a site owner, how do I opt-out from content optimization?
Data compression proxy respects the standard Cache-Control: no-transform directive. Site owners can mark individual resources with this directive and the proxy will pass them through directly to the mobile browser.
https://developer.chrome.com/multidevice/data-compression
Yes, same answer for me. I have a network camera in New Zealand I access from Canada. I noticed a bunch of suspicious access in the Access Log in the range 66-xx-xx-xx, and believing the camera had been hacked I immediately added an access denial for that range (at the time I knew the range was owned by google ... but as far as I was concerned at the time it could have been a cloud machine of unknown purpose.)
Then noticing I could no longer access the netcam on chrome on my mobile (but could on the default browser, and any windows browser) It became clear that there was some kind of proxy in the middle. Further research led me here.
Here's some more info -
https://developer.chrome.com/multidevice/data-compression
Turning off Reduce Data Usage in chrome settings immediately restored access to my netcam
I have to wonder what's in it for google ? what valuable info are the mining from my traffic as it passes through their proxy?
I'm new to Network programming in Unity3D and basically I would like to make a connection between two android devices, through WiFi using the Client Server Model. And I have some questions.. such as
How it is possible to make a server with a specific IP Address?
How can I make a client, who will connect to that server?
How can I transfer messages between client(s) and server?
Any help would be appreciated..
.......
I have write this simple code...
function OnGUI()
{
if(GUILayout.Button(" Initlized server"))
{
Network.InitializeServer(32,25001,false);
Debug.Log("Server has been Initlized");
}
if(GUILayout.Button("connect to server"))
{
Network.Connect("127.0.0.1",25001);
}
}
function OnConnectedToServer() {
Debug.Log("Connected to server");
// Send local player name to server ...
}
I have write this simple code but OnConnectedToServer doesnot give me any responce...
How it is possible to make a server with a specific IP Address?
For the IP address part, you will need a static IP. If you are behind a router, that means you will have to first ensure your ISP gives you a static IP. If they don't, you should try a service such as FreeDNS, which will route your dynamic IP to a web address. You will then need to port forward the specific ports to the server, which should have a static local IP for easy port forwarding.
As for the code itself, I would highly recommend you take a look at THIS website. It has great video tutorials on making a client-server game using Unity's built in networking.
http://www.gamertogamedeveloper.com/
As for your code, you don't state how you run that code. You SHOULD NOT have the client and server being run in the SAME instance. What you need to do to test this is run the Server inside the Unity3d debugger then build the client and run it as a standalone app.
Raknet seems interesting,
have a look here:
RakNet
unity-Raknet
I would like to know what field within the http packet which was sent by client browser to WEB server can i look to detect whether the request was made from mobile device or from a PC.
My web server is open source which uses C programming language and runs a TCP socket and listens on HTTP port.
Can anyone please let me know.
You need to see for HTTP header called "User-Agent". The value of this will help you determine where the request was made from.
For further details you can check this answer: Auto detect mobile browser (via user-agent?)
I wrote a little WS on asp.net, I can open it printing something like
http://46.146.170.225/RouteGen/Service.asmx
in address bar. It's all right, WS works.
But if I print the same address in a browser on the other computer, the page isn't available. How to get access to my web server from other PC? (I need from Android device, but I think it's no difference)
If you started the Web-Service from within Visual Studio then without changing the starup-settings of your project - it's not possible, because VS only starts a local debug web-server that doesn't allow calls from other hosts than localhost.
To allow external IPs to access your web-server, you have to set up the IIS and run your web-service inside it. A firewall could block incoming requests to the IIS but I ran such a service last winter and didn't have to change firewall-settings.
Verify that the website, in IIS, is bound to a public-facing IP address. Right click on your website in IIS, and go to the bindings setting. Then, check the host field. It should have an IP address or domain name that is available publicly.
Verify that your firewall has Port 80 open for incoming traffic