Skip to content

Commit

Permalink
NClientV2 2.9.7
Browse files Browse the repository at this point in the history
* Improved CF token fetch
  • Loading branch information
Dar9586 committed Jun 28, 2022
1 parent 71c94f5 commit e4d8d87
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ android {
applicationId "com.dar.nclientv2"
minSdkVersion 14
targetSdkVersion 32
versionCode 296
versionCode 297
multiDexEnabled true
versionName "2.9.6-stable"
versionName "2.9.7-stable"
vectorDrawables.useSupportLibrary true
proguardFiles 'proguard-rules.pro'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,11 @@ public void intercept() {
}
intercepting = true;
LogUtility.d("Starting intercept CF cookies");
if(!manager.endInterceptor())
interceptInternal();
synchronized (CookieInterceptor.class) {
if (!manager.endInterceptor()) {
interceptInternal();
}
}
this.manager.onFinish();
intercepting = false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.dar.nclientv2.components.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.dar.nclientv2.R;
import com.dar.nclientv2.components.CookieInterceptor;

import java.util.Date;

public class CFTokenView {

private final ViewGroup masterLayout;
private WebView webView;
private Button button;
private final WebView webView;
private final Button button;

public CFTokenView(ViewGroup masterLayout) {
this.masterLayout = masterLayout;
Expand All @@ -35,4 +42,39 @@ public void setVisibility(int visible) {
public void post(Runnable o) {
masterLayout.post(o);
}


public static class CFTokenWebView extends WebView{
private volatile long lastLoad=0;
private static final long MIN_TIME=5000;
public CFTokenWebView(@NonNull Context context) {
super(context);
init();
}

public CFTokenWebView(@NonNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
super(context, attrs);
init();
}

public CFTokenWebView(@NonNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init(){

}

@Override
public void loadUrl(@NonNull String url) {
long actualTime = new Date().getTime();
synchronized (this) {
if (lastLoad + MIN_TIME <= actualTime) {
lastLoad = actualTime;
super.loadUrl(url);
}
}
}
}

}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/cftoken_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<WebView
<view class="com.dar.nclientv2.components.views.CFTokenView$CFTokenWebView"
android:id="@+id/webView"
android:layout_width="0dp"
android:layout_height="0dp"
Expand All @@ -24,5 +24,5 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

</WebView>
</view>
</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit e4d8d87

Please sign in to comment.