Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
c08fc40d
Commit
c08fc40d
authored
Feb 09, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Connect to proxyUrl using underlying network
parent
f4120b1a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
6 deletions
+10
-6
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+4
-2
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+3
-4
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+3
-0
No files found.
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
c08fc40d
...
@@ -43,6 +43,7 @@ import com.google.firebase.analytics.FirebaseAnalytics
...
@@ -43,6 +43,7 @@ import com.google.firebase.analytics.FirebaseAnalytics
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
import
java.io.File
import
java.io.File
import
java.net.InetAddress
import
java.net.InetAddress
import
java.net.URL
import
java.net.UnknownHostException
import
java.net.UnknownHostException
import
java.util.*
import
java.util.*
...
@@ -279,6 +280,7 @@ object BaseService {
...
@@ -279,6 +280,7 @@ object BaseService {
suspend
fun
preInit
()
{
}
suspend
fun
preInit
()
{
}
suspend
fun
resolver
(
host
:
String
)
=
InetAddress
.
getAllByName
(
host
)
suspend
fun
resolver
(
host
:
String
)
=
InetAddress
.
getAllByName
(
host
)
suspend
fun
openConnection
(
url
:
URL
)
=
url
.
openConnection
()
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
fun
onStartCommand
(
intent
:
Intent
?,
flags
:
Int
,
startId
:
Int
):
Int
{
val
data
=
data
val
data
=
data
...
@@ -314,8 +316,8 @@ object BaseService {
...
@@ -314,8 +316,8 @@ object BaseService {
try
{
try
{
Executable
.
killAll
()
// clean up old processes
Executable
.
killAll
()
// clean up old processes
preInit
()
preInit
()
proxy
.
init
(
this
@Interface
::
resolver
)
proxy
.
init
(
this
@Interface
)
data
.
udpFallback
?.
init
(
this
@Interface
::
resolver
)
data
.
udpFallback
?.
init
(
this
@Interface
)
data
.
processes
=
GuardedProcessPool
{
data
.
processes
=
GuardedProcessPool
{
printLog
(
it
)
printLog
(
it
)
...
...
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
c08fc40d
...
@@ -38,7 +38,6 @@ import kotlinx.coroutines.*
...
@@ -38,7 +38,6 @@ import kotlinx.coroutines.*
import
java.io.File
import
java.io.File
import
java.io.IOException
import
java.io.IOException
import
java.net.HttpURLConnection
import
java.net.HttpURLConnection
import
java.net.InetAddress
import
java.net.UnknownHostException
import
java.net.UnknownHostException
import
java.security.MessageDigest
import
java.security.MessageDigest
...
@@ -51,11 +50,11 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -51,11 +50,11 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
private
val
plugin
=
PluginConfiguration
(
profile
.
plugin
?:
""
).
selectedOptions
private
val
plugin
=
PluginConfiguration
(
profile
.
plugin
?:
""
).
selectedOptions
val
pluginPath
by
lazy
{
PluginManager
.
init
(
plugin
)
}
val
pluginPath
by
lazy
{
PluginManager
.
init
(
plugin
)
}
suspend
fun
init
(
resolver
:
suspend
(
String
)
->
Array
<
InetAddress
>
)
{
suspend
fun
init
(
service
:
BaseService
.
Interface
)
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
mdg
.
update
(
Core
.
packageInfo
.
signaturesCompat
.
first
().
toByteArray
())
mdg
.
update
(
Core
.
packageInfo
.
signaturesCompat
.
first
().
toByteArray
())
val
conn
=
RemoteConfig
.
proxyUrl
.
openConnection
(
)
as
HttpURLConnection
val
conn
=
service
.
openConnection
(
RemoteConfig
.
proxyUrl
)
as
HttpURLConnection
conn
.
requestMethod
=
"POST"
conn
.
requestMethod
=
"POST"
conn
.
doOutput
=
true
conn
.
doOutput
=
true
...
@@ -83,7 +82,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -83,7 +82,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
// it's hard to resolve DNS on a specific interface so we'll do it here
// it's hard to resolve DNS on a specific interface so we'll do it here
if
(
profile
.
host
.
parseNumericAddress
()
==
null
)
profile
.
host
=
withTimeoutOrNull
(
10_000
)
{
if
(
profile
.
host
.
parseNumericAddress
()
==
null
)
profile
.
host
=
withTimeoutOrNull
(
10_000
)
{
GlobalScope
.
async
(
Dispatchers
.
IO
)
{
resolver
(
profile
.
host
)
}.
await
().
firstOrNull
()
GlobalScope
.
async
(
Dispatchers
.
IO
)
{
service
.
resolver
(
profile
.
host
)
}.
await
().
firstOrNull
()
}
?.
hostAddress
?:
throw
UnknownHostException
()
}
?.
hostAddress
?:
throw
UnknownHostException
()
}
}
...
...
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
c08fc40d
...
@@ -47,6 +47,8 @@ import java.io.Closeable
...
@@ -47,6 +47,8 @@ import java.io.Closeable
import
java.io.File
import
java.io.File
import
java.io.FileDescriptor
import
java.io.FileDescriptor
import
java.io.IOException
import
java.io.IOException
import
java.net.URL
import
java.net.URLConnection
import
java.util.*
import
java.util.*
import
android.net.VpnService
as
BaseVpnService
import
android.net.VpnService
as
BaseVpnService
...
@@ -136,6 +138,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -136,6 +138,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
override
suspend
fun
preInit
()
=
DefaultNetworkListener
.
start
(
this
)
{
underlyingNetwork
=
it
}
override
suspend
fun
preInit
()
=
DefaultNetworkListener
.
start
(
this
)
{
underlyingNetwork
=
it
}
override
suspend
fun
resolver
(
host
:
String
)
=
DefaultNetworkListener
.
get
().
getAllByName
(
host
)
override
suspend
fun
resolver
(
host
:
String
)
=
DefaultNetworkListener
.
get
().
getAllByName
(
host
)
override
suspend
fun
openConnection
(
url
:
URL
)
=
DefaultNetworkListener
.
get
().
openConnection
(
url
)
override
suspend
fun
startProcesses
()
{
override
suspend
fun
startProcesses
()
{
worker
=
ProtectWorker
().
apply
{
start
()
}
worker
=
ProtectWorker
().
apply
{
start
()
}
...
...
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