Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Host IP address in the overview and sharable #1180

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

FarshidRoohi
Copy link

@FarshidRoohi FarshidRoohi commented Feb 9, 2024

📷 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

  • Added a new field on HttpTransaction
  • Increased Room DB version from 9 to 10

@FarshidRoohi FarshidRoohi requested a review from a team as a code owner February 9, 2024 13:12
Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you test this function?

Copy link
Author

@FarshidRoohi FarshidRoohi Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cortinico cortinico enabled auto-merge (squash) February 12, 2024 08:47
@@ -43,6 +43,7 @@ internal class ResponseProcessor(
requestDate = response.sentRequestAtMillis
responseDate = response.receivedResponseAtMillis
protocol = response.protocol.toString()
hostIp = response.body?.source()?.getHostIp()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()
Copy link
Contributor

@MiSikora MiSikora Mar 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads the whole body of the source to the memory and assumes that it is UTF-8 encoded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants