Skip to content

Commit

Permalink
Merge pull request #416 from gefyrahq/fix/cargo-connect-2.0
Browse files Browse the repository at this point in the history
fix(client): handle new WG field, presharedkey
  • Loading branch information
SteinRobert committed Sep 5, 2023
2 parents 4433311 + 6f40927 commit e543b25
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/gefyra/local/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def create_wireguard_config(
"[Peer]\n"
f"PublicKey = {params.ppublickey}\n"
f"Endpoint = {cargo_endpoint}\n"
f"PresharedKey = {params.presharedkey}\n"
"PersistentKeepalive = 21\n"
"AllowedIPs = 0.0.0.0/0\n"
)
22 changes: 21 additions & 1 deletion client/gefyra/misc/comps/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ def data(params: "GefyraInstallOptions") -> list[dict]:
"image": f"quay.io/gefyra/operator:{params.version}",
"imagePullPolicy": "Always",
"ports": [{"containerPort": 9443}],
"env": [
{
"name": "GEFYRA_STOWAWAY_TAG",
"value": params.version,
},
{
"name": "GEFYRA_CARRIER_IMAGE_TAG",
"value": params.version,
},
],
}
],
},
Expand Down Expand Up @@ -81,7 +91,17 @@ def data(params: "GefyraInstallOptions") -> list[dict]:
"image": f"quay.io/gefyra/operator:{params.version}",
"imagePullPolicy": "Always",
"ports": [{"containerPort": 9443}],
"env": [{"name": "OP_MODE", "value": "webhook"}],
"env": [
{"name": "OP_MODE", "value": "webhook"},
{
"name": "GEFYRA_STOWAWAY_TAG",
"value": params.version,
},
{
"name": "GEFYRA_CARRIER_IMAGE_TAG",
"value": params.version,
},
],
"livenessProbe": {
"exec": {
"command": [
Expand Down
5 changes: 4 additions & 1 deletion client/gefyra/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class StowawayConfig:
pallowedips: str
# Peer.Endpoint: 95.91.248.4:31820
pendpoint: str
# Peer.PublicKey: sy8jXi7S7rUGpqLnqgKnmHFXylqQdvCPCfhBAgSVGEM=
# Peer.PublicKey: sy8jXi7...=
ppublickey: str
# Peer.PresharedKey: WCWY20...=
presharedkey: str


class GefyraClientState(Enum):
Expand Down Expand Up @@ -117,6 +119,7 @@ def _init_data(self, _object: dict[str, Any]):
pallowedips=providerconfig.get("Peer.AllowedIPs"),
pendpoint=providerconfig.get("Peer.Endpoint"),
ppublickey=providerconfig.get("Peer.PublicKey"),
presharedkey=providerconfig.get("Peer.PresharedKey"),
)

def as_dict(self) -> dict[str, Any]:
Expand Down
8 changes: 7 additions & 1 deletion operator/tests/e2e/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys
import platform
from pathlib import Path
import subprocess
import pytest
Expand All @@ -7,9 +9,13 @@
@pytest.fixture(scope="session")
def cargo_image(request):
name = "cargo:pytest"
if sys.platform == "win32" or "microsoft-standard" in platform.release():
target = "cargo-win"
else:
target = "cargo"
subprocess.run(
(
f"docker build -t {name} -f"
f"docker build --target {target} -t {name} -f"
f" {(Path(__file__).parent / Path('../../../cargo/Dockerfile')).resolve()}"
f" {(Path(__file__).parent / Path('../../../cargo/')).resolve()}"
),
Expand Down
10 changes: 3 additions & 7 deletions operator/tests/e2e/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@


def get_dockerfile():
run_patch = ""
if sys.platform == "win32" or "microsoft-standard" in platform.release():
run_patch = "RUN patch /usr/bin/wg-quick /wgquick.patch"
return io.BytesIO(
f"""
"""
FROM "cargo:pytest"
{run_patch}
ARG ADDRESS
ARG MTU
Expand Down Expand Up @@ -146,8 +142,8 @@ def connect(self, configs: dict):
def probe(self):
cargo = self.container
for _ in range(0, 10):
_r = cargo.exec_run(f"timeout 1 ping -c 1 192.168.99.1")
if _r.exit_code != 0:
_exit_code, _ = cargo.exec_run(f"timeout 1 ping -c 1 192.168.99.1")
if _exit_code != 0:
continue
else:
break
Expand Down

0 comments on commit e543b25

Please sign in to comment.