Re: Listening on 2 addresses

Axel Rau <[email protected]> Sun, 31 Mar 2019 17:34:26 +0200
Newsgroups gmane.comp.python.twisted.web
Message-ID <[email protected]>
--===============3863429794986307181==
Content-Type: multipart/alternative;
 boundary="Apple-Mail=_7F5BCE23-7697-4321-A7FD-33A59A5B62BC"

--Apple-Mail=_7F5BCE23-7697-4321-A7FD-33A59A5B62BC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Hi Tom,

thanks for the explanation.  After adding some brackets, your example =
code works like a charm.
>=20
> [1]: https://twistedmatrix.com/documents/current/api/twisted.applicatio=
n.service.MultiService.html <https://twistedmatrix.com/documents/current/=
api/twisted.application.service.MultiService.html>
> [2]: https://twistedmatrix.com/documents/current/api/twisted.applicatio=
n.internet.StreamServerEndpointService.html <https://twistedmatrix.com/do=
cuments/current/api/twisted.application.internet.StreamServerEndpointServ=
ice.html>
> [3]: https://twistedmatrix.com/documents/current/api/twisted.internet.e=
ndpoints.html#serverFromString <https://twistedmatrix.com/documents/curre=
nt/api/twisted.internet.endpoints.html#serverFromString>


Using your pointers, I tried the next step: TLS.

This variant of the makeService method:

		ipv4_endpoint =3D endpoints.serverFromString(
			reactor, 'ssl:{}:privateKey=3D{}:certKey=3D{}:interface=3D{}'.format(
				options['port'],
				endpoints.quoteStringArgument(options['cert_path']),
				endpoints.quoteStringArgument(options['key_path']),
				options['ipv4_address']))
		
		ipv6_endpoint =3D endpoints.serverFromString(
			reactor, 'ssl:{}:privateKey=3D{}:certKey=3D{}:interface=3D{}'.format(
				options['port'],
				endpoints.quoteStringArgument(options['cert_path']),
				endpoints.quoteStringArgument(options['key_path']),
				options['ipv6_address']))
		
		ipv4 =3D internet.StreamServerEndpointService(ipv4_endpoint, meteo_fact=
ory)
		ipv6 =3D internet.StreamServerEndpointService(ipv6_endpoint, meteo_fact=
ory)
		
		root =3D MultiService()
		ipv4.setServiceParent(root)
		ipv6.setServiceParent(root)

does not work. It fails with:
	_parseSSL() got multiple values for argument =E2=80=9Ainterface'
same with private privateKey and certKey.

What did I wrong this time?

Thanks, Axel
=2D--
PGP-Key:29E99DD6  =E2=98=80  computing @ chaos claudius


--Apple-Mail=_7F5BCE23-7697-4321-A7FD-33A59A5B62BC
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbs=
p-mode: space; line-break: after-white-space;" class=3D"">Hi Tom,<br =
class=3D""><div><br class=3D""></div><div>thanks for the explanation. =
&nbsp;After adding some brackets, your example code works like a =
charm.</div><div><blockquote type=3D"cite" class=3D""><div class=3D""><sp=
an style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; =
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weig=
ht: normal; letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; text-decoration: none; float: none; display: inline =
!important;" class=3D""><br class=3D""></span></div><div class=3D""><span=
 style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; =
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weig=
ht: normal; letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; text-decoration: none; float: none; display: inline =
!important;" class=3D"">[1]:<span class=3D"Apple-converted-space">&nbsp;<=
/span></span><a href=3D"https://twistedmatrix.com/documents/current/api/t=
wisted.application.service.MultiService.html" style=3D"font-family: =
Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; =
-webkit-text-stroke-width: 0px;" class=3D"">https://twistedmatrix.com/doc=
uments/current/api/twisted.application.service.MultiService.html</a><br =
style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size=
: 12px; font-style: normal; font-variant-caps: normal; font-weight: =
normal; letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; text-decoration: none;" class=3D""><span style=3D"ca=
ret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 12px; =
font-style: normal; font-variant-caps: normal; font-weight: normal; =
letter-spacing: normal; text-align: start; text-indent: 0px; text-transfo=
rm: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-wid=
th: 0px; text-decoration: none; float: none; display: inline !important;"=
 class=3D"">[2]:<span class=3D"Apple-converted-space">&nbsp;</span></span=
><a href=3D"https://twistedmatrix.com/documents/current/api/twisted.appli=
cation.internet.StreamServerEndpointService.html" style=3D"font-family: =
Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; =
-webkit-text-stroke-width: 0px;" class=3D"">https://twistedmatrix.com/doc=
uments/current/api/twisted.application.internet.StreamServerEndpointServi=
ce.html</a><br style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Reg=
ular; font-size: 12px; font-style: normal; font-variant-caps: normal; =
font-weight: normal; letter-spacing: normal; text-align: start; text-inde=
nt: 0px; text-transform: none; white-space: normal; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; text-decoration: none;" class=3D""><span =
style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size=
: 12px; font-style: normal; font-variant-caps: normal; font-weight: =
normal; letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; text-decoration: none; float: none; display: inline =
!important;" class=3D"">[3]:<span class=3D"Apple-converted-space">&nbsp;<=
/span></span><a href=3D"https://twistedmatrix.com/documents/current/api/t=
wisted.internet.endpoints.html#serverFromString" style=3D"font-family: =
Menlo-Regular; font-size: 12px; font-style: normal; font-variant-caps: =
normal; font-weight: normal; letter-spacing: normal; orphans: auto; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; =
-webkit-text-stroke-width: 0px;" class=3D"">https://twistedmatrix.com/doc=
uments/current/api/twisted.internet.endpoints.html#serverFromString</a><b=
r style=3D"caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; =
font-size: 12px; font-style: normal; font-variant-caps: normal; font-weig=
ht: normal; letter-spacing: normal; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; text-decoration: none;" class=3D""></div></blockquot=
e></div><div class=3D""><br class=3D""></div><div class=3D"">Using your =
pointers, I tried the next step: TLS.</div><div class=3D""><br class=3D""=
></div><div class=3D"">This variant of the makeService method:</div><div =
class=3D""><br class=3D""></div><div class=3D""><div class=3D""><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">		</span>ipv4_endpoint=
 =3D endpoints.serverFromString(</div><div class=3D""><span class=3D"Appl=
e-tab-span" style=3D"white-space:pre">			</span>reactor, 'ssl:{}:privateK=
ey=3D{}:certKey=3D{}:interface=3D{}'.format(</div><div class=3D""><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">				</span>options['po=
rt'],</div><div class=3D""><span class=3D"Apple-tab-span" style=3D"white-=
space:pre">				</span>endpoints.quoteStringArgument(options['cert_path'])=
,</div><div class=3D""><span class=3D"Apple-tab-span" style=3D"white-spac=
e:pre">				</span>endpoints.quoteStringArgument(options['key_path']),</di=
v><div class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre=
">				</span>options['ipv4_address']))</div><div class=3D""><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">		</span></div><div =
class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</s=
pan>ipv6_endpoint =3D endpoints.serverFromString(</div><div class=3D""><s=
pan class=3D"Apple-tab-span" style=3D"white-space:pre">			</span>reactor,=
 'ssl:{}:privateKey=3D{}:certKey=3D{}:interface=3D{}'.format(</div><div =
class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre">				<=
/span>options['port'],</div><div class=3D""><span class=3D"Apple-tab-span=
" style=3D"white-space:pre">				</span>endpoints.quoteStringArgument(opti=
ons['cert_path']),</div><div class=3D""><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">				</span>endpoints.quoteStringArgument(option=
s['key_path']),</div><div class=3D""><span class=3D"Apple-tab-span" =
style=3D"white-space:pre">				</span>options['ipv6_address']))</div><div =
class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</s=
pan></div><div class=3D""><span class=3D"Apple-tab-span" style=3D"white-s=
pace:pre">		</span>ipv4 =3D internet.StreamServerEndpointService(ipv4_end=
point, meteo_factory)</div><div class=3D""><span class=3D"Apple-tab-span"=
 style=3D"white-space:pre">		</span>ipv6 =3D internet.StreamServerEndpoin=
tService(ipv6_endpoint, meteo_factory)</div><div class=3D""><span =
class=3D"Apple-tab-span" style=3D"white-space:pre">		</span></div><div =
class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre">		</s=
pan>root =3D MultiService()</div><div class=3D""><span class=3D"Apple-tab=
-span" style=3D"white-space:pre">		</span>ipv4.setServiceParent(root)</di=
v><div class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre=
">		</span>ipv6.setServiceParent(root)</div></div><div class=3D""><br =
class=3D""></div><div class=3D"">does not work. It fails with:</div><div =
class=3D""><span class=3D"Apple-tab-span" style=3D"white-space:pre">	</sp=
an><span style=3D"background-color: rgb(255, 255, 255);" class=3D""><font=
 face=3D"Monaco" class=3D""><span style=3D"font-size: 11px;" class=3D"">_=
parseSSL() got multiple values for argument&nbsp;=E2=80=9Ainterface'</spa=
n></font></span></div><div class=3D""><span style=3D"font-family: =
Monaco; font-size: 11px; background-color: rgb(255, 255, 255);" class=3D"=
">same with private</span>&nbsp;privateKey and certKey.</div><div =
class=3D""><br class=3D""></div><div class=3D"">What did I wrong this =
time?</div><div class=3D""><span style=3D"orphans: 2; text-align: =
-webkit-auto; widows: 2;" class=3D""><br class=3D""></span></div><div =
class=3D""><span style=3D"orphans: 2; text-align: -webkit-auto; widows: =
2;" class=3D"">Thanks, Axel</span></div><div class=3D""><span style=3D"or=
phans: 2; text-align: -webkit-auto; widows: 2;" class=3D"">---</span></di=
v><div class=3D""><div style=3D"color: rgb(0, 0, 0); letter-spacing: =
normal; orphans: auto; text-align: start; text-indent: 0px; text-transfor=
m: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-te=
xt-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;" class=3D""><div style=3D"color: =
rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant-li=
gatures: normal; font-variant-position: normal; font-variant-caps: =
normal; font-variant-numeric: normal; font-variant-alternates: normal; =
font-variant-east-asian: normal; font-weight: normal; letter-spacing: =
normal; line-height: normal; orphans: 2; text-align: -webkit-auto; =
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word;=
 -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D""><div class=3D"">PGP-Key:29E99DD6 &nbsp;=E2=98=80 &nbsp;computi=
ng @ chaos claudius</div></div></div>
</div>
<br class=3D""></body></html>

--Apple-Mail=_7F5BCE23-7697-4321-A7FD-33A59A5B62BC--

--===============3863429794986307181==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13
ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBzOi8vdHdp
c3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtd2ViCg==

--===============3863429794986307181==--