Compare commits

..

2 Commits

Author SHA1 Message Date
Cyberes 8fae0cd5db fix some things 2024-07-03 19:01:19 -06:00
Cyberes 09602b2745 update gitignore 2024-07-02 22:09:02 -06:00
5 changed files with 17 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
.idea .idea
server/config.yml server/config.yml
.vscode .vscode
*.ino.cpp
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files

View File

@ -271,7 +271,7 @@ bool TeleClientUDP::notify(byte event, const char* payload)
#if SERVER_ENCRYPTION_ENABLE == 1 #if SERVER_ENCRYPTION_ENABLE == 1
unsigned int encrypted_len; unsigned int encrypted_len;
unsigned char* encrypted_buf = encrypt_buffer(netbuf.buffer(), netbuf.length(), &encrypted_len); unsigned char* encrypted_buf = encrypt_buffer(netbuf.buffer(), netbuf.length(), &encrypted_len);
bool cell_send = cell.send((const char *)encrypted_buf, sizeof(encrypted_buf)); bool cell_send = cell.send((const char *)encrypted_buf, encrypted_len);
free(encrypted_buf); free(encrypted_buf);
if (!cell_send) break; if (!cell_send) break;
#else #else

View File

@ -87,8 +87,6 @@ void decrypt_string(const unsigned char *input, size_t length, unsigned char *ou
return; return;
} }
///// END TAG VERIFY
output[decryptedLength] = '\0'; output[decryptedLength] = '\0';
chachaPoly.clear(); chachaPoly.clear();
} }

View File

@ -62,6 +62,12 @@ PID_POLLING_INFO obdData[]= {
{PID_TIMING_ADVANCE, 2}, {PID_TIMING_ADVANCE, 2},
{PID_COOLANT_TEMP, 3}, {PID_COOLANT_TEMP, 3},
{PID_INTAKE_TEMP, 3}, {PID_INTAKE_TEMP, 3},
{PID_ODOMETER, 3},
{PID_DISTANCE, 3},
{PID_AMBIENT_TEMP, 2},
{PID_ENGINE_OIL_TEMP, 2},
{PID_FUEL_LEVEL, 1}
}; };
CBufferManager bufman; CBufferManager bufman;
@ -1009,7 +1015,7 @@ void telemetry(void* inst)
#if SERVER_ENCRYPTION_ENABLE == 1 #if SERVER_ENCRYPTION_ENABLE == 1
unsigned int encrypted_len; unsigned int encrypted_len;
unsigned char* encrypted_buf = encrypt_buffer(store.buffer(), store.length(), &encrypted_len); unsigned char* encrypted_buf = encrypt_buffer(store.buffer(), store.length(), &encrypted_len);
bool transmit_success = teleClient.transmit((const char *)encrypted_buf, sizeof(encrypted_buf)); bool transmit_success = teleClient.transmit((const char *)encrypted_buf, encrypted_len);
free(encrypted_buf); free(encrypted_buf);
if (transmit_success) { if (transmit_success) {
#else #else

View File

@ -86,23 +86,21 @@ func main() {
go func(addr *net.UDPAddr, buf []byte, n int) { go func(addr *net.UDPAddr, buf []byte, n int) {
var plaintext []byte var plaintext []byte
shouldEncrypt := true shouldEncrypt := true
if len(buf[:n]) > 0 { recievedContent := buf[:n]
plaintext, err = encryption.Decrypt(key, buf[:n]) // Use only the part of the buffer that has data. if len(recievedContent) > 0 {
plaintext, err = encryption.Decrypt(key, recievedContent) // Use only the part of the buffer that has data.
if err != nil { if err != nil {
rawHex := hex.EncodeToString(buf[:n]) logger.Warningf(formatLogMsg(addr.IP.String(), dest.Address, dest.Port, fmt.Sprintf(`Error decrypting message: %s. Length: %d, Raw: "%s"`, err, len(recievedContent), recievedContent)))
logger.Warningf(formatLogMsg(addr.IP.String(), dest.Address, dest.Port, fmt.Sprintf(`Error decrypting message: %s. Length: %d, Raw: "%s"`, err, len(rawHex), rawHex))) plaintext = recievedContent // Don't bother with decryption.
plaintext = buf[:n] // Don't bother with decryption.
shouldEncrypt = false shouldEncrypt = false
if len(buf[:n]) > 0 { } else {
logger.Warningln("Encryption failed, possibly recieved unencrypted message") logger.Infof(formatLogMsg(addr.IP.String(), dest.Address, dest.Port, string(plaintext)))
}
} }
} else { } else {
// If empty message. // If empty message.
plaintext = buf[:n] plaintext = recievedContent
shouldEncrypt = false shouldEncrypt = false
} }
logger.Infof(formatLogMsg(addr.IP.String(), dest.Address, dest.Port, string(plaintext)))
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))
if err != nil { if err != nil {