SOCKSServer.html 20 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>SOCKSServer - Documentation</title>
  6. <script src="scripts/prettify/prettify.js"></script>
  7. <script src="scripts/prettify/lang-css.js"></script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
  13. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  14. </head>
  15. <body>
  16. <input type="checkbox" id="nav-trigger" class="nav-trigger" />
  17. <label for="nav-trigger" class="navicon-button x">
  18. <div class="navicon"></div>
  19. </label>
  20. <label for="nav-trigger" class="overlay"></label>
  21. <nav>
  22. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ControlServer.html">ControlServer</a><ul class='methods'><li data-type='method'><a href="ControlServer.html#.instance_info">instance_info</a></li><li data-type='method'><a href="ControlServer.html#close">close</a></li><li data-type='method'><a href="ControlServer.html#createDNSServer">createDNSServer</a></li><li data-type='method'><a href="ControlServer.html#createHTTPServer">createHTTPServer</a></li><li data-type='method'><a href="ControlServer.html#createSOCKSServer">createSOCKSServer</a></li><li data-type='method'><a href="ControlServer.html#createTorPool">createTorPool</a></li><li data-type='method'><a href="ControlServer.html#listen">listen</a></li><li data-type='method'><a href="ControlServer.html#listenTcp">listenTcp</a></li><li data-type='method'><a href="ControlServer.html#listenWs">listenWs</a></li></ul></li><li><a href="DNSServer.html">DNSServer</a><ul class='methods'><li data-type='method'><a href="DNSServer.html#listen">listen</a></li></ul></li><li><a href="HTTPServer.html">HTTPServer</a><ul class='methods'><li data-type='method'><a href="HTTPServer.html#listen">listen</a></li></ul></li><li><a href="SOCKSServer.html">SOCKSServer</a><ul class='methods'><li data-type='method'><a href="SOCKSServer.html#listen">listen</a></li></ul></li><li><a href="TorPool.html">TorPool</a><ul class='methods'><li data-type='method'><a href="TorPool.html#add">add</a></li><li data-type='method'><a href="TorPool.html#add_instance_to_group">add_instance_to_group</a></li><li data-type='method'><a href="TorPool.html#add_instance_to_group_at">add_instance_to_group_at</a></li><li data-type='method'><a href="TorPool.html#add_instance_to_group_by_name">add_instance_to_group_by_name</a></li><li data-type='method'><a href="TorPool.html#create">create</a></li><li data-type='method'><a href="TorPool.html#create_instance">create_instance</a></li><li data-type='method'><a href="TorPool.html#exit">exit</a></li><li data-type='method'><a href="TorPool.html#get_config_at">get_config_at</a></li><li data-type='method'><a href="TorPool.html#get_config_by_name">get_config_by_name</a></li><li data-type='method'><a href="TorPool.html#instance_at">instance_at</a></li><li data-type='method'><a href="TorPool.html#instance_by_name">instance_by_name</a></li><li data-type='method'><a href="TorPool.html#instances_by_group">instances_by_group</a></li><li data-type='method'><a href="TorPool.html#new_identites">new_identites</a></li><li data-type='method'><a href="TorPool.html#new_identites_by_group">new_identites_by_group</a></li><li data-type='method'><a href="TorPool.html#new_identity_at">new_identity_at</a></li><li data-type='method'><a href="TorPool.html#new_identity_by_name">new_identity_by_name</a></li><li data-type='method'><a href="TorPool.html#next">next</a></li><li data-type='method'><a href="TorPool.html#next_by_group">next_by_group</a></li><li data-type='method'><a href="TorPool.html#remove">remove</a></li><li data-type='method'><a href="TorPool.html#remove_at">remove_at</a></li><li data-type='method'><a href="TorPool.html#remove_by_name">remove_by_name</a></li><li data-type='method'><a href="TorPool.html#remove_instance_from_group">remove_instance_from_group</a></li><li data-type='method'><a href="TorPool.html#remove_instance_from_group_at">remove_instance_from_group_at</a></li><li data-type='method'><a href="TorPool.html#remove_instance_from_group_by_name">remove_instance_from_group_by_name</a></li><li data-type='method'><a href="TorPool.html#set_config_all">set_config_all</a></li><li data-type='method'><a href="TorPool.html#set_config_at">set_config_at</a></li><li data-type='method'><a href="TorPool.html#set_config_by_group">set_config_by_group</a></li><li data-type='method'><a href="TorPool.html#set_config_by_name">set_config_by_name</a></li><li data-type='method'><a href="TorPool.html#signal_all">signal_all</a></li><li data-type='method'><a href="TorPool.html#signal_at">signal_at</a></li><li data-type='method'><a href="TorPool.html#signal_by_group">signal_by_group</a></li><li data-type='method'><a href="TorPool.html#signal_by_name">signal_by_name</a></li></ul></li><li><a href="TorProcess.html">TorProcess</a><ul class='methods'><li data-type='method'><a href="TorProcess.html#create">create</a></li><li data-type='method'><a href="TorProcess.html#exit">exit</a></li><li data-type='method'><a href="TorProcess.html#get_config">get_config</a></li><li data-type='method'><a href="TorProcess.html#new_identity">new_identity</a></li><li data-type='method'><a href="TorProcess.html#set_config">set_config</a></li><li data-type='method'><a href="TorProcess.html#signal">signal</a></li></ul></li></ul><h3>Modules</h3><ul><li><a href="module-tor-router.html">tor-router</a></li><li><a href="module-tor-router_ControlServer.html">tor-router/ControlServer</a></li><li><a href="module-tor-router_default_config.html">tor-router/default_config</a></li><li><a href="module-tor-router_default_ports.html">tor-router/default_ports</a></li><li><a href="module-tor-router_DNSServer.html">tor-router/DNSServer</a></li><li><a href="module-tor-router_HTTPServer.html">tor-router/HTTPServer</a></li><li><a href="module-tor-router_launch.html">tor-router/launch</a></li><li><a href="module-tor-router_nconf_load_env.html">tor-router/nconf_load_env</a></li><li><a href="module-tor-router_SOCKSServer.html">tor-router/SOCKSServer</a></li><li><a href="module-tor-router_TorPool.html">tor-router/TorPool</a></li><li><a href="module-tor-router_TorProcess.html">tor-router/TorProcess</a></li><li><a href="module-tor-router_winston_silent_logger.html">tor-router/winston_silent_logger</a></li></ul><h3>Events</h3><ul><li><a href="DNSServer.html#event:instance-connection">instance-connection</a></li><li><a href="HTTPServer.html#event:instance-connection">instance-connection</a></li><li><a href="SOCKSServer.html#event:instance-connection">instance-connection</a></li><li><a href="TorPool.html#event:instance_created">instance_created</a></li><li><a href="TorProcess.html#event:control_listen">control_listen</a></li><li><a href="TorProcess.html#event:controller_ready">controller_ready</a></li><li><a href="TorProcess.html#event:dns_listen">dns_listen</a></li><li><a href="TorProcess.html#event:error">error</a></li><li><a href="TorProcess.html#event:process_exit">process_exit</a></li><li><a href="TorProcess.html#event:ready">ready</a></li><li><a href="TorProcess.html#event:socks_listen">socks_listen</a></li></ul><h3>Global</h3><ul><li><a href="global.html#assembleHost">assembleHost</a></li><li><a href="global.html#cleanUp">cleanUp</a></li><li><a href="global.html#env_whitelist">env_whitelist</a></li><li><a href="global.html#logger">logger</a></li><li><a href="global.html#main">main</a></li><li><a href="global.html#nconf">nconf</a></li><li><a href="global.html#REALM">REALM</a></li><li><a href="global.html#setup_nconf_env">setup_nconf_env</a></li><li><a href="global.html#TOR_ROUTER_PROXY_AGENT">TOR_ROUTER_PROXY_AGENT</a></li></ul>
  23. </nav>
  24. <div id="main">
  25. <h1 class="page-title">SOCKSServer</h1>
  26. <section>
  27. <header>
  28. <h2>
  29. SOCKSServer
  30. </h2>
  31. <div class="class-description">A SOCKS5 proxy server that will route requests to instances in the TorPool provided.</div>
  32. </header>
  33. <article>
  34. <div class="container-overview">
  35. <h2>Constructor</h2>
  36. <h4 class="name" id="SOCKSServer"><span class="type-signature"></span>new SOCKSServer<span class="signature">(tor_pool, logger<span class="signature-attributes">opt</span>, proxy_by_name<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
  37. <dl class="details">
  38. <dt class="tag-source">Source:</dt>
  39. <dd class="tag-source"><ul class="dummy"><li>
  40. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line26">line 26</a>
  41. </li></ul></dd>
  42. </dl>
  43. <div class="description">
  44. Creates an instance of `SOCKSServer`.
  45. </div>
  46. <h5>Parameters:</h5>
  47. <table class="params">
  48. <thead>
  49. <tr>
  50. <th>Name</th>
  51. <th>Type</th>
  52. <th>Attributes</th>
  53. <th class="last">Description</th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. <tr>
  58. <td class="name"><code>tor_pool</code></td>
  59. <td class="type">
  60. <span class="param-type"><a href="TorPool.html">TorPool</a></span>
  61. </td>
  62. <td class="attributes">
  63. </td>
  64. <td class="description last">The pool of instances that will be used for requests</td>
  65. </tr>
  66. <tr>
  67. <td class="name"><code>logger</code></td>
  68. <td class="type">
  69. <span class="param-type">Logger</span>
  70. </td>
  71. <td class="attributes">
  72. &lt;optional><br>
  73. </td>
  74. <td class="description last">Winston logger that will be used for logging. If not specified will disable logging.</td>
  75. </tr>
  76. <tr>
  77. <td class="name"><code>proxy_by_name</code></td>
  78. <td class="type">
  79. <span class="param-type"><a href="global.html#ProxyByNameConfig">ProxyByNameConfig</a></span>
  80. </td>
  81. <td class="attributes">
  82. &lt;optional><br>
  83. </td>
  84. <td class="description last">Enable routing to specific instances or groups of instances using the username field (socks://instance-1:@my-server:9050) when connecting.</td>
  85. </tr>
  86. </tbody>
  87. </table>
  88. </div>
  89. <h3 class="subsection-title">Extends</h3>
  90. <ul>
  91. <li>Server</li>
  92. </ul>
  93. <h3 class="subsection-title">Members</h3>
  94. <h4 class="name" id="logger"><span class="type-signature"></span>logger<span class="type-signature"> :Logger</span></h4>
  95. <dl class="details">
  96. <dt class="tag-source">Source:</dt>
  97. <dd class="tag-source"><ul class="dummy"><li>
  98. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line219">line 219</a>
  99. </li></ul></dd>
  100. </dl>
  101. <div class="description">
  102. Winston logger to use.
  103. </div>
  104. <h5>Type:</h5>
  105. <ul>
  106. <li>
  107. <span class="param-type">Logger</span>
  108. </li>
  109. </ul>
  110. <h4 class="name" id="proxy_by_name"><span class="type-signature"></span>proxy_by_name<span class="type-signature"> :<a href="global.html#ProxyByNameConfig">ProxyByNameConfig</a></span></h4>
  111. <dl class="details">
  112. <dt class="tag-source">Source:</dt>
  113. <dd class="tag-source"><ul class="dummy"><li>
  114. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line233">line 233</a>
  115. </li></ul></dd>
  116. </dl>
  117. <div class="description">
  118. Configuration for the "proxy by name" feature.
  119. </div>
  120. <h5>Type:</h5>
  121. <ul>
  122. <li>
  123. <span class="param-type"><a href="global.html#ProxyByNameConfig">ProxyByNameConfig</a></span>
  124. </li>
  125. </ul>
  126. <h4 class="name" id="tor_pool"><span class="type-signature"></span>tor_pool<span class="type-signature"> :<a href="TorPool.html">TorPool</a></span></h4>
  127. <dl class="details">
  128. <dt class="tag-source">Source:</dt>
  129. <dd class="tag-source"><ul class="dummy"><li>
  130. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line226">line 226</a>
  131. </li></ul></dd>
  132. </dl>
  133. <div class="description">
  134. Pool of instances use to service requests.
  135. </div>
  136. <h5>Type:</h5>
  137. <ul>
  138. <li>
  139. <span class="param-type"><a href="TorPool.html">TorPool</a></span>
  140. </li>
  141. </ul>
  142. <h3 class="subsection-title">Methods</h3>
  143. <h4 class="name" id="listen"><span class="type-signature">(async) </span>listen<span class="signature">(port, host<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
  144. <dl class="details">
  145. <dt class="tag-source">Source:</dt>
  146. <dd class="tag-source"><ul class="dummy"><li>
  147. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line43">line 43</a>
  148. </li></ul></dd>
  149. </dl>
  150. <div class="description">
  151. Binds the server to a port and IP Address.
  152. </div>
  153. <h5>Parameters:</h5>
  154. <table class="params">
  155. <thead>
  156. <tr>
  157. <th>Name</th>
  158. <th>Type</th>
  159. <th>Attributes</th>
  160. <th>Default</th>
  161. <th class="last">Description</th>
  162. </tr>
  163. </thead>
  164. <tbody>
  165. <tr>
  166. <td class="name"><code>port</code></td>
  167. <td class="type">
  168. <span class="param-type">number</span>
  169. </td>
  170. <td class="attributes">
  171. </td>
  172. <td class="default">
  173. </td>
  174. <td class="description last">The port to bind to.</td>
  175. </tr>
  176. <tr>
  177. <td class="name"><code>host</code></td>
  178. <td class="type">
  179. <span class="param-type">string</span>
  180. </td>
  181. <td class="attributes">
  182. &lt;optional><br>
  183. </td>
  184. <td class="default">
  185. <code>"::"</code>
  186. </td>
  187. <td class="description last">Address to bind to. Will default to :: or 0.0.0.0 if not specified.</td>
  188. </tr>
  189. </tbody>
  190. </table>
  191. <h5>Returns:</h5>
  192. <dl class="param-type">
  193. <dt>
  194. Type
  195. </dt>
  196. <dd>
  197. <span class="param-type">Promise</span>
  198. </dd>
  199. </dl>
  200. <h3 class="subsection-title">Type Definitions</h3>
  201. <h4 class="name" id="~authenticate_user_callback"><span class="type-signature"></span>authenticate_user_callback<span class="signature">(allow, user)</span><span class="type-signature"></span></h4>
  202. <dl class="details">
  203. <dt class="tag-source">Source:</dt>
  204. <dd class="tag-source"><ul class="dummy"><li>
  205. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line27">line 27</a>
  206. </li></ul></dd>
  207. </dl>
  208. <div class="description">
  209. Callback for `authenticate_user`.
  210. </div>
  211. <h5>Parameters:</h5>
  212. <table class="params">
  213. <thead>
  214. <tr>
  215. <th>Name</th>
  216. <th>Type</th>
  217. <th class="last">Description</th>
  218. </tr>
  219. </thead>
  220. <tbody>
  221. <tr>
  222. <td class="name"><code>allow</code></td>
  223. <td class="type">
  224. <span class="param-type">boolean</span>
  225. </td>
  226. <td class="description last">Indicates if the connection should be allowed.</td>
  227. </tr>
  228. <tr>
  229. <td class="name"><code>user</code></td>
  230. <td class="type">
  231. <span class="param-type">boolean</span>
  232. </td>
  233. <td class="description last">Indicates if the connection should have a session (authentication was successful).</td>
  234. </tr>
  235. </tbody>
  236. </table>
  237. <h3 class="subsection-title">Events</h3>
  238. <h4 class="name" id="event:instance-connection">instance-connection</h4>
  239. <dl class="details">
  240. <dt class="tag-source">Source:</dt>
  241. <dd class="tag-source"><ul class="dummy"><li>
  242. <a href="SOCKSServer.js.html">SOCKSServer.js</a>, <a href="SOCKSServer.js.html#line157">line 157</a>
  243. </li></ul></dd>
  244. </dl>
  245. <div class="description">
  246. Fires when the proxy has made a connection through an instance.
  247. </div>
  248. <h5>Parameters:</h5>
  249. <table class="params">
  250. <thead>
  251. <tr>
  252. <th>Name</th>
  253. <th>Type</th>
  254. <th class="last">Description</th>
  255. </tr>
  256. </thead>
  257. <tbody>
  258. <tr>
  259. <td class="name"><code>instance</code></td>
  260. <td class="type">
  261. <span class="param-type"><a href="TorProcess.html">TorProcess</a></span>
  262. </td>
  263. <td class="description last">Instance that has been connected to.</td>
  264. </tr>
  265. <tr>
  266. <td class="name"><code>source</code></td>
  267. <td class="type">
  268. <span class="param-type"><a href="global.html#InstanceConnectionSource">InstanceConnectionSource</a></span>
  269. </td>
  270. <td class="description last">Details on the source of the connection.</td>
  271. </tr>
  272. </tbody>
  273. </table>
  274. </article>
  275. </section>
  276. </div>
  277. <br class="clear">
  278. <footer>
  279. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Sep 25 2018 12:53:23 GMT-0400 (Eastern Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
  280. </footer>
  281. <script>prettyPrint();</script>
  282. <script src="scripts/linenumber.js"></script>
  283. </body>
  284. </html>