Signed-off-by: Solomon Hykes <solomon@docker.com>
Solomon Hykes authored on 2014/08/10 10:12:521 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,28 @@ |
0 |
+package opts |
|
1 |
+ |
|
2 |
+import ( |
|
3 |
+ "net" |
|
4 |
+) |
|
5 |
+ |
|
6 |
+type IpOpt struct { |
|
7 |
+ *net.IP |
|
8 |
+} |
|
9 |
+ |
|
10 |
+func NewIpOpt(ref *net.IP, defaultVal string) *IpOpt { |
|
11 |
+ o := &IpOpt{ |
|
12 |
+ IP: ref, |
|
13 |
+ } |
|
14 |
+ o.Set(defaultVal) |
|
15 |
+ return o |
|
16 |
+} |
|
17 |
+ |
|
18 |
+func (o *IpOpt) Set(val string) error { |
|
19 |
+ // FIXME: return a parse error if the value is not a valid IP? |
|
20 |
+ // We are not changing this now to preserve behavior while refactoring. |
|
21 |
+ (*o.IP) = net.ParseIP(val) |
|
22 |
+ return nil |
|
23 |
+} |
|
24 |
+ |
|
25 |
+func (o *IpOpt) String() string { |
|
26 |
+ return (*o.IP).String() |
|
27 |
+} |