summaryrefslogtreecommitdiffhomepage
path: root/tools/config/example_toml.go
blob: 0fb9b93bb0515c34e3618bf2494120aae92765ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main

import (
	"../../config"
	"bytes"
	"fmt"
	"github.com/BurntSushi/toml"
	"net"
)

func main() {
	b := config.BgpType{
		Global: config.GlobalType{
			As:       12332,
			RouterId: net.ParseIP("10.0.0.1"),
		},
		NeighborList: []config.NeighborType{
			config.NeighborType{
				PeerAs:          12333,
				NeighborAddress: net.ParseIP("192.168.177.32"),
				AuthPassword:    "apple",
			},
			config.NeighborType{
				PeerAs:          12334,
				NeighborAddress: net.ParseIP("192.168.177.33"),
				AuthPassword:    "orange",
			},
			config.NeighborType{
				PeerAs:          12335,
				NeighborAddress: net.ParseIP("192.168.177.34"),
				AuthPassword:    "grape",
			},
		},
	}

	var buffer bytes.Buffer
	encoder := toml.NewEncoder(&buffer)
	err := encoder.Encode(b)
	if err != nil {
		panic(err)
	}

	fmt.Printf("%v\n", buffer.String())
}