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

Feature/tls info #252

Merged
merged 3 commits into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ class ChuckerInterceptor @JvmOverloads constructor(
responseCode = response.code()
responseMessage = response.message()

response.handshake()?.let { handshake ->
responseTlsVersion = handshake.tlsVersion().javaName()
responseCipherSuite = handshake.cipherSuite().javaName()
}

responseContentType = response.contentType
responseContentLength = response.contentLenght

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ internal class HttpTransaction(
@ColumnInfo(name = "host") var host: String?,
@ColumnInfo(name = "path") var path: String?,
@ColumnInfo(name = "scheme") var scheme: String?,
@ColumnInfo(name = "responseTlsVersion") var responseTlsVersion: String?,
@ColumnInfo(name = "responseCipherSuite") var responseCipherSuite: String?,
@ColumnInfo(name = "requestContentLength") var requestContentLength: Long?,
@ColumnInfo(name = "requestContentType") var requestContentType: String?,
@ColumnInfo(name = "requestHeaders") var requestHeaders: String?,
Expand Down Expand Up @@ -60,6 +62,8 @@ internal class HttpTransaction(
host = null,
path = null,
scheme = null,
responseTlsVersion = null,
responseCipherSuite = null,
requestContentLength = null,
requestContentType = null,
requestHeaders = null,
Expand Down Expand Up @@ -243,6 +247,8 @@ internal class HttpTransaction(
(host == other.host) &&
(path == other.path) &&
(scheme == other.scheme) &&
(responseTlsVersion == other.responseTlsVersion) &&
(responseCipherSuite == other.responseCipherSuite) &&
(requestContentLength == other.requestContentLength) &&
(requestContentType == other.requestContentType) &&
(requestHeaders == other.requestHeaders) &&
Expand All @@ -256,6 +262,6 @@ internal class HttpTransaction(
(responseHeaders == other.responseHeaders) &&
(responseBody == other.responseBody) &&
(isResponseBodyPlainText == other.isResponseBodyPlainText) &&
responseImageData?.contentEquals(other.responseImageData ?: byteArrayOf()) != false
(responseImageData?.contentEquals(other.responseImageData ?: byteArrayOf()) != false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.MenuInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.constraintlayout.widget.Group
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
Expand All @@ -21,6 +22,10 @@ internal class TransactionOverviewFragment : Fragment() {
private lateinit var status: TextView
private lateinit var response: TextView
private lateinit var ssl: TextView
private lateinit var tlsVersionGroup: Group
private lateinit var tlsVersion: TextView
private lateinit var cipherSuiteGroup: Group
private lateinit var cipherSuiteVersion: TextView
private lateinit var requestTime: TextView
private lateinit var responseTime: TextView
private lateinit var duration: TextView
Expand Down Expand Up @@ -48,6 +53,10 @@ internal class TransactionOverviewFragment : Fragment() {
status = it.findViewById(R.id.chuckerTransactionOverviewStatus)
response = it.findViewById(R.id.chuckerTransactionOverviewResponse)
ssl = it.findViewById(R.id.chuckerTransactionOverviewSsl)
tlsVersionGroup = it.findViewById(R.id.chuckerTransactionOverviewTlsGroup)
tlsVersion = it.findViewById(R.id.chuckerTransactionOverviewTlsVersionValue)
cipherSuiteGroup = it.findViewById(R.id.chuckerTransactionOverviewCipherSuiteGroup)
cipherSuiteVersion = it.findViewById(R.id.chuckerTransactionOverviewTlsChipherSuiteValue)
requestTime = it.findViewById(R.id.chuckerTransactionOverviewRequestTime)
responseTime = it.findViewById(R.id.chuckerTransactionOverviewResponseTime)
duration = it.findViewById(R.id.chuckerTransactionOverviewDuration)
Expand Down Expand Up @@ -80,6 +89,13 @@ internal class TransactionOverviewFragment : Fragment() {
status.text = transaction?.status?.toString()
response.text = transaction?.responseSummaryText
ssl.setText(if (transaction?.isSsl == true) R.string.chucker_yes else R.string.chucker_no)
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 move this also inside the if branch?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👌

if (transaction?.isSsl == true) {
tlsVersionGroup.visibility = View.VISIBLE
tlsVersion.text = transaction.responseTlsVersion

cipherSuiteGroup.visibility = View.VISIBLE
cipherSuiteVersion.text = transaction.responseCipherSuite
}
requestTime.text = transaction?.requestDateString
responseTime.text = transaction?.responseDateString
duration.text = transaction?.durationString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
style="@style/Chucker.TextAppearance.Label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/chucker_base_grid"
android:text="@string/chucker_ssl"
app:layout_constraintEnd_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -126,13 +127,74 @@
<TextView
android:id="@+id/chuckerTransactionOverviewSsl"
style="@style/Chucker.TextAppearance.Value"
android:layout_marginTop="@dimen/chucker_base_grid"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewResponse"
tools:text="Yes" />

<TextView
android:id="@+id/chuckerTransactionOverviewTlsVersion"
style="@style/Chucker.TextAppearance.Label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/chucker_tls_version"
app:layout_constraintEnd_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewSsl" />

<TextView
android:id="@+id/chuckerTransactionOverviewTlsVersionValue"
style="@style/Chucker.TextAppearance.Value"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewSsl"
tools:text="TLS 1.2" />

<androidx.constraintlayout.widget.Group
android:id="@+id/chuckerTransactionOverviewTlsGroup"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:constraint_referenced_ids="chuckerTransactionOverviewTlsVersion,chuckerTransactionOverviewTlsVersionValue"
tools:visibility="visible" />

<TextView
android:id="@+id/chuckerTransactionOverviewTlsChipherSuite"
style="@style/Chucker.TextAppearance.Label"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="@string/chucker_tls_cipher_suite"
android:visibility="gone"
app:layout_constraintEnd_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewTlsVersion"
tools:visibility="visible" />

<TextView
android:id="@+id/chuckerTransactionOverviewTlsChipherSuiteValue"
style="@style/Chucker.TextAppearance.Value"
android:layout_width="0dp"
android:visibility="gone"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewTlsVersion"
tools:text="TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA"
tools:visibility="visible" />

<androidx.constraintlayout.widget.Group
android:id="@+id/chuckerTransactionOverviewCipherSuiteGroup"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:constraint_referenced_ids="chuckerTransactionOverviewTlsChipherSuiteValue,chuckerTransactionOverviewTlsChipherSuite"
tools:visibility="visible" />

<TextView
style="@style/Chucker.TextAppearance.Label"
android:layout_width="0dp"
Expand All @@ -141,7 +203,7 @@
android:text="@string/chucker_request_time"
app:layout_constraintEnd_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewSsl" />
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewTlsChipherSuiteValue" />

<TextView
android:id="@+id/chuckerTransactionOverviewRequestTime"
Expand All @@ -151,7 +213,7 @@
android:layout_marginTop="@dimen/chucker_base_grid"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/chuckerTransactionOverviewGuideline"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewSsl"
app:layout_constraintTop_toBottomOf="@id/chuckerTransactionOverviewTlsChipherSuiteValue"
tools:text="05/02/17 11:52:49" />

<TextView
Expand Down
2 changes: 2 additions & 0 deletions library/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<string name="chucker_protocol">Protocol</string>
<string name="chucker_status">Status</string>
<string name="chucker_ssl">SSL</string>
<string name="chucker_tls_version">TLS version</string>
<string name="chucker_tls_cipher_suite">Cipher Suite</string>
<string name="chucker_request_time">Request time</string>
<string name="chucker_response_time">Response time</string>
<string name="chucker_duration">Duration</string>
Expand Down