Skip to content
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

Custom rest access server #337

Closed
AmirHosseinCV opened this issue Jun 3, 2023 · 7 comments
Closed

Custom rest access server #337

AmirHosseinCV opened this issue Jun 3, 2023 · 7 comments
Assignees
Labels
Waiting for info Further information is requested

Comments

@AmirHosseinCV
Copy link

Is there any documentation available for developing a custom REST access server with additional functionalities, such as restricting connections by DeviceID instead of simultaneous connections? I am interested in creating my own REST access server.

@bobvhood
Copy link
Collaborator

bobvhood commented Jun 3, 2023

Hi, There is no document. The protocol is easy. look at this class to find it out
https://github.com/vpnhood/VpnHood/blob/main/VpnHood.Server.Access/Providers/HttpAccessServerProvider/HttpAccessServer.cs

However, The simultaneous connections are detected by the device id. If you describe your business, we may add that functionality.

@bobvhood bobvhood added the Waiting for info Further information is requested label Jun 3, 2023
@AmirHosseinCV
Copy link
Author

AmirHosseinCV commented Jun 3, 2023

Thanks for your help.
I've been running into some issues lately and it turns out that my servers are under a lot of pressure. After taking a closer look at my user stats, I found that some users have been using up about 700GB of traffic in just two weeks!

So, I decided to dig a bit deeper and check their session logs. It turns out that they were sharing a token, which is only supposed to be used by two clients, with a bunch of different people. Here is the session log of one of them, for just three hours!

2023-06-03 09:00:49.8207        SessionId: 4123 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 09:09:36.1589        SessionId: 4202 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-970a-e7873d00993e  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 09:18:22.4257        SessionId: 4269 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 09:18:35.8187        SessionId: 4271 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 09:20:23.7400        SessionId: 4289 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-a52a-3fc395a31ca9  ClientIp: *     Version: 2.6.326        OS: Android 11
2023-06-03 09:22:54.9236        SessionId: 4317 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-89d5-3c083cf0f7b7  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 09:26:39.4448        SessionId: 4355 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9b17-54949c9f9c95  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 09:26:50.1483        SessionId: 4356 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 09:32:55.3451        SessionId: 4405 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-bbc3-20f99726c5f2  ClientIp: *     Version: 2.6.326        OS: Android 8.0.0
2023-06-03 09:41:05.8673        SessionId: 4482 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 09:53:15.2389        SessionId: 4594 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 09:53:27.7596        SessionId: 4596 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9124-c730a09a0fe9  ClientIp: *     Version: 2.6.326        OS: Android 10
2023-06-03 09:56:49.8084        SessionId: 4626 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9b17-54949c9f9c95  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 10:08:10.7431        SessionId: 4708 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 10:09:02.0648        SessionId: 4733 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 10:11:26.6149        SessionId: 4784 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 10:12:41.5382        SessionId: 4809 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-a9e5-48eb756fb576  ClientIp: *     Version: 2.4.310        OS: Android 10
2023-06-03 10:20:46.5349        SessionId: 4930 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9f7f-322f160defc2  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 10:32:40.9120        SessionId: 5048 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-bbc3-20f99726c5f2  ClientIp: *     Version: 2.6.326        OS: Android 8.0.0
2023-06-03 11:07:22.1668        SessionId: 5364 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-a52a-3fc395a31ca9  ClientIp: *     Version: 2.6.326        OS: Android 11
2023-06-03 11:12:53.1389        SessionId: 5409 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-8446-59615912fb82  ClientIp: *     Version: 2.6.326        OS: Android 11
2023-06-03 11:21:36.4403        SessionId: 5472 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-888d-d63a9f5bf1c3  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 11:21:44.8686        SessionId: 5475 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-888d-d63a9f5bf1c3  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 11:21:55.8550        SessionId: 5476 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-888d-d63a9f5bf1c3  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 11:33:58.0707        SessionId: 5591 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-bbc3-20f99726c5f2  ClientIp: *     Version: 2.6.326        OS: Android 8.0.0
2023-06-03 11:34:32.3281        SessionId: 5597 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-970a-e7873d00993e  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 11:39:46.6377        SessionId: 5640 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-9b17-54949c9f9c95  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 11:56:50.8280        SessionId: 5787 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-b444-83b83f3f233d  ClientIp: *     Version: 2.4.310        OS: Android 8.0.0
2023-06-03 12:02:32.2391        SessionId: 5831 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-adec-1d3dac87b179  ClientIp: *     Version: 2.4.310        OS: Android 11
2023-06-03 12:10:50.3633        SessionId: 5896 New     TokenId: **-9283-642708266623   ClientCount: 0          ClientId: **-98ab-2769cd858890  ClientIp: *     Version: 2.4.310        OS: Android 11

My current proposal is to limit users from connecting with more than two devices per day, regardless of whether the previous device was disconnected or not. This is a temporary solution I suggest.

@bobvhood
Copy link
Collaborator

bobvhood commented Jun 3, 2023

Have you specified MaxClientCount when you create the token? Does the new session drop the old ones, or is there a bug? What is your server version?

@trudyhood, it looks like the ClientCount log report is wrong by FileAccessServer

@AmirHosseinCV
Copy link
Author

AmirHosseinCV commented Jun 3, 2023

Yes, I've set the client limit when I was creating the token. The new sessions do drop the old ones, but after a few minutes, the old ones connect again (But still only two devices are connected at the same time). The server version is: 2.8.361.0.
Yes, client count is always zero. However, I've filtered the session logs, the main file contains some logs like this:

2023-06-03 18:48:00.0515        SessionId: 3759 New     TokenId: **-a022-a3f61f1962c0   ClientCount: 0          ClientId: **-aa63-06ce63b3a6c6  ClientIp: *     Version: 2.9.369        OS: Android 11
2023-06-03 18:48:02.9357        SessionId: 2972 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:48:10.8753        SessionId: 201  Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:48:13.0425        SessionId: 3341 Close   Actor: Access   SuppressBy: YourSelf    ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:48:14.9186        SessionId: 3760 New     TokenId: **-b2b2-15006c9afcbd   ClientCount: 0          ClientId: **-aaa1-010ea40556d1  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 18:48:17.2402        SessionId: 3761 New     TokenId: **-ada0-2fe3666a97f7   ClientCount: 0          ClientId: **-8750-e74945b81ebc  ClientIp: *     Version: 2.4.303        OS: Android 10
2023-06-03 18:48:22.0638        SessionId: 3760 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:48:24.8640        SessionId: 3452 Close   Actor: Access   SuppressBy: None        ErrorCode: SessionError         Message: Exception of type 'VpnHood.Server.Exceptions.ServerSessionException' was thrown.
2023-06-03 18:48:28.0330        SessionId: 3545 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:48:28.1709        SessionId: 3762 New     TokenId: **-a8ad-ccebb45d7995   ClientCount: 0          ClientId: **-bd36-7621128f6cfc  ClientIp: *     Version: 2.8.360        OS: Android 11
2023-06-03 18:48:29.7384        SessionId: 3763 New     TokenId: **-b2b2-15006c9afcbd   ClientCount: 0          ClientId: **-aaa1-010ea40556d1  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 18:48:30.1369        SessionId: 3764 New     TokenId: **-8ac6-e46345b5fe89   ClientCount: 0          ClientId: **-bcb5-7f1e017bd838  ClientIp: *     Version: 2.4.303        OS: Android 11
2023-06-03 18:48:31.6147        SessionId: 3765 New     TokenId: **-958f-2dfafccbff4b   ClientCount: 0          ClientId: **-815a-39ba4c0b2ec5  ClientIp: *     Version: 2.8.360        OS: Android 11
2023-06-03 18:48:35.1435        SessionId: 3766 New     TokenId: **-8cd3-cd26e7fa7a20   ClientCount: 0          ClientId: **-90ac-62d628708e7b  ClientIp: *     Version: 2.6.326        OS: Android 13
2023-06-03 18:48:40.3356        SessionId: 3610 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:48:44.5170        SessionId: 3767 New     TokenId: **-8179-7c04a0d09806   ClientCount: 0          ClientId: **-be0c-f1699bece6a9  ClientIp: *     Version: 2.8.360        OS: Android 10
2023-06-03 18:48:46.5374        SessionId: 3768 New     TokenId: **-a1d3-ae5b864fcec9   ClientCount: 0          ClientId: **-a45d-f346d4f36e1d  ClientIp: *     Version: 2.6.326        OS: Android 11
2023-06-03 18:48:53.4280        SessionId: 3753 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:48:53.4533        SessionId: 3663 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:48:56.3668        SessionId: 3769 New     TokenId: **-8898-28f0795dfc31   ClientCount: 0          ClientId: **-a0b2-8a5f7e9667c3  ClientIp: *     Version: 2.6.326        OS: Android 9
2023-06-03 18:49:03.3103        SessionId: 3551 Close   Actor: Access   SuppressBy: YourSelf    ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:12.8119        SessionId: 3770 New     TokenId: **-ab13-78d2107fc779   ClientCount: 0          ClientId: **-b6f4-026e719be82b  ClientIp: *     Version: 2.6.326        OS: Android 11
2023-06-03 18:49:22.9514        SessionId: 3553 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:22.9588        SessionId: 3178 Close   Actor: Access   SuppressBy: YourSelf    ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:26.4145        SessionId: 3544 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:49:28.8162        SessionId: 2354 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:49:34.8558        SessionId: 3771 New     TokenId: **-ab80-e4f72160628e   ClientCount: 0          ClientId: **-977e-b72b1a58c374  ClientIp: *     Version: 2.9.369        OS: Android 11
2023-06-03 18:49:35.4543        SessionId: 3301 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:49:37.9532        SessionId: 3557 Close   Actor: Access   SuppressBy: YourSelf    ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:37.9532        SessionId: 3556 Close   Actor: Access   SuppressBy: YourSelf    ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:37.9627        SessionId: 2993 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:46.9212        SessionId: 3772 New     TokenId: **-9b86-d66de688e463   ClientCount: 0          ClientId: **-8670-0598286e3283  ClientIp: *     Version: 2.6.326        OS: Android 10
2023-06-03 18:49:48.6268        SessionId: 3773 New     TokenId: **-ada0-2fe3666a97f7   ClientCount: 0          ClientId: **-9d5c-1568c3f919f1  ClientIp: *     Version: 2.4.303        OS: Android 11
2023-06-03 18:49:50.8304        SessionId: 3774 New     TokenId: **-a590-d240f819a6d7   ClientCount: 0          ClientId: **-8447-ba7db8e46d3e  ClientIp: *     Version: 2.4.310        OS: Android 10
2023-06-03 18:49:55.4552        SessionId: 3775 New     TokenId: **-baf5-cc21b4e4a0a5   ClientCount: 0          ClientId: **-b19a-ff592d55c979  ClientIp: *     Version: 2.6.326        OS: Android 10
2023-06-03 18:49:58.0112        SessionId: 3665 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:49:58.7640        SessionId: 3776 New     TokenId: **-a1da-3bd8d46419e4   ClientCount: 0          ClientId: **-bdec-79b97a710824  ClientIp: *     Version: 2.4.304        OS: Android 13
2023-06-03 18:50:02.8091        SessionId: 3666 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:50:13.2508        SessionId: 3564 Close   Actor: Access   SuppressBy: YourSelf    ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:50:14.6375        SessionId: 3777 New     TokenId: **-80e7-2df0b58cdd84   ClientCount: 0          ClientId: **-9bcc-91ed2966ad11  ClientIp: *     Version: 2.4.303        OS: Android 12
2023-06-03 18:50:15.5521        SessionId: 3778 New     TokenId: **-a060-0015102c2569   ClientCount: 0          ClientId: **-84ce-b24ee14bbcd0  ClientIp: *     Version: 2.6.326        OS: Android 9
2023-06-03 18:50:20.6146        SessionId: 3779 New     TokenId: **-bee7-4dee043d649e   ClientCount: 0          ClientId: **-8601-6719c5d9ed3a  ClientIp: *     Version: 2.6.326        OS: Android 12
2023-06-03 18:50:33.0667        SessionId: 3660 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:50:37.5090        SessionId: 3780 New     TokenId: **-9e2e-4a87777661af   ClientCount: 0          ClientId: **-b708-0c3d8512201e  ClientIp: *     Version: 2.6.344        OS: Android 9
2023-06-03 18:50:38.4348        SessionId: 3781 New     TokenId: **-9170-4305ab86422b   ClientCount: 0          ClientId: **-8766-2a35cac91940  ClientIp: *     Version: 2.6.326        OS: Android 11
2023-06-03 18:50:41.6580        SessionId: 3782 New     TokenId: **-aafb-984d52d945c2   ClientCount: 0          ClientId: **-8c84-7897325002d4  ClientIp: *     Version: 2.8.360        OS: Android 8.0.0
2023-06-03 18:50:42.1566        SessionId: 3783 New     TokenId: **-91fc-6b5de83bf457   ClientCount: 0          ClientId: **-884e-99c8f825e5d6  ClientIp: *     Version: 2.6.326        OS: Android 13
2023-06-03 18:50:42.6427        SessionId: 3784 New     TokenId: **-920d-2a15038cc370   ClientCount: 0          ClientId: **-9fe1-7ec0856aa50c  ClientIp: *     Version: 2.6.326        OS: Android 10
2023-06-03 18:50:47.9432        SessionId: 3571 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:50:47.9632        SessionId: 2659 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:50:55.1485        SessionId: 3711 Close   Actor: User     SuppressBy: None        ErrorCode: SessionClosed        Message: None
2023-06-03 18:51:01.4507        SessionId: 3785 New     TokenId: **-91fc-6b5de83bf457   ClientCount: 0          ClientId: **-9d0a-864ff8b3a5d7  ClientIp: *     Version: 2.6.326        OS: Android 7.0
2023-06-03 18:51:09.6273        SessionId: 3363 Close   Actor: Access   SuppressBy: Other       ErrorCode: SessionSuppressedBy  Message: None
2023-06-03 18:51:14.4676        SessionId: 3786 New     TokenId: **-8116-f6349997767a   ClientCount: 0          ClientId: **-9b6e-dcc3603aef54  ClientIp: *     Version: 2.6.326        OS: Android 13
2023-06-03 18:51:16.3658        SessionId: 3787 New     TokenId: **-9e2e-4a87777661af   ClientCount: 0          ClientId: **-8fbd-dba6d30329a5  ClientIp: *     Version: 2.8.360        OS: Android 9

@bobvhood
Copy link
Collaborator

bobvhood commented Jun 3, 2023

OK, So the users wouldn't get proper service while using the shard token, and this consequence should prevent them to share it. We also plan to change this strategy and block the new connections instead of dropping the old ones. However, it may lead users to share their tokens and make a user always connected.

Anyway, why don't you delete the token?

@AmirHosseinCV
Copy link
Author

"We also plan to change this strategy and block the new connections instead of dropping the old ones."
Sounds good!

Sure, that's the temporary solution I'll go with. There are many such tokens! I'm in the process of creating an external service that will take care of removing them and notifying their respective owners.

@bobvhood
Copy link
Collaborator

bobvhood commented Jun 5, 2023

Merged into #340

@bobvhood bobvhood closed this as completed Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting for info Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants