A
A
ArtX2013-12-13 12:55:37
JavaScript
ArtX, 2013-12-13 12:55:37

How to adapt a module from Node.js to run in a browser in BitTorrent Sync?

Purpose:
Control running BitTorrent Sync from a browser. To do this, you need to adapt the library written for Node.js.

Task:
1. Take the ready-made node-bittorrent-sync library: https://github.com/yannickcr/node-bittorrent-sync/...
2. Adapt its execution in the IE browser. Can be done using jQuery.

Documentation:
BitTorrent Sync API: www.bittorrent.com/intl/ru/sync/developers/api
Why do we need BitTorrent Sync: habrahabr.ru/post/201072

Who can help with this task?

Instructions that may be helpful
To run Bittorent Sync with the API enabled, you need to:
1. Install Bittorent Sync itself
2. In the folder next to the exe file, create cmd: BTSync.exe /config "C:\Program Files (x86)\BitTorrent Sync\config.txt"
3. And next to create config.txt:

{
    // path to folder where Sync will store its internal data,
    // folder must exist on disk
    //"storage_path" : "C:\Program Files (x86)\BitTorrent Sync",

    // run Sync in GUI-less mode
    "use_gui" : false,

    "webui" : {
        // IP address and port to access HTTP API
        "listen" : "127.0.0.1:8888",
        // login and password for HTTP basic authentication
        // authentication is optional, but it's recommended to use some
        // secret values unique for each Sync installation
        "login" : "api",
        "password" : "secret",
        // Это мой ключ, который я получил от Bittorent
        "api_key" : "63OPLBB3ZFSLX4LYQYY7ITXGJGS4ICKIRDYVN6ZKEP7XNQGRK7MM7VC3Z2BDIJBWP7UFXEHOJEPWTAUQQTPH7JZGPVG5WAQYPO75EDJ6USHCEQ2A4GWHGKTOULJMZEDBIYAAF7Y"
    }
}


To run node-bittorrent-sync, you need to:
1. Install node.js
2. Install node-bittorrent-sync with the command: npm install bittorrent-sync
3. Run in cmd: node lib\bittorrent-sync.js
4. Install all modules , which it requires
5. We try to run the test, but run into a problem with Jasmine: node test\getOs.js

Autotests are written in Jasmine. We need to figure out exactly how it works.
If the getOs.js code is simplified to be without Jasmine, then everything will start, for example:
nock('http://localhost:8888')
      .get('/api?method=get_os');
btsync.getOs(function(err, result) {
    console.log(result);
    });
nock.cleanAll();


PS:
Any libraries that are connected via require () must be replaced with standard JavaScript functions.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pomeo, 2013-12-13
@pomeo

Of course, you did a great job and wrote a lot of things, but you forgot the most important thing, JAVASCRIPT IN THE BROWSER DOES NOT WORK WITH FILES .
And you need to do the following, throw out all this what you wrote above. Take that library for node.js and write rest api or rpc api or whatever. Screw a simple interface on this and knock from this interface in this api, and there the node will already do what you need.

A
Artur Zayats, 2013-12-14
@zag2art

Have you looked at browserify?

S
Stanislav Lomadurov, 2014-01-11
@lomadurov

Here's a quick sketch: jQuery Bittorent Sync .
If Bittorrent Sync is configured , then you can go here , here is a small demonstration of work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question