mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 02:45:20 +00:00
cleanup logging
This commit is contained in:
@@ -28,7 +28,6 @@ class NoiseSessionManager(
|
||||
*/
|
||||
fun addSession(peerID: String, session: NoiseSession) {
|
||||
sessions[peerID] = session
|
||||
Log.d(TAG, "Added new session for $peerID")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,14 +44,13 @@ class NoiseSessionManager(
|
||||
fun removeSession(peerID: String) {
|
||||
sessions[peerID]?.destroy()
|
||||
sessions.remove(peerID)
|
||||
Log.d(TAG, "Removed session for $peerID")
|
||||
}
|
||||
|
||||
/**
|
||||
* SIMPLIFIED: Initiate handshake - no tie breaker, just start
|
||||
*/
|
||||
fun initiateHandshake(peerID: String): ByteArray {
|
||||
Log.d(TAG, "initiateHandshake($peerID)")
|
||||
Log.i(TAG, "Starting Noise handshake with $peerID")
|
||||
|
||||
// Remove any existing session first
|
||||
removeSession(peerID)
|
||||
@@ -64,15 +62,13 @@ class NoiseSessionManager(
|
||||
localStaticPrivateKey = localStaticPrivateKey,
|
||||
localStaticPublicKey = localStaticPublicKey
|
||||
)
|
||||
Log.d(TAG, "Storing new INITIATOR session for $peerID")
|
||||
addSession(peerID, session)
|
||||
|
||||
try {
|
||||
val handshakeData = session.startHandshake()
|
||||
Log.d(TAG, "Started handshake with $peerID as INITIATOR")
|
||||
return handshakeData
|
||||
return session.startHandshake()
|
||||
} catch (e: Exception) {
|
||||
sessions.remove(peerID)
|
||||
Log.e(TAG, "Failed to start Noise handshake with $peerID: ${e.message}")
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@@ -81,14 +77,12 @@ class NoiseSessionManager(
|
||||
* Handle incoming handshake message
|
||||
*/
|
||||
fun processHandshakeMessage(peerID: String, message: ByteArray): ByteArray? {
|
||||
Log.d(TAG, "processHandshakeMessage($peerID, ${message.size} bytes)")
|
||||
|
||||
try {
|
||||
var session = getSession(peerID)
|
||||
|
||||
// If no session exists, create one as responder
|
||||
if (session == null) {
|
||||
Log.d(TAG, "Creating new RESPONDER session for $peerID")
|
||||
Log.i(TAG, "Responding to Noise handshake from $peerID")
|
||||
session = NoiseSession(
|
||||
peerID = peerID,
|
||||
isInitiator = false,
|
||||
@@ -103,7 +97,7 @@ class NoiseSessionManager(
|
||||
|
||||
// Check if session is established
|
||||
if (session.isEstablished()) {
|
||||
Log.d(TAG, "✅ Session ESTABLISHED with $peerID")
|
||||
Log.i(TAG, "Noise session established with $peerID")
|
||||
val remoteStaticKey = session.getRemoteStaticPublicKey()
|
||||
if (remoteStaticKey != null) {
|
||||
onSessionEstablished?.invoke(peerID, remoteStaticKey)
|
||||
@@ -137,11 +131,9 @@ class NoiseSessionManager(
|
||||
fun decrypt(encryptedData: ByteArray, peerID: String): ByteArray {
|
||||
val session = getSession(peerID)
|
||||
if (session == null) {
|
||||
Log.e(TAG, "No session found for $peerID when trying to decrypt")
|
||||
throw IllegalStateException("No session found for $peerID")
|
||||
}
|
||||
if (!session.isEstablished()) {
|
||||
Log.e(TAG, "Session not established with $peerID when trying to decrypt")
|
||||
throw IllegalStateException("Session not established with $peerID")
|
||||
}
|
||||
return session.decrypt(encryptedData)
|
||||
@@ -151,9 +143,7 @@ class NoiseSessionManager(
|
||||
* Check if session is established with peer
|
||||
*/
|
||||
fun hasEstablishedSession(peerID: String): Boolean {
|
||||
val hasSession = getSession(peerID)?.isEstablished() ?: false
|
||||
Log.d(TAG, "hasEstablishedSession($peerID): $hasSession")
|
||||
return hasSession
|
||||
return getSession(peerID)?.isEstablished() ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -210,7 +200,6 @@ class NoiseSessionManager(
|
||||
fun shutdown() {
|
||||
sessions.values.forEach { it.destroy() }
|
||||
sessions.clear()
|
||||
Log.d(TAG, "Noise session manager shut down")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user