Hello. I have created a script for client Authorization - Deauthorization, with permissions according certain priviledges that I am giving to the users. I am trying to incorporate the server event of onClientConnect - disconnect, in order to handle permissions on renaming, ignoring etc. I see that the onClientConnect passes the ID number of the connected client to the server, and i was wondering if it is possible to also pass the Client_ID, Client_IP that can be passed to the clientAuthorization and all other events. Somehow i need to identify the user that is connected to the server.
Is this possible?
.
I forgot to mention that passing the same parameters to the onClientDisconnect event, would also be very helpfull
.
The onClientConnect will also pass the $ADDRESS$ which is the IP address of the client (I probably should have called it CLIENT_IP like the other events). However at the point this event occurs it is not known what the username of the client is.
.
Ok i understand the case.However the IP is not very usefull in the process of identifing the user because users from inside the same lan network probably have the same external IP.
So something else that could help would be the following.
Do you think that the client disconnect event could pass the Client_ID and Client_IP parameters, allong with the others? This way i could identify the active online users with the appropriate script.
Another thing is the onServerRename event. You don't mention any accept or reject return values. So it would also be usefull for the same parameters to be passed an the return value to be expected, otherwise every user can rename the server.
.
Yes that is a good idea:
Could you try this beta build https://www.virtualhere.com/sites/default/files/usbserver/test/vhusbdx8… (assuming you are using linux 64 , otherwise let me know the os/arch and ill compile a beta build for that)
Changes made reflected here https://www.virtualhere.com/quirks
1. onClientConnect changed $ID$ to $CONNECTION_ID$, and $ADDRESS$ to $CLIENT_IP$
2. onClientDisconnect changed $ID$ to $CONNECTION_ID$, added $CLIENT_ID$
3. UPdated documentation to specify that if onServerRename is specifed the server rename will not take place
.
The server is installed on Synology NAS armada38x.
onServerRename
I didn't got the onServerRename event handling. If I want to accept the server renaming, should I edit the config.ini with the script code? It would be easyer to accept or reject with Return value
onClientDesconnect
I tried to use the new parameters that you 've added, but i realise that the onClientDisconnect also needs the ClientIP parameter, in order to correctly identify the user. Probably 2 or more pc's having the same name etc, could mess things up. So the ClientID along with the ClientIP would be better.
Up until now the only way to control the renamings is to allow it only to users that are connected to a device, so that they have passed the user control script (authorization).
I can test the beta for more feedback.
One more question. Is it possible to send messages to the user inside the SystemMessages log box??
.
No you just need the
$CONNECTION_ID
to identify the user. The$CLIENT_IP$
for the$CONNECTION_ID$
is given in the onClientConnect callback so you can just recall it from there if you need it. (You cant send an message to the system log in the client).
I made another update, if you return
1
fromonServerRename
the rename will occur, anything else (or nothing) then the rename wont occurDownload this beta build of the server for your synology. To install just overwrite the existing vhusbd on your armada38x and stop/start the package
https://www.virtualhere.com/sites/default/files/usbserver/test/vhusbd
OnClientConnect event
Look what is making things difficult. Lets say we want to keep track of connected users an identify their privileges. Initially with the onClientConnect we get the connectionID and the IP of the client. After the authorization script we don't have the association of the userID with the ConnectionID so the authenticated users cannot be linked with the onClientConnect connections apart from their ip address. In case 2 or more users are connecting from the same lan with the same external ip address, we don't have a way to distinguish them. That's why I am registering active users from inside the auth script. I distinguish them using the clientID and ClientIP that is used to the authorization script. Up until now i unregister active users with the deauth script, but it's too early to unregister them and i was trying to unregister them from the active user list as long as the OnClientDisconnect event ocurres. But for that I am missing the ClientID I mentioned.
What are the changes in the beta version?
onServerRename
I think that the onServerRename event also needs the ClientID, and ClientIP parameters, in order to check the privileges of the user asking the rename event.
.
OK
Download the new build here https://www.virtualhere.com/sites/default/files/usbserver/test/vhusbd
Changes:
You can now specify
$CLIENT_ID$
,$CLIENT_IP$
,$NEW_NAME$
,$CONNECTION_ID$
in onServerRename(if you return 1 from onServerRename the rename will occur, anything else (or nothing) then the rename wont occur)
beta - wrong date time at var/log
Hello Michael.
I 've installed the beta version, and I have descovered a bug in the log file (i mean the var/log file). When i started the server after overwritting the new file, the date that writes inside the log file is hugelly outdated. It writes August 20 istead of June the 4th. Except for the "EEST 2020 Started successfully" event which is in the correct date and time. All other events are reported with wrong date and time. I give an example below.
Thu Jun 4 18:13:26 EEST 2020 Starting VirtualHere...
Sun Aug 20 10:32:16 4147 LOG_INFO >>> Starting VirtualHere USB Server v4.1.8 (Built: Jun 3 2020, 20:26:11)<<<
Sun Aug 20 10:32:16 4147 LOG_INFO Using configuration ....
Thu Jun 4 18:13:26 EEST 2020 Started successfully
Sun Aug 20 10:32:16 4147 LOG_INFO Using SSL Server certificate at
errors in log
It also gives me the following error code when connecting to a device
LOG_WARNING Error 22 when watchdog called pthread_cond_timedwait
too many connetion timeouts
Another problem. When I open the client, without connecting to a device, it keeps connecting and disconnecting with reason timeout.
I will restore the stable version.
In general the scripts works for the rename events, but the fact that the client keeps disconnecting when idle, mess things up. The first and most serius is that the server assigns new connection ID to the client so it is very difficult to keep track of the online users using the onClientConnect - onClientDisconnect events. The only way i managed to check the user privileges is if the user is connected to a device, so I can use the CliendID ClientIP parameters allong with the authentication of the password.
.
I have tested this more with the latest build and yes there seems to be a bug in clock_gettime in the synology kernel (or in my c compiler). I can reproduce the issue on my synology DS213j. What exact model synology do you have? Other arm x86_64 etc devices seem fine so i think its related directly to the synology kernel
Synology
I have a DS116 NAS.
What about the other errors that it gave to me? Error 22 and disconnection problems?
.
They are all the same error. If the clock doesnt return a real time then "pthread_cond_timedwait" wont work, the connection will timeout pointlessly etc because the time is wrong. I will investigate this some more early next week. It doesnt seem to happen with any other platforms.
.
Yes and surely it does not happen with the previous version. I can confirm that.
I think that if it was coming from the Synology kernel, it would happen with previous versions as well.
.
Just to confirm with you. The "stable version" that works is the previous version 4.1.7 of the server or is the 3.x from the synology app store?Edit: yes 4.1.7 works for me so ill assume its just 4.1.8 beta with the problem.
.
(Ok i got to the bottom of this issue. I used an updated c library that was recently modified to fix the year 2038 problem , but turns out it has a bug in the backwards compatibility for older kernels like those used in synology)
could you try this build now https://www.virtualhere.com/sites/default/files/usbserver/test/vhusbd
(i rolled back to the older version of the c library)
.
Ok I will test it and return with findings.
Thanks
.
I have tested the latest 4.1.8 version and everything seems to be working just fine.
The scripts for the renamings, also work fine, but i still have to use the authorization and deauthorization events. The onClientDisconnect event needs the ClientIP parameter, in order to be consistent with all other events, that use those 2 parameters to identify the users.
.
Try this 4.1.9 beta version which adds the
$CLIENT_IP$
to the onClientDisconnect eventhttps://www.virtualhere.com/sites/default/files/usbserver/test/vhusbd
success
Hi Michael. I 've tried the beta version and works like a charm.
Thanks for the efford.
.
Great, thanks for letting me know, i'll push this change in 4.19 when i roll that out in a week or so