summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-profile/node_modules/socks/examples/associate.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-profile/node_modules/socks/examples/associate.js')
-rw-r--r--deps/npm/node_modules/npm-profile/node_modules/socks/examples/associate.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-profile/node_modules/socks/examples/associate.js b/deps/npm/node_modules/npm-profile/node_modules/socks/examples/associate.js
new file mode 100644
index 0000000000..82d6afa97b
--- /dev/null
+++ b/deps/npm/node_modules/npm-profile/node_modules/socks/examples/associate.js
@@ -0,0 +1,33 @@
+var Socks = require('../index.js');
+var dgram = require('dgram');
+
+var options = {
+ proxy: {
+ ipaddress: "202.101.228.108",
+ port: 1080,
+ type: 5,
+ command: 'associate'
+ },
+
+ target: {
+ host: "0.0.0.0",
+ port: 0
+ }
+};
+
+Socks.createConnection(options, function(err, socket, info) {
+ if (err)
+ console.log(err);
+ else {
+ console.log("Connected");
+
+ // Associate request completed.
+ // Now we can send properly formed UDP packet frames to this endpoint for forwarding:
+ console.log(info);
+ // { port: 4381, host: '202.101.228.108' }
+
+ var udp = new dgram.Socket('udp4');
+ var packet = SocksClient.createUDPFrame({ host: "1.2.3.4", port: 5454}, new Buffer("Hello"));
+ udp.send(packet, 0, packet.length, info.port, info.host);
+ }
+}); \ No newline at end of file