mirror of https://github.com/zlatinb/muwire
parse profile header from incoming results
parent
216d0db303
commit
deeadf3c42
|
@ -1,5 +1,6 @@
|
||||||
package com.muwire.core.connection
|
package com.muwire.core.connection
|
||||||
|
|
||||||
|
import com.muwire.core.profile.MWProfileHeader
|
||||||
import net.i2p.I2PException
|
import net.i2p.I2PException
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
|
@ -351,6 +352,14 @@ class ConnectionAcceptor {
|
||||||
if (sender.destination != e.getDestination())
|
if (sender.destination != e.getDestination())
|
||||||
throw new IOException("Sender destination mismatch expected ${e.getDestination()}, got $sender.destination")
|
throw new IOException("Sender destination mismatch expected ${e.getDestination()}, got $sender.destination")
|
||||||
|
|
||||||
|
MWProfileHeader profileHeader = null
|
||||||
|
if (headers.containsKey("ProfileHeader")) {
|
||||||
|
byte [] profileHeaderBytes = Base64.decode(headers['ProfileHeader'])
|
||||||
|
profileHeader = new MWProfileHeader(new ByteArrayInputStream(profileHeaderBytes))
|
||||||
|
if (profileHeader.getPersona() != sender)
|
||||||
|
throw new IOException("Sender profile mismatch")
|
||||||
|
}
|
||||||
|
|
||||||
int nResults = Integer.parseInt(headers['Count'])
|
int nResults = Integer.parseInt(headers['Count'])
|
||||||
if (nResults > Constants.MAX_RESULTS)
|
if (nResults > Constants.MAX_RESULTS)
|
||||||
throw new IOException("too many results $nResults")
|
throw new IOException("too many results $nResults")
|
||||||
|
@ -374,6 +383,7 @@ class ConnectionAcceptor {
|
||||||
results[j].chat = chat
|
results[j].chat = chat
|
||||||
results[j].messages = messages
|
results[j].messages = messages
|
||||||
results[j].feed = feed
|
results[j].feed = feed
|
||||||
|
results[j].profileHeader = profileHeader
|
||||||
j++
|
j++
|
||||||
|
|
||||||
if (j == results.length) {
|
if (j == results.length) {
|
||||||
|
|
Loading…
Reference in New Issue