diff --git a/.gitignore b/.gitignore
index e2c1618..a7961a7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -126,4 +126,5 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
-config.ini
\ No newline at end of file
+config.ini
+public.cer
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..e62755d
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..0f1af6e
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Main.go b/Main.go
deleted file mode 100644
index 1f6a634..0000000
--- a/Main.go
+++ /dev/null
@@ -1,61 +0,0 @@
-package main
-
-import (
- "crypto/tls"
- "fmt"
- "git.nevets.tech/Steven/ezconf"
- "github.com/getlantern/systray"
- "os"
- "time"
-)
-
-var Config *ezconf.Configuration
-var Connection *tls.Conn
-
-func main() {
- Config = ezconf.NewConfiguration("./config.ini")
- Connection = New(Config.GetAsString("General.server"), Config.GetAsInt("General.port"))
-
- systray.Run(onReady, onExit)
-}
-
-func onReady() {
- systray.SetIcon(getIcon("assets/icon.ico"))
- systray.SetTooltip("SimpleFileSync")
- itemOne := systray.AddMenuItem("Item-1", "Highlighted Item 1")
- systray.AddSeparator()
- sync := systray.AddMenuItem("Sync", "Trigger Sync Now")
- systray.AddSeparator()
- quit := systray.AddMenuItem("Quit", "Quit")
-
- go func() {
- for {
- select {
- case <-itemOne.ClickedCh:
- if itemOne.Checked() {
- itemOne.Uncheck()
- } else {
- itemOne.Check()
- }
- case <-sync.ClickedCh:
- sync.SetTitle("Syncing...")
- time.Sleep(1000)
- sync.SetTitle("Last sync at " + time.Now().Format(time.TimeOnly))
- case <-quit.ClickedCh:
- systray.Quit()
- }
- }
- }()
-}
-
-func onExit() {
-
-}
-
-func getIcon(location string) []byte {
- bytes, err := os.ReadFile(location)
- if err != nil {
- fmt.Print(err)
- }
- return bytes
-}
diff --git a/assets/information.png b/assets/information.png
new file mode 100644
index 0000000..d47243d
Binary files /dev/null and b/assets/information.png differ
diff --git a/assets/warning.png b/assets/warning.png
new file mode 100644
index 0000000..3c63d16
Binary files /dev/null and b/assets/warning.png differ
diff --git a/c_libs/.idea/.gitignore b/c_libs/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/c_libs/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/c_libs/.idea/c_libs.iml b/c_libs/.idea/c_libs.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/c_libs/.idea/c_libs.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/c_libs/.idea/misc.xml b/c_libs/.idea/misc.xml
new file mode 100644
index 0000000..79b3c94
--- /dev/null
+++ b/c_libs/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/c_libs/.idea/modules.xml b/c_libs/.idea/modules.xml
new file mode 100644
index 0000000..2ae9efd
--- /dev/null
+++ b/c_libs/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/c_libs/.idea/vcs.xml b/c_libs/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/c_libs/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/c_libs/CMakeLists.txt b/c_libs/CMakeLists.txt
new file mode 100644
index 0000000..f522dfc
--- /dev/null
+++ b/c_libs/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.25)
+project(c_libs C)
+
+set(CMAKE_C_STANDARD 11)
+
+include_directories(.)
+
+add_executable(c_libs
+ notification.h notification.hpp notification.cpp cnotification.cpp)
diff --git a/c_libs/cnotification.cpp b/c_libs/cnotification.cpp
new file mode 100644
index 0000000..e69de29
diff --git a/c_libs/notification.cpp b/c_libs/notification.cpp
new file mode 100644
index 0000000..e8fbd78
--- /dev/null
+++ b/c_libs/notification.cpp
@@ -0,0 +1,5 @@
+#include "notification.hpp"
+
+void Notification::buildNotification(void) {
+
+}
diff --git a/c_libs/notification.h b/c_libs/notification.h
new file mode 100644
index 0000000..33562f2
--- /dev/null
+++ b/c_libs/notification.h
@@ -0,0 +1,12 @@
+#ifndef NOTIFICATION_H
+#define NOTIFICATION_H
+#include
+
+typedef struct Notification {
+ FILE *icon;
+ char title[16];
+ char message[];
+} Notification;
+
+int buildNotification(char title[], char message[], FILE *icon);
+#endif
\ No newline at end of file
diff --git a/c_libs/notification.hpp b/c_libs/notification.hpp
new file mode 100644
index 0000000..771757d
--- /dev/null
+++ b/c_libs/notification.hpp
@@ -0,0 +1,9 @@
+class Notification {
+public:
+ FILE icon;
+ char title[16];
+ char message[];
+
+ Notification(FILE _icon, char _title[16], char _message[]):icon(_icon)title(_title){}
+ void buildNotification();
+};
\ No newline at end of file
diff --git a/ezconf b/ezconf
index 397365d..e5bdaa6 160000
--- a/ezconf
+++ b/ezconf
@@ -1 +1 @@
-Subproject commit 397365ddd2fa6359058b7f6dd62eb516387e3994
+Subproject commit e5bdaa67f6b2ad812b8aa5674316af02ae87e652
diff --git a/filetransfer.go b/filetransfer.go
index 06ab7d0..ca83694 100644
--- a/filetransfer.go
+++ b/filetransfer.go
@@ -1 +1,25 @@
package main
+
+import (
+ "fmt"
+ "net"
+ "os"
+)
+
+func testClient() {
+ conn, err := net.Dial("tcp", "localhost:2455")
+ if err != nil {
+ fmt.Printf("Error connecting to server: %v", err)
+ os.Exit(1)
+ }
+ _, err = conn.Write(NewSFS(254).ToBytes())
+ if err != nil {
+ fmt.Printf("Error sending data: %v", err)
+ os.Exit(1)
+ }
+ err = conn.Close()
+ if err != nil {
+ fmt.Printf("Error closing connection: %v", err)
+ os.Exit(1)
+ }
+}
diff --git a/go.mod b/go.mod
index 8e5087e..fea80b1 100644
--- a/go.mod
+++ b/go.mod
@@ -7,9 +7,12 @@ replace git.nevets.tech/Steven/ezconf v0.0.0-20230501190348-397365ddd2fa => ./ez
require (
git.nevets.tech/Steven/ezconf v0.0.0-20230501190348-397365ddd2fa
github.com/getlantern/systray v1.2.1
+ github.com/sqweek/dialog v0.0.0-20220809060634-e981b270ebbf
)
require (
+ github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d // indirect
+ github.com/gen2brain/beeep v0.0.0-20230307103607-6e717729cb4f // indirect
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 // indirect
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 // indirect
github.com/getlantern/golog v0.0.0-20190830074920-4ef2e798c2d7 // indirect
@@ -17,8 +20,12 @@ require (
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
github.com/go-stack/stack v1.8.0 // indirect
+ github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
+ github.com/godbus/dbus/v5 v5.1.0 // indirect
+ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
- golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect
+ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
+ golang.org/x/sys v0.8.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
diff --git a/go.sum b/go.sum
index ee63953..473039e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,11 @@
+github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf h1:FPsprx82rdrX2jiKyS17BH6IrTmUBYqZa/CXT4uvb+I=
+github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf/go.mod h1:peYoMncQljjNS6tZwI9WVyQB3qZS6u79/N3mBOcnd3I=
+github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d h1:2xp1BQbqcDDaikHnASWpVZRjibOxu7y9LhAv04whugI=
+github.com/TheTitanrain/w32 v0.0.0-20200114052255-2654d97dbd3d/go.mod h1:peYoMncQljjNS6tZwI9WVyQB3qZS6u79/N3mBOcnd3I=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/gen2brain/beeep v0.0.0-20230307103607-6e717729cb4f h1:oRm7Hy2dQWfHgOuOWRaYZf+kZcWJst7fxAlq+yjdLss=
+github.com/gen2brain/beeep v0.0.0-20230307103607-6e717729cb4f/go.mod h1:0W7dI87PvXJ1Sjs0QPvWXKcQmNERY77e8l7GFhZB/s4=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4=
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY=
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So=
@@ -16,15 +22,28 @@ github.com/getlantern/systray v1.2.1 h1:udsC2k98v2hN359VTFShuQW6GGprRprw6kD6539J
github.com/getlantern/systray v1.2.1/go.mod h1:AecygODWIsBquJCJFop8MEQcJbWFfw/1yWbVabNgpCM=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
+github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE=
+github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
+github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
+github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
+github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/sqweek/dialog v0.0.0-20220809060634-e981b270ebbf h1:pCxn3BCfu8n8VUhYl4zS1BftoZoYY0J4qVF3dqAQ4aU=
+github.com/sqweek/dialog v0.0.0-20220809060634-e981b270ebbf/go.mod h1:/qNPSY91qTz/8TgHEMioAUc6q7+3SOybeKczHMXFcXw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
+github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk=
+github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
+golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..8c4d2eb
--- /dev/null
+++ b/main.go
@@ -0,0 +1,86 @@
+package main
+
+import (
+ "crypto/tls"
+ "fmt"
+ "git.nevets.tech/Steven/ezconf"
+ "github.com/getlantern/systray"
+ "github.com/sqweek/dialog"
+ "os"
+ "time"
+)
+
+var Config *ezconf.Configuration
+var Connection *tls.Conn
+
+func main() {
+ Config = ezconf.NewConfiguration("./config.ini")
+ //var err error
+ //Connection, err = NewConnection(Config.GetAsString("General.server"), Config.GetAsInt("General.port"))
+ //if err != nil {
+ // fmt.Printf("Error establishing connection: %v", err)
+ // os.Exit(1)
+ //}
+
+ //_, err = Connection.Write(NewSFS(254).ToBytes())
+ //if err != nil {
+ // fmt.Printf("Error sending data: %v", err)
+ // os.Exit(1)
+ //}
+ //
+ //rawData := make([]byte, 1)
+ //_, err = Connection.Read(rawData)
+ //if err != nil {
+ // fmt.Printf("Error reading data: %v", err)
+ // os.Exit(1)
+ //}
+ //sfsData := NewSFSFromBytes(rawData)
+ //fmt.Printf("SFS Data: %v", sfsData)
+ //
+ //err = Connection.Close()
+ //if err != nil {
+ // fmt.Printf("Error closing connection: %v", err)
+ // os.Exit(1)
+ //}
+
+ sendNotification("Notification", "This is the message displayed!")
+
+ systray.Run(onReady, onExit)
+}
+
+func onReady() {
+ systray.SetIcon(getIcon("assets/icon.ico"))
+ systray.SetTooltip("SimpleFileSync")
+ itemOne := systray.AddMenuItem("Dialog", "Opens Dialog Box")
+ systray.AddSeparator()
+ sync := systray.AddMenuItem("Sync", "Trigger Sync Now")
+ systray.AddSeparator()
+ quit := systray.AddMenuItem("Quit", "Quit")
+
+ go func() {
+ for {
+ select {
+ case <-itemOne.ClickedCh:
+ dialog.Message("This is a popup from Simple File Sync!").Title("Simple File Sync").Info()
+ case <-sync.ClickedCh:
+ sync.SetTitle("Syncing...")
+ time.Sleep(1000)
+ sync.SetTitle("Last sync at " + time.Now().Format(time.TimeOnly))
+ case <-quit.ClickedCh:
+ systray.Quit()
+ }
+ }
+ }()
+}
+
+func onExit() {
+ Config.Save()
+}
+
+func getIcon(location string) []byte {
+ bytes, err := os.ReadFile(location)
+ if err != nil {
+ fmt.Print(err)
+ }
+ return bytes
+}
diff --git a/notifications.go b/notifications.go
new file mode 100644
index 0000000..38785e0
--- /dev/null
+++ b/notifications.go
@@ -0,0 +1,7 @@
+package main
+
+import "github.com/TheTitanrain/w32"
+
+func sendNotification(title string, message string) {
+ w32.DialogBox()
+}
diff --git a/serverconnection.go b/serverconnection.go
index 6e0a573..40a491b 100644
--- a/serverconnection.go
+++ b/serverconnection.go
@@ -20,32 +20,45 @@ type Credentials struct {
pass string
}
-func New(host string, port int) *tls.Conn {
- cert, err := os.ReadFile("./public.pem")
+func NewConnection(host string, port int) (*tls.Conn, error) {
+ _, err := os.Stat("./public.cer")
if err != nil {
- fmt.Printf("Error reading cert from ./public.pem: %v", err)
- os.Exit(1)
+ getPublicKey()
+ }
+
+ cert, err := os.ReadFile("./public.cer")
+ if err != nil {
+ return nil, fmt.Errorf("error reading cert from ./public.cer: %v", err)
}
certPool := x509.NewCertPool()
if ok := certPool.AppendCertsFromPEM(cert); !ok {
- fmt.Printf("Error loading certificate %v into cert pool", cert)
- os.Exit(1)
+ return nil, fmt.Errorf("error loading certificate %v into cert pool", cert)
}
- config := &tls.Config{RootCAs: certPool}
- conn, err := tls.Dial("tcp", host+":"+string(rune(port)), config)
- return conn
+ config := &tls.Config{
+ RootCAs: certPool,
+ CipherSuites: []uint16{
+ tls.TLS_AES_128_GCM_SHA256,
+ tls.TLS_AES_256_GCM_SHA384,
+ tls.TLS_CHACHA20_POLY1305_SHA256,
+ },
+ }
+ conn, err := tls.Dial("tcp", fmt.Sprintf("%s:%d", host, port), config)
+ if err != nil {
+ return nil, err
+ }
+ return conn, nil
}
func getPublicKey() {
- out, err := os.Create("./public.pem")
+ out, err := os.Create("./public.cer")
if err != nil {
fmt.Printf("Error closing file writer: %v", err)
os.Exit(1)
}
defer out.Close()
- resp, err := http.Get(Config.GetAsString("General.http-server") + "/public.pem")
+ resp, err := http.Get(Config.GetAsString("General.http-server") + "/public.cer")
if err != nil {
fmt.Printf("Error fetching public key: %v", err)
os.Exit(1)
diff --git a/sfsproto.go b/sfsproto.go
new file mode 100644
index 0000000..096f8c0
--- /dev/null
+++ b/sfsproto.go
@@ -0,0 +1,23 @@
+package main
+
+type SFSData struct {
+ length uint8
+}
+
+func NewSFSFromBytes(data []byte) *SFSData {
+ return &SFSData{
+ length: data[0],
+ }
+}
+
+func NewSFS(length uint8) *SFSData {
+ return &SFSData{
+ length: length,
+ }
+}
+
+func (sfs *SFSData) ToBytes() []byte {
+ return []byte{
+ sfs.length,
+ }
+}