Novage / wt-tracker

High-performance WebTorrent tracker
Apache License 2.0
248 stars 86 forks source link

Detail guide how to config file config.json #10

Open quanghuy1288 opened 5 years ago

quanghuy1288 commented 5 years ago

Detail guide how to config file config.json. I can not config it

mrlika commented 5 years ago

We will do it but currently working on other P2P functionality.

Everything is very simple. Check the example: https://github.com/Novage/wt-tracker/blob/master/sample/config.json

Most of the stuff is self-explanatory.

ckcr4lyf commented 5 years ago

Mind if I ask what other features potentially?

mrlika commented 5 years ago

Working on:

ckcr4lyf commented 5 years ago

C++ implementation sounds great, best of luck

I have a suggestion / request for P2P media loader, functionality for having a stream completely powered by P2P, somewhat like Acestream?

One "server" has a source, which it to "clients" only via P2P, i.e. a WebRTC based connection to the server, for both the manifest as well as fragments.

A partial way to do it is change the HTTP fragment probability to 0, but it still relies on the HTTP for the manifest (.m3u8)

I am trying to understand the library to see if I can do it myself, but seems a bit tricky.

mrlika commented 5 years ago

As far as I know, Ace Stream is not completely powered by P2P. In Ace Stream you have to stream video to their server. Initial video data is loaded from their server. You can see it when streaming stops - they loop the same few seconds of video each time you try to play the stream.

P2P Media Loader has no vendor lock. You can stream through any server\CDN.

I don't know production-ready completely serverless live P2P video streaming solutions. Bittorrent is working on it many years already.

ckcr4lyf commented 5 years ago

Yeah, that is true. Ace stream "contentIDs" need to be validated on their server with their black-box code.

Thanks for the feedback, I shall continue to explore this field. Cheers

quanghuy1288 commented 5 years ago

I have clone your project to my centos 7 server (you can check via my httpd http://103.216.120.135:85/p2p/wt-tracker/). Then i install nodejs 12 then run 2 commands:

npm install
npm run build

Then i try to start wt-tracker: ./bin/wt-tracker _config.json (check detail from _config.json; and check pem file which i have used in _config.json in this http://103.216.120.135:85/p2p/keyssl/ ) but it show

listening 0.0.0.0:8000
failed to start the web server: App construction failed

If i run wt-tracker without param: ./bin/wt-tracker it not show error but my demo p2p-media-loader cannot connect this wt-tracker. p2p-media-loader-core.min.js:1 WebSocket connection to 'wss://103.216.120.135:8000/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

(you can check my demo p2p-media-loader from this link http://103.216.120.135:85/p2p/custom.html )

ckcr4lyf commented 5 years ago

Try forcing a ws:// connection instead of wss:// (in your HTML page) and see if that works

quanghuy1288 commented 5 years ago

Try forcing a ws:// connection instead of wss:// (in your HTML page) and see if that works

Thanks!. It work when i run wt-tracker without config.json

But with config.json wt-tracker still failed to start

ckcr4lyf commented 5 years ago

Try removing the SSL configuration in your _config.json file, specifically this part:

, {
      "server": {
        "port": 8433,
        "host": "0.0.0.0",
        "key_file_name": "/home/vega/p2p/keyssl/server.key.pem",
        "cert_file_name": "/home/vega/p2p/keyssl/server.cert.pem",
        "passphrase": "[redacted]",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }

I'll try and spin up a VPS with wt-tracker and see if I can get it to work with a config.json

quanghuy1288 commented 5 years ago

Try removing the SSL configuration in your _config.json file, specifically this part:

, {
      "server": {
        "port": 8433,
        "host": "0.0.0.0",
        "key_file_name": "/home/vega/p2p/keyssl/server.key.pem",
        "cert_file_name": "/home/vega/p2p/keyssl/server.cert.pem",
        "passphrase": "[redacted]",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }

I'll try and spin up a VPS with wt-tracker and see if I can get it to work with a config.json

Ok thanks, it worked when i do as your guide

mrlika commented 5 years ago

I have no good error messages from the underlying uWebSockets.js library about problems with SSL keys and other stuff. That is why just report "failed to start the web server: App construction failed" I will try to improve the messages.

quanghuy1288 commented 5 years ago

I have tried to config ssl. then using it in my demo http://103.216.120.135:85/p2p/custom.html But error show from console : WebSocket connection to 'wss://103.216.120.135:8433/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

Could you guide me to fix this problem?

ckcr4lyf commented 5 years ago

That means your SSL certificate is not validated by global CA authorities. Did you just create a pair with OpenSSL?

Browsers do not allow secure connections to certificates that have not been verified by a root CA.

If you need a free SSL certificate for your domain you can check out Lets Encrypt E..g for github: image

quanghuy1288 commented 5 years ago

Could you guide me create ssl cert with Lets Encrypt. I have been configured nginx with certbot and Lets Encrypt. It work well.

But with wt-tracker i do not know how to config. Could you help me

ckcr4lyf commented 5 years ago

By default, the certificates are placed in /etc/letsencrypt/live/YOUR-DOMAIN/

You can try pointing here as the path in your config.json

quanghuy1288 commented 5 years ago

I do as your guide and new error issue: p2p-media-loader-core.min.js:1 WebSocket connection to 'wss://103.216.120.135:8433/' failed: Error in connection establishment: net::ERR_CERT_COMMON_NAME_INVALID

ckcr4lyf commented 5 years ago

You certificate is signed to your domain. So, when you connect using a secure connection, you must specify your domain, such as wss://streming.tk:8433/, and not just the IP.

Alexdrr commented 5 years ago

I used a bunch of cloudflare flexible ssl for the domain of the tracker. For the tracker itself, I used a self-signed server certificate. everything works fine. My config.json

{
  "servers": [{
      "server": {
        "port": 8000,
        "host": "0.0.0.0"
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }, {
      "server": {
        "port": 8433,
        "host": "0.0.0.0",
        "key_file_name": "/home/user/wt/misc/key.pem",
        "cert_file_name": "/home/user/wt/misc/cert.pem",
        "passphrase": "1234",
        "dh_params_file_name": "/home/user/wt/misc/dh.dh",
        "ssl_prefer_low_memory_usage": true
      },
      "websockets": {
        "path": "/*",
        "maxPayloadLength": 65536,
        "idleTimeout": 240,
        "compression": 1
      }
    }
  ],

  "tracker": {
    "maxOffers": 20,
    "announceInterval": 120
  },

  "websocketsAccess": {
    "allowOrigins": ["http://domain.life"],

    "denyEmptyOrigin": true
  }
}

To create a self-signed server certificate you need to run the command (linux)

user@server:~$ openssl req -new > cert.csr
user@server:~$ openssl rsa -in privkey.pem -out key.pem
user@server:~$ openssl x509 -in cert.csr -out cert.pem -req -signkey key.pem -days 1001
user@server:~$ cat key.pem>>cert.pem 
user@server:~$ openssl dhparam -out /home/user/wt/misc/dh.dh 2048
quanghuy1288 commented 5 years ago

openssl rsa -in privkey.pem -out key.pem

@Alexdrr how to generate privkey.pem

mrlika commented 5 years ago

My config for wss://tracker.novage.com.ua

{
  "servers": [{
    "server": {
      "port": 443,
      "host": "0.0.0.0",
      "key_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/privkey.pem",
      "cert_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/fullchain.pem",
      "ssl_prefer_low_memory_usage": true
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }, {
    "server": {
      "port": 80,
      "host": "0.0.0.0"
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }],

  "tracker": {
    "maxOffers": 10,
    "announceInterval": 120
  }
}

How to use letsencrypt to get free certificates for your domain on your server you should read the guides. Google it. Many articles, many approaches.

ghost commented 4 years ago

My config for wss://tracker.novage.com.ua

{
  "servers": [{
    "server": {
      "port": 443,
      "host": "0.0.0.0",
      "key_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/privkey.pem",
      "cert_file_name": "/etc/letsencrypt/live/tracker.novage.com.ua/fullchain.pem",
      "ssl_prefer_low_memory_usage": true
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }, {
    "server": {
      "port": 80,
      "host": "0.0.0.0"
    },
    "websockets": {
      "path": "/*",
      "maxPayloadLength": 16384,
      "idleTimeout": 240,
      "compression": 1
    }
  }],

  "tracker": {
    "maxOffers": 10,
    "announceInterval": 120
  }
}

How to use letsencrypt to get free certificates for your domain on your server you should read the guides. Google it. Many articles, many approaches.

Where should I put this config.json?

mrlika commented 4 years ago

https://github.com/Novage/wt-tracker#run-instructions

ghost commented 4 years ago

https://github.com/Novage/wt-tracker#run-instructions

When I run ./bin/wt-tracker [config.json] It show error: failed to read configuration file: Error: ENOENT: no such file or directory, open '[config.json]'

mrlika commented 4 years ago

You should run as ./bin/wt-tracker config.json

mrlika commented 4 years ago

[ ] usually means optional parameter when a CLI tool is described

ghost commented 4 years ago

You should run as ./bin/wt-tracker config.json

Screen Shot 2020-03-10 at 1 13 02 PM

Still not working as the screen shoot

mrlika commented 4 years ago

It says that config.json file is missing in the working/current directory