Revision db4e138b
b/lib/http/__init__.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2007, 2008 Google Inc. |
|
4 |
# Copyright (C) 2007, 2008, 2010 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
570 | 570 |
self._ssl_key = None |
571 | 571 |
self._ssl_cert = None |
572 | 572 |
|
573 |
def _CreateSocket(self, ssl_params, ssl_verify_peer): |
|
573 |
def _CreateSocket(self, ssl_params, ssl_verify_peer, family):
|
|
574 | 574 |
"""Creates a TCP socket and initializes SSL if needed. |
575 | 575 |
|
576 | 576 |
@type ssl_params: HttpSslParams |
... | ... | |
578 | 578 |
@type ssl_verify_peer: bool |
579 | 579 |
@param ssl_verify_peer: Whether to require client certificate |
580 | 580 |
and compare it with our certificate |
581 |
@type family: int |
|
582 |
@param family: socket.AF_INET | socket.AF_INET6 |
|
581 | 583 |
|
582 | 584 |
""" |
583 |
self._ssl_params = ssl_params
|
|
585 |
assert family in (socket.AF_INET, socket.AF_INET6)
|
|
584 | 586 |
|
585 |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
|
587 |
self._ssl_params = ssl_params |
|
588 |
sock = socket.socket(family, socket.SOCK_STREAM) |
|
586 | 589 |
|
587 | 590 |
# Should we enable SSL? |
588 | 591 |
self.using_ssl = ssl_params is not None |
b/lib/http/server.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2007, 2008 Google Inc. |
|
4 |
# Copyright (C) 2007, 2008, 2010 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
33 | 33 |
|
34 | 34 |
from ganeti import http |
35 | 35 |
from ganeti import utils |
36 |
from ganeti import netutils |
|
36 | 37 |
|
37 | 38 |
|
38 | 39 |
WEEKDAYNAME = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
... | ... | |
478 | 479 |
self.mainloop = mainloop |
479 | 480 |
self.local_address = local_address |
480 | 481 |
self.port = port |
481 |
|
|
482 |
self.socket = self._CreateSocket(ssl_params, ssl_verify_peer) |
|
482 |
family = netutils.IPAddress.GetAddressFamily(local_address) |
|
483 |
self.socket = self._CreateSocket(ssl_params, ssl_verify_peer, family)
|
|
483 | 484 |
|
484 | 485 |
# Allow port to be reused |
485 | 486 |
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |
Also available in: Unified diff