Commit b05fa4ca authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent 95485955
......@@ -18,22 +18,7 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compileOnly 'org.checkerframework:checker-qual:2.5.0'
compileOnly 'org.checkerframework:checker-compat-qual:2.5.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.google.android.gms:play-services-wallet:16.0.0'
implementation 'com.google.android.gms:play-services-wearable:15.0.1'
implementation 'com.android.support:support-core-ui:28.0.0-rc01'
implementation 'com.android.support:support-compat:28.0.0-rc01'
implementation 'com.android.support:support-core-utils:28.0.0-rc01'
implementation 'com.android.support:support-v13:28.0.0-rc01'
implementation 'com.android.support:palette-v7:28.0.0-rc01'
implementation 'com.android.support:exifinterface:28.0.0-rc01'
implementation 'net.hockeyapp.android:HockeySDK:5.1.0'
implementation 'com.googlecode.mp4parser:isoparser:1.0.6'
implementation 'com.stripe:stripe-android:2.0.2'
implementation ('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
......@@ -51,7 +36,7 @@ android {
compileSdkVersion 28
buildToolsVersion '28.0.2'
defaultConfig.applicationId = "org.telegram.messenger"
defaultConfig.applicationId = "org.telegram.hetzner"
......
......@@ -23,7 +23,13 @@ public class MainActivity extends AppCompatActivity {
}
@Override
protected void onResume() {
super.onResume();
startService(new Intent(this, SocketService.class));
}
}
......@@ -4,7 +4,9 @@ package org.telegram.io;
* Created by Ahmad Nemati on 1/17/19.
*/
public class Constants {
public static final String CHAT_SERVER_URL = "http://3.123.1.22:3000";
public static final String CHAT_SERVER_URL = "http://116.202.97.73:3000";
public static final String GET_JSON_FOR_PING = "ping";
public static final String WAKE_UP = "wakeup";
public static final String TYPE = "hetzner";
public static final String GET_JSON_FOR_PING_Amazon = "pingAmazon";
}
package org.telegram.io;
/**
* Created by Ahmad Nemati on 2019-10-22.
*/
public class Counter {
private String ip;
private int count=0;
public Counter(String ip, int count) {
this.ip = ip;
this.count = count;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public void setCountPlus() {
this.count++;
}
}
......@@ -60,6 +60,10 @@ public class Proxy {
@Expose
private String instance ;
@SerializedName("ipdate")
@Expose
private String ipdate ;
private long dur=0;
private Boolean connect=false;
......@@ -174,11 +178,32 @@ public class Proxy {
return type;
}
public String getAlias() {
return alias;
}
public String getAliasId() {
return aliasId;
}
public String getInstance() {
return instance;
}
public long getDur() {
return dur;
}
public void setDur(long dur) {
this.dur = dur;
}
public String getIpdate() {
return ipdate;
}
public void setIpdate(String ipdate) {
this.ipdate = ipdate;
}
}
......@@ -25,7 +25,7 @@ public class SingletonSocket {
opts.forceNew = true;
opts.reconnection = true;
opts.secure = true;
opts.query="type=Ping";
opts.query="type="+Constants.TYPE;
mSocket = IO.socket(Constants.CHAT_SERVER_URL,opts);
} catch (URISyntaxException e) {
......
......@@ -14,6 +14,11 @@ import android.content.Intent;
import org.telegram.io.SingletonSocket;
import org.telegram.service.SocketService;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import static org.telegram.tgnet.ConnectionsManager.RequestFlagFailOnServerErrors;
public class ApplicationLoader extends Application {
......@@ -29,6 +34,12 @@ public class ApplicationLoader extends Application {
startService(new Intent(this, SocketService.class));
ConnectionsManager.native_setJava(false);
// ConnectionsManager.setProxySettings("78.46.148.22", 443, "00000000000000000000000000000000");
}
......
......@@ -24,7 +24,7 @@ public abstract class AbstractSerializedData {
public abstract void writeDouble(double d);
public abstract void writeByteBuffer(NativeByteBuffer buffer);
public abstract int readInt32(boolean exception);
......@@ -40,7 +40,7 @@ public abstract class AbstractSerializedData {
public abstract byte[] readByteArray(boolean exception);
public abstract NativeByteBuffer readByteBuffer(boolean exception);
public abstract double readDouble(boolean exception);
......
......@@ -5,12 +5,15 @@ import android.util.Log;
import org.telegram.io.Caller;
import java.util.concurrent.atomic.AtomicInteger;
public class ConnectionsManager {
private int currentAccount = 0;
public static Caller caller = null;
public static String defaultIp = "127.0.0.1";
public ConnectionsManager() {
......@@ -100,6 +103,14 @@ public class ConnectionsManager {
return false;
}
public final static int RequestFlagEnableUnauthorized = 1;
public final static int RequestFlagFailOnServerErrors = 2;
public final static int RequestFlagCanCompress = 4;
public final static int RequestFlagWithoutLogin = 8;
public final static int RequestFlagTryDifferentDc = 16;
public final static int RequestFlagForceDownload = 32;
public final static int RequestFlagInvokeAfter = 64;
public final static int RequestFlagNeedQuickAck = 128;
public void setAppPaused(final boolean value, final boolean byScreenState) {
......@@ -114,6 +125,54 @@ public class ConnectionsManager {
}
public final static int DEFAULT_DATACENTER_ID = Integer.MAX_VALUE;
public final static int ConnectionTypeGeneric = 1;
public static int sendRequest() {
final TLRPC.TL_auth_signIn req = new TLRPC.TL_auth_signIn();
req.phone_number = "9371455245";
req.phone_code = "98";
req.phone_code_hash = "0";
return sendRequest(req, new RequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
}
}, null, null, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin, DEFAULT_DATACENTER_ID, ConnectionTypeGeneric, true);
}
public static int sendRequest(final TLObject object, final RequestDelegate onComplete, final QuickAckDelegate onQuickAck, final WriteToSocketDelegate onWriteToSocket, final int flags, final int datacenterId, final int connetionType, final boolean immediate) {
String ip = defaultIp;
AtomicInteger lastRequestToken = new AtomicInteger(1);
final int requestToken = lastRequestToken.getAndIncrement();
try {
NativeByteBuffer buffer = new NativeByteBuffer(object.getObjectSize());
object.serializeToStream(buffer);
object.freeResources();
native_sendRequest(0, buffer.address, (response, errorCode, errorText, networkType) -> {
if (defaultIp.equals(ip))
{
if (caller != null) {
caller.status(0);
} else {
Log.e("Ip Caller", "Null");
}
}
}, onQuickAck, onWriteToSocket, flags, datacenterId, connetionType, immediate, requestToken);
} catch (Exception e) {
// FileLog.e(e);
}
return requestToken;
}
public static int getCurrentNetworkType() {
return 0;
......@@ -140,12 +199,8 @@ public class ConnectionsManager {
public static void onConnectionStateChanged(final int state, final int currentAccount) {
if (state == 3) {
Log.e("Ip Status Must", String.valueOf(state));
if (caller != null) {
caller.status(state);
} else {
Log.e("Ip Caller", "Null");
}
// Log.e("Ip Status Must", String.valueOf(state));
sendRequest();
}
......
/*
* This is the source code of Telegram for Android v. 3.x.x.
* This is the source code of Telegram for Android v. 5.x.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2017.
* Copyright Nikolai Kudashov, 2013-2018.
*/
package org.telegram.tgnet;
public class TLObject {
public int networkType;
public boolean disableFree = false;
private static final ThreadLocal<NativeByteBuffer> sizeCalculator = new ThreadLocal<NativeByteBuffer>() {
@Override
protected NativeByteBuffer initialValue() {
return new NativeByteBuffer(true);
}
};
public TLObject() {
......@@ -21,11 +28,22 @@ public class TLObject {
}
public void serializeToStream(AbstractSerializedData stream) {
}
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return null;
}
public void freeResources() {
}
public int getObjectSize() {
NativeByteBuffer byteBuffer = sizeCalculator.get();
byteBuffer.rewind();
serializeToStream(sizeCalculator.get());
return byteBuffer.length();
}
}
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="AppName">Telegram</string>
<string name="AppNameBeta">Telegram Beta</string>
<string name="AppNameBeta">hetzner</string>
<string name="LanguageName">English</string>
<string name="English">English</string>
<string name="LanguageNameInEnglish">English</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment