blob: 22e5230ab70259d897f781658da788ee66b48474 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package main
import (
"crypto/ed25519"
"encoding/base64"
"flag"
"fmt"
"os"
"strings"
)
func main() {
flag.Parse()
if flag.Arg(0) == "setup" {
// Create keys
pubKey, privKey, err := ed25519.GenerateKey(nil)
if err != nil {
panic(err)
}
err = os.WriteFile("pubkey", pubKey, 644)
if err != nil {
panic(err)
}
err = os.WriteFile("privkey", privKey, 600)
if err != nil {
panic(err)
}
// Create servers file
_, err = os.Create("servers")
if err != nil {
panic(err)
}
fmt.Printf("Success! Your user ID: %s", base64.RawURLEncoding.EncodeToString(pubKey))
return
}
pubKeyBytes, err := os.ReadFile("pubkey")
if err != nil {
panic(err)
}
pubKey := ed25519.PublicKey(pubKeyBytes)
privKeyBytes, err := os.ReadFile("privkey")
if err != nil {
panic(err)
}
privKey := ed25519.PublicKey(privKeyBytes)
serversBytes, err := os.ReadFile("servers")
if err != nil {
panic(err)
}
servers := strings.Split(string(serversBytes), "\n")
if flag.Arg(0) == "associate" {
}
}
|