def bootstrap(self, fail=None, peers=[]):
		'''
		Bootstraps the peer into the (P2P) network. It calls the specific
		method 'doBootstrap' to handle overlay specific steps.
		'''
		node = None

		try:
			node = peers.pop(0)
		except IndexError:
			print ' *\033[91m Bootstrapping failed:\033[0m cannot reach any introducer node.'
			return

		if fail is None:
			print '-+- Bootstrapping into the network -+-'
		else:
			print >> stderr, '   * Bootstrapping with this peer has failed'

		print ' | trying with %s, port %s, kind %s and protocol %s' % (
			node['address'], node['port'], node['kind'], node['protocol']
		)

		try:
			wind = WindManager.findWind(
				kind=node['kind'], protocol=node['protocol'])
		except NoSuchAWindError:
			return self.bootstrap(peers=peers)

		try:
			d = wind.factory.connect(node['address'], node['port'])

			d.addCallback(self.doBootstrap, peers=peers)
			d.addErrback(self.bootstrap, peers=peers)

		except AttributeError as e:
			print ' * Bootstrapping with %s (%s:%s) protocol %s has failed' % (
						node['address'], node['port'],
						node['kind'], node['protocol']
			)
			print '   Can\'t find a suitable wind for this bootstrap node.'
			return
	def sayHello(self, peer):
		w = None

		for c in peer.getConnections():
			try:
				w = WindManager.findWind(c[2], c[3])
			except NoSuchAWindError:
				pass
			else:
				break
		else:
			print >> stderr, (
				" * Couldn't find a wind for contacting %s" % peer.getName())
			raise NoSuchAWindError, 'No wind for contacting ' + peer.getName()

		return w.factory.connect(
			c[0], c[1] # Address / Port
		).addCallback(
			peer.setTransport
		).addCallback(
			self.sendHello)
			).addCallback(
				lambda m: True
			).addErrback(
				self.introRecvdErrback, message=message)

		else:
			node = message.getElement('node')

			peer = CyclonPeer(node.getAttribute('name'))
			peer.addConnectionsFromXML(node.childNodes)

			winds = [ ]

			for c in peer.getConnections():
				try:
					w = WindManager.findWind(c[2], c[3])
				except NoSuchAWindError:
					continue

				winds.append((w,c))

			if len(Cyclon.peerList) > 0:
				introduced = Cyclon.peerList.getRandomPeer()
			else:
				introduced = Cyclon.myself

			self.introductoryConnection(None, peer, introduced, winds)

	def introreplyReceived(self, (transport, message)):
		try:
			node = message.getElement('node')
def main():
	from twisted.internet import reactor

	from configparser import ConfigParser
	from wind import WindManager
	from overlay import OverlayManager
	from message import MessageKeeper
	from extension import ComponentManager
	from extension import PluginManager

	from sys import stderr

	print '-+- Parsing configuration file and CLI -+-'

	cfg = ConfigParser()

	try:
		cfg.parseOptions()
	except RuntimeError as e:
		print >> stderr, ' * Error while parsing configurations'

		for l in str(e).splitlines():
			print >> stderr, '\t>', l

		return -1

	except Warning as e:
		errors = str(e).splitlines()

		print >> stderr, ' *', errors[0]
		for l in errors[1:]:
			print >> stderr, '\t>', l

	print '-+- Loading Winds -+-'

	try:
		WindManager.load(cfg['winds'])

	except RuntimeError as e:
		print >> stderr, ' * Error while loading winds:'

		for l in str(e).splitlines():
			print >>  stderr, '\t>', l

	wdesc = WindManager.getDescriptors()

	if len(wdesc) == 0:
		print >> stderr, " * No wind was loaded. Exiting with error."
		return -1

	print '-+- Loading Overlay -+-'

	try:
		OverlayManager.load(cfg['overlay'])

	except RuntimeError as e:
		print >> stderr, (' * Error while loading overlay\n\t' + str(e))
		return -1

	print '-+- Loading Management Components -+-'

	try:
		ComponentManager.load(cfg['managementComponents'])

	except RuntimeError as e:
		print >> stderr, (
			' * Error while loading management component\n\t' + str(e))
		return -1

	overlay = OverlayManager.getOverlay()
	overlay.start(cfg['node'], WindManager.getDescriptors())

	MessageKeeper.startToKeep()
	WindManager.startListening(overlay)
	ComponentManager.register(overlay)

	if len(cfg['bootstrap']) > 0:
		reactor.callWhenRunning(overlay.bootstrap, None, cfg['bootstrap'])

	reactor.run()