예제 #1
0
	BeforeEach(func() {
		var err error

		fakeRunner = fake_command_runner.New()
		testCfg = &sysconfig.IPTablesNATConfig{
			PreroutingChain:  "nat-prerouting-chain",
			PostroutingChain: "nat-postrouting-chain",
			InstancePrefix:   "nat-instance-prefix",
		}

		containerID = "some-ctr-id"
		bridgeName = "some-bridge"
		ip, network, err = net.ParseCIDR("1.2.3.4/28")
		Expect(err).NotTo(HaveOccurred())

		chain = iptables_manager.NewNATChain(testCfg, fakeRunner, lagertest.NewTestLogger("test"))
	})

	Describe("ContainerSetup", func() {
		var specs []fake_command_runner.CommandSpec
		BeforeEach(func() {
			expectedNatInstanceChain := testCfg.InstancePrefix + containerID
			specs = []fake_command_runner.CommandSpec{
				fake_command_runner.CommandSpec{
					Path: "iptables",
					Args: []string{"--wait", "--table", "nat", "-N", expectedNatInstanceChain},
				},
				fake_command_runner.CommandSpec{
					Path: "iptables",
					Args: []string{"--wait", "--table", "nat", "-A", testCfg.PreroutingChain,
						"--jump", expectedNatInstanceChain},
예제 #2
0
파일: main.go 프로젝트: timani/garden-linux
func createIPTablesManager(sysconfig sysconfig.Config, runner command_runner.CommandRunner, log lager.Logger) linux_container.IPTablesManager {
	filterChain := iptables_manager.NewFilterChain(&sysconfig.IPTables.Filter, runner, log.Session("iptables-manager-filter"))
	natChain := iptables_manager.NewNATChain(&sysconfig.IPTables.NAT, runner, log.Session("iptables-manager-nat"))
	return iptables_manager.New().AddChain(filterChain).AddChain(natChain)
}