-
Notifications
You must be signed in to change notification settings - Fork 8
/
...
65 lines (54 loc) · 1.04 KB
/
...
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"net"
"syscall"
"github.com/libipvs"
)
func main() {
h, err := libipvs.New()
if err != nil {
panic(err)
}
if err := h.Flush(); err != nil {
panic(err)
}
info, err := h.GetInfo()
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", info)
svcs, err := h.ListServices()
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", svcs)
svc := libipvs.Service{
Address: net.ParseIP("172.192.168.1"),
AddressFamily: syscall.AF_INET,
Protocol: libipvs.Protocol(syscall.IPPROTO_TCP),
Port: 80,
SchedName: libipvs.RoundRobin,
}
if err := h.NewService(&svc); err != nil {
panic(err)
}
svcs, err = h.ListServices()
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", svcs)
dst := libipvs.Destination{
Address: net.ParseIP("172.192.100.1"),
AddressFamily: syscall.AF_INET,
Port: 80,
}
if err := h.NewDestination(&svc, &dst); err != nil {
panic(err)
}
dsts, err := h.ListDestinations(&svc)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", dsts)
}