Skip to content

Commit

Permalink
switch to brook
Browse files Browse the repository at this point in the history
  • Loading branch information
uoosef committed Jun 4, 2023
1 parent 1453b14 commit f3a4749
Show file tree
Hide file tree
Showing 32 changed files with 430 additions and 415 deletions.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 21 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 28
compileSdkVersion 33
defaultConfig {
applicationId "com.example.chepass"
minSdkVersion 15
targetSdkVersion 28
minSdkVersion 23
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -18,13 +18,23 @@ android {
}
}

repositories {
flatDir {
dirs 'src/libs'
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(path: ':tun2socks-sources')
implementation project(path: ':tun2socks')
implementation 'androidx.activity:activity:1.6.1'
implementation 'androidx.fragment:fragment:1.5.5'
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'androidx.recyclerview:recyclerview:1.3.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.github.aslamanver:retrofit-lite:v2.0.6'
implementation 'com.google.code.gson:gson:2.10.1'

api(name: 'golibs', ext: 'aar')
}
19 changes: 12 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:allowBackup="true"
Expand All @@ -14,18 +15,22 @@
android:theme="@style/AppTheme">

<service
android:name=".ChepassService"
android:name=".ChepassVpnService"
android:enabled="true"
android:exported="true"/>

<service android:name=".ChepassVpnService"
android:permission="android.permission.BIND_VPN_SERVICE">
android:exported="false"
android:permission="android.permission.BIND_VPN_SERVICE"
android:process=":vpn_background">
<intent-filter>
<action android:name="android.net.VpnService"/>
<action android:name="android.net.VpnService" />
</intent-filter>

<meta-data
android:name="android.net.VpnService.SUPPORTS_ALWAYS_ON"
android:value="true" />
</service>

<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
Binary file added app/src/main/assets/chepass/arm/brook
Binary file not shown.
Binary file removed app/src/main/assets/chepass/arm/ssh
Binary file not shown.
Binary file removed app/src/main/assets/chepass/arm/sshpass
Binary file not shown.
Binary file removed app/src/main/assets/chepass/arm/tun2socks
Binary file not shown.
Binary file added app/src/main/assets/chepass/x86/brook
Binary file not shown.
Binary file removed app/src/main/assets/chepass/x86/ssh
Binary file not shown.
Binary file removed app/src/main/assets/chepass/x86/sshpass
Binary file not shown.
Binary file removed app/src/main/assets/chepass/x86/tun2socks
Binary file not shown.
81 changes: 81 additions & 0 deletions app/src/main/java/com/example/chepass/Authenticate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.example.chepass;

import android.content.Context;
import android.widget.Toast;

import com.google.gson.Gson;
import com.retrofit.lite.services.APITask;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Map;

class ApiResponse {
public Boolean register;
public String address;
public String pass;
}

public class Authenticate implements APITask.Listener {
private final Context context;
private Callback callback;
private final String code;
private Boolean isCodeOnDisk;

public Authenticate(Context ctx, String c, Callback clbk){
context = ctx;
code = c;
callback = clbk;
}

public void Auth(){
isCodeOnDisk = CheckIfIsInDisk();
APITask.from(context).sendGET(101, "https://example.com/codes/" + code + ".json", null, this);
}

public boolean CheckIfIsInDisk(){
File file = new File(context.getFilesDir(),code + ".json");
return file.exists();
}

public void SaveOnDisk(){
try {
FileOutputStream fos = context.openFileOutput(code+".json",Context.MODE_PRIVATE);
Writer out = new OutputStreamWriter(fos);
out.write("ok");
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}

@Override
public void onSuccess(int pid, int status, Map<String, String> headers, String body) {
Gson gson = new Gson();
ApiResponse gsonObj = gson.fromJson(body, ApiResponse.class);
if(gsonObj.address == null || gsonObj.register == null || gsonObj.pass == null){
Toast.makeText(context, "Invalid Response",
Toast.LENGTH_LONG).show();
return;
}
//if(!isCodeOnDisk && !gsonObj.register){
if(!gsonObj.register){
Toast.makeText(context, "This code was used! please obtain a new one",
Toast.LENGTH_LONG).show();
return;
}
/*if(!isCodeOnDisk){
SaveOnDisk();
}*/
callback.onSuccess(gsonObj.address, gsonObj.pass);
}

@Override
public void onFailed(int pid, Exception ex) {
Toast.makeText(context, "Server side error please contact with support.",
Toast.LENGTH_LONG).show();
}
}
23 changes: 23 additions & 0 deletions app/src/main/java/com/example/chepass/BrookConnection.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.chepass;
import tun2socks.Tun2socks;

public class BrookConnection extends Thread{
public String address;
public String pass;
public void kill(){
try{
Tun2socks.stopClient();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void run(){
try{
Tun2socks.startClient("127.0.0.1:8080", address, pass);
} catch (Exception e) {
e.printStackTrace();
}
}
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/example/chepass/Callback.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.chepass;

public interface Callback {
void onSuccess(String address, String pass);
}
78 changes: 0 additions & 78 deletions app/src/main/java/com/example/chepass/ChepassService.java

This file was deleted.

Loading

0 comments on commit f3a4749

Please sign in to comment.