func New(conf *config.Config, version string) *Kontrol {
	kontrol := NewWithoutHandlers(conf, version)
	kontrol.Kite.HandleFunc("register", kontrol.HandleRegister)
	kontrol.Kite.HandleFunc("registerMachine", kontrol.HandleMachine).DisableAuthentication()
	kontrol.Kite.HandleFunc("getKites", kontrol.HandleGetKites)
	kontrol.Kite.HandleFunc("getToken", kontrol.HandleGetToken)
	kontrol.Kite.HandleFunc("getKey", kontrol.HandleGetKey)
	kontrol.Kite.HandleHTTPFunc("/register", kontrol.HandleRegisterHTTP)
	kontrol.Kite.HandleHTTPFunc("/heartbeat", kontrol.HandleHeartbeat)
	return kontrol
}
New creates a new kontrol instance with the given version and config
instance, and the default kontrol handlers. Publickey is used for
validating tokens and privateKey is used for signing tokens.

Public and private keys are RSA pem blocks that can be generated with the
following command:

openssl genrsa -out testkey.pem 2048
openssl rsa -in testkey.pem -pubout > testkey_pub.pem

If you need to provide custom handlers in place of the default ones,
use the following command instead:

NewWithoutHandlers(conf, version)
package kontrol
import (
	"errors"
	"fmt"
	"math/rand"
	"strings"
	"sync"
	"time"
	jwt "github.com/dgrijalva/jwt-go"
	"github.com/koding/kite"
	"github.com/koding/kite/config"
	"github.com/koding/kite/kitekey"
	kontrolprotocol "github.com/koding/kite/kontrol/protocol"
	uuid "github.com/satori/go.uuid"
)
const (
	KontrolVersion = "0.0.4"
	KitesPrefix    = "/kites"
)
var (
	TokenTTL = 48 * time.Hour
	TokenLeeway = 5 * time.Minute
	DefaultPort = 4000
	HeartbeatInterval = time.Second * 10
	HeartbeatDelay = time.Second * 20
	UpdateInterval = time.Second * 60
	KeyTTL = time.Second * 90
)
type Kontrol struct {
	Kite *kite.Kite
	MachineAuthenticate func(authType string, r *kite.Request) error
	MachineKeyPicker func(r *kite.Request) (*KeyPair, error)
	TokenTTL time.Duration
	TokenLeeway time.Duration
	TokenNoNBF bool
	clientLocks *IdLock
	heartbeats   map[string]*heartbeat
	heartbeatsMu sync.Mutex  
	tokenCache   map[string]cachedToken
	tokenCacheMu sync.Mutex
	closed chan struct{}
	keyPair KeyPairStorage
	lastIDs     []string
	lastPublic  []string
	lastPrivate []string
	storage Storage
	selfKeyPair *KeyPair
	RegisterURL string
	log kite.Logger
}
type heartbeat struct {
	updateC chan func() error
	timer   *time.Timer
}