more ideas

This commit is contained in:
Risotto Bias 2025-04-07 05:01:15 -06:00
parent 3915036ebd
commit c70dd77203
14 changed files with 82 additions and 0 deletions

1
cmd/kvdel.go Normal file
View file

@ -0,0 +1 @@
package cmd

1
cmd/kvget.go Normal file
View file

@ -0,0 +1 @@
package cmd

1
cmd/kvlist.go Normal file
View file

@ -0,0 +1 @@
package cmd

1
cmd/kvset.go Normal file
View file

@ -0,0 +1 @@
package cmd

1
cmd/serversadd.go Normal file
View file

@ -0,0 +1 @@
package cmd

1
cmd/serverslist.go Normal file
View file

@ -0,0 +1 @@
package cmd

1
cmd/serversremove.go Normal file
View file

@ -0,0 +1 @@
package cmd

11
example/README.md Normal file
View file

@ -0,0 +1,11 @@
# Trade Example
- export a key `export KEY_PASSWD="blarg test"`
- spawn two servers: `./example 8080 &` `./example 8081`
- register the servers:
- `./trade servers add localhost:8080`
- `./trade servers add localhost:8081`
- visit one server: [https://localhost:8080](https://localhost:8080)
- set a value (like "hello world")
- visit the other server: [https://localhost:8081](https://localhost:8081)
- see the value set

5
example/routes.go Normal file
View file

@ -0,0 +1,5 @@
package example
func home() {
}

28
example/server.go Normal file
View file

@ -0,0 +1,28 @@
package example
import (
"fmt"
"net/http"
"os"
"git.bivouac.wiki/use/trade"
)
func main() {
// get key password from env variable
passwd, exist := os.LookupEnv("KEY_PASSWD")
if !exist {
fmt.Println("no KEY_PASSWD environment variable")
os.Exit(1)
}
if len(os.Args) != 1 {
fmt.Println("no key path specified")
os.Exit(1)
}
keypath := os.Args[1]
// spawn trade KV
trade.Load(passwd, keypath, GLOBAL_KV)
// load self key or generate one
// spawn server
http.Serve()
}

9
example/store.go Normal file
View file

@ -0,0 +1,9 @@
package example
import "git.bivouac.wiki/go/gobstore"
var GLOBAL_KV gobstore.GobStore[string]
func init() {
}

6
regdelserver.go Normal file
View file

@ -0,0 +1,6 @@
package trade
// RegDelServer revokes a server's trade access
func RegDelServer() {
}

8
routeget.go Normal file
View file

@ -0,0 +1,8 @@
package trade
// RouteGet responds to a get request after validating the remote server
func RouteGet() {
// validate message
// validate that sender is in allowed servers
// query KV and return
}

8
routeset.go Normal file
View file

@ -0,0 +1,8 @@
package trade
// RouteSet verifies another server's set command
func RouteSet() {
// check signature validity
// check if signature is in list of allowed identities
// set local value
}