This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProxyGuard: Update to latest common integration
- Loading branch information
1 parent
24ec736
commit 4f74567
Showing
4 changed files
with
111 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from typing import List | ||
from urllib.parse import urlparse | ||
|
||
from eduvpn.utils import handle_exception | ||
|
||
|
||
class Proxy: | ||
"""The class that represents a proxyguard instance | ||
:param: common: The common library | ||
:param: peer: str: The remote peer string | ||
:param: listen: str: The listen proxy string | ||
""" | ||
|
||
def __init__( | ||
self, | ||
common, | ||
config, | ||
wrapper, | ||
): | ||
self.common = common | ||
self.config = config | ||
self.wrapper = wrapper | ||
|
||
def forward_exception(self, error): | ||
handle_exception(self.common, error) | ||
|
||
def tunnel(self, wgport): | ||
self.wrapper.tunnel(wgport) | ||
|
||
@property | ||
def peer(self) -> str: | ||
return self.config.peer | ||
|
||
@property | ||
def source_port(self) -> int: | ||
return self.config.source_port | ||
|
||
@property | ||
def listen_port(self) -> int: | ||
return self.config.listen_port | ||
|
||
@property | ||
def peer_ips(self) -> List[str]: | ||
return self.wrapper.peer_ips | ||
|
||
@property | ||
def peer_scheme(self) -> str: | ||
try: | ||
parsed = urlparse(self.config.peer) | ||
return parsed.scheme | ||
except Exception: | ||
return "" | ||
|
||
@property | ||
def peer_port(self): | ||
if self.peer_scheme == "http": | ||
return 80 | ||
return 443 |