This repository was archived by the owner on Jun 20, 2024. It is now read-only.
File tree 1 file changed +14
-9
lines changed
1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,18 @@ func (i *Ipam) Allocate(args *skel.CmdArgs) (types.Result, error) {
39
39
var ipnet * net.IPNet
40
40
41
41
if len (conf .IPs ) == 1 {
42
- ip := conf .IPs [0 ]
43
- if ip .Version == "4" {
44
- ipnet = & ip .Address
45
- err = i .weave .ClaimIP (containerID , ipnet , false )
46
- } else {
42
+ ip := net .ParseIP (conf .IPs [0 ]).To4 ()
43
+
44
+ if ip == nil {
47
45
return nil , errors .New ("allocation of ipv6 addresses is not implemented" )
48
46
}
47
+
48
+ ipnet := & net.IPNet {
49
+ IP : ip ,
50
+ Mask : ip .DefaultMask (),
51
+ }
52
+
53
+ err = i .weave .ClaimIP (containerID , ipnet , false )
49
54
} else if conf .Subnet == "" {
50
55
ipnet , err = i .weave .AllocateIP (containerID , false )
51
56
} else {
@@ -80,10 +85,10 @@ func (i *Ipam) Release(args *skel.CmdArgs) error {
80
85
}
81
86
82
87
type ipamConf struct {
83
- Subnet string `json:"subnet,omitempty"`
84
- Gateway net.IP `json:"gateway,omitempty"`
85
- Routes []* types.Route `json:"routes"`
86
- IPs []* current. IPConfig `json:"ips,omitempty"`
88
+ Subnet string `json:"subnet,omitempty"`
89
+ Gateway net.IP `json:"gateway,omitempty"`
90
+ Routes []* types.Route `json:"routes"`
91
+ IPs []string `json:"ips,omitempty"`
87
92
}
88
93
89
94
type netConf struct {
You can’t perform that action at this time.
0 commit comments