agrinman / tunnelto

Expose your local web server to the internet with a public URL.
https://tunnelto.dev
MIT License
2.11k stars 114 forks source link

self-host server register trace root error: TelemetryLayerNotRegistered #55

Open qingpengchen2011 opened 3 years ago

toshalpatel commented 3 years ago

Faced the same problem. Any leads? Thanks!

syjung6967 commented 2 years ago

+1. This is my test code.

Server

$ ALLOWED_HOSTS="localhost" CTRL_PORT=50000 PORT=40000 CTRL_TLS_OFF=1 tunnelto_server --verbose
Jan 26 17:57:45.594  INFO tunnelto_server: starting server!
Jan 26 17:57:45.594  INFO tunnelto_server: started tunnelto server on 0.0.0.0:50000
Jan 26 17:57:45.594  INFO tunnelto_server: start network service on [::]:6000
Jan 26 17:57:45.594  INFO tunnelto_server: listening on: [::]:40000
Jan 26 17:57:45.595  INFO Server::run{addr=[::]:6000}: warp::server: listening on http://[::]:6000
Jan 26 17:57:45.595  INFO Server::run{addr=0.0.0.0:50000}: warp::server: listening on http://0.0.0.0:50000

Client

$ CTRL_HOST="localhost" CTRL_PORT=50000 CTRL_TLS_OFF=1 tunnelto -p 4000 --verbose

Then, error occurs for both server and client sides.

Server

register trace root error: TelemetryLayerNotRegistered

Client

 INFO  tunnelto::config > Control Server URL: ws://localhost:50000/wormhole
 DEBUG tunnelto::update > Using latest version.
🌎 Opening remote tunnel...
>> Please use an access key with the `--key` option
>> You can get your access key here: https://dashboard.tunnelto.dev

Error: Server denied the connection.

Do I need some key even for self-hosting server?

syjung6967 commented 2 years ago

To detour the "key" problem, the below code can be modified.

diff --git a/tunnelto_server/src/auth/client_auth.rs b/tunnelto_server/src/auth/client_auth.rs
index 8769894..0595435 100644
--- a/tunnelto_server/src/auth/client_auth.rs
+++ b/tunnelto_server/src/auth/client_auth.rs
@@ -104,7 +104,7 @@ async fn auth_client(

     // next authenticate the sub-domain
     let sub_domain = match crate::AUTH_DB_SERVICE
-        .auth_sub_domain(&auth_key.0, &requested_sub_domain)
+        .auth_sub_domain(&(), &requested_sub_domain)
         .await
     {
         Ok(AuthResult::Available) | Ok(AuthResult::ReservedByYou) => requested_sub_domain,
diff --git a/tunnelto_server/src/main.rs b/tunnelto_server/src/main.rs
index 533d5f3..d9402ee 100644
--- a/tunnelto_server/src/main.rs
+++ b/tunnelto_server/src/main.rs
@@ -42,12 +42,12 @@ use tracing::{error, info, Instrument};
 lazy_static! {
     pub static ref CONNECTIONS: Connections = Connections::new();
     pub static ref ACTIVE_STREAMS: ActiveStreams = Arc::new(DashMap::new());
-    pub static ref AUTH_DB_SERVICE: AuthDbService =
-        AuthDbService::new().expect("failed to init auth-service");
+    //pub static ref AUTH_DB_SERVICE: AuthDbService =
+    //    AuthDbService::new().expect("failed to init auth-service");
     pub static ref CONFIG: Config = Config::from_env();

     // To disable all authentication:
-    // pub static ref AUTH_DB_SERVICE: crate::auth::NoAuth = crate::auth::NoAuth;
+    pub static ref AUTH_DB_SERVICE: crate::auth::NoAuth = crate::auth::NoAuth;
 }

 #[tokio::main]

But the tunneling does not work well for neither public tunnel URL nor <subdomain>.localhost.

Server

Jan 26 18:40:48.614  WARN begin span{id=0b6bde74-ed76-4fe7-a1a5-5bbb3e8af2d6 source=handle_websocket req=1e009d1415a2473c95ee282f6d9c49b6}:handle_new_connection{client_ip=127.0.0.1}:try_client_handshake:auth_client_handshake:auth_client:instance_for_host{host="mytest"}: tunnelto_server::network: warning! gossip mode disabled!
Jan 26 18:40:48.615  INFO begin span{id=0b6bde74-ed76-4fe7-a1a5-5bbb3e8af2d6 source=handle_websocket req=1e009d1415a2473c95ee282f6d9c49b6}:handle_new_connection{client_ip=127.0.0.1}:try_client_handshake:auth_client_handshake:auth_client: tunnelto_server::auth::client_auth: will auth sub domain requested_sub_domain=mytest
Jan 26 18:40:48.615  INFO begin span{id=0b6bde74-ed76-4fe7-a1a5-5bbb3e8af2d6 source=handle_websocket req=1e009d1415a2473c95ee282f6d9c49b6}:handle_new_connection{client_ip=127.0.0.1}:try_client_handshake:auth_client_handshake:auth_client: tunnelto_server::auth::client_auth: did auth sub_domain subdomain=mytest
Jan 26 18:40:48.616  INFO begin span{id=0b6bde74-ed76-4fe7-a1a5-5bbb3e8af2d6 source=handle_websocket req=1e009d1415a2473c95ee282f6d9c49b6}:handle_new_connection{client_ip=127.0.0.1}: tunnelto_server::control_server: open tunnel client_ip=127.0.0.1 subdomain=mytest
register trace root error: TelemetryLayerNotRegistered
register trace root error: TelemetryLayerNotRegistered
register trace root error: TelemetryLayerNotRegistered

Client

$ CTRL_HOST="localhost" CTRL_PORT=50000 CTRL_TLS_OFF=1 target/debug/tunnelto -p 8080 --subdomain mytest --key DUMMY_STR --dashboard-port 55555 --verbose
 INFO  tunnelto::config > Control Server URL: ws://localhost:50000/wormhole
 DEBUG tunnelto::update > Using latest version.
🌎 Opening remote tunnel...
 INFO  tunnelto         > connecting to wormhole...
🌏 Success! Remote tunnel is now open.

+-------------------------+------------------------------------+
| Public tunnel URL       |     http://mytest.tunnelto.dev     |
+-------------------------+------------------------------------+
| Local inspect dashboard |     http://localhost:55555         |
+-------------------------+------------------------------------+
| Forwarding traffic to   |     http://localhost:8080          |
+-------------------------+------------------------------------+
 INFO  tunnelto         > got ping. reconnect_token=false
 DEBUG tunnelto         > Processed packet: "PING"
 INFO  tunnelto         > got ping. reconnect_token=false
 DEBUG tunnelto         > Processed packet: "PING"

Tester

$ curl http://mytest.tunnelto.dev
curl: (52) Empty reply from server

$ curl https://mytest.tunnelto.dev
Error: Tunnel Not Found

$ curl http://mytest.<my_subdomain>:8080
curl: (6) Could not resolve host

$ curl http://localhost:8080
(Some results from my static service)

$ curl http://mytest.localhost:8080
(Same as above)

# In fact, any subdomain is not effective
$ curl http://XXX.YYY.ZZZ.localhost:8080
(Same as above)

# From local tunnelto TCP server
$ curl -H 'mytest.localhost' http://localhost:6000
Invalid query string

# At last, get info from Inspector
$ curl http://localhost:55555
...
No requests yet
...
almottier commented 2 years ago

I have the same issue. Any update ?