Skip to content

Commit

Permalink
feat: improve tunnel selector
Browse files Browse the repository at this point in the history
  • Loading branch information
JingBh committed Feb 15, 2024
1 parent fa7f629 commit 6b1a768
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions bjut_tech/tunnel/_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,23 @@ def get_best(self) -> AbstractTunnel:

raise RuntimeError('No tunnel available')

@staticmethod
def find(name: str) -> Type[AbstractTunnel]:
for tunnel_cls in _TUNNELS:
if tunnel_cls.get_name() == name:
return tunnel_cls
raise ValueError('No such tunnel')

@staticmethod
def check_availability(cls_name: str) -> bool:
for tunnel_cls in _TUNNELS:
if tunnel_cls.__name__ == cls_name:
return tunnel_cls.is_available()
return False

@staticmethod
def has_available() -> bool:
for tunnel_cls in _TUNNELS:
if tunnel_cls.is_available():
return True
return False

0 comments on commit 6b1a768

Please sign in to comment.