update readme

This commit is contained in:
Dustin Stiles 2025-03-09 10:32:16 -04:00
parent 4e6d33ad81
commit 6ac855b0d1
Signed by: duwstiles
GPG Key ID: BCD9912EC231FC87
4 changed files with 27 additions and 67 deletions

View File

@ -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 ./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: Command-line flags for dsfx-server:
-host (default "localhost") -host (default "localhost")
@ -107,7 +109,7 @@ Contributions to dsfx are welcome and encouraged!
### How to Contribute ### How to Contribute
1. **Fork the Repository:** Create your own branch from the latest code in `main`. 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. 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. 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 ## 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.

View File

@ -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
}

View File

@ -2,6 +2,9 @@ package main
import ( import (
"context" "context"
"crypto/ecdsa"
"crypto/x509"
"encoding/pem"
"flag" "flag"
"fmt" "fmt"
"log/slog" "log/slog"
@ -98,3 +101,23 @@ func handleConnection(ctx context.Context, conn net.Conn) error {
return nil 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
}

View File

@ -14,19 +14,6 @@ import (
"koti.casa/numenor-labs/dsfx/shared/dlog" "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 // Handshake initiates the handshake process between the given actor
// and the remote actor. // and the remote actor.
func Handshake( func Handshake(