Key Value Services is a cli tools that help to you create your Key-Value store services.
I want to create a content sharing tool that is managed by only one person and readable by many people in a secure network environment, so that I can use some common content in the terminal.
curl -fsSL https://raw.githubusercontent.com/youth95/kvs/main/install.sh | sh
or use proxy
curl -fsSL https://ghproxy.com/https://raw.githubusercontent.com/youth95/kvs/main/install.sh | PROXY=https://ghproxy.com/ sh
or use cargo
cargo install key_value_service
This project is still in the early stage of development and is only used as a development tool. Do not use it for data storage in the production environment. If you have this requirement, I recommend that you use redis. Some APIs will undergo destructive changes without notice.
- Start kvs in your server
> kvs start
2022-03-18T15:59:26.503861Z INFO starting with 0.0.0.0:8888 successfully!
- Login the kvs services from client
> kvs -r 0.0.0.0:8888 login
2022-03-18T16:05:05.022305Z INFO Token: FAAAAAAAAACUH40t6d+A9jzhexGHktUINvWwL317xp1/AQAAFAAAAAAAAACrtlLcjeSqhMZCj5rnNn2hkf0K/w==
2022-03-18T16:05:05.022393Z INFO Save Token file to: .kvs/token
- Create a private key value
> kvs -r 0.0.0.0:8888 create foo "hello world"
default, kvs will encrypt the value use your priv_key
in local. Remote just judge the key's owner. The decryption process needs to be completed by the client itself.
- Read a key
> kvs -r 0.0.0.0:8888 read foo
hello world
- Create a public key value
> kvs -r 0.0.0.0:8888 create priv_foo "priv hello world" -p
If you just do. kvs will send the value and save value as plaintext in remote.
- Read a private key
> kvs -r 0.0.0.0:8888 cat priv_foo
priv hello world
- Delete a Key
> kvs -r 0.0.0.0:8888 delete priv_foo
You just can delete key that owner is you.
- Update a Key
kvs -r 0.0.0.0:8888 create priv_foo "this is change data"
kvs -r 0.0.0.0:8888 read priv_foo
this is change data
- show remote info
> kvs -r 0.0.0.0:8888 remote
0.1.3
- show local info
> kvs local
scope: 0x4d7153428dd617a410f114468d212a9cd1b7ccd0
pub: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD9qWAweIhnLfBdjYj8oty1z2FYycQ8qhebrDLCQBJPTF1IfV282WCHET7Fsjd1C9+XMbW2xT0f73cZgSExgILeGjZFlx9gEf5VVJyBezfQ6yU2V9Emo58zRh6fjfoBGUsXmVIJIGCpnVjHg/ECEVKuDVQ3h0SEHrdxE98bSl9RIQIDAQAB
- Read other scope key
> kvs -r 0.0.0.0:8888 read 0xad359ae3e478342ed2b5512ed7ff4ebb3ceb2dd:test_pub
pub content
- Restart the kvs Server
> kvs restart
- Stop the kvs Server
> kvs stop
- remove all keys
> kvs -r 0.0.0.0:8888 list | awk -F '\t' '{print "kvs delete " $2}' | bash
Your team have a big list of resource id.
# important_resource_id.txt
...
A7EB0B7B-3E27-4531-B239-750300EE8D0C
B9164246-49E3-45F1-A8CE-D871CEBE3971
92312D9B-B2D8-4A92-B7B5-9A5491FF9BEC
8E1B24ED-0023-45E0-BF34-1548C8D8884D
...
Some times, the team member need create the url by the big list.
# important_resource_urls.txt
...
http://xxx.xxx.xxx.xxx/app/goods/A7EB0B7B-3E27-4531-B239-750300EE8D0C
http://xxx.xxx.xxx.xxx/app/goods/B9164246-49E3-45F1-A8CE-D871CEBE3971
http://xxx.xxx.xxx.xxx/app/goods/92312D9B-B2D8-4A92-B7B5-9A5491FF9BEC
http://xxx.xxx.xxx.xxx/app/goods/8E1B24ED-0023-45E0-BF34-1548C8D8884D
...
Let's assume we have written a command line tool named transform
to handle this case.
cat important_resource_urls.txt | transform
The question is, how do I share important_resource_urls.txt
with other team members.
Granted, there are many ways to share it. But you can fast finish it if you use the kvs
.
# create the key
kvs create important_resource_urls -f important_resource_urls.txt
# and then, other team member can use it.
kvs read important_resource_urls | transform
curl https://xxx/a.json | json "important" | kvs create important -f -p
kvs read important -s your_scope
You can tail your pub key
to some website.
> kvs local
scope: 0x4d7153428dd617a410f114468d212a9cd1b7ccd0
pub: MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD9qWAweIhnLfBdjYj8oty1z2FYycQ8qhebrDLCQBJPTF1IfV282WCHET7Fsjd1C9+XMbW2xT0f73cZgSExgILeGjZFlx9gEf5VVJyBezfQ6yU2V9Emo58zRh6fjfoBGUsXmVIJIGCpnVjHg/ECEVKuDVQ3h0SEHrdxE98bSl9RIQIDAQAB
Website will tail you a cipher text.
website: (your pub key) + (random value) -> (cipher text)
Now you can use kvs de
command to decrypt the (cipher text)
> kvs de (cipher text)
(random value)
Tail the (random value) to website. you will prove yourself to website.
Community
-
add
sync
command to sync all file in one directory and use the relative directory as key. -
add
list
command to list all key meta in your scope. -
add
restart
command to restart the server. -
add
stop
command to stop the server. -
add
set
andget
command to config some value in client local. -
add
set
command to set the config in client local. -
add
--file
option in create and upload command. -
add the same option in
sync
command look likecreate
update
. -
append show public key in
kvs local
. -
add
kvs de
command to decrypt some content. use local private key by default. -
add
kvs en
command to encrypt some content. use local public key by default. -
remove
--scope
option in read, you can usekvs read your_scope:some_key
to read a public key. -
add
kvs set whitelist
command to set a whitelist. -
add
kvs search
command to search some content in different repository. -
add
kvs upgrade
command to upgrade the kvs bin file. -
add
--local
global option. means-r 0.0.0.0:8888
. -
add
kvs migrate
command to migrate the data to other repository node. -
fix
--file
option in create and upload command can be not give the filename, kvs will use the stdin content as value if you do that. -
add github action to release the bin file.
-
add unit test and docs.
-
config docker container.
-
multi identity support.
-
refactor the
Store trait
and implementFSStore
andOSSStore
. -
add server config to config the store backend. eg use
OSSStore
. -
identity data monitoring.
-
advocate some key representing identity.
-
refactor the
aes session
to be aaes stream
.
Commercial
- add the p2p in share key progress.
- build a free central storage node.
- design reasonable pricing.
- regulatory public data.
- get public data by http.