hachikuji commented on a change in pull request #9103:
URL: https://github.com/apache/kafka/pull/9103#discussion_r510536894



##########
File path: core/src/main/scala/kafka/network/SocketServer.scala
##########
@@ -1005,6 +1013,36 @@ private[kafka] class Processor(val id: Int,
     selector.clearCompletedReceives()
   }
 
+  private def parseEnvelopeRequest(receive: NetworkReceive,
+                                   nowNanos: Long,
+                                   connectionId: String,
+                                   context: RequestContext,
+                                   principalSerde: 
Option[KafkaPrincipalSerde]) = {
+    val envelopeRequest = 
context.parseRequest(receive.payload).request.asInstanceOf[EnvelopeRequest]
+
+    val originalHeader = RequestHeader.parse(envelopeRequest.requestData)
+    // Leave the principal null here is ok since we will fail the request 
during Kafka API handling.
+    val originalPrincipal = if (principalSerde.isDefined)
+      principalSerde.get.deserialize(envelopeRequest.principalData)
+    else
+      null
+
+    // The forwarding broker and the active controller should have the same 
DNS resolution, and we need
+    // to have the original client address for authentication purpose.
+    val originalClientAddress = 
InetAddress.getByName(envelopeRequest.clientHostName)

Review comment:
       I was thinking a little bit about this and trying to decide if the 
envelope request should have a more literal representation of the client ip 
address. The way it is working right now, it looks like the following:
   
   1) Use `Socket.getInetAddress` to populate `RequestContext.clientAddress`.
   2) Use `InetAddress.getHostName` to populate the `clientHostName` field in 
the envelope request. This will do a reverse dns lookup based on the IP address 
from 1).
   3) Now we send `clientHostName` over the wire. It gets unpacked here by 
doing a dns lookup to get to the `InetAddress` object.
   
   So it seems we should be skipping the dns translation and just using the IP 
address from 1). The `InetAddress` class gives us `getAddress` and 
`getHostAddress`. The first provides the raw byte representation of the ip 
address, while the latter provides a textual representation. I am thinking we 
should use `getAddress` and let this field be represented as bytes. What do you 
think?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to