etunnel 1.6.7 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/etunnel.rb +8 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 513865da570e6eb157f1e1f82a4a286b4f607e7223a6fe8e30c149fec016ca9a
|
|
4
|
+
data.tar.gz: 8491e8ba52b4046bd43fdcea3ae418339c664c612ec4bb4fddf63049feeb874f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eacc008839d2734f1d09a8e0e30949248d96d8a4104abb49294254b3a0bd0ce8b346fee7a04ad90acaac961ee187c7f21aae125bbc5120c742f0fc7e80b1d4e8
|
|
7
|
+
data.tar.gz: 03c907a42d766e7c0c19c7bcee576d4e9ade6a160443dd811999f94ec85ebeafb5e719e7d3e25c22066ee2ccb6e37870e2cee6389f9d2a4021d31671987746a8
|
data/lib/etunnel.rb
CHANGED
|
@@ -276,15 +276,14 @@ def Etunnel.main(argv = ARGV)
|
|
|
276
276
|
nap.call(delay)
|
|
277
277
|
end
|
|
278
278
|
end
|
|
279
|
-
Etunnel.main if $PROGRAM_NAME == __FILE__
|
|
280
279
|
|
|
281
|
-
|
|
280
|
+
# --- CLI loopback login (RFC 8252 style; server /auth/cli/* endpoints) ---
|
|
282
281
|
# creds = Etunnel.login('https://t.etun.uk') # opens the browser
|
|
283
282
|
# # -> { 'api_token' => ..., 'subdomains' => [...], 'plan' => ..., 'expires_at' => 0 }
|
|
284
283
|
# Binds a random 127.0.0.1 port, waits for the one-time code on /callback
|
|
285
284
|
# (10-minute budget), exchanges it. Persist the result and pass api_token
|
|
286
285
|
# as token: on future Etunnel.connect calls.
|
|
287
|
-
|
|
286
|
+
def Etunnel.login(server, open_browser: nil, timeout: 600)
|
|
288
287
|
require 'socket'
|
|
289
288
|
require 'net/http'
|
|
290
289
|
require 'json'
|
|
@@ -320,7 +319,9 @@ Etunnel.main if $PROGRAM_NAME == __FILE__
|
|
|
320
319
|
end
|
|
321
320
|
$stderr.puts "etunnel: authorize in your browser: #{start['auth_url']}" unless opened
|
|
322
321
|
|
|
323
|
-
|
|
322
|
+
th.join(timeout)
|
|
323
|
+
raise 'etunnel: login timed out' if th.alive?
|
|
324
|
+
code = th.value
|
|
324
325
|
server_sock.close
|
|
325
326
|
raise 'etunnel: login: callback without code' if code.empty?
|
|
326
327
|
|
|
@@ -329,3 +330,6 @@ Etunnel.main if $PROGRAM_NAME == __FILE__
|
|
|
329
330
|
raise 'etunnel: login: no api_token in exchange response' if creds['api_token'].to_s.empty?
|
|
330
331
|
creds
|
|
331
332
|
end
|
|
333
|
+
|
|
334
|
+
Etunnel.main if $PROGRAM_NAME == __FILE__
|
|
335
|
+
|