Mercurial > prosody-hg
comparison plugins/mod_admin_telnet.lua @ 10644:6c4ab1b87588
mod_admin_telnet: Avoid indexing missing socket (thanks tmolitor)
if `sock` was nil it would still proceed with SNI and ALPN checks
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 05 Feb 2020 23:29:39 +0100 |
| parents | 09d98cd38fe2 |
| children | 197ba9539390 |
comparison
equal
deleted
inserted
replaced
| 10643:417eadd0f567 | 10644:6c4ab1b87588 |
|---|---|
| 578 if session.secure then | 578 if session.secure then |
| 579 local sock = session.conn and session.conn.socket and session.conn:socket(); | 579 local sock = session.conn and session.conn.socket and session.conn:socket(); |
| 580 if sock and sock.info then | 580 if sock and sock.info then |
| 581 local info = sock:info(); | 581 local info = sock:info(); |
| 582 line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher); | 582 line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher); |
| 583 if sock.getsniname then | |
| 584 local name = sock:getsniname(); | |
| 585 if name then | |
| 586 line[#line+1] = ("(SNI:%q)"):format(name); | |
| 587 end | |
| 588 end | |
| 589 if sock.getalpn then | |
| 590 local proto = sock:getalpn(); | |
| 591 if proto then | |
| 592 line[#line+1] = ("(ALPN:%q)"):format(proto); | |
| 593 end | |
| 594 end | |
| 583 else | 595 else |
| 584 line[#line+1] = "(cipher info unavailable)"; | 596 line[#line+1] = "(cipher info unavailable)"; |
| 585 end | |
| 586 if sock.getsniname then | |
| 587 local name = sock:getsniname(); | |
| 588 if name then | |
| 589 line[#line+1] = ("(SNI:%q)"):format(name); | |
| 590 end | |
| 591 end | |
| 592 if sock.getalpn then | |
| 593 local proto = sock:getalpn(); | |
| 594 if proto then | |
| 595 line[#line+1] = ("(ALPN:%q)"):format(proto); | |
| 596 end | |
| 597 end | 597 end |
| 598 else | 598 else |
| 599 line[#line+1] = "(insecure)"; | 599 line[#line+1] = "(insecure)"; |
| 600 end | 600 end |
| 601 return table.concat(line, " "); | 601 return table.concat(line, " "); |
