Add Host IP address in the overview and sharable#1180
Open
FarshidRoohi wants to merge 4 commits into
Open
Conversation
cortinico
reviewed
Feb 9, 2024
Member
cortinico
left a comment
There was a problem hiding this comment.
Thanks for the PR @FarshidRoohi.
I've left one comment
Comment on lines
+9
to
+17
| public fun Response.getHostIp(): String? { | ||
| val body = body?.source()?.readUtf8() | ||
| val pattern: Pattern = Pattern.compile(IP_REGEX) | ||
| val matcher: Matcher? = body?.let { pattern.matcher(it) } | ||
| if (matcher?.find() == true) { | ||
| return matcher.group() | ||
| } | ||
| return null | ||
| } |
Author
There was a problem hiding this comment.
I wrote two tests for this extension function.
https://github.com/ChuckerTeam/chucker/pull/1180/files#diff-9e02dc5b49faba047a35920cbd28850dec0ae4a568dd09ba6264dc754c332dcaR55
cortinico
approved these changes
Feb 12, 2024
MiSikora
reviewed
Mar 1, 2024
| requestDate = response.sentRequestAtMillis | ||
| responseDate = response.receivedResponseAtMillis | ||
| protocol = response.protocol.toString() | ||
| hostIp = response.body?.source()?.getHostIp() |
Contributor
There was a problem hiding this comment.
I'm having trouble understanding this. Why is it assumed that the response body contains IP?
| private const val IP_REGEX = "(?:\\d{1,3}\\.){3}\\d{1,3}" | ||
|
|
||
| public fun BufferedSource.getHostIp(): String? { | ||
| val body = readUtf8() |
Contributor
There was a problem hiding this comment.
This reads the whole body of the source to the memory and assumes that it is UTF-8 encoded.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📷 Screenshots
📄 Context
I needed to know the IP address of each request because each request might be directed to a specific server with a specific IP address. Having the CDN IP address can be very helpful in troubleshooting issues. Therefore, I thought it would be useful for other developers as well, and that's why I added this information.
📝 Changes