Compare commits

..

No commits in common. "db785fd2672c3b45fd0b3317b303302597a48b24" and "42d558b85eea76723b585523e721e91863e3e2c8" have entirely different histories.

4 changed files with 27 additions and 71 deletions

View File

@ -924,9 +924,7 @@ function rawStartTelebitRemote(keepAlive) {
function onConnect() { function onConnect() {
console.info('[connect] relay established'); console.info('[connect] relay established');
myRemote.removeListener('error', onConnectError); myRemote.removeListener('error', onConnectError);
myRemote.once('error', function (err) { myRemote.once('error', function () {
console.log("[debug] Error after connect.");
console.log(err);
if (!keepAlive.state) { if (!keepAlive.state) {
reject(err); reject(err);
return; return;
@ -939,16 +937,20 @@ function rawStartTelebitRemote(keepAlive) {
function onConnectError(err) { function onConnectError(err) {
myRemote = null; myRemote = null;
if (handleError(err, 'onConnectError')) { // Likely causes:
// * DNS lookup failed (no Internet)
// * Rejected (bad authn)
if ('ENOTFOUND' === err.code) {
// DNS issue, probably network is disconnected
if (!keepAlive.state) { if (!keepAlive.state) {
reject(err); reject(err);
return; return;
} }
console.warn('[Warn] onConnectError: network error, will retry', err);
safeReload(10 * 1000).then(resolve).catch(reject); safeReload(10 * 1000).then(resolve).catch(reject);
return; return;
} }
console.error('[Error] onConnectError: no retry (possibly bad auth):'); console.error('[Error] onConnectError: no retry (possibly bad auth)', err);
console.error(err);
reject(err); reject(err);
return; return;
} }
@ -986,68 +988,32 @@ function rawStartTelebitRemote(keepAlive) {
return startHelper(); return startHelper();
} }
function handleError(err, prefix) {
// Likely causes:
// * DNS lookup failed (no Internet)
// * Rejected (bad authn)
if ('ENOTFOUND' === err.code) {
// DNS issue, probably network is disconnected
err.message = [
'[warn] (' + prefix + '): DNS address not found.'
, ' Either the remote does not exist or local network is down or blocked.'
, ' You might check wifi, eth, paywall, etc.'
].join('\n');
if (keepAlive.error !== err.code) {
console.warn(err.message);
keepAlive.error = err.code;
console.warn("(retrying silently)");
}
return true;
} else if ('ECONNREFUSED' === err.code) {
// Server issue. If it's the development server, it's probably down
err.message = [
'[warn] onConnectError: Connection Refused.'
, ' Either the remote does not exist or local network is blocking it.'
, ' Is the relay service provider\'s website up? Did you make a typo?'
, ' Is there a local firewall or paywall? Might the relay be otherwise blocked?'
].join('\n');
if (keepAlive.error !== err.code) {
console.warn(err.message);
keepAlive.error = err.code;
console.warn("(retrying silently)");
}
return true;
}
}
// get the wss url // get the wss url
function retryWssLoop(err) { function retryWssLoop(err) {
if (!keepAlive.state) { if (!keepAlive.state) {
console.log("[debug] error getting wss url:");
console.log(err);
return PromiseA.reject(err); return PromiseA.reject(err);
} }
myRemote = null; myRemote = null;
if (handleError(err, 'retryWssLoop')) { if (!err) {
// Always retry at this stage. It *is* a connectivity problem. return startHelper();
// Since the internet is disconnected, try again and again and again.
return safeReload(2 * 1000);
} else {
console.error("[error] retryWssLoop (will not retry):");
console.error(err.message);
return PromiseA.reject(err);
} }
if ('ENOTFOUND' === err.code) {
// The internet is disconnected
// try again, and again, and again
return safeReload(2 * 1000);
}
return PromiseA.reject(err);
} }
// It makes since for this to be in here because the server
// could be restarting to force a change of the metadata
return promiseWss(state).then(function (wss) { return promiseWss(state).then(function (wss) {
state.wss = wss; state.wss = wss;
console.log("[debug] got wss url");
keepAlive.error = null;
return startHelper(); return startHelper();
}).catch(retryWssLoop); }).catch(function (err) {
return retryWssLoop(err);
});
}); });
} }

View File

@ -53,22 +53,12 @@
<h2>You've claimed <span class="js-servername">{{servername}}</span></h2> <h2>You've claimed <span class="js-servername">{{servername}}</span></h2>
<p>Here's some ways you can use it:</p> <p>Here's some ways you can use it:</p>
<div class="code-block"> <div class="code-block">
<pre><code>telebit http ~/Public # serve a public folder <pre><code>telebit http 3000 # forward all https traffic to localhost:3000
telebit http 3000 # forward all https traffic to localhost:3000 telebit http /path/to/module # handle incoming https traffic with a node module
telebit http none # remove all https handlers</code></pre> telebit http none # remove all https handlers</code></pre>
</div> </div>
</div> </div>
<p>You can <em>always</em> tunnel <strong>SSH over HTTPS</strong>, <p>You can <em>always</em> use this port for <strong>SSH over HTTPS</strong>, even while you're using it for something else:</p>
even while you're using it for something else:</p>
<div class="code-block"><pre><code>telebit ssh auto</code></pre>
<br>
<pre><code>telebit ssh <span class="js-servername">{{servername}}</span></code></pre>
- or -
<pre><code>ssh -o ProxyCommand='<a href="https://telebit.cloud/sclient">sclient</a> %h' <span class="js-servername">{{servername}}</span></code></pre>
- or -
<pre><code>proxy_cmd='openssl s_client -connect %h:443 -servername %h -quiet'
ssh -o ProxyCommand="$proxy_cmd" <span class="js-servername">{{servername}}</span></code></pre>
</div>
<pre><code>ssh -o ProxyCommand='openssl s_client -connect %h:443 -servername %h -quiet' <span class="js-servername">{{servername}}</span></code></pre> <pre><code>ssh -o ProxyCommand='openssl s_client -connect %h:443 -servername %h -quiet' <span class="js-servername">{{servername}}</span></code></pre>

View File

@ -1,6 +1,6 @@
{ {
"name": "telebit", "name": "telebit",
"version": "0.20.2-wip", "version": "0.20.1-wip",
"description": "Break out of localhost. Connect to any device from anywhere over any tcp port or securely in a browser. A secure tunnel. A poor man's reverse VPN.", "description": "Break out of localhost. Connect to any device from anywhere over any tcp port or securely in a browser. A secure tunnel. A poor man's reverse VPN.",
"main": "lib/remote.js", "main": "lib/remote.js",
"files": [ "files": [

View File

@ -54,8 +54,8 @@
<string>{TELEBIT_PATH}</string> <string>{TELEBIT_PATH}</string>
<key>StandardErrorPath</key> <key>StandardErrorPath</key>
<string>{TELEBIT_LOG_DIR}/telebit.log</string> <string>{TELEBIT_LOG_DIR}/error.log</string>
<key>StandardOutPath</key> <key>StandardOutPath</key>
<string>{TELEBIT_LOG_DIR}/telebit.log</string> <string>{TELEBIT_LOG_DIR}/info.log</string>
</dict> </dict>
</plist> </plist>