-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added possibility to configure interface bindings #231
base: master
Are you sure you want to change the base?
Conversation
I think we should aim for "interface names", not "IP addresses" in the UI. Also, what happens if the interface the server is using the IP of goes down? |
@bk138 Hi, sorry for the late response. As for what happens when the interface is down... I'm sorry, I didn't check for that when I made the fix, I've checked while commenting this though. I've made the server listening to my wifi IP Address and, if I disable wifi while the server is running, it simply stops (that is, the server gracefully stops and you can restart it, I guess this is the default behaviour you programmed?), if I do the same thing but when listening on localhost, nothing happens, the server continues to listen, same thing if using 0.0.0.0. |
What I mean is that we should not bother the user to enter IP addresses in the UI but present choices like "Wifi interface", LAN, WAN etc and handle the device->address resolution under the hood. |
How about a spinner with the current up interfaces plus, the possibility to define a custom IP address? Any It seems XVnc has a -interface option in order to customize the ip address. |
Yes, but why would the user want to set a custom IP? |
Ehr... eh eh, that's actually a good question... because... why not? :P |
Let's keep it as simple as needed: https://en.wikipedia.org/wiki/KISS_principle :-) |
Ok, done, now it should be better, let me know what you think. |
1a1571c
to
be567d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments. Before delving into details, the two grand topics are:
- what's the strategy when a listen interface goes down while the server is running?
- what's the strategy when the server is started wit a listen interface that's not up?
If solutions for these are too hard to be found, the details are kinda moot...
app/src/main/java/net/christianbeier/droidvnc_ng/ListenIfAdapter.java
Outdated
Show resolved
Hide resolved
app/src/main/java/net/christianbeier/droidvnc_ng/ListenIfAdapter.java
Outdated
Show resolved
Hide resolved
app/src/main/java/net/christianbeier/droidvnc_ng/MainService.java
Outdated
Show resolved
Hide resolved
app/src/main/java/net/christianbeier/droidvnc_ng/OnBootReceiver.java
Outdated
Show resolved
Hide resolved
f60d76c
to
c7845a4
Compare
f133256
to
beba90d
Compare
Waiting for review @bk138, of course, when you have time. |
@elluisian I'll try to take a look ASAP - will take some time due to the PR's size. |
So, do I understand this is implemented ? |
@freebrowser1 No, it's not. I didn't find time for a thorough review yet. |
@freebrowser1 Unfortunately not, I'm waiting for it too. |
@elluisian thanks for the offer - yes you can rebase, that would help. I have not forgotten about this PR, otherwise I would have closed it. It's simply a matter of urgencies/priorities :-) |
- Added the entry "main_activity_settings_listening_interface", used as label for the spinner which will determine the used interface; - Added the entry "main_activity_settings_listenif_spin_any", used as label for the spinner entry that indicates the usage of "any interface";
- Added a section (label + spinner) needed to choose the interface to use ("any" included);
- Added constant PREFS_KEY_SETTINGS_LISTEN_INTERFACE, to store the chosen interface to use; - Added listenInterface property with value "loopback" to Defaults;
Added ifaceutils package which contains classes that will be helpful in detecting and managing NICs (Network Interface Card). - INetIfData, NetIfData and NetIfDataDecorator: These represent a single NIC, the last one can be used to customize the name of the interface; - IfCollector: As the name suggests, this class simply collects all the available interfaces at once; - NetworkInterfaceTester: As the name suggests, this class uses IfCollector and listens for network changes;
- ListenIfAdapter is an adapter class that will be used with the Spinner present in MainActivity in order to choose what interface to use; - NetIfDataDefaultNameDecorator simply gives friendly name to interfaces "loopback" and "any" (these are taken from strings.xml);
- Added method getIPv4ForInterface(NetworkInterface) and getIPv4ForInterface(String) which returns a list of ip4 addresses given a NetworkInterface instance/String name of interface; - Added method getAvailableNICs(Boolean, Boolean) and getAvailableNICs() which return a list of NetworkInterface instances that represents available NICs on the system;
- droidvnc-ng.c: Method Java_net_christianbeier_droidvnc_1ng_MainService_vncStartServer modified to accept a futher "jstring listenIf" parameter. This way, it is possible to use rfbScreen->listenInterface property to perform interface binding; - MainActivity: Now it makes use of ListenIfAdapter, allowing to change the used interface (default is loopback); - MainService: Now it makes use of NetworkInterfaceTester and IfCollector to detect the state of the network and stop itself, if needed; - OnBootReceiver: Now it correctly detects whether an interface is disabled/non-existent and if so, it DOESN't start the service, moreover, it sends a notification about the problem.
d37cd48
to
8d49c47
Compare
Hi @bk138 , I've improved the pull request, from 11 commits to just 7, moreover, they are a bit more "organized". |
UPDATE, Monday, February 17th 2025
This commit implements the feature requests reported on the issues #43 and #227.
It is now possible to make the server listen only on certain interfaces, instead of all of them.
This not only increases security, but it also allows the "typical SSH usage", that is, SSH server + public key authentication + local port forwarding + VNC server listening on localhost.
OLD MESSAGE
When applied, this commit tries to implement the feature requests reported on the issues #43 and #227. Basically, with this, it is now possible to make the server listen only on certain addresses. This increases security and allows the typical "SSH usage", that is, SSH + publickey auth + local port forwarding + VNC listening on localhost only.
To achieve this:
on droidvnc-ng.c, vncServerStart was modified in order to provide a further "jstring listenIf" parameter. It uses rfbScreenInfo*'s listenInterface property.
A TableRow was added in order to allow users to input the desired address to use ("Listening Address").
On droidvnc-ng.c, the method vncServerGetListenInterface was introduced in order to track if the server is currenctly set to listen to 0.0.0.0 or not (this is used to properly show what addresses are available to use on the UI).
Please note that, if an invalid address/host is set, by default, it is assumed the address 0.0.0.0 is requested.