Revision 58bb385c lib/impexpd/__init__.py
b/lib/impexpd/__init__.py | ||
---|---|---|
35 | 35 |
from ganeti import constants |
36 | 36 |
from ganeti import errors |
37 | 37 |
from ganeti import utils |
38 |
from ganeti import netutils |
|
38 | 39 |
|
39 | 40 |
|
40 | 41 |
#: Used to recognize point at which socat(1) starts to listen on its socket. |
... | ... | |
144 | 145 |
if self._opts.bind is not None: |
145 | 146 |
common_addr_opts.append("bind=%s" % self._opts.bind) |
146 | 147 |
|
148 |
assert not (self._opts.ipv4 and self._opts.ipv6) |
|
149 |
|
|
150 |
if self._opts.ipv4: |
|
151 |
common_addr_opts.append("pf=ipv4") |
|
152 |
elif self._opts.ipv6: |
|
153 |
common_addr_opts.append("pf=ipv6") |
|
154 |
|
|
147 | 155 |
if self._mode == constants.IEM_IMPORT: |
148 | 156 |
if self._opts.port is None: |
149 | 157 |
port = 0 |
... | ... | |
162 | 170 |
addr2 = ["stdout"] |
163 | 171 |
|
164 | 172 |
elif self._mode == constants.IEM_EXPORT: |
173 |
if self._opts.host and netutils.IP6Address.IsValid(self._opts.host): |
|
174 |
host = "[%s]" % self._opts.host |
|
175 |
else: |
|
176 |
host = self._opts.host |
|
177 |
|
|
165 | 178 |
addr1 = ["stdin"] |
166 | 179 |
addr2 = [ |
167 |
"OPENSSL:%s:%s" % (self._opts.host, self._opts.port),
|
|
180 |
"OPENSSL:%s:%s" % (host, self._opts.port), |
|
168 | 181 |
|
169 | 182 |
# How long to wait per connection attempt |
170 | 183 |
"connect-timeout=%s" % self._opts.connect_timeout, |
... | ... | |
329 | 342 |
"""Verify address given as listening address by socat. |
330 | 343 |
|
331 | 344 |
""" |
332 |
# TODO: Implement IPv6 support |
|
333 |
if family != socket.AF_INET: |
|
345 |
if family not in (socket.AF_INET, socket.AF_INET6): |
|
334 | 346 |
raise errors.GenericError("Address family %r not supported" % family) |
335 | 347 |
|
348 |
if (family == socket.AF_INET6 and address.startswith("[") and |
|
349 |
address.endswith("]")): |
|
350 |
address = address.lstrip("[").rstrip("]") |
|
351 |
|
|
336 | 352 |
try: |
337 | 353 |
packed_address = socket.inet_pton(family, address) |
338 | 354 |
except socket.error: |
Also available in: Unified diff