github.com/outbrain/consul@v1.4.5/agent/connect/ca/plugin/serve.go (about)

     1  package plugin
     2  
     3  import (
     4  	"github.com/hashicorp/consul/agent/connect/ca"
     5  	"github.com/hashicorp/go-plugin"
     6  )
     7  
     8  // Name is the name of the plugin that users of the package should use
     9  // with *plugin.Client.Dispense to get the proper plugin instance.
    10  const Name = "consul-connect-ca"
    11  
    12  // handshakeConfig is the HandshakeConfig used to configure clients and servers.
    13  var handshakeConfig = plugin.HandshakeConfig{
    14  	// The ProtocolVersion is the version that must match between Consul
    15  	// and CA plugins. This should be bumped whenever a change happens in
    16  	// one or the other that makes it so that they can't safely communicate.
    17  	ProtocolVersion: 1,
    18  
    19  	// The magic cookie values should NEVER be changed.
    20  	MagicCookieKey:   "CONSUL_PLUGIN_MAGIC_COOKIE",
    21  	MagicCookieValue: "f31f63b28fa82a3cdb30a6284cb1e50e3a13b7e60ba105a2c91219da319d216c",
    22  }
    23  
    24  // Serve serves a CA plugin. This function never returns and should be the
    25  // final function called in the main function of the plugin.
    26  func Serve(p ca.Provider) {
    27  	plugin.Serve(&plugin.ServeConfig{
    28  		HandshakeConfig: handshakeConfig,
    29  		Plugins: map[string]plugin.Plugin{
    30  			Name: &ProviderPlugin{Impl: p},
    31  		},
    32  	})
    33  }