Skip to content

Commit

Permalink
1.1.0b0 (#365)
Browse files Browse the repository at this point in the history
* Add WireGuard Server support (#334)

* Add Merlin flag to the device identity (#344)

* Add support for VPN Fusion (#345)

* Add `convert_to_ha_data` method (#348)

* Force VPNC check before setting a state (#349)

* Force VPNC state re-check after a setting (#350)

* Improve HA converters (#351)

* Add CPU `usage` value on startup (#352)

* Add OpenVPN Server support (stock 388) (#353)

* Save WireGuard Server state on setting (#354)

* Optimize OpenVPN code (#355)

* Add WireGuard Client support (merlin 388) (#356)

* Add data drop when needed (#357)

* Add `dump` tools (#358)

* Fix small details (#359)

* Improve handling of legacy clients (#360)

* Improve logging on connection failure (#361)

* Add dual wan support (#363)

* Block requests on closed session (#364)

* Bump version to `1.1.0b0`
  • Loading branch information
Vaskivskyi authored Nov 12, 2023
1 parent dcf155f commit 1dcfa1c
Show file tree
Hide file tree
Showing 25 changed files with 1,515 additions and 166 deletions.
3 changes: 3 additions & 0 deletions asusrouter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
"""Library init"""

from .asusrouter import AsusRouter
from .error import AsusRouterError
from .modules.data import AsusData
from .modules.endpoint import Endpoint
from .tools.dump import AsusRouterDump
119 changes: 119 additions & 0 deletions asusrouter/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"""Starting point for the AsusRouter."""

from __future__ import annotations

import argparse
import asyncio
import logging

import aiohttp

from asusrouter import AsusRouter, AsusRouterDump, AsusRouterError

_LOGGER = logging.getLogger(__name__)


async def _connect_and_dump(args: argparse.Namespace) -> None:
"""Connect to the router and dump the data."""

_LOGGER.info("Starting dump...")

with AsusRouterDump(args.output, args.dump, args.zip) as dump:
async with aiohttp.ClientSession() as session:
_LOGGER.debug("Created aiohttp session")

# Create the router
router = AsusRouter(
hostname=args.host,
username=args.username,
password=args.password,
use_ssl=args.ssl,
session=session,
dumpback=dump.dump,
)
_LOGGER.debug("Created router")

# Connect to the router and gather identity data
_LOGGER.debug("Connecting to the router...")
await router.async_connect()

if not router.connected:
_LOGGER.error("Failed to connect to the router")
return

_LOGGER.debug("Connected and identified")

# Disconnect from the router
await router.async_disconnect()
_LOGGER.debug("Disconnected")

_LOGGER.info("Dump finished. Saved to: %s", args.output)


def main():
"""Run AsusRouter as a program."""

parser = argparse.ArgumentParser(
description="AsusRouter package command line interface."
)
parser.add_argument(
"-o", "--output", type=str, required=True, help="The output folder for the log."
)
parser.add_argument("--dump", action="store_true", help="Perform a full dump.")
parser.add_argument(
"--host",
type=str,
required=True,
help="The hostname / ip address of the router.",
)
parser.add_argument(
"-u",
"--username",
type=str,
default="admin",
help="The username for the router. Default: `admin`.",
)
parser.add_argument(
"-p",
"--password",
type=str,
default="admin",
help="The password for the router. Default: `admin`.",
)
parser.add_argument(
"-s",
"--ssl",
action="store_true",
default=False,
help="Use SSL for the connection.",
)
parser.add_argument(
"-P",
"--port",
type=int,
default=None,
help="The port to connect to. Only when using non-default settings.\
Default is 80 for HTTP and 443 for HTTPS.",
)
parser.add_argument("--debug", action="store_true", help="Enable debug logging.")
parser.add_argument(
"--zip", action="store_true", default=False, help="Zip the output."
)

args = parser.parse_args()

# Set up logging
logging.basicConfig(
level=logging.DEBUG if args.debug else logging.INFO,
format="%(asctime)s [%(levelname)s] %(module)s: %(message)s",
)

# Connect to the router and dump the data
try:
asyncio.run(_connect_and_dump(args))
except AsusRouterError as ex:
_LOGGER.error("AsusRouterError: %s", ex)


if __name__ == "__main__":
main()
Loading

0 comments on commit 1dcfa1c

Please sign in to comment.