Skip to content

Add Host IP address in the overview and sharable#1180

Open
FarshidRoohi wants to merge 4 commits into
ChuckerTeam:mainfrom
FarshidRoohi:fa/add-host-ip-address-overview
Open

Add Host IP address in the overview and sharable#1180
FarshidRoohi wants to merge 4 commits into
ChuckerTeam:mainfrom
FarshidRoohi:fa/add-host-ip-address-overview

Conversation

@FarshidRoohi

@FarshidRoohi FarshidRoohi commented Feb 9, 2024

Copy link
Copy Markdown

📷 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

@cortinico cortinico left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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?

@FarshidRoohi FarshidRoohi Feb 9, 2024

Copy link
Copy Markdown
Author

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
requestDate = response.sentRequestAtMillis
responseDate = response.receivedResponseAtMillis
protocol = response.protocol.toString()
hostIp = response.body?.source()?.getHostIp()

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

@MiSikora MiSikora Mar 1, 2024

Copy link
Copy Markdown
Contributor

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