Skip to content

0xN0x/photon-packet-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Photon Packet Parser

This package is a parser for Photon Engine packets.

It embeds a deserializer for the Protocol16.

Example

const PhotonParser = require('photon-packet-parser');
const Cap = require('cap').Cap;
const decoders = require('cap').decoders;

// Initiate the parser
const manager = new PhotonParser();
const capture = new Cap();
const device = Cap.findDevice('<interface ip>');
const filter = 'udp and (dst port 5056 or src port 5056)';
const bufSize = 10 * 1024 * 1024;
const buffer = Buffer.alloc(65535);
const linkType = capture.open(device, filter, bufSize, buffer);

capture.setMinBytes && capture.setMinBytes(0);

capture.on('packet', (nbytes, trunc) => {
	let  ret = decoders.Ethernet(buffer);
	ret = decoders.IPV4(buffer, ret.offset);
	ret = decoders.UDP(buffer, ret.offset);

	let payload = buffer.slice(ret.offset, nbytes);

	// Parse the UDP payload
	manager.handle(payload);
});

About

A parser for photon's protocol16 packet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published