Skip to content

Commit

Permalink
Add hack to make UDP fallback work
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Apr 19, 2020
1 parent a12d0b0 commit a252f19
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ object BaseService {
udpFallback?.start(this,
File(Core.deviceStorage.noBackupFilesDir, "stat_udp"),
File(configRoot, CONFIG_FILE_UDP),
"-u")
"-u", false)
data.localDns = LocalDnsWorker(this::rawResolver).apply { start() }
}

Expand Down
8 changes: 5 additions & 3 deletions core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
* Sensitive shadowsocks configuration file requires extra protection. It may be stored in encrypted storage or
* device storage, depending on which is currently available.
*/
fun start(service: BaseService.Interface, stat: File, configFile: File, extraFlag: String? = null) {
fun start(service: BaseService.Interface, stat: File, configFile: File, extraFlag: String? = null,
dnsRelay: Boolean = true) {
trafficMonitor = TrafficMonitor(stat)

this.configFile = configFile
Expand All @@ -130,11 +131,12 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
val cmd = arrayListOf(
File((service as Context).applicationInfo.nativeLibraryDir, Executable.SS_LOCAL).absolutePath,
"--stat-path", stat.absolutePath,
"--dns-relay", "${DataStore.listenAddress}:${DataStore.portLocalDns}",
"--remote-dns", "${dns.host}:${if (dns.port < 0) 53 else dns.port}",
"-c", configFile.absolutePath)
if (service.isVpnService) cmd += arrayListOf("--vpn")
if (extraFlag != null) cmd.add(extraFlag)
if (dnsRelay) cmd += arrayListOf(
"--dns-relay", "${DataStore.listenAddress}:${DataStore.portLocalDns}",
"--remote-dns", "${dns.host}:${if (dns.port < 0) 53 else dns.port}")

if (route != Acl.ALL) {
cmd += "--acl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class AlertDialogFragment<Arg : Parcelable, Ret : Parcelable> :
}
protected abstract fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener)

protected val arg by lazy { arguments!!.getParcelable<Arg>(KEY_ARG)!! }
protected val arg by lazy { requireArguments().getParcelable<Arg>(KEY_ARG)!! }
protected open fun ret(which: Int): Ret? = null
fun withArg(arg: Arg) = apply { arguments = Bundle().apply { putParcelable(KEY_ARG, arg) } }

Expand Down

0 comments on commit a252f19

Please sign in to comment.