Skip to content

Commit

Permalink
Test with slirpnetstack
Browse files Browse the repository at this point in the history
  • Loading branch information
blechschmidt committed Jul 15, 2024
1 parent 543ba3e commit 8e574cd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
21 changes: 16 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ while true; do
done

contains() { case "$1" in *"$2"*) true ;; *) false ;; esac }

# shellcheck disable=SC2039
is_root() { [ "${EUID:-$(id -u)}" -eq 0 ]; }

Expand Down Expand Up @@ -256,9 +257,21 @@ install_slirp4netns() {
test $? -eq 0 || install_pkg slirp4netns
}

install_slirpnetstack() {
command -v slirpnetstack >/dev/null 2>&1
{ test $? -eq 0 || test -f /usr/local/bin/slirpnetstack; } && return
get_goarch
SUFFIX="$RESULT"
URL=https://github.com/tun2proxy/slirpnetstack/releases/latest/download/slirpnetstack-linux-"$SUFFIX"

ask_continue "$URL will be downloaded and extracted to /usr/local/bin/."
curl -L "$URL" > /usr/local/bin/slirpnetstack
chmod 755 /usr/local/bin/slirpnetstack
}

install_tun2socks() {
command -v tun2socks >/dev/null 2>&1
{ test $? -eq 0 || test -f /usr/bin/tun2socks; } && return
{ test $? -eq 0 || test -f /usr/local/bin/tun2socks; } && return
get_goarch
SUFFIX="$RESULT"
test "$SUFFIX" = "arm" && SUFFIX=armv5
Expand All @@ -273,9 +286,7 @@ install_tun2socks() {
install_unzip
unzip -d "$TMP" "$TMP/tun2socks.zip" tun2socks-linux-"$SUFFIX"
install -m 0755 "$TMP/tun2socks-linux-$SUFFIX" /usr/local/bin/tun2socks
rm "$TMP/tun2socks.zip"
rm "$TMP/tun2socks-linux-$SUFFIX"
rmdir "$TMP"
rm -r "$TMP"
}

install_gvisor() {
Expand Down Expand Up @@ -309,6 +320,6 @@ test "$DEPENDENCIES_ONLY" = "1" || {
test "$NO_DEPENDENCIES" != "1" && {
install_tor
install_tun2socks
install_slirp4netns
install_slirpnetstack
install_gvisor
}
8 changes: 4 additions & 4 deletions pallium/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ def parse_path(path: str, session: int, sandbox_name: typing.Optional[str] = Non
split = path.split(':', maxsplit=1)
if '/' in split[0]: # The part before the colon is not a sandbox name.
return path
config = os.path.join(runtime.PROFILE_DIR, split[0] + '.json')
profile = Profile.from_file(config)
config_path = get_config_path(split[0])
profile = Profile.from_file(config_path)
path = split[1]
else:
profile = Profile.from_file(sandbox_name)
path = path
config_path = get_config_path(sandbox_name)
profile = Profile.from_file(config_path)
session = profile.get_session(session)
pid = session.sandbox_pid
return '/proc/%d/root' % pid + path
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def wait_for_startup(self):
break
exit_code = self.process.poll()
if exit_code is not None and exit_code != 0:
raise subprocess.CalledProcessError(exit_code, 'Pallium terminated with a non-zero exit code '
'and did not write to the PID file.')
raise Exception('Pallium terminated with a non-zero exit code (%d) '
'and did not write to the PID file' % exit_code)

def exec(self, command, stripped=True):
return pallium_exec_profile_path(self.profile_path, command, stripped).decode()
Expand Down

0 comments on commit 8e574cd

Please sign in to comment.