Desktop Icon & Copy to Clipboard

main
Robert 5 months ago
parent 1440c48191
commit ffdf6262e3
  1. 13
      README
  2. 27
      client.go
  3. 1
      go.mod
  4. 2
      go.sum
  5. BIN
      net-lock.png
  6. 12
      vaultClient.desktop

@ -2,6 +2,7 @@
go get github.com/mattn/go-sqlite3
go get golang.org/x/crypto/bcrypt
go get gopkg.in/yaml.v2
go get github.com/atotto/clipboard
go mod download golang.org/x/term
go mod tidy
@ -10,8 +11,9 @@ go run chaKey.go
nano default.yaml
sudo mkdir /etc/cliVault
sudo mv encrypted_aes_key.pem /etc/cliVault/
sudo cp default.yaml /etc/cliVault/config.yaml
sudo chown $USER:$USER /etc/cliVault
mv encrypted_aes_key.pem /etc/cliVault/
cp default.yaml /etc/cliVault/config.yaml
sudo apt install gcc
CGO_ENABLED=1 go build -o cliVault server.go
@ -32,4 +34,11 @@ sudo systemctl start cliVault
## Client
```
go build -o vaultClient client.go
sudo cp vaultClient /usr/local/bin/
sudo cp net-lock.png /usr/share/icons/net-lock.png
cp vaultClient.desktop ~/.local/share/applications/
update-desktop-database ~/.local/share/applications
OR use /usr/local/share/applications -- for all users
```

@ -4,6 +4,7 @@ import (
"crypto/sha256"
"crypto/rand"
"golang.org/x/crypto/chacha20poly1305"
"github.com/atotto/clipboard"
"encoding/base64"
"encoding/gob"
"encoding/hex"
@ -113,6 +114,21 @@ func chDec(eText string)(string) {
return string(decrypted)
}
func copyText(text string) {
err := clipboard.WriteAll(text)
if err != nil {
fmt.Println("Failed to copy to clipboard:", err)
return
}
fmt.Println("Text copied to clipboard!")
}
func pause() {
var input string
fmt.Print("Press Enter to continue...")
fmt.Scanln(&input)
}
func main() {
configFilePtr := flag.String("config", "config.yaml", "Path to the YAML configuration file")
flag.Parse()
@ -120,6 +136,7 @@ func main() {
if *configFilePtr == "" {
fmt.Println("Please specify a configuration file using -config")
flag.Usage()
pause()
os.Exit(1)
}
@ -127,6 +144,7 @@ func main() {
yamlFile, err := ioutil.ReadFile(*configFilePtr)
if err != nil {
log.Fatalf("Error reading YAML file: %v\n", err)
pause()
}
// Parse the YAML
@ -134,11 +152,13 @@ func main() {
err = yaml.Unmarshal(yamlFile, &config)
if err != nil {
log.Fatalf("Error parsing YAML file: %v\n", err)
pause()
}
// Print the ChaKey
if config.Auth.ChaKey == "" {
fmt.Println("Warning: ChaKey not found in configuration file")
pause()
}
ChaKey = []byte(config.Auth.ChaKey)
@ -212,18 +232,23 @@ func main() {
if err := enc.Encode(req); err != nil {
fmt.Println("Failed to send request:", err)
pause()
return
}
var res Response
if err := dec.Decode(&res); err != nil {
fmt.Println("Failed to receive response:", err)
pause()
return
}
if res.Message != "" {
fmt.Println("Server response:", res.Message)
} else {
fmt.Println("Server response:", chDec(res.Enc))
passwd := chDec(res.Enc)
fmt.Println("Server response:", passwd)
copyText(passwd)
}
pause()
}

@ -9,6 +9,7 @@ require (
)
require (
github.com/atotto/clipboard v0.1.4 // indirect
golang.org/x/sys v0.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

@ -1,3 +1,5 @@
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/mattn/go-sqlite3 v1.14.28 h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A=
github.com/mattn/go-sqlite3 v1.14.28/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -0,0 +1,12 @@
[Desktop Entry]
Version=1.0
Name=PWD_Server
Comment=Password Server
GenericName=PWD_Server
Keywords=pass,password
Exec=/usr/local/bin/vaultClient -config /etc/cliVault/config.yaml
Terminal=false
Type=Application
Path=/etc/cliVault
Icon=/usr/share/icons/net-lock.png
Categories=GNOME;GTK;
Loading…
Cancel
Save