# This file is part of bish-bosh. It is subject to the licence terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/raphaelcohn/bish-bosh/master/COPYRIGHT. No part of bish-bosh, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
# Copyright © 2014-2015 The developers of bish-bosh. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/raphaelcohn/bish-bosh/master/COPYRIGHT.


core_usesIn core functions
core_functions_register _bishbosh_backend_registration nc
core_usesIn bishbosh/backend ncFreeBSD ncOpenBSD ncMacOSX ncMirBSD ncDebianOpenBSD ncSolaris ncGNU ncDebianTraditional ncToybox ncBusyBox

bishbosh_backend_nc_check()
{
	if [ "$bishbosh_tunnel" != 'none' ]; then
		return 1
	fi
	
	if ! core_compatibility_whichNoOutput nc; then
		return 1
	fi
	
	local binary="$(core_compatibility_which nc)"
	
	local ncVariantCheckFunction
	for ncVariantCheckFunction in ncFreeBSD ncOpenBSD ncMirBSD ncMacOSX ncDebianOpenBSD ncSolaris ncGNU ncDebianTraditional ncToybox ncBusyBox
	do
		if bishbosh_backend_${ncVariantCheckFunction}_checkIfNetcatVariant; then
			backendName="$ncVariantCheckFunction"
			return 0
		fi
	done
	core_message WARN "Could not determine which netcat (nc, at path '$binary') you have installed."
	return 1
}

bishbosh_backend_nc_port()
{
	printf '%s' 1883
}
