mirror of
https://github.com/MatsuriDayo/NekoBoxForAndroid.git
synced 2025-12-19 06:30:05 +08:00
Add workaround for bulkBarrierPreWrite: unaligned arguments panic
This commit is contained in:
parent
ad61b2ee66
commit
fd825c5532
@ -23,6 +23,7 @@ import io.nekohasekai.sagernet.ktx.*
|
|||||||
import libcore.Libcore
|
import libcore.Libcore
|
||||||
import moe.matsuri.nb4a.Protocols
|
import moe.matsuri.nb4a.Protocols
|
||||||
import moe.matsuri.nb4a.proxy.config.ConfigBean
|
import moe.matsuri.nb4a.proxy.config.ConfigBean
|
||||||
|
import moe.matsuri.nb4a.utils.Util
|
||||||
import org.ini4j.Ini
|
import org.ini4j.Ini
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
@ -66,10 +67,11 @@ object RawUpdater : GroupUpdater() {
|
|||||||
setURL(subscription.link)
|
setURL(subscription.link)
|
||||||
setUserAgent(subscription.customUserAgent.takeIf { it.isNotBlank() } ?: USER_AGENT)
|
setUserAgent(subscription.customUserAgent.takeIf { it.isNotBlank() } ?: USER_AGENT)
|
||||||
}.execute()
|
}.execute()
|
||||||
proxies = parseRaw(response.contentString)
|
proxies = parseRaw(Util.getStringBox(response.contentString))
|
||||||
?: error(app.getString(R.string.no_proxies_found))
|
?: error(app.getString(R.string.no_proxies_found))
|
||||||
|
|
||||||
subscription.subscriptionUserinfo = response.getHeader("Subscription-Userinfo")
|
subscription.subscriptionUserinfo =
|
||||||
|
Util.getStringBox(response.getHeader("Subscription-Userinfo"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val proxiesMap = LinkedHashMap<String, AbstractBean>()
|
val proxiesMap = LinkedHashMap<String, AbstractBean>()
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import io.nekohasekai.sagernet.databinding.LayoutAssetsBinding
|
|||||||
import io.nekohasekai.sagernet.ktx.*
|
import io.nekohasekai.sagernet.ktx.*
|
||||||
import io.nekohasekai.sagernet.widget.UndoSnackbarManager
|
import io.nekohasekai.sagernet.widget.UndoSnackbarManager
|
||||||
import libcore.Libcore
|
import libcore.Libcore
|
||||||
|
import moe.matsuri.nb4a.utils.Util
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
@ -283,7 +284,7 @@ class AssetsActivity : ThemedActivity() {
|
|||||||
setURL("https://api.github.com/repos/$repo/releases/latest")
|
setURL("https://api.github.com/repos/$repo/releases/latest")
|
||||||
}.execute()
|
}.execute()
|
||||||
|
|
||||||
val release = JSONObject(response.contentString)
|
val release = JSONObject(Util.getStringBox(response.contentString))
|
||||||
val tagName = release.optString("tag_name")
|
val tagName = release.optString("tag_name")
|
||||||
|
|
||||||
if (tagName == localVersion) {
|
if (tagName == localVersion) {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import io.nekohasekai.sagernet.utils.cf.RegisterRequest
|
|||||||
import io.nekohasekai.sagernet.utils.cf.UpdateDeviceRequest
|
import io.nekohasekai.sagernet.utils.cf.UpdateDeviceRequest
|
||||||
import libcore.Libcore
|
import libcore.Libcore
|
||||||
import moe.matsuri.nb4a.utils.JavaUtil.gson
|
import moe.matsuri.nb4a.utils.JavaUtil.gson
|
||||||
|
import moe.matsuri.nb4a.utils.Util
|
||||||
|
|
||||||
// kang from wgcf
|
// kang from wgcf
|
||||||
object Cloudflare {
|
object Cloudflare {
|
||||||
@ -37,8 +38,9 @@ object Cloudflare {
|
|||||||
setUserAgent("okhttp/3.12.1")
|
setUserAgent("okhttp/3.12.1")
|
||||||
}.execute()
|
}.execute()
|
||||||
|
|
||||||
Logs.d(response.contentString)
|
Logs.d(Util.getStringBox(response.contentString))
|
||||||
val device = gson.fromJson(response.contentString, DeviceResponse::class.java)
|
val device =
|
||||||
|
gson.fromJson(Util.getStringBox(response.contentString), DeviceResponse::class.java)
|
||||||
val accessToken = device.token
|
val accessToken = device.token
|
||||||
|
|
||||||
client.newRequest().apply {
|
client.newRequest().apply {
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package moe.matsuri.nb4a.utils
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
|
import libcore.StringBox
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@ -181,4 +182,10 @@ object Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getStringBox(b: StringBox?): String {
|
||||||
|
if (b != null && b.value != null) {
|
||||||
|
return b.value
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
source ../../env_go.sh || true
|
||||||
source ../buildScript/init/env_ndk.sh
|
source ../buildScript/init/env_ndk.sh
|
||||||
|
|
||||||
BUILD=".build"
|
BUILD=".build"
|
||||||
|
|||||||
12
libcore/fix.go
Normal file
12
libcore/fix.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package libcore
|
||||||
|
|
||||||
|
// https://github.com/golang/go/issues/46893
|
||||||
|
// TODO: remove after `bulkBarrierPreWrite: unaligned arguments` fixed
|
||||||
|
|
||||||
|
type StringBox struct {
|
||||||
|
Value string
|
||||||
|
}
|
||||||
|
|
||||||
|
func wrapString(value string) *StringBox {
|
||||||
|
return &StringBox{Value: value}
|
||||||
|
}
|
||||||
@ -45,9 +45,9 @@ type HTTPRequest interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HTTPResponse interface {
|
type HTTPResponse interface {
|
||||||
GetHeader(string) string
|
GetHeader(string) *StringBox
|
||||||
GetContent() ([]byte, error)
|
GetContent() ([]byte, error)
|
||||||
GetContentString() (string, error)
|
GetContentString() (*StringBox, error)
|
||||||
WriteTo(path string) error
|
WriteTo(path string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ type httpResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpResponse) errorString() string {
|
func (h *httpResponse) errorString() string {
|
||||||
content, err := h.GetContentString()
|
content, err := h.getContentString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Sprint("HTTP ", h.Status)
|
return fmt.Sprint("HTTP ", h.Status)
|
||||||
}
|
}
|
||||||
@ -214,8 +214,8 @@ func (h *httpResponse) errorString() string {
|
|||||||
return fmt.Sprint("HTTP ", h.Status, ": ", content)
|
return fmt.Sprint("HTTP ", h.Status, ": ", content)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpResponse) GetHeader(key string) string {
|
func (h *httpResponse) GetHeader(key string) *StringBox {
|
||||||
return h.Header.Get(key)
|
return wrapString(h.Header.Get(key))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpResponse) GetContent() ([]byte, error) {
|
func (h *httpResponse) GetContent() ([]byte, error) {
|
||||||
@ -226,7 +226,15 @@ func (h *httpResponse) GetContent() ([]byte, error) {
|
|||||||
return h.content, h.contentError
|
return h.content, h.contentError
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *httpResponse) GetContentString() (string, error) {
|
func (h *httpResponse) GetContentString() (*StringBox, error) {
|
||||||
|
content, err := h.getContentString()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return wrapString(content), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *httpResponse) getContentString() (string, error) {
|
||||||
content, err := h.GetContent()
|
content, err := h.GetContent()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user