#!/bin/sh

# determine the installation directory of stic_std_variables and execute inline
if test -n "$STIC_MAIN_DIR"
then
  stic_init_dir=$STIC_MAIN_DIR
elif test -r $HOME/.stic_main_dir
then
  stic_init_dir=$(cat $HOME/.stic_main_dir)
fi
if test "$stic_init_dir" = ""
then
  stic_init_dir=$(dirname "$0")/
else
  stic_init_dir="$stic_init_dir"/scripts/
fi
if test -r "$stic_init_dir"stic_std_variables
then
  . "$stic_init_dir"stic_std_variables
elif test  -z "$STIC_NO_BASH" -a -n "$(type -p stic_std_variables)"
then
  . stic_std_variables
fi


#
# A TCP/IP based server for connections from localhost only.
#
# The connections nevertheless have to be encrypted. So you
# need to have a keyfile to use this server. If there is none
# yet then write at least 64 secret characters into the file
# $HOME/tnl_keydir/me.tnl and execute
#   similar -make_userkey:tcp:me
# Also add the command
#   -security:tcp:user:me 
# to $HOME/.similar_rc .
#
# This is sufficient if client and server are run by the same user
# multi-user servers may use file copies or a central keydirectory
# (set by -security:tcp:keydirectory:... )
# and suitable names for the users.
#

if test "$1" = "-similar_server_no_cache"
then
  cache=
else
  cache=-caching:on
fi

"$stic_bin_dir"similar \
  "$@" \
  -security:tcp:tunnel:require \
  -permission:all:end:deny \
  -permission:all:shell:deny \
  -permission:internal_owner:all:permit \
  -tcp_service:2:localhost:0:FFFFFFFF \
  -guarded_map:tcp \
  $cache \
  -internal:stdout:off \

