当前位置: 首页>>代码示例>>Golang>>正文


Golang Config.Bridge方法代码示例

本文整理汇总了Golang中github.com/weaveworks/weave/router.Config.Bridge方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.Bridge方法的具体用法?Golang Config.Bridge怎么用?Golang Config.Bridge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/weaveworks/weave/router.Config的用法示例。


在下文中一共展示了Config.Bridge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: main


//.........这里部分代码省略.........
		checkFatal(err)
		os.Exit(0)

	case deleteDatapath:
		checkFatal(weave.DeleteDatapath(datapathName))
		os.Exit(0)

	case addDatapathInterface != "":
		checkFatal(weave.AddDatapathInterface(datapathName, addDatapathInterface))
		os.Exit(0)
	}

	Log.Println("Command line options:", options())
	Log.Println("Command line peers:", peers)

	if protocolMinVersion < weave.ProtocolMinVersion || protocolMinVersion > weave.ProtocolMaxVersion {
		Log.Fatalf("--min-protocol-version must be in range [%d,%d]", weave.ProtocolMinVersion, weave.ProtocolMaxVersion)
	}
	config.ProtocolMinVersion = byte(protocolMinVersion)

	var fastDPOverlay weave.Overlay
	if datapathName != "" {
		// A datapath name implies that "Bridge" and "Overlay"
		// packet handling use fast datapath, although other
		// options can override that below.  Even if both
		// things are overridden, we might need bridging on
		// the datapath.
		fastdp, err := weave.NewFastDatapath(weave.FastDatapathConfig{
			DatapathName: datapathName,
			Port:         config.Port,
		})

		checkFatal(err)
		config.Bridge = fastdp.Bridge()
		fastDPOverlay = fastdp.Overlay()
	}

	if ifaceName != "" {
		// -iface can coexist with -datapath, because
		// pcap-based packet capture is a bit more efficient
		// than capture via ODP misses, even when using an
		// ODP-based bridge.  So when using weave encyption,
		// it's preferable to use -iface.
		var err error
		iface, err = weavenet.EnsureInterface(ifaceName)
		checkFatal(err)

		// bufsz flag is in MB
		config.Bridge, err = weave.NewPcap(iface, bufSzMB*1024*1024)
		checkFatal(err)
	}

	if password == "" {
		password = os.Getenv("WEAVE_PASSWORD")
	}

	if password == "" {
		Log.Println("Communication between peers is unencrypted.")
	} else {
		config.Password = []byte(password)
		Log.Println("Communication between peers is encrypted.")

		// fastdp doesn't support encryption
		fastDPOverlay = nil
	}
开发者ID:ravisinghsfbay,项目名称:weave,代码行数:66,代码来源:main.go


注:本文中的github.com/weaveworks/weave/router.Config.Bridge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。