#!/usr/bin/perl
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;
	my $ret;
	if ($_{to} >= $this->mcpsession_min_version && 
	    $this->mcpsession_max_version >= $_{version}) {
		$ret=$_{to} > $this->mcpsession_max_version ? $this->mcpsession_max_version : $_{to};
	}
	else {
		$ret='';
	}
	$this->mcpsession_enabled($ret);
	if ($ret) {
		umask(077); # protect the key from prying eyes
		$this->mcpsession_auth_key($_{'authentication-key'});
		my $startmeth="mcp-negotiate_start";
		$this->$startmeth if $this->implements($startmeth);
	}
	return $ret;
}
