Skip to content

Commit

Permalink
bug fixes and overall stability
Browse files Browse the repository at this point in the history
  • Loading branch information
uoosef committed Aug 16, 2023
1 parent 1753f61 commit cc4145e
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app_bepass/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ android {
defaultConfig {
applicationId = "moe.matsuri.plugin.bepass"
versionCode = 1
versionName = "1.2.1"
versionName = "1.3.6"
}
}
8 changes: 4 additions & 4 deletions download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ dl_and_chmod() {
}

download_bepass() {
dl_and_chmod arm64-v8a "https://github.com/uoosef/bepass/releases/download/v1.1.11/Bepass-linux-arm64.0f0d99.zip"
dl_and_chmod armeabi-v7a "https://github.com/uoosef/bepass/releases/download/v1.1.11/Bepass-linux-arm7.0f0d99.zip"
dl_and_chmod x86 "https://github.com/uoosef/bepass/releases/download/v1.1.11/Bepass-linux-386.0f0d99.zip"
dl_and_chmod x86_64 "https://github.com/uoosef/bepass/releases/download/v1.1.11/Bepass-linux-amd64.0f0d99.zip"
dl_and_chmod arm64-v8a "https://github.com/uoosef/bepass/releases/download/v1.1.12/Bepass-linux-arm64.e8e7a3.zip"
dl_and_chmod armeabi-v7a "https://github.com/uoosef/bepass/releases/download/v1.1.12/Bepass-linux-arm7.e8e7a3.zip"
dl_and_chmod x86 "https://github.com/uoosef/bepass/releases/download/v1.1.12/Bepass-linux-386.e8e7a3.zip"
dl_and_chmod x86_64 "https://github.com/uoosef/bepass/releases/download/v1.1.12/Bepass-linux-amd64.e8e7a3.zip"
}

download_"$1"
21 changes: 21 additions & 0 deletions js/common/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,27 @@ export var translates = {
workerDNSOnly: {
"": "DNS Only",
},
dnsCacheTTL: {
"": "DNS Cache TTL",
},
dnsRequestTimeout: {
"": "DNS Request Timeout",
},
enableDNSFragmentation: {
"": "Enable DNS Fragmentation",
},
tlsPaddingEnabled: {
"": "Enable TLS Padding",
},
tlsPaddingSize: {
"": "TLS Padding Range",
},
hosts: {
"": "Domain to IP mappings(hosts)",
},
tlsPaddingCategory: {
"": "TLS Padding Options",
},

// shadowTLS
shadowTlsServerName: {
Expand Down
19 changes: 19 additions & 0 deletions js/common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ class utilClass {
}
return addr
}

stringToHostsArray(str){
const hosts = []
const hostsList = str.trim().split(",")
if(hostsList){
for(let i = 0; i < hostsList.length; i++) {
const sTemp = hostsList[i].split(":")
if(sTemp.length > 1){
hosts.push(
{
"Domain": sTemp[0],
"IP": sTemp[1]
}
)
}
}
}
return hosts
}
}

export const util = new utilClass();
Expand Down
102 changes: 91 additions & 11 deletions js/plugin_bepass/bepass.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ class bepassClass {
this.defaultSharedStorage.jsVersion = 1;
this.defaultSharedStorage.name = "bepass";
// end of default keys
this.defaultSharedStorage.tlsHeaderLength = 5;
this.defaultSharedStorage.remoteDNSAddr = "https://1.1.1.1/dns-query";
this.defaultSharedStorage.dnsCacheTTL = 30;
this.defaultSharedStorage.baSniChunksLengthRange = "1, 5";
this.defaultSharedStorage.tlsHeaderLength = "5";
this.defaultSharedStorage.remoteDNSAddr = "https://yarp.lefolgoc.net/dns-query";
this.defaultSharedStorage.dnsCacheTTL = "1800";
this.defaultSharedStorage.dnsRequestTimeout = "10";
this.defaultSharedStorage.baSniChunksLengthRange = "5, 10";
this.defaultSharedStorage.sniChunksLengthRange = "1, 5";
this.defaultSharedStorage.chunksDelayRange = "20, 50";
this.defaultSharedStorage.chunksDelayRange = "30, 40";
this.defaultSharedStorage.allowInsecure = false;
this.defaultSharedStorage.enableDNSFragmentation = false;
this.defaultSharedStorage.workerEnabled = false;
this.defaultSharedStorage.workerDNSOnly = false;
this.defaultSharedStorage.tlsPaddingEnabled = false;
this.defaultSharedStorage.tlsPaddingSize = "200, 500";
this.defaultSharedStorage.workerCleanIPAndPort = "104.31.16.104:443";
this.defaultSharedStorage.hosts = "example.com:1.2.3.4, yarp.lefolgoc.net:5.39.88.20";
this.defaultSharedStorage.workerAddress = "https://example.user.worker.dev/dns-query";

for (var k in this.defaultSharedStorage) {
Expand Down Expand Up @@ -54,9 +59,13 @@ class bepassClass {
builder.searchParams.set("remoteDNSAddr", this.sharedStorage.remoteDNSAddr)
builder.searchParams.set("sniChunksLengthRange", this.sharedStorage.sniChunksLengthRange)
builder.searchParams.set("baSniChunksLengthRange", this.sharedStorage.baSniChunksLengthRange)
builder.searchParams.set("tlsPaddingSize", this.sharedStorage.tlsPaddingSize)
builder.searchParams.set("chunksDelayRange", this.sharedStorage.chunksDelayRange)
builder.searchParams.set("workerAddress", this.sharedStorage.workerAddress)
builder.searchParams.set("workerCleanIPAndPort", this.sharedStorage.workerCleanIPAndPort)
builder.searchParams.set("hosts", this.sharedStorage.hosts)
builder.searchParams.set("dnsCacheTTL", this.sharedStorage.dnsCacheTTL)
builder.searchParams.set("dnsRequestTimeout", this.sharedStorage.dnsRequestTimeout)

if (this.sharedStorage.allowInsecure) {
builder.searchParams.set("allow_insecure", "1")
Expand All @@ -68,6 +77,18 @@ class bepassClass {
builder.searchParams.set("workerEnabled", "0")
}

if (this.sharedStorage.enableDNSFragmentation) {
builder.searchParams.set("enableDNSFragmentation", "1")
} else {
builder.searchParams.set("enableDNSFragmentation", "0")
}

if (this.sharedStorage.tlsPaddingEnabled) {
builder.searchParams.set("tlsPaddingEnabled", "1")
} else {
builder.searchParams.set("tlsPaddingEnabled", "0")
}

if (this.sharedStorage.workerDNSOnly) {
builder.searchParams.set("workerDNSOnly", "1")
} else {
Expand All @@ -88,15 +109,30 @@ class bepassClass {
{
title: "TLS Client Hello Split Settings",
preferences: [
{
type: "EditTextPreference",
key: "tlsHeaderLength",
icon: "ic_baseline_layers_24",
},
{
type: "EditTextPreference",
key: "remoteDNSAddr",
icon: "ic_maps_directions_boat",
},
{
type: "EditTextPreference",
key: "tlsHeaderLength",
icon: "ic_baseline_layers_24",
key: "dnsCacheTTL",
icon: "ic_baseline_refresh_24",
},
{
type: "EditTextPreference",
key: "dnsRequestTimeout",
icon: "ic_service_busy",
},
{
"type": "SwitchPreference",
"key": "enableDNSFragmentation",
"icon": "ic_baseline_view_list_24",
},
{
type: "EditTextPreference",
Expand All @@ -113,6 +149,16 @@ class bepassClass {
key: "chunksDelayRange",
icon: "ic_baseline_timelapse_24",
},
{
type: "EditTextPreference",
key: "hosts",
icon: "baseline_wrap_text_24",
},
{
"type": "SwitchPreference",
"key": "tlsPaddingEnabled",
"icon": "ic_baseline_fingerprint_24",
},
{
"type": "SwitchPreference",
"key": "allowInsecure",
Expand Down Expand Up @@ -145,6 +191,16 @@ class bepassClass {
},
]
},
{
"key": "tlsPaddingCategory",
"preferences": [
{
"type": "EditTextPreference",
"key": "tlsPaddingSize",
"icon": "ic_file_cloud_queue",
},
]
},
];
this.common._applyTranslateToPreferenceScreenConfig(sb, TR);
return JSON.stringify(sb);
Expand Down Expand Up @@ -189,9 +245,16 @@ class bepassClass {
_onPreferenceChanged(key, newValue) {
if (key == "wrokerEnabled") {
if (newValue == true) {
neko.setPreferenceVisibility("serverSecurityCategory", true)
neko.setPreferenceVisibility("workerSettingsCategory", true)
} else {
neko.setPreferenceVisibility("workerSettingsCategory", false)
}
}
if (key == "tlsPaddingEnabled") {
if (newValue == true) {
neko.setPreferenceVisibility("tlsPaddingCategory", true)
} else {
neko.setPreferenceVisibility("serverSecurityCategory", false)
neko.setPreferenceVisibility("tlsPaddingCategory", false)
}
}
}
Expand All @@ -214,6 +277,10 @@ class bepassClass {
this.sharedStorage.chunksDelayRange = builder.searchParams.get("chunksDelayRange")
this.sharedStorage.workerAddress = builder.searchParams.get("workerAddress")
this.sharedStorage.workerCleanIPAndPort = builder.searchParams.get("workerCleanIPAndPort")
this.sharedStorage.tlsPaddingSize = builder.searchParams.get("tlsPaddingSize")
this.sharedStorage.dnsCacheTTL = builder.searchParams.get("dnsCacheTTL")
this.sharedStorage.dnsRequestTimeout = builder.searchParams.get("dnsRequestTimeout")
this.sharedStorage.hosts = builder.searchParams.get("hosts")

util.ifNotNull(url.searchParams.get("allow_insecure"), (it) => {
if (it == "1" || it == "true") this.sharedStorage.allowInsecure = true
Expand All @@ -223,6 +290,14 @@ class bepassClass {
if (it == "1" || it == "true") this.sharedStorage.workerEnabled = true
})

util.ifNotNull(url.searchParams.get("enableDNSFragmentation"), (it) => {
if (it == "1" || it == "true") this.sharedStorage.enableDNSFragmentation = true
})

util.ifNotNull(url.searchParams.get("tlsPaddingEnabled"), (it) => {
if (it == "1" || it == "true") this.sharedStorage.tlsPaddingEnabled = true
})

util.ifNotNull(url.searchParams.get("workerDNSOnly"), (it) => {
if (it == "1" || it == "true") this.sharedStorage.workerDNSOnly = true
})
Expand All @@ -238,8 +313,12 @@ class bepassClass {

let configObject = {
"TLSHeaderLength": util.stringToInt(bepass.tlsHeaderLength),
"TLSPaddingEnabled": bepass.tlsPaddingEnabled,
"TLSPaddingSize": util.stringToRange(bepass.tlsPaddingSize),
"RemoteDNSAddr": bepass.remoteDNSAddr,
"DnsCacheTTL": 300,
"EnableDNSFragmentation": bepass.enableDNSFragmentation,
"DnsCacheTTL": util.stringToInt(bepass.dnsCacheTTL),
"DnsRequestTimeout": util.stringToInt(bepass.dnsRequestTimeout),
"BindAddress": "127.0.0.1:" + args.port,
"ChunksLengthBeforeSni": util.stringToRange(bepass.baSniChunksLengthRange),
"SniChunksLength": util.stringToRange(bepass.sniChunksLengthRange),
Expand All @@ -249,7 +328,8 @@ class bepassClass {
"WorkerIPPortAddress": util.stringToWorkerIPPort(bepass.workerCleanIPAndPort),
"WorkerEnabled": bepass.workerEnabled,
"WorkerDNSOnly": bepass.workerDNSOnly,
"EnableLowLevelSockets": true
"EnableLowLevelSockets": true,
"Hosts": util.stringToHostsArray(bepass.hosts)
};

let v = {};
Expand Down
9 changes: 5 additions & 4 deletions js/plugin_bepass/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export function nekoProtocol(protocolId) {
}

export function nekoAbout() {
return "早期测试版本,上游版本 v0.1.2\n" +
"1 目前不兼容链式代理\n" +
"2 目前无法使用域名,请使用 IP 地址类型的服务器\n" +
"这个插件是实验性的。如果在使用过程中遇到任何问题,请自行解决。"
return "Bepass plugin v1.3.6-beta\n" +
"Fragmentation support\n" +
"TLS padding support\n" +
"Full tcp proxy through cloudflare support\n" +
"For more info please visit https://github.com/uoosef/nekobepass"
}

// export interface to browser
Expand Down

0 comments on commit cc4145e

Please sign in to comment.