🖌️
fanqiang
  • 翻墙-科学上网、翻墙工具、翻墙教程项目库
  • MAC允许未知来源的应用
  • V2ray机场
  • 苹果iPhone、ios翻墙方法
  • 中国大陆注册ChatGPT教程
  • Shadowsocks+v2ray插件教程
  • v2ray免费账号(长期更新)
  • SS/SSR免费账号(长期更新)
  • 安卓翻墙APP: V2ray VPN 下载
  • FirefoxFQ,火狐firefox一键翻墙包
  • 苹果电脑MAC翻墙方法
  • ChromeGo,Chrome一键翻墙包
  • ChromeGoMac,Chrome一键翻墙包 Mac版
  • EdgeGo,Edge一键翻墙包
  • Firefox一键翻墙包 Linux版
  • Android 安卓翻墙教程
    • 安卓翻墙APP:BifrostV 教程
    • 安卓翻墙APP:Shadowsocks for Android 教程
    • 安卓手机 SSR 翻墙教程
    • 安卓手机 Surfboard 翻墙教程
    • 安卓手机 V2rayNG 翻墙教程
    • 安卓手机翻墙APP: Clash for Android教程
    • V2ray.VPN 教程
  • deprecated
    • ipfs-qanqiang
    • readme
      • 聊聊 GFW 如何封杀 Resilio Sync(BTSync)?以及如何【免翻墙】继续使用?
  • 翻墙新闻(FQNews)安卓APP
    • shadowsocks-android plugin framework
      • CHANGES
      • doc
  • 翻墙新闻(FQNews)安卓APP(新版)
    • CHANGELOG
    • fastlane
  • 游戏机翻墙加速教程
    • Mac电脑使用ClashX Pro作为网关旁路由给其它设备翻墙
    • Oculus Quest 如何翻墙
    • PS4-PS5游戏机通过局域网翻墙,加速游戏,以及下载游戏教程
    • SStap和Netch免费游戏加速器教程
    • Switch、 PlayStation、Xbox等游戏机翻墙教程,利用MAC电脑做旁路由加速
    • Windows如何共享Wifi无线网卡翻墙热点给其它设备翻墙
    • 在Mac上使用clashx pro给switch开启游戏加速
    • 苹果电视Apple Tv翻墙指南
  • iPhone/iPad V2ray/SS 翻墙APP教程
    • 注册苹果美区 Apple ID 帐号并购买APP指南
    • Kitsunebi 教程
    • Potatso Lite 教程
    • Quantumult X 配置使用简易教程
    • 导入 Quantumult 完整配置
    • Quantumult 教程
    • Shadowrocket小火箭配置使用教程
    • Surge 教程
    • Iphone/iPad通过电脑局域网共享翻墙
  • Linux 翻墙教程
  • Mac翻墙软件教程
    • ClashX 翻墙教程
    • macOS平台 Surge教程
    • macOS翻墙 V2rayU教程
    • macOS翻墙 V2rayX 教程
  • 路由器翻墙教程
    • 梅林路由器翻墙教程
    • OpenWRT路由器翻墙教程
  • Tor Browser Portable
  • V2Ray Shadowsocks Brook 自建翻墙服务器教程
    • Brook之TLS+WebSocket+CDN翻墙教程
    • Brook之TLS+WebSocket+Web服务器翻墙教程
    • Brook之TLS+WebSocket翻墙教程
    • SSH连接VPS教程
    • V2Ray之TLS+WebSocket+Nginx+CDN配置方法
    • V2Ray之TLS+WebSocket翻墙方法
    • V2ray官方一键安装脚本(新版)
    • Windows版V2ray客户端安装配置指南
    • 使用FileZilla和VPS传输文件教程
    • 最简单的Google BBR 一键加速VPS教程
    • 翻墙VPS推荐:搬瓦工VPS购买教程
    • 自建Shadowsocks服务器简明教程
    • 自建V2Ray+TLS翻墙配置方法
    • 自建V2ray服务器简明教程
    • 购买Vultr VPS图文教程
    • PAC
  • Windows V2ray/SS/SSR 翻墙教程
    • Clash for Windows 翻墙教程
    • SSTap教程
    • Windows翻墙之SSR教程
    • V2rayN配置使用教程
    • tor-v2ray
  • .github
    • ISSUE_TEMPLATE
      • custom
      • feedbank
Powered by GitBook
On this page
  • Official plugins
  • Developer's guide
  • Package name
  • Add dependency
  • Native binary configuration
  • Implement a binary provider
  • Add user interfaces

Was this helpful?

  1. 翻墙新闻(FQNews)安卓APP

shadowsocks-android plugin framework

Previous翻墙新闻(FQNews)安卓APPNextCHANGES

Last updated 3 years ago

Was this helpful?

|

Support library for easier development on for Android. Also includes some useful resources to easily get consistent styling with the main app.

Official plugins

These are some plugins ready to use on shadowsocks-android.

Developer's guide

This library is designed with Java interoperability in mind so theoretically you can use this library with other languages and/or build tools but there isn't documentation for that yet. This guide is written for Scala + SBT. Contributions are welcome.

Package name

There are no arbitrary restrictions/requirements on package name, component name and content provider authority, but you're suggested to follow the format in this documentations. For package name, use com.github.shadowsocks.plugin.$PLUGIN_ID if it only contains a single plugin to prevent duplicated plugins. In some places hyphens are not accepted, for example package name. In that case, hyphens - should be changed into underscores _. For example, the package name for obfs-local would probably be com.github.shadowsocks.plugin.obfs_local.

Add dependency

First you need to add this library to your dependencies. This library is written mostly in Kotlin but can also work with Java-only projects:

implementation 'com.github.shadowsocks:plugin:$LATEST_VERSION'

Native binary configuration

First you need to get your native binary compiling on Android platform.

In addition to functionalities of a normal plugin, it has to support these additional flags that may get passed through arguments:

  • -V: VPN mode. In this case, the plugin should pass all file descriptors that needs protecting

    from VPN connections (i.e. its traffic will not be forwarded through the VPN) through an

    ancillary message to ./protect_path;

  • --fast-open: TCP fast open enabled.

Implement a binary provider

You just need to implement two or three methods. For example for v2ray:

class BinaryProvider : NativePluginProvider() {
    override fun populateFiles(provider: PathProvider) {
        provider.addPath("v2ray", 0b111101101)
        // add additional files here
    }

  // remove this method to disable fast mode, read more in the documentation
    override fun getExecutable() = context!!.applicationInfo.nativeLibraryDir + "/libv2ray.so"

    override fun openFile(uri: Uri): ParcelFileDescriptor = when (uri.path) {
        "/v2ray" -> ParcelFileDescriptor.open(File(getExecutable()), ParcelFileDescriptor.MODE_READ_ONLY)
        // handle additional files here
        else -> throw FileNotFoundException()
    }
}

Then add it to your manifest:

<manifest>
    ...
    <application>
        ...
        <provider android:name=".BinaryProvider"
                  android:exported="true"
                  android:directBootAware="true"
                  android:authorities="$FULLY_QUALIFIED_NAME_OF_YOUR_CONTENTPROVIDER">
            <intent-filter>
                <action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/>
            </intent-filter>
            <intent-filter>
                <action android:name="com.github.shadowsocks.plugin.ACTION_NATIVE_PLUGIN"/>
                <data android:scheme="plugin"
                      android:host="com.github.shadowsocks"
                      android:path="/$PLUGIN_ID"/>
            </intent-filter>
            <meta-data android:name="com.github.shadowsocks.plugin.id"
                       android:value="$PLUGIN_ID"/>
            <!-- Optional: default is empty -->
            <meta-data android:name="com.github.shadowsocks.plugin.default_config"
                       android:value="dummy=default;plugin=options"/>
            <!-- Optional: remove to disable faster mode, read more in the documentation -->
            <meta-data android:name="com.github.shadowsocks.plugin.executable_path"
                       android:value="$PATH_TO_EXECUTABLE_RELATIVE_TO_NATIVE_LIB_DIR"/>
        </provider>
        ...
    </application>
</manifest>

Add user interfaces

You should add to your plugin app a configuration activity or a help activity or both if you're going to use ConfigurationActivity.fallbackToManualEditor.

Configuration activity

This is used if found instead of a manual input dialog when user clicks "Configure..." in the main app. This gives you maximum freedom of the user interface. To implement this, you need to extend ConfigurationActivity and you will get current options via onInitializePluginOptions(PluginOptions) and you can invoke saveChanges(PluginOptions) or discardChanges() before finish() or fallbackToManualEditor(). Then add it to your manifest:

<manifest>
    ...
    <application>
        ...
        <activity android:name=".ConfigActivity">
            <intent-filter>
                <action android:name="com.github.shadowsocks.plugin.ACTION_CONFIGURE"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:scheme="plugin"
                      android:host="com.github.shadowsocks"
                      android:path="/$PLUGIN_ID"/>
            </intent-filter>
        </activity>
        ...
    </application>
</manifest>

Help activity/callback

This is started when user taps "?" in manual editor. To implement this, you need to extend HelpCallback if you want a simple dialog with help message as CharSequence or HelpActivity if you want to provide custom user interface, implement the required methods, then add it to your manifest:

<manifest>
    ...
    <application>
        ...
        <activity android:name=".HelpActivity">
            <intent-filter>
                <action android:name="com.github.shadowsocks.plugin.ACTION_HELP"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:scheme="plugin"
                      android:host="com.github.shadowsocks"
                      android:path="/$PLUGIN_ID"/>
            </intent-filter>
        </activity>
        ...
    </application>
</manifest>

Great. Now your plugin is ready to use.

;

.

Documentation
Change log
shadowsocks plugin
v2ray
kcptun
simple-obfs
Sample project for C
Sample project for Go