Some refactor again
This commit is contained in:
@@ -1 +1,6 @@
|
|||||||
from .server import run
|
from .server import run
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'run'
|
||||||
|
]
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
from . import db, models
|
from . import db, models
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'db',
|
||||||
|
'models'
|
||||||
|
]
|
||||||
|
|||||||
@@ -1,2 +1,7 @@
|
|||||||
from .onion import Onion
|
from .onion import Onion
|
||||||
from .onion import get_available_port
|
from .onion import get_available_port
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
'Onion',
|
||||||
|
'get_available_port'
|
||||||
|
]
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class Onion(object):
|
|||||||
tor_cookie_auth_file: str
|
tor_cookie_auth_file: str
|
||||||
tor_data_directory: tempfile.TemporaryDirectory
|
tor_data_directory: tempfile.TemporaryDirectory
|
||||||
tor_path: str = dirs.get_tor_paths()
|
tor_path: str = dirs.get_tor_paths()
|
||||||
tor_proc: subprocess.Popen
|
tor_proc: subprocess.Popen | None
|
||||||
c: Controller
|
c: Controller
|
||||||
connected_to_tor: bool = False
|
connected_to_tor: bool = False
|
||||||
auth_string: str
|
auth_string: str
|
||||||
|
|||||||
@@ -16,7 +16,12 @@ def get_latest_version() -> str:
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def get_build() -> Literal['windows-x86_64', 'linux-x86_64', 'macos-x86_64', 'macos-aarch64']:
|
def get_build() -> Literal[
|
||||||
|
'windows-x86_64',
|
||||||
|
'linux-x86_64',
|
||||||
|
'macos-x86_64',
|
||||||
|
'macos-aarch64'
|
||||||
|
]:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return 'windows-x86_64'
|
return 'windows-x86_64'
|
||||||
elif sys.platform == 'linux':
|
elif sys.platform == 'linux':
|
||||||
@@ -31,18 +36,25 @@ def get_build() -> Literal['windows-x86_64', 'linux-x86_64', 'macos-x86_64', 'ma
|
|||||||
raise 'System not supported'
|
raise 'System not supported'
|
||||||
|
|
||||||
|
|
||||||
def get_tor_expert_bundles(version: str = get_latest_version(), platform: str = get_build()):
|
def get_tor_expert_bundles(version: str = get_latest_version(),
|
||||||
return f'https://dist.torproject.org/torbrowser/{version}/tor-expert-bundle-{version}-{platform}.tar.gz'
|
platform: str = get_build()):
|
||||||
|
return f'https://dist.torproject.org/torbrowser/{version}/tor-expert-bundle-' \
|
||||||
|
f'{version}-{platform}.tar.gz'
|
||||||
|
|
||||||
|
|
||||||
def download_tor(url: str = get_tor_expert_bundles(), dist: str = 'tor'):
|
def download_tor(url: str = get_tor_expert_bundles(), dist: str = 'tor'):
|
||||||
if not os.path.exists(dist):
|
if not os.path.exists(dist):
|
||||||
os.makedirs(dist)
|
os.makedirs(dist)
|
||||||
|
|
||||||
(tar := tarfile.open(fileobj=io.BytesIO(requests.get(url).content), mode='r:gz')).extractall(members=[
|
(tar := tarfile.open(fileobj=io.BytesIO(requests.get(url).content),
|
||||||
tarinfo for tarinfo in tar.getmembers()
|
mode='r:gz')).extractall(
|
||||||
if tarinfo.name.startswith("tor/")
|
members=
|
||||||
], path=dist)
|
[
|
||||||
|
tarinfo
|
||||||
|
for tarinfo
|
||||||
|
in tar.getmembers()
|
||||||
|
if tarinfo.name.startswith("tor/")
|
||||||
|
], path=dist)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Reference in New Issue
Block a user