[GH-ISSUE #127] Howto reset a restricted user #107

Closed
opened 2026-02-26 12:33:59 +03:00 by kerem · 7 comments
Owner

Originally created by @aboka2k on GitHub (Aug 27, 2020).
Original GitHub issue: https://github.com/cbeuw/Cloak/issues/127

hi, hv search but can't find a way to reset a restricted user. for eg. i allocate 1GB each month for them, do i need to reset it, or it will reset itself every 30 days? but what if i want to start the count from 1st starting next month? so i need to find a way to reset the their value

i try download the .db file to my Windows pc, and use MS Access & DB Browser for SQLite but both also cant open the file. Please advice.

Thank you,

Originally created by @aboka2k on GitHub (Aug 27, 2020). Original GitHub issue: https://github.com/cbeuw/Cloak/issues/127 hi, hv search but can't find a way to reset a restricted user. for eg. i allocate 1GB each month for them, do i need to reset it, or it will reset itself every 30 days? but what if i want to start the count from 1st starting next month? so i need to find a way to reset the their value i try download the .db file to my Windows pc, and use MS Access & DB Browser for SQLite but both also cant open the file. Please advice. Thank you,
kerem closed this issue 2026-02-26 12:33:59 +03:00
Author
Owner

@HirbodBehnam commented on GitHub (Aug 28, 2020):

Hello
The database is created using an engine called bbolt. You can try this database browser in order to explore the database and edit values. I think this is also possible via Cloak Panel. (Delete and add a new entry)
You can automate this task (to for example reset users at the beginning of the month) but it might be not easy. You have to use something like cron to start a script that:

  1. Starts cloak client in admin mode (Example)
  2. Collects all users and extracts their UIDs (Example)
  3. Delete all UIDs (Example of deleting one user)
  4. Add UIDs again with a desired quota (Example of adding one limited user)

Good luck!

<!-- gh-comment-id:682356157 --> @HirbodBehnam commented on GitHub (Aug 28, 2020): Hello The database is created using an engine called [bbolt](https://github.com/etcd-io/bbolt). You can try [this](https://github.com/br0xen/boltbrowser) database browser in order to explore the database and edit values. I think this is also possible via [Cloak Panel](https://github.com/cbeuw/Cloak-panel/). (Delete and add a new entry) You can automate this task (to for example reset users at the beginning of the month) but it might be not easy. You have to use something like `cron` to start a script that: 1. Starts cloak client in admin mode ([Example](https://github.com/HirbodBehnam/Shadowsocks-Cloak-Installer/blob/master/Cloak2-Installer.sh#L30)) 2. Collects all users and extracts their UIDs ([Example](https://github.com/HirbodBehnam/Shadowsocks-Cloak-Installer/blob/master/Cloak2-Installer.sh#L262-L265)) 3. Delete all UIDs ([Example of deleting one user](https://github.com/HirbodBehnam/Shadowsocks-Cloak-Installer/blob/master/Cloak2-Installer.sh#L245)) 4. Add UIDs again with a desired quota ([Example of adding one limited user](https://github.com/HirbodBehnam/Shadowsocks-Cloak-Installer/blob/master/Cloak2-Installer.sh#L152-L153)) Good luck!
Author
Owner

@aboka2k commented on GitHub (Aug 28, 2020):

hi @HirbodBehnam thanks a lot for the reply, hopefully another 'issue' solve :) i follow your advice and try to install bbolt on my ubuntu 20.04 LTS vps, but it will always give 'error':

I run this code 'go get github.com/br0xen/boltbrowser' and download the git file and put together inside the /go/bin/ folder
`root@v2ray:
/go/bin# ls
boltbrowser go.mod main.go README.md screen.go
bolt_model.go go.sum mainloop.go screen_about.go stringify.go
cursor.go LICENSE mainloop_windows.go screen_browser.go style.go

root@v2ray:~/go/bin# boltbrowser --help
boltbrowser: command not found
`
same 'error' if i supply the filename with the command - 'boltbrowser /etc/cloak/userinfo.db'. i also try to run/compile using 'go run' 'go build' for some of the 'go' file but no luck :/

any idea how to fix this? in the meantime, i install the Windows version and it is working. but working inside Ubuntu is the first choice as no need to download/upload etc.

What type of 'value' is the field using now? For eg., now the ExpiryTime shows '1684913254' how do i find out/convert its value to x number of days? need to know howto convert back/forth so i can edit them in future.

Thank you,

<!-- gh-comment-id:682403939 --> @aboka2k commented on GitHub (Aug 28, 2020): hi @HirbodBehnam thanks a lot for the reply, hopefully another 'issue' solve :) i follow your advice and try to install bbolt on my ubuntu 20.04 LTS vps, but it will always give 'error': I run this code 'go get github.com/br0xen/boltbrowser' and download the git file and put together inside the ~/go/bin/ folder `root@v2ray:~/go/bin# ls boltbrowser go.mod main.go README.md screen.go bolt_model.go go.sum mainloop.go screen_about.go stringify.go cursor.go LICENSE mainloop_windows.go screen_browser.go style.go root@v2ray:~/go/bin# boltbrowser --help boltbrowser: command not found ` same 'error' if i supply the filename with the command - 'boltbrowser /etc/cloak/userinfo.db'. i also try to run/compile using 'go run' 'go build' for some of the 'go' file but no luck :/ any idea how to fix this? in the meantime, i install the Windows version and it is working. but working inside Ubuntu is the first choice as no need to download/upload etc. What type of 'value' is the field using now? For eg., now the ExpiryTime shows '1684913254' how do i find out/convert its value to x number of days? need to know howto convert back/forth so i can edit them in future. Thank you,
Author
Owner

@HirbodBehnam commented on GitHub (Aug 28, 2020):

Sometimes GO does not add ~/go/bin in the PATH. You can manually add it later. At first you should run it like ./boltbrowser --help or if you are in another directory you can try ~/go/bin/boltbrowser --help.
Also ExpiryTime value is in unix epoch format. You can use something like this site to convert linux epoch in human readable format and vise versa.

<!-- gh-comment-id:682485186 --> @HirbodBehnam commented on GitHub (Aug 28, 2020): Sometimes GO does not add `~/go/bin` in the PATH. You can manually add it later. At first you should run it like `./boltbrowser --help` or if you are in another directory you can try `~/go/bin/boltbrowser --help`. Also `ExpiryTime` value is in unix epoch format. You can use something like [this site](https://www.epochconverter.com/) to convert linux epoch in human readable format and vise versa.
Author
Owner

@aboka2k commented on GitHub (Aug 28, 2020):

@HirbodBehnam thanks alot as you have help solve another piece of the puzzle 👍

p/s - pls take a look at this if possible, https://github.com/cbeuw/Cloak/issues/126 , its the last piece of puzzle for this Cloak project. cheers~!

<!-- gh-comment-id:682501140 --> @aboka2k commented on GitHub (Aug 28, 2020): @HirbodBehnam thanks alot as you have help solve another piece of the puzzle :+1: p/s - pls take a look at this if possible, [https://github.com/cbeuw/Cloak/issues/126](https://github.com/cbeuw/Cloak/issues/126) , its the last piece of puzzle for this Cloak project. cheers~!
Author
Owner

@aboka2k commented on GitHub (Aug 28, 2020):

p/ss - im sorry, what is the correct way to stop ck-server(etc) so we could edit the database? as it won't let me open - 'File /etc/cloak/userinfo.db is locked. Make sure it's not used by another app and try again'

is this the correct way to do it - find ck-server PID then kill it, edit the database and then reboot the server?

thank you,

<!-- gh-comment-id:682503765 --> @aboka2k commented on GitHub (Aug 28, 2020): p/ss - im sorry, what is the correct way to stop ck-server(etc) so we could edit the database? as it won't let me open - 'File /etc/cloak/userinfo.db is locked. Make sure it's not used by another app and try again' is this the correct way to do it - find ck-server PID then kill it, edit the database and then reboot the server? thank you,
Author
Owner

@HirbodBehnam commented on GitHub (Aug 28, 2020):

Hello
As I said before I don't know about CDN mode and I have not tested it. (and I think I never will because I'm from Iran)
For editing the database you need to at first stop the cloak using systemctl stop cloak-server to stop cloak. Then edit the database and then use systemctl start cloak-server to start the cloak again.

<!-- gh-comment-id:682603645 --> @HirbodBehnam commented on GitHub (Aug 28, 2020): Hello As I said before I don't know about CDN mode and I have not tested it. (and I think I never will because I'm from Iran) For editing the database you need to at first stop the cloak using `systemctl stop cloak-server` to stop cloak. Then edit the database and then use `systemctl start cloak-server` to start the cloak again.
Author
Owner

@LindaFerum commented on GitHub (Jun 27, 2024):

In case anyone is looking for ways to manipulate userinfo.db using command line (which I am currently struggling with) this issue (which I self-closed) should provide you with enough to get started

https://github.com/cbeuw/Cloak/issues/268

A CLI tool to inspect bold DB https://developer.hashicorp.com/vault/tutorials/monitoring/inspect-data-boltdb

A tool which apparently can manipulate them (which I am currently trying to sort out into a cron-able bash wrapper) https://github.com/spacewander/boltcli

<!-- gh-comment-id:2194370937 --> @LindaFerum commented on GitHub (Jun 27, 2024): In case anyone is looking for ways to manipulate userinfo.db using command line (which I am currently struggling with) this issue (which I self-closed) should provide you with enough to get started https://github.com/cbeuw/Cloak/issues/268 A CLI tool to inspect bold DB https://developer.hashicorp.com/vault/tutorials/monitoring/inspect-data-boltdb A tool which apparently can manipulate them (which I am currently trying to sort out into a cron-able bash wrapper) https://github.com/spacewander/boltcli
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Cloak#107
No description provided.