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 .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, encrypted_len); bool cell_send = cell.send((const char *)encrypted_buf, sizeof(encrypted_buf));
free(encrypted_buf); free(encrypted_buf);
if (!cell_send) break; if (!cell_send) break;
#else #else

View File

@ -87,6 +87,8 @@ 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,12 +62,6 @@ 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;
@ -1015,7 +1009,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, encrypted_len); bool transmit_success = teleClient.transmit((const char *)encrypted_buf, sizeof(encrypted_buf));
free(encrypted_buf); free(encrypted_buf);
if (transmit_success) { if (transmit_success) {
#else #else

View File

@ -86,21 +86,23 @@ 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
recievedContent := buf[:n] if len(buf[:n]) > 0 {
if len(recievedContent) > 0 { plaintext, err = encryption.Decrypt(key, buf[:n]) // Use only the part of the buffer that has data.
plaintext, err = encryption.Decrypt(key, recievedContent) // Use only the part of the buffer that has data.
if err != nil { 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))) rawHex := hex.EncodeToString(buf[:n])
plaintext = recievedContent // Don't bother with decryption. 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 shouldEncrypt = false
} else { if len(buf[:n]) > 0 {
logger.Infof(formatLogMsg(addr.IP.String(), dest.Address, dest.Port, string(plaintext))) logger.Warningln("Encryption failed, possibly recieved unencrypted message")
}
} }
} else { } else {
// If empty message. // If empty message.
plaintext = recievedContent plaintext = buf[:n]
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 {