| 253 | const connPiper = libNet.connPiper |
| 254 | |
| 255 | function startHyperTeleServer() { |
| 256 | |
| 257 | argv.l = "55900"; |
| 258 | argv.seed = libKeys.randomBytes(32).toString('hex'); |
| 259 | |
| 260 | const helpMsg = 'Usage:\nhypertele-server -l service_port -u unix_socket ?--address service_address ?-c conf.json ?--seed seed ?--cert-skip' |
| 261 | |
| 262 | if (argv.help) { |
| 263 | console.log(helpMsg) |
| 264 | process.exit(-1) |
| 265 | } |
| 266 | |
| 267 | if (!argv.u && !+argv.l) { |
| 268 | console.error('Error: proxy port invalid') |
| 269 | process.exit(-1) |
| 270 | } |
| 271 | |
| 272 | if (argv.u && argv.l) { |
| 273 | console.error('Error: cannot listen to both a port and a Unix domain socket') |
| 274 | process.exit(-1) |
| 275 | } |
| 276 | |
| 277 | const conf = {} |
| 278 | |
| 279 | if (argv.seed) { |
| 280 | conf.seed = argv.seed |
| 281 | } |
| 282 | |
| 283 | if (argv.c) { |
| 284 | libUtils.readConf(conf, argv.c) |
| 285 | } |
| 286 | |
| 287 | if (argv.compress) { |
| 288 | conf.compress = true |
| 289 | } |
| 290 | |
| 291 | if (argv['cert-skip']) { |
| 292 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0 |
| 293 | } |
| 294 | |
| 295 | if (!conf.seed) { |
| 296 | console.error('Error: conf.seed invalid') |
| 297 | process.exit(-1) |
| 298 | } |
| 299 | |
| 300 | if (conf.allow) { |
| 301 | conf.allow = libKeys.prepKeyList(conf.allow) |
| 302 | } |
| 303 | |
| 304 | const debug = argv.debug |
| 305 | |
| 306 | const seed = Buffer.from(conf.seed, 'hex') |
| 307 | |
| 308 | const dht = new HyperDHT() |
| 309 | const keyPair = HyperDHT.keyPair(seed) |
| 310 | |
| 311 | const stats = {} |
| 312 | |