Re: Listening on 2 addresses

"Tom Most" <[email protected]> Mon, 01 Apr 2019 23:25:55 -0400
Newsgroups gmane.comp.python.twisted.web
Message-ID <[email protected]>
--===============7189687213140384824==
Content-Type: multipart/alternative;
 boundary=96e8c555e44343e1bc3f4f8602684128

--96e8c555e44343e1bc3f4f8602684128
Content-Type: text/plain;charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Axel,

I'm not entirely sure what's going wrong there (maybe quote the ipv6 add=
ress?), but you want to retain the various independent command-line opti=
ons you should instantiate endpoints directly rather than constructing a=
n endpoint string (the endpoint string is useful to expose *directly* as=
 a CLI parameter).

I.e., you can construct SSL4ServerEndpoint <https://twistedmatrix.com/do=
cuments/current/api/twisted.internet.endpoints.SSL4ServerEndpoint.html> =
directly. Oddly SSL6ServerEndpoint doesn't exist, though, and I don't se=
e a generic server wrapper like wrapClientTLS <https://twistedmatrix.com=
/documents/current/api/twisted.internet.endpoints.html#wrapClientTLS> fo=
r the server site. I'm afraid I may have led you down the wrong path ---=
 I didn't realize this was missing.

---Tom

On Sun, Mar 31, 2019, at 8:34 AM, Axel Rau wrote:
> Hi Tom,
>=20
> thanks for the explanation. After adding some brackets, your example c=
ode works like a charm.
>>=20
>> [1]: https://twistedmatrix.com/documents/current/api/twisted.applicat=
ion.service.MultiService.html
>> [2]: https://twistedmatrix.com/documents/current/api/twisted.applicat=
ion.internet.StreamServerEndpointService.html
>> [3]: https://twistedmatrix.com/documents/current/api/twisted.internet=
.endpoints.html#serverFromString
>=20
> Using your pointers, I tried the next step: TLS.
>=20
> This variant of the makeService method:
>=20
> 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']))
>=20
> 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']))
>=20
> ipv4 =3D internet.StreamServerEndpointService(ipv4_endpoint, meteo_fac=
tory)
> ipv6 =3D internet.StreamServerEndpointService(ipv6_endpoint, meteo_fac=
tory)
>=20
> root =3D MultiService()
> ipv4.setServiceParent(root)
> ipv6.setServiceParent(root)
>=20
> does not work. It fails with:
> _parseSSL() got multiple values for argument =E2=80=9Ainterface'
> same with private privateKey and certKey.
>=20
> What did I wrong this time?
>=20
> Thanks, Axel
> ---
> PGP-Key:29E99DD6 =E2=98=80 computing @ chaos claudius
>=20
> _______________________________________________
> Twisted-web mailing list
> [email protected]
> https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>=20

--96e8c555e44343e1bc3f4f8602684128
Content-Type: text/html;charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.Mso=
Normal,p.MsoNoSpacing{margin:0}</style></head><body><div>Hi Axel,<br></d=
iv><div><br></div><div>I'm not entirely sure what's going wrong there (m=
aybe quote the ipv6 address?), but you want to retain the various indepe=
ndent command-line options you should instantiate endpoints directly rat=
her than constructing an endpoint string (the endpoint string is useful =
to expose <i>directly</i> as a CLI parameter).<br></div><div><br></div><=
div>I.e., you can construct <a href=3D"https://twistedmatrix.com/documen=
ts/current/api/twisted.internet.endpoints.SSL4ServerEndpoint.html">SSL4S=
erverEndpoint</a> directly. Oddly SSL6ServerEndpoint doesn't exist, thou=
gh, and I don't see a generic server wrapper like <a href=3D"https://twi=
stedmatrix.com/documents/current/api/twisted.internet.endpoints.html#wra=
pClientTLS">wrapClientTLS</a> for the server site. I'm afraid I may have=
 led you down the wrong path --- I didn't realize this was missing.<br><=
/div><div><br></div><div>---Tom<br></div><div><br></div><div>On Sun, Mar=
 31, 2019, at 8:34 AM, Axel Rau wrote:<br></div><blockquote type=3D"cite=
" id=3D"fastmail-quoted"><div>Hi Tom,<br></div><div><br></div><div>thank=
s for the explanation. &nbsp;After adding some brackets, your example co=
de works like a charm.<br></div><div><blockquote class=3D"fastmail-quote=
d-" type=3D"cite"><div class=3D"fastmail-quoted-"><span style=3D"font-fa=
mily:Menlo-Regular" class=3D"font"><span style=3D"font-size:12px" class=3D=
"size"></span></span><br></div><div class=3D"fastmail-quoted-"><div><spa=
n style=3D"font-family:Menlo-Regular" class=3D"font"><span style=3D"font=
-size:12px" class=3D"size">[1]:<span class=3D"fastmail-quoted-Apple-conv=
erted-space">&nbsp;</span></span></span><a class=3D"fastmail-quoted-" st=
yle=3D"font-family:Menlo-Regular;font-size:12px;font-style:normal;font-v=
ariant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:s=
tart;text-indent:0px;text-transform:none;white-space:normal;word-spacing=
:0px;-moz-text-size-adjust:auto;-webkit-text-stroke-width:0px;" href=3D"=
https://twistedmatrix.com/documents/current/api/twisted.application.serv=
ice.MultiService.html">https://twistedmatrix.com/documents/current/api/t=
wisted.application.service.MultiService.html</a><br></div><div><span sty=
le=3D"font-family:Menlo-Regular" class=3D"font"><span style=3D"font-size=
:12px" class=3D"size">[2]:<span class=3D"fastmail-quoted-Apple-converted=
-space">&nbsp;</span></span></span><a class=3D"fastmail-quoted-" style=3D=
"font-family:Menlo-Regular;font-size:12px;font-style:normal;font-variant=
-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;t=
ext-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;-=
moz-text-size-adjust:auto;-webkit-text-stroke-width:0px;" href=3D"https:=
//twistedmatrix.com/documents/current/api/twisted.application.internet.S=
treamServerEndpointService.html">https://twistedmatrix.com/documents/cur=
rent/api/twisted.application.internet.StreamServerEndpointService.html</=
a><br></div><div><span style=3D"font-family:Menlo-Regular" class=3D"font=
"><span style=3D"font-size:12px" class=3D"size">[3]:<span class=3D"fastm=
ail-quoted-Apple-converted-space">&nbsp;</span></span></span><a class=3D=
"fastmail-quoted-" style=3D"font-family:Menlo-Regular;font-size:12px;fon=
t-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacin=
g:normal;text-align:start;text-indent:0px;text-transform:none;white-spac=
e:normal;word-spacing:0px;-moz-text-size-adjust:auto;-webkit-text-stroke=
-width:0px;" href=3D"https://twistedmatrix.com/documents/current/api/twi=
sted.internet.endpoints.html#serverFromString">https://twistedmatrix.com=
/documents/current/api/twisted.internet.endpoints.html#serverFromString<=
/a><br></div></div></blockquote></div><div class=3D"fastmail-quoted-"><b=
r></div><div class=3D"fastmail-quoted-">Using your pointers, I tried the=
 next step: TLS.<br></div><div class=3D"fastmail-quoted-"><br></div><div=
 class=3D"fastmail-quoted-">This variant of the makeService method:<br><=
/div><div class=3D"fastmail-quoted-"><br></div><div class=3D"fastmail-qu=
oted-"><div class=3D"fastmail-quoted-"><span style=3D"white-space:pre;" =
class=3D"fastmail-quoted-Apple-tab-span"></span>ipv4_endpoint =3D endpoi=
nts.serverFromString(<br></div><div class=3D"fastmail-quoted-"><span sty=
le=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></span>=
reactor, 'ssl:{}:privateKey=3D{}:certKey=3D{}:interface=3D{}'.format(<br=
></div><div class=3D"fastmail-quoted-"><span style=3D"white-space:pre;" =
class=3D"fastmail-quoted-Apple-tab-span"></span>options['port'],<br></di=
v><div class=3D"fastmail-quoted-"><span style=3D"white-space:pre;" class=
=3D"fastmail-quoted-Apple-tab-span"></span>endpoints.quoteStringArgument=
(options['cert_path']),<br></div><div class=3D"fastmail-quoted-"><span s=
tyle=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></spa=
n>endpoints.quoteStringArgument(options['key_path']),<br></div><div clas=
s=3D"fastmail-quoted-"><span style=3D"white-space:pre;" class=3D"fastmai=
l-quoted-Apple-tab-span"></span>options['ipv4_address']))<br></div><div =
class=3D"fastmail-quoted-"><span style=3D"white-space:pre;" class=3D"fas=
tmail-quoted-Apple-tab-span"></span><br></div><div class=3D"fastmail-quo=
ted-"><span style=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-ta=
b-span"></span>ipv6_endpoint =3D endpoints.serverFromString(<br></div><d=
iv class=3D"fastmail-quoted-"><span style=3D"white-space:pre;" class=3D"=
fastmail-quoted-Apple-tab-span"></span>reactor, 'ssl:{}:privateKey=3D{}:=
certKey=3D{}:interface=3D{}'.format(<br></div><div class=3D"fastmail-quo=
ted-"><span style=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-ta=
b-span"></span>options['port'],<br></div><div class=3D"fastmail-quoted-"=
><span style=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-spa=
n"></span>endpoints.quoteStringArgument(options['cert_path']),<br></div>=
<div class=3D"fastmail-quoted-"><span style=3D"white-space:pre;" class=3D=
"fastmail-quoted-Apple-tab-span"></span>endpoints.quoteStringArgument(op=
tions['key_path']),<br></div><div class=3D"fastmail-quoted-"><span style=
=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></span>op=
tions['ipv6_address']))<br></div><div class=3D"fastmail-quoted-"><span s=
tyle=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></spa=
n><br></div><div class=3D"fastmail-quoted-"><span style=3D"white-space:p=
re;" class=3D"fastmail-quoted-Apple-tab-span"></span>ipv4 =3D internet.S=
treamServerEndpointService(ipv4_endpoint, meteo_factory)<br></div><div c=
lass=3D"fastmail-quoted-"><span style=3D"white-space:pre;" class=3D"fast=
mail-quoted-Apple-tab-span"></span>ipv6 =3D internet.StreamServerEndpoin=
tService(ipv6_endpoint, meteo_factory)<br></div><div class=3D"fastmail-q=
uoted-"><span style=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-=
tab-span"></span><br></div><div class=3D"fastmail-quoted-"><span style=3D=
"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></span>root =
=3D MultiService()<br></div><div class=3D"fastmail-quoted-"><span style=3D=
"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></span>ipv4.=
setServiceParent(root)<br></div><div class=3D"fastmail-quoted-"><span st=
yle=3D"white-space:pre;" class=3D"fastmail-quoted-Apple-tab-span"></span=
>ipv6.setServiceParent(root)<br></div></div><div class=3D"fastmail-quote=
d-"><br></div><div class=3D"fastmail-quoted-">does not work. It fails wi=
th:<br></div><div class=3D"fastmail-quoted-"><span style=3D"white-space:=
pre;" class=3D"fastmail-quoted-Apple-tab-span"></span><span style=3D"bac=
kground-color:rgb(255, 255, 255)" class=3D"highlight"><span style=3D"fon=
t-family:Monaco" class=3D"font"><span style=3D"font-size:11px" class=3D"=
size">_parseSSL() got multiple values for argument&nbsp;=E2=80=9Ainterfa=
ce'</span></span></span><br></div><div class=3D"fastmail-quoted-"><span =
style=3D"background-color:rgb(255, 255, 255)" class=3D"highlight"><span =
style=3D"font-family:Monaco" class=3D"font"><span style=3D"font-size:11p=
x" class=3D"size">same with private</span></span></span>&nbsp;privateKey=
 and certKey.<br></div><div class=3D"fastmail-quoted-"><br></div><div cl=
ass=3D"fastmail-quoted-">What did I wrong this time?<br></div><div class=
=3D"fastmail-quoted-"><span class=3D"fastmail-quoted-" style=3D""></span=
><br></div><div class=3D"fastmail-quoted-"><span class=3D"fastmail-quote=
d-" style=3D"">Thanks, Axel</span><br></div><div class=3D"fastmail-quote=
d-"><span class=3D"fastmail-quoted-" style=3D"">---</span><br></div><div=
 class=3D"fastmail-quoted-"><div class=3D"fastmail-quoted-" style=3D"col=
or:rgb(0, 0, 0);letter-spacing:normal;text-align:start;text-indent:0px;t=
ext-transform:none;white-space:normal;word-spacing:0px;-webkit-text-stro=
ke-width:0px;overflow-wrap:break-word;"><div class=3D"fastmail-quoted-" =
style=3D"color:rgb(0, 0, 0);font-family:Helvetica;font-style:normal;font=
-variant-ligatures: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;text-indent:0px;text-transform:none;white-space:normal;wor=
d-spacing:0px;-webkit-text-stroke-width:0px;overflow-wrap:break-word;"><=
div class=3D"fastmail-quoted-">PGP-Key:29E99DD6 &nbsp;=E2=98=80 &nbsp;co=
mputing @ chaos claudius<br></div></div></div></div><div><br></div><div>=
_______________________________________________<br></div><div>Twisted-we=
b mailing list<br></div><div>[email protected]<br></div><div=
>https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web<br></div=
><div><br></div></blockquote><div><br></div></body></html>
--96e8c555e44343e1bc3f4f8602684128--

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

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13
ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBzOi8vdHdp
c3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtd2ViCg==

--===============7189687213140384824==--