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
2df7f3a1
Commit
2df7f3a1
authored
Jan 31, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
257d1e51
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
30 deletions
+37
-30
build.gradle
TMessagesProj/build.gradle
+1
-0
Proxy.java
TMessagesProj/src/main/java/org/telegram/io/Proxy.java
+3
-2
SocketService.java
...roj/src/main/java/org/telegram/service/SocketService.java
+30
-25
ConnectionsManager.java
.../src/main/java/org/telegram/tgnet/ConnectionsManager.java
+3
-3
No files found.
TMessagesProj/build.gradle
View file @
2df7f3a1
...
...
@@ -39,6 +39,7 @@ dependencies {
implementation
'com.google.code.gson:gson:2.8.5'
compile
'io.reactivex:rxandroid:1.2.1'
compile
'io.reactivex:rxjava:1.1.6'
compile
'com.jakewharton:process-phoenix:2.0.0'
}
...
...
TMessagesProj/src/main/java/org/telegram/io/Proxy.java
View file @
2df7f3a1
...
...
@@ -43,8 +43,9 @@ public class Proxy {
@SerializedName
(
"messageId"
)
@Expose
private
String
messageId
;
private
int
retry
=
0
;
@SerializedName
(
"retry"
)
@Expose
private
int
retry
;
public
int
getId
()
{
return
id
;
...
...
TMessagesProj/src/main/java/org/telegram/service/SocketService.java
View file @
2df7f3a1
...
...
@@ -8,6 +8,7 @@ import android.util.Log;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.jakewharton.processphoenix.ProcessPhoenix
;
import
org.telegram.io.Constants
;
import
org.telegram.io.CryptLib
;
...
...
@@ -25,6 +26,7 @@ import javax.crypto.NoSuchPaddingException;
import
io.socket.emitter.Emitter
;
import
rx.Observable
;
import
rx.Subscriber
;
import
rx.android.schedulers.AndroidSchedulers
;
import
rx.schedulers.Schedulers
;
...
...
@@ -70,12 +72,10 @@ public class SocketService extends Service implements Emitter.Listener {
@Override
public
void
call
(
Object
...
args
)
{
if
(
args
.
length
==
0
)
return
;
if
(
work
)
{
Log
.
e
(
"Ping"
,
"Reject Worker is work!"
);
return
;
}
Log
.
e
(
"Received from server"
,
String
.
valueOf
(
args
.
length
));
if
(
args
.
length
==
0
||
work
)
return
;
Log
.
e
(
"Ping from server Size"
,
String
.
valueOf
(
args
.
length
));
String
chiper
=
String
.
valueOf
(
args
[
0
]);
try
{
...
...
@@ -101,7 +101,7 @@ public class SocketService extends Service implements Emitter.Listener {
ConnectionsManager
.
setProxySettings
(
proxy
.
getIp
(),
proxy
.
getPort
(),
proxy
.
getSecret
());
connectionsManager
.
checkProxy
(
proxy
.
getIp
(),
proxy
.
getPort
(),
proxy
.
getSecret
()
,
time
->
{
proxy
.
setPing
(
time
);
proxy
.
setPing
(
time
==
-
1
?
0
:
time
);
subscriber
.
onNext
(
proxy
);
subscriber
.
onCompleted
();
});
...
...
@@ -110,6 +110,8 @@ public class SocketService extends Service implements Emitter.Listener {
}
public
void
initCheckProxy
(
List
<
Proxy
>
proxyList
)
{
...
...
@@ -118,31 +120,19 @@ public class SocketService extends Service implements Emitter.Listener {
.
subscribeOn
(
Schedulers
.
io
())
.
concatMap
(
proxy
->
getPingServerObservable
(
proxy
)
.
subscribeOn
(
Schedulers
.
io
())
.
timeout
(
5
,
TimeUnit
.
SECONDS
)
.
timeout
(
10
,
TimeUnit
.
SECONDS
)
.
onErrorResumeNext
(
t
->
{
if
(
proxy
.
getRetry
()
==
1
)
{
proxy
.
setPing
(
0
);
return
Observable
.
just
(
proxy
);
}
Log
.
e
(
"Ping"
,
"Try Retry"
);
proxy
.
setRetry
(
1
);
return
getPingServerObservable
(
proxy
)
.
subscribeOn
(
Schedulers
.
newThread
())
.
timeout
(
5
,
TimeUnit
.
SECONDS
)
.
onErrorResumeNext
(
throwable
->
{
proxy
.
setPing
(
0
);
return
Observable
.
just
(
proxy
);
});
{
proxy
.
setPing
(
0
);
return
Observable
.
just
(
proxy
);
}))
.
toList
()
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
new
Subscriber
<
List
<
Proxy
>>()
{
@Override
public
void
onCompleted
()
{
work
=
false
;
//Log.e("Ping", "Done");
}
@Override
...
...
@@ -152,8 +142,22 @@ public class SocketService extends Service implements Emitter.Listener {
@Override
public
void
onNext
(
List
<
Proxy
>
proxyList
)
{
int
w
=
0
;
int
n
=
0
;
Boolean
needReset
=
true
;
for
(
Proxy
proxy
:
proxyList
)
{
if
(
proxy
.
getPing
()
>
0
)
{
needReset
=
false
;
w
++;
}
else
n
++;
}
if
(
needReset
)
ProcessPhoenix
.
triggerRebirth
(
SocketService
.
this
);
work
=
false
;
Log
.
e
(
"Ping"
,
"Task Check Finished for "
+
proxyList
.
size
()
+
" Ips"
);
Log
.
e
(
"Ping"
,
"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
);
...
...
@@ -167,4 +171,5 @@ public class SocketService extends Service implements Emitter.Listener {
}
}
TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java
View file @
2df7f3a1
...
...
@@ -6,6 +6,8 @@ import android.util.Log;
public
class
ConnectionsManager
{
private
int
currentAccount
=
0
;
private
static
volatile
ConnectionsManager
[]
Instance
=
new
ConnectionsManager
[
3
];
...
...
@@ -19,9 +21,7 @@ public class ConnectionsManager {
public
long
checkProxy
(
String
address
,
int
port
,
String
secret
,
RequestTimeDelegate
requestTimeDelegate
)
{
long
l
=
native_checkProxy
(
currentAccount
,
address
,
port
,
""
,
""
,
secret
,
requestTimeDelegate
);
Log
.
e
(
"Here"
,
String
.
valueOf
(
l
));
return
l
;
return
native_checkProxy
(
currentAccount
,
address
,
port
,
""
,
""
,
secret
,
requestTimeDelegate
);
}
...
...
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