diff --git a/app/lib/dto/PeerDTO.ts b/app/lib/dto/PeerDTO.ts
index d0e661bb80811df8340da93342ad1c2788de3256..2bb2e91cd462bec73de7a9301a442f6515b77e5c 100644
--- a/app/lib/dto/PeerDTO.ts
+++ b/app/lib/dto/PeerDTO.ts
@@ -98,7 +98,18 @@ export class PeerDTO implements Cloneable {
     let api:{ uuid:string, host:string, port:number, path:string }|null = null
     const endpointRegexp = (tor) ? CommonConstants.WS2PTOR_REGEXP:CommonConstants.WS2P_REGEXP
     for (const ep of this.endpoints) {
-      const matches:any = !api && ep.match(endpointRegexp)
+      if (tor) {
+        const matches:any = ep.match(CommonConstants.WS2PTOR_REGEXP)
+        if (matches) {
+          return {
+            uuid: matches[1],
+            host: matches[2] || '',
+            port: parseInt(matches[3]) || 0,
+            path: matches[4]
+          }
+        }
+      }
+      const matches:any = !api && ep.match(CommonConstants.WS2P_REGEXP)
       if (matches) {
         api = {
           uuid: matches[1],
diff --git a/app/modules/ws2p/index.ts b/app/modules/ws2p/index.ts
index 6a3dd8fbc7d61b4303881b6a38060128ba4dcf94..a225e63ec314dc43e0dd77f308ec4cb7a5d2a58b 100644
--- a/app/modules/ws2p/index.ts
+++ b/app/modules/ws2p/index.ts
@@ -141,7 +141,7 @@ export const WS2PDependency = {
             const peers = await server.dal.getWS2Peers()
             for (const p of peers) {
               for (const ep of p.endpoints) {
-                if (ep.match(/^WS2P /)) {
+                if (ep.match(/^WS2P/)) {
                   console.log(p.pubkey, ep)
                 }
               }
diff --git a/app/modules/ws2p/lib/WS2PCluster.ts b/app/modules/ws2p/lib/WS2PCluster.ts
index d1aa4ece5337c4acf34d4386d910d1a5adfe843c..93e8119d8dbbcc6e3f5666ff3069d8f97c115f5f 100644
--- a/app/modules/ws2p/lib/WS2PCluster.ts
+++ b/app/modules/ws2p/lib/WS2PCluster.ts
@@ -369,7 +369,7 @@ export class WS2PCluster {
     let i = 0
     while (i < peers.length && this.clientsCount() < this.maxLevel1Size) {
       const p = peers[i]
-      const api = p.getWS2P(imCanReachTorEndpoint !== undefined)
+      const api = p.getWS2P(imCanReachTorEndpoint)
       if (api) {
         try {
           await this.connectToRemoteWS(api.host, api.port, api.path, this.messageHandler, p.pubkey, api.uuid)