diff --git a/certbot-nginx/certbot_nginx/obj.py b/certbot-nginx/certbot_nginx/obj.py index 8868fcfad..d5a6b0624 100644 --- a/certbot-nginx/certbot_nginx/obj.py +++ b/certbot-nginx/certbot_nginx/obj.py @@ -36,7 +36,7 @@ class Addr(common.Addr): UNSPECIFIED_IPV4_ADDRESSES = ('', '*', '0.0.0.0') CANONICAL_UNSPECIFIED_ADDRESS = UNSPECIFIED_IPV4_ADDRESSES[0] - def __init__(self, host, port, ssl, default, ipv6, ipv6only): + def __init__(self, host, port, ssl, default, ipv6, ipv6only, otherparts=None): # pylint: disable=too-many-arguments super(Addr, self).__init__((host, port)) self.ssl = ssl @@ -44,6 +44,7 @@ class Addr(common.Addr): self.ipv6 = ipv6 self.ipv6only = ipv6only self.unspecified_address = host in self.UNSPECIFIED_IPV4_ADDRESSES + self.otherparts = otherparts @classmethod def fromstring(cls, str_addr): @@ -84,6 +85,7 @@ class Addr(common.Addr): port = tup[2] # The rest of the parts are options; we only care about ssl and default + otherparts = set() while len(parts) > 0: nextpart = parts.pop() if nextpart == 'ssl': @@ -94,8 +96,10 @@ class Addr(common.Addr): default = True elif nextpart == "ipv6only=on": ipv6only = True + else: + otherparts.add(nextpart) - return cls(host, port, ssl, default, ipv6, ipv6only) + return cls(host, port, ssl, default, ipv6, ipv6only, otherparts) def to_string(self, include_default=True): """Return string representation of Addr""" @@ -111,6 +115,12 @@ class Addr(common.Addr): parts += ' default_server' if self.ssl: parts += ' ssl' + if self.ipv6only: + parts += ' ipv6only=on' + if self.otherparts: + for word in self.otherparts: + parts += ' ' + parts += word return parts diff --git a/certbot-nginx/certbot_nginx/tests/obj_test.py b/certbot-nginx/certbot_nginx/tests/obj_test.py index 9e5853c4a..c3c90592f 100644 --- a/certbot-nginx/certbot_nginx/tests/obj_test.py +++ b/certbot-nginx/certbot_nginx/tests/obj_test.py @@ -57,7 +57,7 @@ class AddrTest(unittest.TestCase): self.assertEqual(str(self.addr3), "192.168.1.1:80") self.assertEqual(str(self.addr4), "*:80 default_server ssl") self.assertEqual(str(self.addr5), "myhost") - self.assertEqual(str(self.addr6), "80 default_server") + self.assertEqual(str(self.addr6), "80 default_server spdy") self.assertEqual(str(self.addr8), "*:80 default_server ssl") def test_to_string(self): @@ -67,8 +67,8 @@ class AddrTest(unittest.TestCase): self.assertEqual(self.addr4.to_string(), "*:80 default_server ssl") self.assertEqual(self.addr4.to_string(include_default=False), "*:80 ssl") self.assertEqual(self.addr5.to_string(), "myhost") - self.assertEqual(self.addr6.to_string(), "80 default_server") - self.assertEqual(self.addr6.to_string(include_default=False), "80") + self.assertEqual(self.addr6.to_string(), "80 default_server spdy") + self.assertEqual(self.addr6.to_string(include_default=False), "80 spdy") def test_eq(self): from certbot_nginx.obj import Addr @@ -163,7 +163,7 @@ class VirtualHostTest(unittest.TestCase): from certbot_nginx.obj import VirtualHost vhost1b = VirtualHost( "filep", - set([Addr.fromstring("localhost blah")]), False, False, + set([Addr.fromstring("localhost")]), False, False, set(['localhost']), [], []) self.assertEqual(vhost1b, self.vhost1)