modified: .github/workflows/mikrotik_patch.yml

modified:   upgrade.py
This commit is contained in:
zyb 2024-06-24 17:43:02 +08:00
parent ce2277e822
commit 10427f983b
2 changed files with 24 additions and 10 deletions

View File

@ -20,6 +20,7 @@ jobs:
LATEST7_VERSION_URL: 'https://upgrade.mikrotik.com/routeros/NEWESTa7'
LATEST6_VERSION_URL: 'http://upgrade.mikrotik.com/routeros/LATEST.6'
LATEST_VERSION: ""
LATEST_CHANGELOG: ""
CUSTOM_LICENSE_PRIVATE_KEY: ${{ secrets.CUSTOM_LICENSE_PRIVATE_KEY }}
CUSTOM_LICENSE_PUBLIC_KEY: ${{ secrets.CUSTOM_LICENSE_PUBLIC_KEY }}
CUSTOM_NPK_SIGN_PRIVATE_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PRIVATE_KEY }}
@ -74,7 +75,10 @@ jobs:
echo $(uname -a)
LATEST_VERSION=$(wget -nv -O - ${{ env.LATEST7_VERSION_URL }}.${{ matrix.channel }} | cut -d ' ' -f1)
echo Latest Version:$LATEST_VERSION
LATEST_CHANGELOG=$(wget -nv -O - https://upgrade.mikrotik.com/routeros/$LATEST_VERSION/CHANGELOG)
echo Latest Changelog:$LATEST_CHANGELOG
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
echo "LATEST_CHANGELOG=${LATEST_CHANGELOG}" >> $GITHUB_ENV
- name: Cache Mikrotik ${{ env.LATEST_VERSION }}
id: cache-mikrotik
@ -278,8 +282,8 @@ jobs:
- name: Create Release tag ${{ env.LATEST_VERSION }}
uses: softprops/action-gh-release@v2
with:
name: "MikroTik RouterOS ${{ env.LATEST_VERSION }}"
body: "MikroTik RouterOS ${{ env.LATEST_VERSION }}"
name: "RouterOS ${{ env.LATEST_VERSION }}"
body: "${{ env.LATEST_CHANGELOG }}"
tag_name: ${{ env.LATEST_VERSION }}
make_latest: ${{ matrix.channel == 'stable' && matrix.branch == '7' }}
prerelease: ${{ matrix.channel == 'testing' }}

View File

@ -1,8 +1,19 @@
from mitmproxy import http
from mitmproxy.tools.dump import DumpMaster
from mitmproxy import options,http
import os
#https://upgrade.mikrotik.com/routeros/NEWESTa7.stable
#https://upgrade.mikrotik.com/routeros/7.15.1/CHANGELOG
class UpgradeAddon:
def __init__(self, upstream_server):
self.upstream_server = upstream_server
def request(self,flow: http.HTTPFlow) -> None:
flow.request.host = self.upstream_server
flow.request.scheme = "https"
flow.request.port = 443
print(flow.request.url)
if len(flow.request.path_components)==3 and flow.request.path_components[0] == 'routeros':
version = flow.request.path_components[1]
file = os.path.join(version,flow.request.path_components[2])
@ -29,13 +40,10 @@ class UpgradeAddon:
flow.response = http.Response.make(status_code=404)
async def start_listen(port):
from mitmproxy.tools.dump import DumpMaster
from mitmproxy import options
opts = options.Options(listen_host='0.0.0.0',listen_port=port,mode=['reverse:https://upgrade.mikrotik.com/'])
print(f'listening at *:{port}')
print(f'open http://127.0.0.1:{port}')
opts = options.Options(listen_host='0.0.0.0',listen_port=port)
upstream_server = "upgrade.mikrotik.com"
master = DumpMaster(opts)
master.addons.add([UpgradeAddon()])
master.addons.add(UpgradeAddon(upstream_server))
try:
await master.run()
except KeyboardInterrupt:
@ -46,4 +54,6 @@ if __name__ == "__main__":
check_install_package(['mitmproxy'])
print(f'ip dns static add name=upgrade.mikrotik.com address=<your ip address>')
print(f'ip dns cache flush')
asyncio.run(start_listen(80))
asyncio.run(start_listen(80))