How to implement managment (opening/closing) of the internet connection on local PCs (LAN)?
-
Hi.
I have problems adding function that controls sharing the Internet connection over the LAN PCs. Tried few ways:
- Over QNetworkConfigurationManager + QNetworkSession, finding local machine by mac address;
- Over two separated programs (server and client), just using QTcpServer and QTcpSocket;
Got stuck. Did I miss something? Need only 3 slots: OpenInternetConnection, CheckStatus, CloseInternetConnection.
Sorry for nooby-dooby :D
Appreciation guaranteed!
-
[quote author="sopchek" date="1290367439"]I have problems adding function that controls sharing the Internet connection over the LAN PCs.[/quote]
Please provide more details what exactly you want to do. Currently I can think about 2 different tasks:
You host works like a gateway to the Internet. You are trying to manage from you application the gateway settings: turn Internet access on and off
You just want to connect to some address in the Internet
-
[quote author="blex" date="1290404630"]
Please provide more details what exactly you want to do. Currently I can think about 2 different tasks:
You host works like a gateway to the Internet. You are trying to manage from you application the gateway settings: turn Internet access on and off
You just want to connect to some address in the Internet
[/quote]
Hi, blex.
Yes, I want a gateway to the Internet. It might be one app or it might be two separate server and client. What can you advice?
-
I am still not sure that I understand the question correctly.
If you want to configure the PC as a gateway then just do that. Use existing solutions: configure NAT or setup proxy.
If you want to control the gateway settings then one possible solution is to run external command. On Linux that command requires root access, and it will be some issue how to send password to it. If you faced this issue just google for the solution - I do not remember it, but DejaGnu provides this possibility.
If you want to develop your own proxy server analog then look for existing open-source implementation, it definitely available.
Let me know if I do not answer your question.
-
Hi,
ok, look. I am about to write some client-server app. Here is kind of topology <a href="http://files.gw.kz/4btjfsjj9r.html">schema</a> of the target network. The application which will run on the local server should have an ability to control the Internet connection on the client machines over my client app installed on them. Local clients should only have an ability to connect to the Internet with the client application running on their machines, and also it will be a way of getting the status information about the server. That is the idea.
Appreciate your help.
-
here, try this http://www.FreeUploadShare.com/DOWNLOAD/e93ea513/schema.JPG
-
-
Good idea to control server status. If I were you then I would use ping to do this from the client application. But maybe you should get additional info from server - in this case follow your way, but try to reduce network traffic, the network looks quite large.
-
Internet access control. It seems like not Qt task. Maybe it will be simpler to setup proxy server and just control it's configuration from the Qt app (allowed IP, port, protocol etc.)
-
-
[quote author="blex" date="1291132659"]1. Good idea to control server status. If I were you then I would use ping to do this from the client application. But maybe you should get additional info from server - in this case follow your way, but try to reduce network traffic, the network looks quite large.
[/quote]
Yes, the client should not only ping the server. To reduce the traffic I want to use a digit-coded server query transfered packages, such as for example "01" is server uptime, "02" is on-line clients list, etc. How do you think of that?[quote author="blex" date="1291132659"]
2. Internet access control. It seems like not Qt task. Maybe it will be simpler to setup proxy server and just control it's configuration from the Qt app (allowed IP, port, protocol etc.)
[/quote]Indeed, but how about using QNetworkProxy class from within the running server app? -
[quote author="sopchek" date="1291145778"]
To reduce the traffic I want to use a digit-coded server query transfered packages, such as for example "01" is server uptime, "02" is on-line clients list, etc. How do you think of that?[/quote]Any frequently issued request may increase network load. TCP packets contains not only data fields but also headers for TCP, IP, Ethernet etc. protocols. So, no large difference between "01" request and "IsServerRunning" request.
Maybe it is not a time for optimization jet but think about the following:
- rarely issued requests are usual TCP connections
- server status is broadcast (multicast) UDP packet issued by the server. It may contain not only "I am alive" information but any useful (in Ethernet max. packet size is about 1500 bytes, WiFi - do not know)
-
[quote author="sopchek" date="1291145778"]Indeed, but how about using QNetworkProxy class from within the running server app?[/quote]
Maybe I am completely wrong but it seems to me that QNetworkProxy is the Client-side class that enables the application to connect to Internet using proxy. It should be used in the client applications.
You own implementation of the proxy server is not a simple task (also from the network performance point of view), so I suggest to use existing proxy implementation.