Skip to content

Commit

Permalink
Add local dependecy package
Browse files Browse the repository at this point in the history
  • Loading branch information
yillkid committed Oct 11, 2017
1 parent f3a9043 commit ddd32cf
Show file tree
Hide file tree
Showing 540 changed files with 468 additions and 151,100 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ and [ccurl](https://github.com/iotaledger/ccurl.git), and override the iota.api.

```
IOTA proxy server started
Listing on port 14265
POW timeout is set to 15 min
Listening on port 14265
Relaying requests to iota.bitfinex.com:80
```

Expand Down
54 changes: 54 additions & 0 deletions build/config.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"coverage": "false",
"force_dynamic_crt": 0,
"host_arch": "arm64",
"icu_gyp_path": "tools/icu/icu-system.gyp",
"icu_small": "false",
"node_byteorder": "little",
"node_enable_d8": "false",
"node_enable_v8_vtunejit": "false",
"node_install_npm": "false",
"node_module_version": 46,
"node_prefix": "/usr",
"node_release_urlbase": "",
"node_shared": "false",
"node_shared_http_parser": "false",
"node_shared_libuv": "true",
"node_shared_openssl": "true",
"node_shared_zlib": "true",
"node_tag": "",
"node_use_bundled_v8": "true",
"node_use_dtrace": "false",
"node_use_etw": "false",
"node_use_lttng": "false",
"node_use_openssl": "true",
"node_use_perfctr": "false",
"node_use_v8_platform": "true",
"openssl_fips": "",
"openssl_no_asm": 0,
"shlib_suffix": "so.46",
"target_arch": "arm64",
"uv_parent_path": "/deps/uv/",
"uv_use_dtrace": "false",
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 0,
"v8_random_seed": 0,
"v8_use_snapshot": "true",
"want_separate_host_toolset": 0,
"nodedir": "/usr/include/nodejs",
"copy_dev_lib": "true",
"standalone_static_library": 1
}
}
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
/**
* Simple proxy server for IOTA.
* Relays commands to the IOTA Tangle, but intercepts attachToTangle commands and performs PoW locally.
*
* This proxy server useful for when you want to perform transfers with iota.lib.js in Node but do not
*
* This proxy server useful for when you want to perform transfers with iota.lib.js in Node but do not
* have access to a full node that grants you access to the necessary attachToTangle commands.
*/

var iotaProxy = require('./lib/iotaproxy.js');

iotaProxy.start(
{
host: 'http://node0.puyuma.org',
port: 14265,
host: 'http://node0.puyuma.org',
port: 14265,
localPort: 14266,
overrideAttachToTangle: true
overrideAttachToTangle: true,
timeout: 15
}
);

47 changes: 24 additions & 23 deletions lib/iotaproxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* Simple proxy server for IOTA.
* Intercepts attachToTangle commands and performs PoW locally.
*
*
* Author: Tim Samshuijzen
*
* References code copied from:
Expand All @@ -20,6 +20,7 @@ let iotaProxy =
port: 0,
localPort: 0,
overrideAttachToTangle: false,
timeout: 0,
running: false,
server: null,

Expand All @@ -30,25 +31,26 @@ let iotaProxy =
this.port = (opts.port ? opts.port : 80);
this.localPort = (opts.localPort ? opts.localPort : 14265);
this.overrideAttachToTangle = (opts.overrideAttachToTangle ? true : false);
this.timeout = (opts.timeout ? opts.timeout : 15);

if (this.running)
{
this.stop();
}
this.running = true;
let that = this;

if (this.overrideAttachToTangle)
{
ccurlProvider.init();
}

this.server = http.createServer(
function (request, response)
{
let requestbody = '';
request.on(
'data',
'data',
function (data)
{
requestbody += data;
Expand All @@ -59,7 +61,7 @@ let iotaProxy =
}
);
request.on(
'end',
'end',
function ()
{
let requestbodyOb = null;
Expand All @@ -72,7 +74,7 @@ let iotaProxy =
requestbodyOb = null;
}
if (requestbodyOb !== null)
{/*
{
if ((that.overrideAttachToTangle) && (ccurlProvider.isOpen()) && (requestbodyOb.command === 'attachToTangle'))
{
console.log('Processing command ' + requestbodyOb.command);
Expand All @@ -95,11 +97,10 @@ let iotaProxy =
}
);
}
*/
// else
//{
else
{
console.log('Relaying command ' + requestbodyOb.command);
let proxyRequestOptions =
let proxyRequestOptions =
{
hostname: that.host,
port: that.port,
Expand All @@ -108,38 +109,38 @@ let iotaProxy =
};
if (requestbody.length > 0)
{
proxyRequestOptions.headers =
proxyRequestOptions.headers =
{
'Content-Type': request.headers['content-type'],
'Content-Length': requestbody.length
};
}

let proxyRequest = http.request(
proxyRequestOptions,
function (proxyResponse)
{
let proxyResult = '';
proxyResponse.on(
'data',
'data',
function (data)
{
proxyResult += data;
}
);
proxyResponse.on(
'end',
'end',
function()
{
response.writeHead(proxyResponse.statusCode, proxyResponse.statusMessage, {'Content-Type': proxyResponse.headers['content-type']});
response.write(proxyResult);
response.end();
}
);
);
}
);
proxyRequest.on(
'error',
'error',
function (err)
{
response.writeHead(404, 'Not Found', {'Content-Type': 'text/plain'});
Expand All @@ -149,7 +150,7 @@ let iotaProxy =
);
proxyRequest.write(requestbody);
proxyRequest.end();
//}
}
}
else
{
Expand All @@ -161,21 +162,22 @@ let iotaProxy =
);
}
);
this.server.setTimeout(15 * 60 * 1000); // 15 minutes timeout, allow enough time for PoW.
this.server.setTimeout(this.timeout * 60 * 1000); // Default is 15 minutes timeout -> allow enough time for PoW.
this.server.on(
'clientError',
'clientError',
function(err, socket)
{
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n');
}
);
this.server.listen(this.localPort);
console.log('IOTA proxy server started');
console.log('Listing on port ' + this.localPort);
console.log('POW timeout is set to ' + this.timeout + ' min');
console.log('Listening on port ' + this.localPort);
console.log('Relaying requests to ' + this.host + ':' + this.port);

},

stop: function()
{
if (this.running)
Expand All @@ -196,4 +198,3 @@ let iotaProxy =
};

module.exports = iotaProxy;

1 change: 1 addition & 0 deletions node-ffi
Submodule node-ffi added at 8212d0
97 changes: 0 additions & 97 deletions node_modules/bindings/README.md

This file was deleted.

Loading

0 comments on commit ddd32cf

Please sign in to comment.