Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszWojciechO committed Jan 28, 2025
1 parent 893ef2a commit 5409d17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions meshnet/exitnode/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package exitnode

import (
"fmt"
"log"
"net/netip"
"sync"

"github.com/NordSecurity/nordvpn-linux/config"
"github.com/NordSecurity/nordvpn-linux/core/mesh"
"github.com/NordSecurity/nordvpn-linux/internal"
"github.com/NordSecurity/nordvpn-linux/kernel"
)

Expand Down Expand Up @@ -85,8 +87,10 @@ func (en *Server) ResetPeers(peers mesh.MachinePeers, lanAvailable bool, killswi
}

func (en *Server) resetPeers(lanAvailable bool, killswitch bool) error {
log.Println(internal.DebugPrefix, "resetPeeers: lan-available:", lanAvailable)
trafficPeers := make([]TrafficPeer, 0, len(en.peers))
for _, peer := range en.peers {
log.Println(internal.DebugPrefix, "resetPeeers: peer:", peer.Nickname, "/", peer.Hostname, "local:", peer.DoIAllowLocalNetwork)
if peer.Address.IsValid() {
trafficPeers = append(trafficPeers, TrafficPeer{
netip.PrefixFrom(peer.Address, peer.Address.BitLen()),
Expand Down
6 changes: 5 additions & 1 deletion test/qa/lib/meshnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,20 @@ def bool_to_permission(permission: bool) -> str:

# ignore any failures that might occur when permissions are already configured to the desired value
if routing is not None:
sh.nordvpn.mesh.peer.routing(bool_to_permission(routing), peer, _ok_code=(0, 1))
result = sh.nordvpn.mesh.peer.routing(bool_to_permission(routing), peer, _ok_code=(0, 1))
logging.log(f"DEBUG: set routing to {routing} for {peer} output: {result}, return code: {result.exit_code}")

if local is not None:
sh.nordvpn.mesh.peer.local(bool_to_permission(local), peer, _ok_code=(0, 1))
logging.log(f"DEBUG: set local to {local} for {peer} output: {result}, return code: {result.exit_code}")

if incoming is not None:
sh.nordvpn.mesh.peer.incoming(bool_to_permission(incoming), peer, _ok_code=(0, 1))
logging.log(f"DEBUG: set incoming to {incoming} for {peer} output: {result}, return code: {result.exit_code}")

if fileshare is not None:
sh.nordvpn.mesh.peer.fileshare(bool_to_permission(fileshare), peer, _ok_code=(0, 1))
logging.log(f"DEBUG: set fileshare to {fileshare} for {peer} output: {result}, return code: {result.exit_code}")


def get_clean_peer_list(peer_list: str):
Expand Down
9 changes: 7 additions & 2 deletions test/qa/test_meshnet_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import sh

import lib
from lib import daemon, meshnet, network, settings, ssh
from lib import daemon, meshnet, network, settings, ssh, logging


ssh_client = ssh.Ssh("qa-peer", "root", "root")

Expand All @@ -28,7 +29,11 @@ def teardown_function(function): # noqa: ARG001
@pytest.mark.parametrize("lan_discovery", [True, False])
@pytest.mark.parametrize("local", [True, False])
def test_lan_discovery_exitnode(lan_discovery: bool, local: bool):
peer_ip = meshnet.PeerList.from_str(sh.nordvpn.mesh.peer.list()).get_external_peer().ip
logging.log(f"DEBUG: lan_discovery: {lan_discovery}, local: {local}")
peer_list = sh.nordvpn.mesh.peer.list()
logging.log(peer_list)
logging.log(peer_list.exit_code)
peer_ip = meshnet.PeerList.from_str(peer_list).get_external_peer().ip
meshnet.set_permissions(peer_ip, True, local, True, True)

lan_discovery_value = "on" if lan_discovery else "off"
Expand Down

0 comments on commit 5409d17

Please sign in to comment.