{
    # process all information-bay directories

    my %vpns;
    tie %vpns, 'esmith::config', '/home/e-smith/vpns';

    my $key;
    my $value;
    my $result = "";

    my ($LocalNetwork, $LocalBroadcast) =
	esmith::util::computeNetworkAndBroadcast($LocalIP, $LocalNetmask);

    while (($key,$value) = each %vpns)
    {
	my ($type, %properties) = split (/\|/, $value, -1);
	if (($type eq 'remotenetwork'))
	{
	    $result .= "##############################################################\n\n";

	    #------------------------------------------
	    # If public access is set to none, then force the share
	    # to go directly to the files subdirectory for Mac. filesharing
	    # Otherwise, have the share show all 3 subfolders to give html content
	    #------------------------------------------
	    my $remoteID = $properties {'RemoteID'};
	    my $remoteHost = $properties {'RemoteHost'};
	    my $remoteNetwork = $key;
	    my $remoteInternalSubnetMask = $properties {'InternalMask'};
	    my $remotePubKey = $properties {'PubKey'};
	    my $remoteNAT = $properties {'NAT'};
	    my $protectNetToNet = $properties {'NetToNet'};
	    my $protectGateToGate = $properties {'GateToGate'};
	    my $protectGateToNet = $properties {'GateToNet'};

	    if ($properties {'Function'} && ($properties {'Function'} eq 'server')) 
	    {
		if ($protectNetToNet && ($protectNetToNet eq 'yes'))
		{
			$result .= "conn net.local-net.$remoteNetwork\n";
			$result .= "\talso=net.local.left\n";
			$result .= "\tright=$remoteHost\n";
			$result .= "\trightsubnet=$remoteNetwork/$remoteInternalSubnetMask\n";
			$result .= "\trightfirewall=$remoteNAT\n";
			$result .= "\trightid=\@$remoteID\n";
			$result .= "\trightrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";
		}
		if ($protectGateToGate && ($protectGateToGate eq 'yes'))
		{
			$result .= "conn gate.local-gate.$remoteNetwork\n";
			$result .= "\talso=gate.local.left\n";
			$result .= "\tright=$remoteHost\n";
			$result .= "\trightid=\@$remoteID\n";
			$result .= "\trightrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";
		}
		if ($protectGateToNet && ($protectGateToNet eq 'yes'))
		{
			$result .= "conn net.local-gate.$remoteNetwork\n";
			$result .= "\talso=net.local.left\n";
			$result .= "\tright=$remoteHost\n";
			$result .= "\trightid=\@$remoteID\n";
			$result .= "\trightrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";

			$result .= "conn gate.local-net.$remoteNetwork\n";
			$result .= "\talso=gate.local.left\n";
			$result .= "\tright=$remoteHost\n";
			$result .= "\trightsubnet=$remoteNetwork/$remoteInternalSubnetMask\n";
			$result .= "\trightfirewall=$remoteNAT\n";
			$result .= "\trightid=\@$remoteID\n";
			$result .= "\trightrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";
		}
	    }
	    elsif ($properties {'Function'} && ($properties {'Function'} eq 'client'))
	    {
		if ($protectNetToNet && ($protectNetToNet eq 'yes'))
		{
			$result .= "conn net.local-net.$remoteNetwork\n";
			$result .= "\talso=net.local.right\n";
			$result .= "\tleft=$remoteHost\n";
			$result .= "\tleftsubnet=$remoteNetwork/$remoteInternalSubnetMask\n";
			$result .= "\tleftfirewall=$remoteNAT\n";
			$result .= "\tleftid=\@$remoteID\n";
			$result .= "\tleftrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";
		}
		if ($protectGateToGate && ($protectGateToGate eq 'yes'))
		{
			$result .= "conn gate.local-gate.$remoteNetwork\n";
			$result .= "\talso=gate.local.right\n";
			$result .= "\tleft=$remoteHost\n";
			$result .= "\tleftid=\@$remoteID\n";
			$result .= "\tleftrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";
		}
		if ($protectGateToNet && ($protectGateToNet eq 'yes'))
		{
			$result .= "conn net.local-gate.$remoteNetwork\n";
			$result .= "\talso=net.local.right\n";
			$result .= "\tleft=$remoteHost\n";
			$result .= "\tleftid=\@$remoteID\n";
			$result .= "\tleftrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";

			$result .= "conn gate.local-net.$remoteNetwork\n";
			$result .= "\talso=gate.local.right\n";
			$result .= "\tleft=$remoteHost\n";
			$result .= "\tleftsubnet=$remoteNetwork/$remoteInternalSubnetMask\n";
			$result .= "\tleftfirewall=$remoteNAT\n";
			$result .= "\tleftid=\@$remoteID\n";
			$result .= "\tleftrsasigkey=$remotePubKey\n";
			$result .= "\tauto=start\n\n";
		}
	    }

	    $result .= "##############################################################\n\n\n";
	}
    }

    $result;
}
