I would like to add a feature to my rails (5.0.1) application and have it only available on a certain wifi network.
Is there a way of finding out what wifi network the user is on?
Thank you!
Your question doesn't provide quite enough context. The short answer is "probably not how you want to." The long answer is:
If you're concerned about what network a user of your application is on, you can use request.remote_ip to get the remote IP,
If you're concerned about where your application is deployed, you can run a system command to get the current Wifi SSID (or equivalent) and run a check against that
Edit: Per your comment you want the ability to ensure that the user is only using it on your private network.
One way you can do this is to make the application not accessible from the outside world. This is a better question for something like serverfault.com
It's simply not possible to detect what Wifi network name they're connected to from Rails, or from Javascript (exceptions apply). But, you can, with a little sysadmin work, detect that they're connected to an IP within your private network.
Related
I ask this question out of curiosity and because I have it. But is there a way that I can change a normal WiFi router into an adapter? Okay to be really precise in my question: I mean that can I take the antennas out of the router and somehow give it the USB port thingy and then plug it onto my computer so that I can access WiFi networks over longer distances? Kind of like getting yourself an external WiFi adapter. I wanted to do something with my old router before I gave up on it.
PS: its a TP-Link
I was thinking about a project the other day and an idea stumbled across my mind:
How would you set up a server, for instance at a restaurant, and have an app of the restaurant chain which finds and directly connects to the locally running server without being in the same network. This should work at higher ranges, so simple Bluetooth is not fitting here.
I've done some research, but I'm not very... good with protocols, and nothing I've found seems to really fit that goal. So I'm wondering what the best way to code this connection would be. Any ideas would be helpful :)
Here are the requirements:
A standard phone should be able to perform the operation.
It should have a fairly high range, think a big store or restaurant.
Server and device do not have to be in the same network.
The connection get's established by the phone on app start, to a server that can do whatever it needs to get this done.
I'm trying to understand how the choice of the bonjour domain will influence device discovery on the network. I find the documentation somewhat unclear on some points, and would like to ask for clarification.
From here:
Most network service browser clients do not have to use this method—it is sufficient to publish a service with the empty string, which registers it in any available registration domains automatically."
This seems like a recommendation. Lets put a pin on that.
From here:
#""—Registers the service in the default set of domains. Pass this value unless you have a specific reason not to."
Reforces the recommendation, but what does this mean? What's the default set of domains? And what does that imply?
From the same link:
#"local"—Registers the service only on the local network. Pass this value if you need to prevent publishing your service over Back to My Mac or wide-area Bonjour.
What does publishing "over Back to My Mac or wide-area Bonjour" mean? Should I use this if I'm using bonjour for proximity only? Doesn't this contradict the recommendation?
Also from the same link:
A user-specified domain—Registers the service in only the specified domain.
I actually tried this and the service doesn't even get advertised on the network. I get a call to the delegate method netServiceWillPublish: and that's it, nor didPublish nor didNotPublish are called afterwards. Is there a strict set of domains that can be used? I'm using simple names, like test.
Basically, it's still very unclear to me what the domain name accomplishes on the network. How does it influence the discovery process? Ou does it influence service matching? Does it have consequences on network performance? I know these seem like a lot of questions, but mostly, I think that if I understand what domains are for most of them will go away. Hopefully :)
Best.
I've got an old connection log to a website which contains the IP addresses, the user agent string and the timestamp.
I want to know how many of them used 3G to access a website as I suspect there is a latency issue.
Now I know that I can use some code to have this info directly from the user.
But I still want to process this old log using only IP addresses even if it is only for one ISP.
I thought I could do that by finding a list of the subnets used for 3g.
Do you think it can be done?
Otherwise, what do you suggest?
Hope you can help.
Cheers,
One approach could be to lookup every IP using "whois" services, if the ISP listed is a phone carrier only, you can be certain the connection was made by a mobile connection.
This is not a total solution, but it might give you enough information.
Now, to find a service which will allow you to make all the requests required, might be another matter.
I have a headless raspberry pi with a wifi dongle and I want to use wifi two ways.
1) To make the rPI a wireless access point when there is no local wifi access point so I can connect to the rPI from my iPhone.
2) When wifi is available use the wifi dongle to do normal connection to the internet.
I think I know how to do each of these individually. It wasn't easy but I now have it connecting to my local wifi at home.
I see references to using hostapd and dnsmasq with wifi to make a local access point but they mostly assume internet connection comes from ethernet.
I'll be studying these in more detail. However I don't even know if the end goal of using the same configuration to fill both needs with one wifi dongle is even possible.
Obviously I can create two sets of config files and a script to swap them as needed but that only works if I have a connection already so I can log in.
If I add a jumper or switch to the rPI GPIO interface I could run the configuration script at startup and let it read the switch.
I might try to make the script look for an existing wifi link and go to access point mode if it doesn't find one it can access.
This would probably be a steep learning curve for me but I could probably figure it out eventually.
What I am trying to figure out now is whether I can avoid these potentially complex solutions by creating a single configuration that does both. Is a single wifi dongle sharable between these functions?
Note: I don't need it to do both at the same time. I just need the decision to be automated so it happens automatically during boot.
It is possible, although tricky to get right. (For example, what happens if you boot up, don't see an existing network for a second due to interference, then wrongly create your own network?)
Take a look at the "iwlist" command. It can scan and tell you what SSIDs (base stations) it sees. Then you can use 'grep' to see if your home network is on the list, and use that as your decision.