mirror of
https://git.numenor-labs.us/dsfx.git
synced 2025-04-29 08:10:34 +00:00
update readme
This commit is contained in:
parent
4e6d33ad81
commit
6ac855b0d1
@ -48,6 +48,8 @@ The dsfx-server requires a listening host, port, and a master key (ECDSA private
|
||||
|
||||
./dsfx-server -host localhost -port 8000 -masterKey /path/to/masterkey.pem
|
||||
|
||||
> Note, if you need to generate a new ECDSA key, you can use the following command: `go run ./cmd/genid > path/to/masterkey.pem`
|
||||
|
||||
Command-line flags for dsfx-server:
|
||||
|
||||
-host (default "localhost")
|
||||
@ -107,7 +109,7 @@ Contributions to dsfx are welcome and encouraged!
|
||||
### How to Contribute
|
||||
|
||||
1. **Fork the Repository:** Create your own branch from the latest code in `main`.
|
||||
2. **Make Your Changes:** Follow the [TigerStyle for Go](./TIGERSTYLE.md) guidelines to ensure code consistency and quality.
|
||||
2. **Make Your Changes:** Follow the [TigerStyle for Go](./tigerstyle.md) guidelines to ensure code consistency and quality.
|
||||
3. **Write Tests:** Ensure that new features and bug fixes include proper tests.
|
||||
4. **Submit a Pull Request:** Document your changes clearly in your pull request.
|
||||
|
||||
@ -119,4 +121,4 @@ Please use the Git repository's issue tracker to report bugs or to suggest new f
|
||||
|
||||
## License
|
||||
|
||||
dsfx is distributed under the MIT License. See [LICENSE](LICENSE) for details.
|
||||
dsfx is distributed under the MIT License. See [LICENSE](./LICENSE) for details.
|
||||
|
@ -1,52 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
MasterKeyPath string `json:"masterKeyPath"`
|
||||
DataDirectory string `json:"dataDirectory"`
|
||||
}
|
||||
|
||||
// LoadConfig loads the configuration from the given path.
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
var config Config
|
||||
configFile, err := os.Open(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer configFile.Close()
|
||||
err = json.NewDecoder(configFile).Decode(&config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
func LoadMasterKey(path string) (*ecdsa.PrivateKey, error) {
|
||||
masterKeyFile, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// The second argument is not an error.
|
||||
derEncoded, _ := pem.Decode(masterKeyFile)
|
||||
if derEncoded == nil {
|
||||
return nil, fmt.Errorf("failed to decode master key file")
|
||||
}
|
||||
|
||||
masterKey, err := x509.ParseECPrivateKey(derEncoded.Bytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return masterKey, nil
|
||||
}
|
@ -2,6 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
@ -98,3 +101,23 @@ func handleConnection(ctx context.Context, conn net.Conn) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func LoadMasterKey(path string) (*ecdsa.PrivateKey, error) {
|
||||
masterKeyFile, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// The second argument is not an error.
|
||||
derEncoded, _ := pem.Decode(masterKeyFile)
|
||||
if derEncoded == nil {
|
||||
return nil, fmt.Errorf("failed to decode master key file")
|
||||
}
|
||||
|
||||
masterKey, err := x509.ParseECPrivateKey(derEncoded.Bytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return masterKey, nil
|
||||
}
|
||||
|
@ -14,19 +14,6 @@ import (
|
||||
"koti.casa/numenor-labs/dsfx/shared/dlog"
|
||||
)
|
||||
|
||||
type Hand struct {
|
||||
State byte
|
||||
Identity *ecdsa.PrivateKey
|
||||
AuthMessage []byte
|
||||
}
|
||||
|
||||
func NewHandshake(identity *ecdsa.PrivateKey) *Hand {
|
||||
return &Hand{
|
||||
State: 0,
|
||||
Identity: identity,
|
||||
}
|
||||
}
|
||||
|
||||
// Handshake initiates the handshake process between the given actor
|
||||
// and the remote actor.
|
||||
func Handshake(
|
||||
|
Loading…
x
Reference in New Issue
Block a user