How to use the binary.stream function in binary

To help you get started, we’ve selected a few binary examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brozeph / simple-socks / src / socks5.js View on Github external
function connect (buffer) {
				let binaryStream = binary.stream(buffer);

				binaryStream
					.word8('ver')
					.word8('cmd')
					.word8('rsv')
					.word8('atyp')
					.tap((args) => {
						// capture the raw buffer
						args.requestBuffer = buffer;

						// verify version is appropriate
						if (args.ver !== RFC_1928_VERSION) {
							return end(RFC_1928_REPLIES.GENERAL_FAILURE, args);
						}

						// append socket to active sessions
github Srar / telegram-socks5-proxy / lib / socks5.js View on Github external
function handshake (buffer) {
		binary
			.stream(buffer)
			.word8('ver')
			.word8('nmethods')
			.buffer('methods', 'nmethods')
			.tap(function (args) {
				// verify version is appropriate
				if (args.ver !== RFC_1928_VERSION) {
					return end(RFC_1928_REPLIES.GENERAL_FAILURE, args);
				}

				// convert methods buffer to an array
				var
					acceptedMethods = [].slice.call(args.methods).reduce(function (methods, method) {
						methods[method] = true;
						return methods;
					}, {}),
github brozeph / simple-socks / src / socks5.js View on Github external
function handshake (buffer) {
				binary
					.stream(buffer)
					.word8('ver')
					.word8('nmethods')
					.buffer('methods', 'nmethods')
					.tap((args) => {
						// verify version is appropriate
						if (args.ver !== RFC_1928_VERSION) {
							return end(RFC_1928_REPLIES.GENERAL_FAILURE, args);
						}

						// convert methods buffer to an array
						let
							acceptedMethods = [].slice.call(args.methods).reduce((methods, method) => {
								methods[method] = true;
								return methods;
							}, {}),
github mrene / node-minidsp / src / transport / net.js View on Github external
constructor({ host, port = 5333 } = {}) {
		super();
		let self = this;

		debug(`Connecting to ${host}:${port}`);

		this.connection = net.createConnection({ host, port }, () => {
			debug('Connection established');
		});

		binary.stream(this.connection)
			.loop(function () {
				 this.peek(function() {
			        this.word8u('size');
			    })
				.buffer('data', 'size')
				.tap(function(vars) {
					debug('fromRemoteClient', vars.data);
					self.emit('data', vars.data);
			    });
			});
	}
github lersh / potatoStream / lib / potato.js View on Github external
Resolve: function (buff) {
        //var decipher = crypto.createDecipher(algorithm, password);
        buff = decipherGCM(buff, password);//试试看用GCM算法解码 //decipher.update(buff);
        if (buff === null)
            return null;//解码失败返回空
        var msg = {};
        binary
            .stream(buff)
            .word8('flag')//标识位1个字节
            .word16be('len')//长度2个字节,代表后面的域名字符串的长度
            .tap(function (args) {
                args.dst = {};
                this
                    .buffer('addr', args.len)
                    .tap(function (args) {
                        args.dst.addr = args.addr.toString();
                    });
            })
            .word16be('port')
            .word64be('timestamp')
            .tap(function (args) {
                args.dst.port = args.port;
                msg = args;