reorganize

This commit is contained in:
Cyberes 2024-06-30 19:14:16 -06:00
parent e77a56e4bc
commit f5d0608e03
12 changed files with 26 additions and 3 deletions

24
server/build.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
if [ -z ${1+x} ]; then
VERSION="0.0.0"
else
VERSION="$1"
fi
mkdir -p "$SCRIPT_DIR/dist"
rm "$SCRIPT_DIR"/dist/* &> /dev/null
BUILDARGS="$(uname)-$(uname -p)"
OUTPUTFILE="$SCRIPT_DIR/dist/freematics-encrypt-$VERSION-$BUILDARGS"
cd "$SCRIPT_DIR/src" || exit 1
go mod tidy
go build -v -trimpath -ldflags "-s -w -X main.VersionDate=$(date -u --iso-8601=minutes) -X main.Version=v$VERSION" -o "$OUTPUTFILE"
if [ $? -eq 0 ]; then
chmod +x "$OUTPUTFILE"
echo "Build Succeeded -> $OUTPUTFILE"
fi

View File

@ -30,7 +30,7 @@ func main() {
logger := logging.GetLogger() logger := logging.GetLogger()
if *configFile == "" { if *configFile == "" {
logger.Fatalln("Please provide a configuration file") logger.Fatalln("Provide a configuration file via --config")
} }
data, err := os.ReadFile(*configFile) data, err := os.ReadFile(*configFile)
@ -96,6 +96,7 @@ func main() {
} }
} else { } else {
plaintext = buf[:n] plaintext = buf[:n]
logger.Warningln("Got unencrypted message!")
} }
forwardAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", dest.Address, dest.Port)) forwardAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", dest.Address, dest.Port))
@ -142,8 +143,6 @@ func main() {
return return
} }
//fmt.Println(string(backendResponse[:]))
// Encrypt the backend's response. // Encrypt the backend's response.
encryptedBackendResponse, err := encryption.Encrypt(key, backendResponse[:n]) encryptedBackendResponse, err := encryption.Encrypt(key, backendResponse[:n])
if err != nil { if err != nil {