Compare commits

..

No commits in common. "master" and "v1.2.0" have entirely different histories.

5 changed files with 14 additions and 17 deletions

1
.gitignore vendored
View File

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

View File

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

View File

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

View File

@ -62,12 +62,6 @@ PID_POLLING_INFO obdData[]= {
{PID_TIMING_ADVANCE, 2},
{PID_COOLANT_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;
@ -1015,7 +1009,7 @@ void telemetry(void* inst)
#if SERVER_ENCRYPTION_ENABLE == 1
unsigned int encrypted_len;
unsigned char* encrypted_buf = encrypt_buffer(store.buffer(), store.length(), &encrypted_len);
bool transmit_success = teleClient.transmit((const char *)encrypted_buf, encrypted_len);
bool transmit_success = teleClient.transmit((const char *)encrypted_buf, sizeof(encrypted_buf));
free(encrypted_buf);
if (transmit_success) {
#else

View File

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