mirror of
https://github.com/elseif/MikroTikPatch
synced 2026-07-17 18:49:41 +00:00
modified: .github/workflows/mikrotik_patch.yml
modified: upgrade.py
This commit is contained in:
parent
ce2277e822
commit
10427f983b
8
.github/workflows/mikrotik_patch.yml
vendored
8
.github/workflows/mikrotik_patch.yml
vendored
@ -20,6 +20,7 @@ jobs:
|
|||||||
LATEST7_VERSION_URL: 'https://upgrade.mikrotik.com/routeros/NEWESTa7'
|
LATEST7_VERSION_URL: 'https://upgrade.mikrotik.com/routeros/NEWESTa7'
|
||||||
LATEST6_VERSION_URL: 'http://upgrade.mikrotik.com/routeros/LATEST.6'
|
LATEST6_VERSION_URL: 'http://upgrade.mikrotik.com/routeros/LATEST.6'
|
||||||
LATEST_VERSION: ""
|
LATEST_VERSION: ""
|
||||||
|
LATEST_CHANGELOG: ""
|
||||||
CUSTOM_LICENSE_PRIVATE_KEY: ${{ secrets.CUSTOM_LICENSE_PRIVATE_KEY }}
|
CUSTOM_LICENSE_PRIVATE_KEY: ${{ secrets.CUSTOM_LICENSE_PRIVATE_KEY }}
|
||||||
CUSTOM_LICENSE_PUBLIC_KEY: ${{ secrets.CUSTOM_LICENSE_PUBLIC_KEY }}
|
CUSTOM_LICENSE_PUBLIC_KEY: ${{ secrets.CUSTOM_LICENSE_PUBLIC_KEY }}
|
||||||
CUSTOM_NPK_SIGN_PRIVATE_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PRIVATE_KEY }}
|
CUSTOM_NPK_SIGN_PRIVATE_KEY: ${{ secrets.CUSTOM_NPK_SIGN_PRIVATE_KEY }}
|
||||||
@ -74,7 +75,10 @@ jobs:
|
|||||||
echo $(uname -a)
|
echo $(uname -a)
|
||||||
LATEST_VERSION=$(wget -nv -O - ${{ env.LATEST7_VERSION_URL }}.${{ matrix.channel }} | cut -d ' ' -f1)
|
LATEST_VERSION=$(wget -nv -O - ${{ env.LATEST7_VERSION_URL }}.${{ matrix.channel }} | cut -d ' ' -f1)
|
||||||
echo Latest Version:$LATEST_VERSION
|
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_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
|
||||||
|
echo "LATEST_CHANGELOG=${LATEST_CHANGELOG}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Cache Mikrotik ${{ env.LATEST_VERSION }}
|
- name: Cache Mikrotik ${{ env.LATEST_VERSION }}
|
||||||
id: cache-mikrotik
|
id: cache-mikrotik
|
||||||
@ -278,8 +282,8 @@ jobs:
|
|||||||
- name: Create Release tag ${{ env.LATEST_VERSION }}
|
- name: Create Release tag ${{ env.LATEST_VERSION }}
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
name: "MikroTik RouterOS ${{ env.LATEST_VERSION }}"
|
name: "RouterOS ${{ env.LATEST_VERSION }}"
|
||||||
body: "MikroTik RouterOS ${{ env.LATEST_VERSION }}"
|
body: "${{ env.LATEST_CHANGELOG }}"
|
||||||
tag_name: ${{ env.LATEST_VERSION }}
|
tag_name: ${{ env.LATEST_VERSION }}
|
||||||
make_latest: ${{ matrix.channel == 'stable' && matrix.branch == '7' }}
|
make_latest: ${{ matrix.channel == 'stable' && matrix.branch == '7' }}
|
||||||
prerelease: ${{ matrix.channel == 'testing' }}
|
prerelease: ${{ matrix.channel == 'testing' }}
|
||||||
|
|||||||
24
upgrade.py
24
upgrade.py
@ -1,8 +1,19 @@
|
|||||||
from mitmproxy import http
|
from mitmproxy.tools.dump import DumpMaster
|
||||||
|
from mitmproxy import options,http
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
#https://upgrade.mikrotik.com/routeros/NEWESTa7.stable
|
||||||
|
#https://upgrade.mikrotik.com/routeros/7.15.1/CHANGELOG
|
||||||
|
|
||||||
|
|
||||||
class UpgradeAddon:
|
class UpgradeAddon:
|
||||||
|
def __init__(self, upstream_server):
|
||||||
|
self.upstream_server = upstream_server
|
||||||
def request(self,flow: http.HTTPFlow) -> None:
|
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':
|
if len(flow.request.path_components)==3 and flow.request.path_components[0] == 'routeros':
|
||||||
version = flow.request.path_components[1]
|
version = flow.request.path_components[1]
|
||||||
file = os.path.join(version,flow.request.path_components[2])
|
file = os.path.join(version,flow.request.path_components[2])
|
||||||
@ -29,13 +40,10 @@ class UpgradeAddon:
|
|||||||
flow.response = http.Response.make(status_code=404)
|
flow.response = http.Response.make(status_code=404)
|
||||||
|
|
||||||
async def start_listen(port):
|
async def start_listen(port):
|
||||||
from mitmproxy.tools.dump import DumpMaster
|
opts = options.Options(listen_host='0.0.0.0',listen_port=port)
|
||||||
from mitmproxy import options
|
upstream_server = "upgrade.mikrotik.com"
|
||||||
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}')
|
|
||||||
master = DumpMaster(opts)
|
master = DumpMaster(opts)
|
||||||
master.addons.add([UpgradeAddon()])
|
master.addons.add(UpgradeAddon(upstream_server))
|
||||||
try:
|
try:
|
||||||
await master.run()
|
await master.run()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@ -47,3 +55,5 @@ if __name__ == "__main__":
|
|||||||
print(f'ip dns static add name=upgrade.mikrotik.com address=<your ip address>')
|
print(f'ip dns static add name=upgrade.mikrotik.com address=<your ip address>')
|
||||||
print(f'ip dns cache flush')
|
print(f'ip dns cache flush')
|
||||||
asyncio.run(start_listen(80))
|
asyncio.run(start_listen(80))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user