Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
apk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
apk
Commits
b05fa4ca
Commit
b05fa4ca
authored
Dec 13, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
95485955
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
36813 additions
and
157 deletions
+36813
-157
build.gradle
TMessagesProj/build.gradle
+2
-17
MainActivity.java
TMessagesProj/src/main/java/org/telegram/MainActivity.java
+6
-0
Constants.java
TMessagesProj/src/main/java/org/telegram/io/Constants.java
+3
-1
Counter.java
TMessagesProj/src/main/java/org/telegram/io/Counter.java
+33
-0
Proxy.java
TMessagesProj/src/main/java/org/telegram/io/Proxy.java
+25
-0
SingletonSocket.java
...esProj/src/main/java/org/telegram/io/SingletonSocket.java
+1
-1
ApplicationLoader.java
...c/main/java/org/telegram/messenger/ApplicationLoader.java
+11
-0
SocketService.java
...roj/src/main/java/org/telegram/service/SocketService.java
+85
-122
AbstractSerializedData.java
.../main/java/org/telegram/tgnet/AbstractSerializedData.java
+2
-2
ConnectionsManager.java
.../src/main/java/org/telegram/tgnet/ConnectionsManager.java
+61
-6
TLObject.java
TMessagesProj/src/main/java/org/telegram/tgnet/TLObject.java
+23
-5
TLRPC.java
TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
+36560
-2
strings.xml
TMessagesProj/src/main/res/values/strings.xml
+1
-1
No files found.
TMessagesProj/build.gradle
View file @
b05fa4ca
...
@@ -18,22 +18,7 @@ dependencies {
...
@@ -18,22 +18,7 @@ dependencies {
implementation
'com.android.support.constraint:constraint-layout:1.1.3'
implementation
'com.android.support.constraint:constraint-layout:1.1.3'
compileOnly
'org.checkerframework:checker-qual:2.5.0'
compileOnly
'org.checkerframework:checker-qual:2.5.0'
compileOnly
'org.checkerframework:checker-compat-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'
)
{
implementation
(
'io.socket:socket.io-client:1.0.0'
)
{
// excluding org.json which is provided by Android
// excluding org.json which is provided by Android
exclude
group:
'org.json'
,
module:
'json'
exclude
group:
'org.json'
,
module:
'json'
...
@@ -51,7 +36,7 @@ android {
...
@@ -51,7 +36,7 @@ android {
compileSdkVersion
28
compileSdkVersion
28
buildToolsVersion
'28.0.2'
buildToolsVersion
'28.0.2'
defaultConfig
.
applicationId
=
"org.telegram.
messeng
er"
defaultConfig
.
applicationId
=
"org.telegram.
hetzn
er"
...
...
TMessagesProj/src/main/java/org/telegram/MainActivity.java
View file @
b05fa4ca
...
@@ -23,7 +23,13 @@ public class MainActivity extends AppCompatActivity {
...
@@ -23,7 +23,13 @@ public class MainActivity extends AppCompatActivity {
}
}
@Override
protected
void
onResume
()
{
super
.
onResume
();
startService
(
new
Intent
(
this
,
SocketService
.
class
));
}
}
}
TMessagesProj/src/main/java/org/telegram/io/Constants.java
View file @
b05fa4ca
...
@@ -4,7 +4,9 @@ package org.telegram.io;
...
@@ -4,7 +4,9 @@ package org.telegram.io;
* Created by Ahmad Nemati on 1/17/19.
* Created by Ahmad Nemati on 1/17/19.
*/
*/
public
class
Constants
{
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
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"
;
public
static
final
String
GET_JSON_FOR_PING_Amazon
=
"pingAmazon"
;
}
}
TMessagesProj/src/main/java/org/telegram/io/Counter.java
0 → 100644
View file @
b05fa4ca
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
++;
}
}
TMessagesProj/src/main/java/org/telegram/io/Proxy.java
View file @
b05fa4ca
...
@@ -60,6 +60,10 @@ public class Proxy {
...
@@ -60,6 +60,10 @@ public class Proxy {
@Expose
@Expose
private
String
instance
;
private
String
instance
;
@SerializedName
(
"ipdate"
)
@Expose
private
String
ipdate
;
private
long
dur
=
0
;
private
long
dur
=
0
;
private
Boolean
connect
=
false
;
private
Boolean
connect
=
false
;
...
@@ -174,11 +178,32 @@ public class Proxy {
...
@@ -174,11 +178,32 @@ public class Proxy {
return
type
;
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
)
{
public
void
setDur
(
long
dur
)
{
this
.
dur
=
dur
;
this
.
dur
=
dur
;
}
}
public
String
getIpdate
()
{
return
ipdate
;
}
public
void
setIpdate
(
String
ipdate
)
{
this
.
ipdate
=
ipdate
;
}
}
}
TMessagesProj/src/main/java/org/telegram/io/SingletonSocket.java
View file @
b05fa4ca
...
@@ -25,7 +25,7 @@ public class SingletonSocket {
...
@@ -25,7 +25,7 @@ public class SingletonSocket {
opts
.
forceNew
=
true
;
opts
.
forceNew
=
true
;
opts
.
reconnection
=
true
;
opts
.
reconnection
=
true
;
opts
.
secure
=
true
;
opts
.
secure
=
true
;
opts
.
query
=
"type=
Ping"
;
opts
.
query
=
"type=
"
+
Constants
.
TYPE
;
mSocket
=
IO
.
socket
(
Constants
.
CHAT_SERVER_URL
,
opts
);
mSocket
=
IO
.
socket
(
Constants
.
CHAT_SERVER_URL
,
opts
);
}
catch
(
URISyntaxException
e
)
{
}
catch
(
URISyntaxException
e
)
{
...
...
TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java
View file @
b05fa4ca
...
@@ -14,6 +14,11 @@ import android.content.Intent;
...
@@ -14,6 +14,11 @@ import android.content.Intent;
import
org.telegram.io.SingletonSocket
;
import
org.telegram.io.SingletonSocket
;
import
org.telegram.service.SocketService
;
import
org.telegram.service.SocketService
;
import
org.telegram.tgnet.ConnectionsManager
;
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
{
public
class
ApplicationLoader
extends
Application
{
...
@@ -29,6 +34,12 @@ public class ApplicationLoader extends Application {
...
@@ -29,6 +34,12 @@ public class ApplicationLoader extends Application {
startService
(
new
Intent
(
this
,
SocketService
.
class
));
startService
(
new
Intent
(
this
,
SocketService
.
class
));
ConnectionsManager
.
native_setJava
(
false
);
ConnectionsManager
.
native_setJava
(
false
);
// ConnectionsManager.setProxySettings("78.46.148.22", 443, "00000000000000000000000000000000");
}
}
...
...
TMessagesProj/src/main/java/org/telegram/service/SocketService.java
View file @
b05fa4ca
...
@@ -10,16 +10,15 @@ import com.google.gson.Gson;
...
@@ -10,16 +10,15 @@ import com.google.gson.Gson;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
org.telegram.io.Constants
;
import
org.telegram.io.Constants
;
import
org.telegram.io.Counter
;
import
org.telegram.io.CryptLib
;
import
org.telegram.io.CryptLib
;
import
org.telegram.io.Proxy
;
import
org.telegram.io.Proxy
;
import
org.telegram.io.SingletonSocket
;
import
org.telegram.io.SingletonSocket
;
import
org.telegram.io.Utils
;
import
org.telegram.io.Utils
;
import
org.telegram.tgnet.ConnectionsManager
;
import
org.telegram.tgnet.ConnectionsManager
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -42,6 +41,7 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -42,6 +41,7 @@ public class SocketService extends Service implements Emitter.Listener {
ConnectionsManager
connectionsManager
;
ConnectionsManager
connectionsManager
;
Boolean
work
=
false
;
Boolean
work
=
false
;
Boolean
workAmazon
=
false
;
Boolean
workAmazon
=
false
;
private
List
<
Counter
>
counters
=
new
ArrayList
<>();
@Override
@Override
...
@@ -56,12 +56,23 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -56,12 +56,23 @@ public class SocketService extends Service implements Emitter.Listener {
}
catch
(
NoSuchPaddingException
e
)
{
}
catch
(
NoSuchPaddingException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
SingletonSocket
.
getInstance
().
getSocket
().
on
(
Constants
.
GET_JSON_FOR_PING
,
this
);
SingletonSocket
.
getInstance
().
getSocket
().
on
(
Constants
.
GET_JSON_FOR_PING
,
this
);
SingletonSocket
.
getInstance
().
getSocket
().
on
(
Constants
.
GET_JSON_FOR_PING_Amazon
,
new
PingAmazon
());
SingletonSocket
.
getInstance
().
getSocket
().
on
(
Constants
.
WAKE_UP
,
args
->
{
if
(
work
)
return
;
needSendProxy
();
});
SingletonSocket
.
getInstance
().
getSocket
().
connect
();
SingletonSocket
.
getInstance
().
getSocket
().
connect
();
}
}
private
void
needSendProxy
()
{
SingletonSocket
.
getInstance
().
getSocket
().
emit
(
"need"
,
""
);
}
@Nullable
@Nullable
@Override
@Override
public
IBinder
onBind
(
Intent
intent
)
{
public
IBinder
onBind
(
Intent
intent
)
{
...
@@ -79,7 +90,7 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -79,7 +90,7 @@ public class SocketService extends Service implements Emitter.Listener {
if
(
args
.
length
==
0
||
work
)
return
;
if
(
args
.
length
==
0
||
work
)
return
;
Log
.
e
(
"P
ing
from server Size"
,
String
.
valueOf
(
args
.
length
));
Log
.
e
(
"P
roxy
from server Size"
,
String
.
valueOf
(
args
.
length
));
String
chiper
=
String
.
valueOf
(
args
[
0
]);
String
chiper
=
String
.
valueOf
(
args
[
0
]);
try
{
try
{
...
@@ -102,16 +113,16 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -102,16 +113,16 @@ public class SocketService extends Service implements Emitter.Listener {
return
Observable
.
create
(
subscriber
->
{
return
Observable
.
create
(
subscriber
->
{
if
(
proxy
.
getType
().
equals
(
"especial"
)
)
{
// if (getCounter(proxy.getIp()) > 2
) {
proxy
.
setConnect
(
true
);
// subscriber.onError(null
);
subscriber
.
onNext
(
proxy
);
// subscriber.onCompleted(
);
subscriber
.
onCompleted
()
;
// return
;
}
//
}
long
startTime
=
System
.
nanoTime
();
long
startTime
=
System
.
nanoTime
();
ConnectionsManager
.
defaultIp
=
proxy
.
getIp
();
ConnectionsManager
.
setCaller
(
status
->
{
ConnectionsManager
.
setCaller
(
status
->
{
Log
.
e
(
"Proxy Connect"
,
"IP :"
+
proxy
.
getIp
());
Log
.
e
(
"Proxy Connect"
,
"IP ***Work*** :"
+
proxy
.
getIp
()
+
" "
+
Constants
.
TYPE
);
addCounter
(
proxy
.
getIp
(),
true
);
long
endTime
=
System
.
nanoTime
();
long
endTime
=
System
.
nanoTime
();
long
duration
=
(
endTime
-
startTime
)
/
1000000
-
120
;
long
duration
=
(
endTime
-
startTime
)
/
1000000
-
120
;
proxy
.
setDur
(
duration
);
proxy
.
setDur
(
duration
);
...
@@ -126,112 +137,78 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -126,112 +137,78 @@ public class SocketService extends Service implements Emitter.Listener {
});
});
}
}
p
ublic
Observable
<
Proxy
>
getPingAmazonServerObservable
(
Proxy
proxy
)
{
p
rivate
Boolean
addCounter
(
String
ip
,
Boolean
work
)
{
for
(
int
i
=
0
;
i
<
counters
.
size
();
i
++)
{
if
(
counters
.
get
(
i
).
getIp
().
equals
(
ip
))
{
return
Observable
.
create
(
subscriber
->
{
try
{
Process
process
=
Runtime
.
getRuntime
().
exec
(
"ping -c 7 "
+
proxy
.
getIp
());
if
(
work
)
{
BufferedReader
bufferedReader
=
new
BufferedReader
(
counters
.
get
(
i
).
setCount
(
0
);
new
InputStreamReader
(
process
.
getInputStream
()));
return
true
;
String
log
=
""
;
String
line
;
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
if
(!
line
.
contains
(
"received"
))
continue
;
log
=
line
;
}
else
{
counters
.
get
(
i
).
setCountPlus
();
return
counters
.
get
(
i
).
getCount
()
<=
5
;
}
}
}
String
[]
res
=
log
.
split
(
","
);
int
packetRes
=
Integer
.
parseInt
(
res
[
1
].
replace
(
"received"
,
""
).
trim
());
if
(
packetRes
<=
2
)
}
proxy
.
setConnect
(
false
);
else
proxy
.
setConnect
(
true
);
subscriber
.
onNext
(
proxy
);
subscriber
.
onCompleted
();
}
catch
(
IOException
e
)
{
Counter
counter
=
new
Counter
(
ip
,
work
?
0
:
1
);
Log
.
e
(
"Amazon Error"
,
"Error"
);
proxy
.
setConnect
(
true
);
subscriber
.
onNext
(
proxy
);
subscriber
.
onCompleted
();
}
counters
.
add
(
counter
);
return
true
;
});
}
}
private
int
getCounter
(
String
ip
)
{
public
void
initCheckProxy
(
List
<
Proxy
>
proxyList
)
{
for
(
int
i
=
0
;
i
<
counters
.
size
();
i
++)
{
if
(
counters
.
get
(
i
).
getIp
().
equals
(
ip
))
{
return
counters
.
get
(
i
).
getCount
();
Observable
.
from
(
proxyList
)
}
.
subscribeOn
(
Schedulers
.
newThread
())
.
concatMap
(
proxy
->
getPingServerObservable
(
proxy
)
.
subscribeOn
(
Schedulers
.
newThread
())
.
timeout
(
5
,
TimeUnit
.
SECONDS
)
.
onErrorResumeNext
(
throwable
->
{
ConnectionsManager
.
setCaller
(
null
);
proxy
.
setConnect
(
false
);
return
Observable
.
just
(
proxy
);
}))
.
toList
()
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
new
Subscriber
<
List
<
Proxy
>>()
{
@Override
public
void
onCompleted
()
{
work
=
false
;
}
}
@Override
public
void
onError
(
Throwable
e
)
{
work
=
false
;
}
@Override
Counter
counter
=
new
Counter
(
ip
,
0
);
public
void
onNext
(
List
<
Proxy
>
proxyList
)
{
counters
.
add
(
counter
);
int
w
=
0
;
int
n
=
0
;
for
(
Proxy
proxy
:
proxyList
)
{
return
0
;
if
(
proxy
.
getConnect
())
w
++;
else
n
++;
}
work
=
false
;
}
Log
.
e
(
"Status Result :"
,
"Task Check Finished for "
+
proxyList
.
size
()
+
" Ips And "
+
w
+
" Ips Work and "
+
n
+
" IPS not work"
);
try
{
String
cipherText
=
cryptLib
.
encryptPlainTextWithRandomIV
(
gson
.
toJson
(
proxyList
),
key
);
SingletonSocket
.
getInstance
().
getSocket
().
emit
(
"checkping"
,
cipherText
);
}
catch
(
Exception
e
)
{
public
void
initCheckProxy
(
List
<
Proxy
>
proxyList
)
{
e
.
printStackTrace
();
}
}
});
Observable
.
from
(
proxyList
)
.
subscribeOn
(
Schedulers
.
newThread
())
.
concatMap
(
proxy
->
getPingServerObservable
(
proxy
)
.
subscribeOn
(
Schedulers
.
newThread
())
.
timeout
(
10
,
TimeUnit
.
SECONDS
)
.
onErrorResumeNext
(
throwable
->
{
ConnectionsManager
.
setCaller
(
null
);
if
(!
addCounter
(
proxy
.
getIp
(),
false
))
{
proxy
.
setConnect
(
false
);
Log
.
e
(
"Proxy Connect"
,
"IP Not Work :"
+
proxy
.
getIp
()
+
" "
+
Constants
.
TYPE
);
}
else
{
proxy
.
setConnect
(
true
);
Log
.
e
(
"Proxy Connect"
,
"IP So So :"
+
proxy
.
getIp
()
+
" "
+
Constants
.
TYPE
);
}
}
public
void
initCheckAmazonProxy
(
List
<
Proxy
>
proxyList
)
{
return
Observable
.
just
(
proxy
);
Observable
.
from
(
proxyList
)
}))
.
subscribeOn
(
Schedulers
.
newThread
())
.
flatMap
(
proxy
->
getPingAmazonServerObservable
(
proxy
)
.
subscribeOn
(
Schedulers
.
newThread
()))
.
toList
()
.
toList
()
...
@@ -239,63 +216,49 @@ public class SocketService extends Service implements Emitter.Listener {
...
@@ -239,63 +216,49 @@ public class SocketService extends Service implements Emitter.Listener {
.
subscribe
(
new
Subscriber
<
List
<
Proxy
>>()
{
.
subscribe
(
new
Subscriber
<
List
<
Proxy
>>()
{
@Override
@Override
public
void
onCompleted
()
{
public
void
onCompleted
()
{
work
Amazon
=
false
;
work
=
false
;
}
}
@Override
@Override
public
void
onError
(
Throwable
e
)
{
public
void
onError
(
Throwable
e
)
{
work
Amazon
=
false
;
work
=
false
;
}
}
@Override
@Override
public
void
onNext
(
List
<
Proxy
>
proxyList
)
{
public
void
onNext
(
List
<
Proxy
>
proxyList
)
{
int
w
=
0
;
int
w
=
0
;
int
n
=
0
;
int
n
=
0
;
List
<
Proxy
>
notWork
=
new
ArrayList
<>();
for
(
Proxy
proxy
:
proxyList
)
{
for
(
Proxy
proxy
:
proxyList
)
{
if
(
proxy
.
getConnect
())
if
(
proxy
.
getConnect
())
w
++;
w
++;
else
else
{
notWork
.
add
(
proxy
);
n
++;
n
++;
Log
.
e
(
"Status"
,
proxy
.
getInstance
());
}
}
}
work
=
false
;
Log
.
e
(
"Status Amazon Result :"
,
"Task Check Finished for "
+
proxyList
.
size
()
+
" Ips And "
+
w
+
" Ips Work and "
+
n
+
" IPS not work"
);
work
=
false
;
Log
.
e
(
"Status Proxy Result :"
,
"Task Check Finished for "
+
proxyList
.
size
()
+
" Ips And "
+
w
+
" Ips Work and "
+
n
+
" IPS not work"
+
" "
+
Constants
.
TYPE
);
if
(
notWork
.
size
()
!=
0
)
{
try
{
try
{
String
cipherText
=
cryptLib
.
encryptPlainTextWithRandomIV
(
gson
.
toJson
(
proxyList
),
key
);
String
cipherText
=
cryptLib
.
encryptPlainTextWithRandomIV
(
gson
.
toJson
(
notWork
),
key
);
SingletonSocket
.
getInstance
().
getSocket
().
emit
(
"checkAmazonP
ing"
,
cipherText
);
SingletonSocket
.
getInstance
().
getSocket
().
emit
(
"checkp
ing"
,
cipherText
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
});
}
}
});
private
class
PingAmazon
implements
Emitter
.
Listener
{
@Override
public
void
call
(
Object
...
args
)
{
if
(
args
.
length
==
0
||
workAmazon
)
return
;
String
chiper
=
String
.
valueOf
(
args
[
0
]);
try
{
String
decrypt
=
cryptLib
.
decryptCipherTextWithRandomIV
(
chiper
,
key
);
List
<
Proxy
>
proxyList
=
gson
.
fromJson
(
decrypt
,
new
TypeToken
<
List
<
Proxy
>>()
{
}.
getType
());
proxyList
=
Utils
.
removeDuplicator
(
proxyList
);
workAmazon
=
true
;
initCheckAmazonProxy
(
proxyList
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
}
TMessagesProj/src/main/java/org/telegram/tgnet/AbstractSerializedData.java
View file @
b05fa4ca
...
@@ -24,7 +24,7 @@ public abstract class AbstractSerializedData {
...
@@ -24,7 +24,7 @@ public abstract class AbstractSerializedData {
public
abstract
void
writeDouble
(
double
d
);
public
abstract
void
writeDouble
(
double
d
);
public
abstract
void
writeByteBuffer
(
NativeByteBuffer
buffer
);
public
abstract
int
readInt32
(
boolean
exception
);
public
abstract
int
readInt32
(
boolean
exception
);
...
@@ -40,7 +40,7 @@ public abstract class AbstractSerializedData {
...
@@ -40,7 +40,7 @@ public abstract class AbstractSerializedData {
public
abstract
byte
[]
readByteArray
(
boolean
exception
);
public
abstract
byte
[]
readByteArray
(
boolean
exception
);
public
abstract
NativeByteBuffer
readByteBuffer
(
boolean
exception
);
public
abstract
double
readDouble
(
boolean
exception
);
public
abstract
double
readDouble
(
boolean
exception
);
...
...
TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
View file @
b05fa4ca
...
@@ -5,12 +5,15 @@ import android.util.Log;
...
@@ -5,12 +5,15 @@ import android.util.Log;
import
org.telegram.io.Caller
;
import
org.telegram.io.Caller
;
import
java.util.concurrent.atomic.AtomicInteger
;
public
class
ConnectionsManager
{
public
class
ConnectionsManager
{
private
int
currentAccount
=
0
;
private
int
currentAccount
=
0
;
public
static
Caller
caller
=
null
;
public
static
Caller
caller
=
null
;
public
static
String
defaultIp
=
"127.0.0.1"
;
public
ConnectionsManager
()
{
public
ConnectionsManager
()
{
...
@@ -100,6 +103,14 @@ public class ConnectionsManager {
...
@@ -100,6 +103,14 @@ public class ConnectionsManager {
return
false
;
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
)
{
public
void
setAppPaused
(
final
boolean
value
,
final
boolean
byScreenState
)
{
...
@@ -114,6 +125,54 @@ public class ConnectionsManager {
...
@@ -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
()
{
public
static
int
getCurrentNetworkType
()
{
return
0
;
return
0
;
...
@@ -140,12 +199,8 @@ public class ConnectionsManager {
...
@@ -140,12 +199,8 @@ public class ConnectionsManager {
public
static
void
onConnectionStateChanged
(
final
int
state
,
final
int
currentAccount
)
{
public
static
void
onConnectionStateChanged
(
final
int
state
,
final
int
currentAccount
)
{
if
(
state
==
3
)
{
if
(
state
==
3
)
{
Log
.
e
(
"Ip Status Must"
,
String
.
valueOf
(
state
));
// Log.e("Ip Status Must", String.valueOf(state));
if
(
caller
!=
null
)
{
sendRequest
();
caller
.
status
(
state
);
}
else
{
Log
.
e
(
"Ip Caller"
,
"Null"
);
}
}
}
...
...
TMessagesProj/src/main/java/org/telegram/tgnet/TLObject.java
View file @
b05fa4ca
/*
/*
* 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.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
* You should have received a copy of the license in this archive (see LICENSE).
*
*
* Copyright Nikolai Kudashov, 2013-201
7
.
* Copyright Nikolai Kudashov, 2013-201
8
.
*/
*/
package
org
.
telegram
.
tgnet
;
package
org
.
telegram
.
tgnet
;
public
class
TLObject
{
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
()
{
public
TLObject
()
{
...
@@ -21,11 +28,22 @@ public class 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
();
}
}
}
TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
View file @
b05fa4ca
This source diff could not be displayed because it is too large. You can
view the blob
instead.
TMessagesProj/src/main/res/values/strings.xml
View file @
b05fa4ca
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppName"
>
Telegram
</string>
<string
name=
"AppNameBeta"
>
Telegram Beta
</string>
<string
name=
"AppNameBeta"
>
hetzner
</string>
<string
name=
"LanguageName"
>
English
</string>
<string
name=
"LanguageName"
>
English
</string>
<string
name=
"English"
>
English
</string>
<string
name=
"English"
>
English
</string>
<string
name=
"LanguageNameInEnglish"
>
English
</string>
<string
name=
"LanguageNameInEnglish"
>
English
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment