Skip to content

Commit ac25464

Browse files
committed
Initial Commit - Base Files
1 parent 4f8406b commit ac25464

File tree

8 files changed

+2173
-0
lines changed

8 files changed

+2173
-0
lines changed

.github/workflows/build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Build Module
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
major:
7+
type: number
8+
description: 'Major version increment by? (e.g. 1)'
9+
default: 0
10+
required: true
11+
minor:
12+
type: number
13+
description: 'Minor version increment by? (e.g. 1)'
14+
default: 1
15+
required: true
16+
17+
jobs:
18+
build-release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Read current module.prop
25+
id: read_version
26+
run: |
27+
cd ./module
28+
VERSION=$(grep '^version=' module.prop | cut -d'=' -f2)
29+
VERSION_CODE=$(grep '^versionCode=' module.prop | cut -d'=' -f2)
30+
31+
MAJOR="${{ github.event.inputs.major }}"
32+
MINOR="${{ github.event.inputs.minor }}"
33+
34+
IFS='.' read -r CURRENT_MAJOR CURRENT_MINOR <<< "$VERSION"
35+
NEW_VERSION="$((CURRENT_MAJOR + MAJOR)).$((CURRENT_MINOR + MINOR))"
36+
NEW_VERSIONCODE=$((VERSION_CODE + 1))
37+
38+
echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV"
39+
echo "new_versioncode=$NEW_VERSIONCODE" >> "$GITHUB_ENV"
40+
41+
- name: Update module.prop
42+
run: |
43+
cd ./module
44+
sed -i "s/^version=.*/version=${{ env.new_version }}/" module.prop
45+
sed -i "s/^versionCode=.*/versionCode=${{ env.new_versioncode }}/" module.prop
46+
47+
# Update the updateJson URL inside module.prop
48+
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
49+
sed -i "s|^updateJson=.*|updateJson=https://raw.githubusercontent.com/${{ github.repository }}/${BRANCH_NAME}/update.json|g" module.prop
50+
51+
cat module.prop
52+
53+
- name: Commit updated module.prop
54+
run: |
55+
cd ./module
56+
git config --local user.email "[email protected]"
57+
git config --local user.name "GitHub Action"
58+
git add module.prop
59+
git commit -m "Bump version to ${{ env.new_version }} (${{ env.new_versioncode }})"
60+
git push origin HEAD:${{ github.ref_name }}
61+
62+
cd ..
63+
git tag v${{ env.new_version }}
64+
git push origin v${{ env.new_version }}
65+
66+
- name: Create module zip
67+
run: |
68+
cd ./module
69+
MODULE_NAME="TCP_Optimiser-${{ env.new_version }}-${{ env.new_versioncode }}"
70+
zip -r "../$MODULE_NAME.zip" . -x "*.git*" -x ".github/*" -x "*.yml" -x "README.md"
71+
72+
- name: Upload Artifact
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: module-zip
76+
path: "*.zip"
77+
78+
- name: Create Release
79+
id: create_release
80+
uses: actions/create-release@v1
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
tag_name: v${{ env.new_version }}
85+
release_name: ${{ env.new_version }}
86+
draft: true
87+
prerelease: ${{ github.ref == 'refs/heads/main' && 'false' || 'true' }}
88+
89+
- name: Upload Release Asset
90+
uses: actions/upload-release-asset@v1
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
with:
94+
upload_url: ${{ steps.create_release.outputs.upload_url }}
95+
asset_path: ./TCP_Optimiser-${{ env.new_version }}-${{ env.new_versioncode }}.zip
96+
asset_name: TCP_Optimiser-${{ env.new_version }}-${{ env.new_versioncode }}.zip
97+
asset_content_type: application/zip

.github/workflows/publish.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Publish Release & Update update.json
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
update-release-info:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout release tag
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.event.release.tag_name }}
16+
path: release
17+
18+
- name: Fetch and checkout branch where tag was created
19+
working-directory: release
20+
run: |
21+
git fetch --all --tags
22+
TAG_COMMIT=$(git rev-list -n 1 ${{ github.event.release.tag_name }})
23+
BRANCH=$(git branch -r --contains $TAG_COMMIT | grep -v '\->' | grep -v 'HEAD' | head -n1 | sed 's|origin/||' | xargs)
24+
25+
if [ -z "$BRANCH" ]; then
26+
echo "No branch found for tag commit. Falling back to 'main'."
27+
BRANCH="main"
28+
fi
29+
30+
echo "Tag commit: $TAG_COMMIT"
31+
echo "Detected branch: $BRANCH"
32+
33+
git checkout $BRANCH
34+
echo "checked_out_branch=$BRANCH" >> "$GITHUB_ENV"
35+
36+
- name: Get version info from module.prop
37+
id: read_version
38+
working-directory: release
39+
run: |
40+
cd ./module
41+
VERSION=$(grep '^version=' module.prop | cut -d'=' -f2)
42+
VERSION_CODE=$(grep '^versionCode=' module.prop | cut -d'=' -f2)
43+
44+
echo "version=$VERSION" >> "$GITHUB_ENV"
45+
echo "versionCode=$VERSION_CODE" >> "$GITHUB_ENV"
46+
47+
- name: Save release body to changelog
48+
working-directory: release
49+
run: |
50+
echo "${{ github.event.release.body }}" > CHANGELOG.md
51+
52+
- name: Checkout manifest branch
53+
uses: actions/checkout@v4
54+
with:
55+
ref: ${{ env.checked_out_branch }}
56+
path: ${{ env.checked_out_branch }}
57+
58+
- name: Copy changelog to manifest branch
59+
working-directory: ${{ env.checked_out_branch }}
60+
run: |
61+
cp ../release/CHANGELOG.md CHANGELOG.md
62+
63+
- name: Update update.json in Checked-out branch
64+
working-directory: ${{ env.checked_out_branch }}
65+
run: |
66+
cat > update.json <<EOL
67+
{
68+
"version": "${{ env.version }}",
69+
"versionCode": ${{ env.versionCode }},
70+
"zipUrl": "https://github.com/${{ github.repository }}/releases/latest/download/TCP_Optimiser-${{ env.version }}-${{ env.versionCode }}.zip",
71+
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/${{ env.checked_out_branch }}/CHANGELOG.md"
72+
}
73+
EOL
74+
echo "Updated update.json:"
75+
cat update.json
76+
77+
- name: Commit and push to Checked-out branch
78+
working-directory: ${{ env.checked_out_branch }}
79+
run: |
80+
git config user.email "[email protected]"
81+
git config user.name "GitHub Action"
82+
git add update.json CHANGELOG.md
83+
git commit -m "Update update.json and CHANGELOG.md for version ${{ env.version }}"
84+
git push origin ${{ env.checked_out_branch }}
85+
86+
- name: Upload artifacts (optional)
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: release-assets
90+
path: |
91+
${{ env.checked_out_branch }}/CHANGELOG.md
92+
${{ env.checked_out_branch }}/update.json

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
# TCP_Optimiser_Module
22
A Magisk/KernelSU module to change tcp congestion algorithm based on current active internet type and some network enhancements.
3+
4+
# Why?
5+
In certain kernel, TCP Congestion Algorithm BBR might be enabled. Or you want to enable certain algorithm or settings based on what interface you are using. I observed that in my kernel, when i use BBR with WiFi I get 50-60 Mbps more upload speed compared to cubic, but BBR gives bad upload speed in cellular. So I designed this module to switch based on active internet facing interface.
6+
7+
# How to use
8+
1. Install the module.
9+
2. It creates 2 files `wlan_{algo}` and `rmnet_data_{algo}` in module folder.
10+
3. Reboot device.
11+
12+
## Note:
13+
1. Default algorithm is **cubic** for **cellular**.
14+
2. Default algorithm is **brr** if exists for **WiFi**. Else **cubic**.
15+
3. You can change algorithm by just renaming the file in same format. Eg: If you want to change WiFi TCP congestion algorithm to **reno**, rename `wlan_{algo}` file to `wlan_reno`.
16+
4. There is an option to kill current tcp connections during algorithm change. This might stop downloads, uploads or other ongoing connections. So apps affected might need to be restarted. To enable create a file named `kill_connections` in module folder. This is disabled by default.
17+
5. Algorithm is applied only if present in kernel.

0 commit comments

Comments
 (0)