當前位置: 首頁>>代碼示例>>Golang>>正文


Golang DriverEncryptionConfig.Keys方法代碼示例

本文整理匯總了Golang中github.com/docker/libnetwork/discoverapi.DriverEncryptionConfig.Keys方法的典型用法代碼示例。如果您正苦於以下問題:Golang DriverEncryptionConfig.Keys方法的具體用法?Golang DriverEncryptionConfig.Keys怎麽用?Golang DriverEncryptionConfig.Keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/docker/libnetwork/discoverapi.DriverEncryptionConfig的用法示例。


在下文中一共展示了DriverEncryptionConfig.Keys方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: agentDriverNotify

func (c *controller) agentDriverNotify(d driverapi.Driver) {
	if c.agent == nil {
		return
	}

	d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
		Address:     c.agent.advertiseAddr,
		BindAddress: c.agent.bindAddr,
		Self:        true,
	})

	drvEnc := discoverapi.DriverEncryptionConfig{}
	keys, tags := c.getKeys(subsysIPSec)
	drvEnc.Keys = keys
	drvEnc.Tags = tags

	c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
		err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
		if err != nil {
			logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
		}
		return false
	})

}
開發者ID:CWSpear,項目名稱:docker,代碼行數:25,代碼來源:agent.go

示例2: agentDriverNotify

func (c *controller) agentDriverNotify(d driverapi.Driver) {
	if c.agent == nil {
		return
	}

	d.DiscoverNew(discoverapi.NodeDiscovery, discoverapi.NodeDiscoveryData{
		Address: c.agent.bindAddr,
		Self:    true,
	})

	drvEnc := discoverapi.DriverEncryptionConfig{}
	for _, key := range c.keys {
		if key.Subsystem == "networking:gossip" /*"networking:ipsec"*/ {
			drvEnc.Keys = append(drvEnc.Keys, hex.EncodeToString(key.Key))
			drvEnc.Tags = append(drvEnc.Tags, strconv.FormatUint(key.LamportTime, 10))
		}
	}
	c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
		err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
		if err != nil {
			logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
		}
		return false
	})

}
開發者ID:amitshukla,項目名稱:docker,代碼行數:26,代碼來源:agent.go

示例3: agentInit

func (c *controller) agentInit(bindAddrOrInterface string) error {
	if !c.isAgent() {
		return nil
	}

	drvEnc := discoverapi.DriverEncryptionConfig{}

	// sort the keys by lamport time
	sort.Sort(ByTime(c.keys))

	gossipkey := [][]byte{}
	for _, key := range c.keys {
		if key.Subsystem == "networking:gossip" {
			gossipkey = append(gossipkey, key.Key)
		}
		if key.Subsystem == "networking:gossip" /*"networking:ipsec"*/ {
			drvEnc.Keys = append(drvEnc.Keys, hex.EncodeToString(key.Key))
			drvEnc.Tags = append(drvEnc.Tags, strconv.FormatUint(key.LamportTime, 10))
		}
	}

	bindAddr, err := resolveAddr(bindAddrOrInterface)
	if err != nil {
		return err
	}

	hostname, _ := os.Hostname()
	nDB, err := networkdb.New(&networkdb.Config{
		BindAddr: bindAddr,
		NodeName: hostname,
		Keys:     gossipkey,
	})

	if err != nil {
		return err
	}

	ch, cancel := nDB.Watch("endpoint_table", "", "")

	c.agent = &agent{
		networkDB:         nDB,
		bindAddr:          bindAddr,
		epTblCancel:       cancel,
		driverCancelFuncs: make(map[string][]func()),
	}

	go c.handleTableEvents(ch, c.handleEpTableEvent)

	c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
		err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
		if err != nil {
			logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
		}
		return false
	})

	return nil
}
開發者ID:amitshukla,項目名稱:docker,代碼行數:58,代碼來源:agent.go

示例4: agentInit

func (c *controller) agentInit(bindAddrOrInterface string) error {
	if !c.isAgent() {
		return nil
	}

	drvEnc := discoverapi.DriverEncryptionConfig{}

	keys, tags := c.getKeys(subsysGossip) // getKeys(subsysIPSec)
	drvEnc.Keys = keys
	drvEnc.Tags = tags

	bindAddr, err := resolveAddr(bindAddrOrInterface)
	if err != nil {
		return err
	}

	hostname, _ := os.Hostname()
	nDB, err := networkdb.New(&networkdb.Config{
		BindAddr: bindAddr,
		NodeName: hostname,
		Keys:     keys,
	})

	if err != nil {
		return err
	}

	ch, cancel := nDB.Watch("endpoint_table", "", "")

	c.agent = &agent{
		networkDB:         nDB,
		bindAddr:          bindAddr,
		epTblCancel:       cancel,
		driverCancelFuncs: make(map[string][]func()),
	}

	go c.handleTableEvents(ch, c.handleEpTableEvent)

	c.drvRegistry.WalkDrivers(func(name string, driver driverapi.Driver, capability driverapi.Capability) bool {
		err := driver.DiscoverNew(discoverapi.EncryptionKeysConfig, drvEnc)
		if err != nil {
			logrus.Warnf("Failed to set datapath keys in driver %s: %v", name, err)
		}
		return false
	})

	return nil
}
開發者ID:CheggEng,項目名稱:docker,代碼行數:48,代碼來源:agent.go


注:本文中的github.com/docker/libnetwork/discoverapi.DriverEncryptionConfig.Keys方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。