Skip to content

Commit

Permalink
Merge pull request #53 from greatfire/envoy-urls
Browse files Browse the repository at this point in the history
support envoy and ss urls
  • Loading branch information
mnbogner authored Mar 13, 2023
2 parents bcc7b8f + 94d404e commit 653943a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion android/demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {
implementation 'com.android.volley:volley:1.2.1'

implementation project(path: ':envoy')
implementation 'org.greatfire.envoy:cronet:102.0.5005.195-1'
implementation 'org.greatfire.envoy:cronet:102.0.5005.195-3'
implementation 'androidx.viewpager2:viewpager2:1.0.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Expand Down
2 changes: 1 addition & 1 deletion android/envoy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dependencies {
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'org.greatfire.envoy:cronet:102.0.5005.195-1'
implementation 'org.greatfire.envoy:cronet:102.0.5005.195-3'
implementation 'org.greatfire:IEnvoyProxy:1.2.1'

// debugApi(name: 'cronet-debug', ext: 'aar')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ class NetworkIntentService : IntentService("NetworkIntentService") {
private val cacheMap = Collections.synchronizedMap(mutableMapOf<String, String>())
private val cronetMap = Collections.synchronizedMap(mutableMapOf<String, CronetEngine>())

private val httpPrefixes = Collections.synchronizedList(mutableListOf<String>("https", "http", "envoy"))
private val supportedPrefixes = Collections.synchronizedList(mutableListOf<String>("v2ws", "v2srtp", "v2wechat", "hysteria", "ss"))

inner class NetworkBinder : Binder() {
// Return this instance of LocalService so clients can call public methods
fun getService(): NetworkIntentService = this@NetworkIntentService
Expand Down Expand Up @@ -223,12 +226,16 @@ class NetworkIntentService : IntentService("NetworkIntentService") {
}
} else {
urlsToSubmit.forEach() { url ->
val parts = url.split(":")
val prefix = parts[0]
if (url.contains("test")) {
// no-op
} else if (url.startsWith("http")) {
} else if (httpPrefixes.contains(prefix)) {
shuffledHttps.add(url)
} else {
} else if (supportedPrefixes.contains(prefix)) {
shuffledUrls.add(url)
} else {
Log.w(TAG, "found url with unsupported prefix: " + prefix)
}
}
Log.d(TAG, "shuffle " + (shuffledHttps.size + shuffledUrls.size) + " submitted urls")
Expand Down Expand Up @@ -331,9 +338,12 @@ class NetworkIntentService : IntentService("NetworkIntentService") {
} else if (envoyUrl.startsWith("ss://")) {
Log.d(TAG, "found ss url: " + envoyUrl)
handleShadowsocksSubmit(envoyUrl, captive_portal_url, hysteriaCert, dnsttConfig, dnsttUrls)
} else {
Log.d(TAG, "found (https?) url: " + envoyUrl)
} else if (envoyUrl.startsWith("http") || envoyUrl.startsWith("envoy")) {
Log.d(TAG, "found http/envoy url: " + envoyUrl)
handleHttpsSubmit(envoyUrl, captive_portal_url, hysteriaCert, dnsttConfig, dnsttUrls)
} else {
// prefix check should handle this but if not, batch count may not add up
Log.w(TAG, "found unsupported url: " + envoyUrl)
}
}

Expand Down

0 comments on commit 653943a

Please sign in to comment.