Skip to content

Commit c923eab

Browse files
committed
node/server: m lint
1 parent c990a72 commit c923eab

1 file changed

Lines changed: 12 additions & 23 deletions

File tree

src/server-node.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -682,20 +682,7 @@ function trapSecureServerEvents(id, s) {
682682
}
683683

684684
/**
685-
* @param {TLSSocket|Socket} sock
686-
*/
687-
function addrstr(sock) {
688-
if (!sock) return "";
689-
if (sock.localAddress == null || sock.remoteAddress == null) return "";
690-
return (
691-
`[${sock.localAddress}]:${sock.localPort}` +
692-
"->" +
693-
`[${sock.remoteAddress}]:${sock.remotePort}`
694-
);
695-
}
696-
697-
/**
698-
* @param {tls.Server} s
685+
* @param {tls.Server?} s
699686
* @returns {void}
700687
*/
701688
function rotateTkt(s) {
@@ -738,14 +725,14 @@ function close(sock) {
738725
}
739726

740727
/**
741-
* @param {Http2ServerResponse} res
728+
* @param {Http2ServerResponse?} res
742729
*/
743730
function resClose(res) {
744731
if (res && !res.destroy) res.destroy();
745732
}
746733

747734
/**
748-
* @param {Http2ServerResponse} res
735+
* @param {Http2ServerResponse?} res
749736
* @returns {Boolean}
750737
*/
751738
function resOkay(res) {
@@ -754,20 +741,21 @@ function resOkay(res) {
754741
}
755742

756743
/**
757-
* @param {Socket} sock
744+
* @param {Socket?} sock
758745
* @returns {Boolean}
759746
*/
760747
function tcpOkay(sock) {
761-
return sock.writable;
748+
return sock && sock.writable;
762749
}
763750

764751
/**
765752
* Creates a duplex pipe between `a` and `b` sockets.
766-
* @param {Socket} a
767-
* @param {Socket} b
753+
* @param {Socket?} a
754+
* @param {Socket?} b
768755
* @return {Boolean} - true if pipe created, false if error
769756
*/
770757
function proxySockets(a, b) {
758+
if (!a || !b) return false;
771759
if (a.destroyed || b.destroyed) return false;
772760
// handle errors? stackoverflow.com/a/61091744
773761
a.pipe(b);
@@ -914,12 +902,13 @@ function getDnRE(socket) {
914902

915903
/**
916904
* Gets flag and hostname from the wildcard domain name.
917-
* @param {String} sni - Wildcard SNI
905+
* @param {String?} sni - Wildcard SNI
918906
* @return {<[String, String]>} [flag, hostname] - may be empty strings
919907
*/
920908
function getMetadata(sni) {
909+
const fakesni = envutil.allowDomainFronting();
910+
921911
if (util.emptyString(sni)) {
922-
const fakesni = envutil.allowDomainFronting();
923912
return ["", fakesni ? "nosni.tld" : ""];
924913
}
925914
// 1-flag.max.rethinkdns.com => ["1-flag", "max", "rethinkdns", "com"]
@@ -978,7 +967,7 @@ function serveTLS(socket) {
978967
log.d(`(${proto}), reused? ${reused}; ticket: ${tkt}; sess: ${sess}`);
979968
}
980969

981-
const [flag, host] = isOurWcDn ? getMetadata(sni) : ["", sni];
970+
const [flag, host] = getMetadata(sni);
982971
const sb = new ScratchBuffer();
983972

984973
log.d("----> dot request", flag, host);

0 commit comments

Comments
 (0)