Skip to content

git-xiaocao/pixiv-local-reverse-proxy

Repository files navigation

Pixiv本地反向代理

用于WebView登录Pixiv

如何使用?

Test

直接运行main_test.go里的函数

img.png

Go版本1.18

Android

获取gomobile

go install golang.org/x/mobile/cmd/gomobile

配置环境变量(示例)

  1. 指定ANDROID_HOMEAndroid SDK安装目录
  2. 指定ANDROID_NDK_HOME%ANDROID_HOME%\ndk\23.0.7599858

gomobile 编译 参考build_android

Gradle Groovy

implementation files("pixiv_local_reverse_proxy.aar")

Gradle KTS

implementation(files("pixiv_local_reverse_proxy.aar"))

WebView设置代理

if (WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) {
    val proxyConfig: ProxyConfig = ProxyConfig.Builder()
        .addProxyRule("127.0.0.1:12345")
        .addDirect()
        .build()
    ProxyController.getInstance().setProxyOverride(
        proxyConfig,
        { command -> command?.run() },
    ) {
        //
    }
}

启动

PixivLocalReverseProxy.startServer(12345)

停止

PixivLocalReverseProxy.stopServer()

Windows

CGO编译 参考build_windows

x64 编译器设置

go env -w GOARCH=amd64
go env -w CGO_ENABLED=0

x86 编译器设置

go env -w GOARCH=386
go env -w CGO_ENABLED=1

C#声明

[DllImport(@"PixivLocalReverseProxy.dll")]
public static extern void StartServer(ushort bindPort);

[DllImport(@"PixivLocalReverseProxy.dll")]
public static extern void StopServer();

Microsoft Edge WebView2设置代理

Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", $"--proxy-server=127.0.0.1:12345 --ignore-certificate-errors");

如果要获取登录成功后的Uri里的信息(也就是pixiv://account)

需要使用webView.CoreWebView2.NavigationStarting 而不是webView.NavigationStarting

MicrosoftEdge/WebView2Feedback/issues/2102

注意系统代理比 Environment.SetEnvironmentVariable的优先级高

感谢dylech30th 为我提供的C#语言 .NET平台 WinUI3 等基础知识讲解(恶补)

iOS

gomobile 编译 参考build_ios

自己想办法 我的GTX750Ti显卡装不了黑苹果 没弄过iOS