netplaySniff – Diff between revs 10 and 11

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 10 Rev 11
Line 107... Line 107...
107   107  
108 const cap = new Cap() 108 const cap = new Cap()
109 const filter = `tcp and dst port ${config.netplay.port}` 109 const filter = `tcp and dst port ${config.netplay.port}`
110 const bufSize = 10 * 1024 * 1024 110 const bufSize = 10 * 1024 * 1024
-   111 const buffer = Buffer.alloc(65535)
111 const buffer = Buffer.alloc(65535) 112 var device = Cap.findDevice(config.host);
112 const linkType = cap.open('any', filter, bufSize, buffer) 113 const linkType = cap.open(device, filter, bufSize, buffer)
113 cap.setMinBytes && cap.setMinBytes(0) 114 cap.setMinBytes && cap.setMinBytes(0)
114 cap.on('packet', () => { 115 cap.on('packet', () => {
115 let netplay = {} 116 let netplay = {}
116 if (linkType !== 'ETHERNET') { 117 if (linkType !== 'ETHERNET') {
Line 124... Line 125...
124   125  
125 ret = decoders.IPV4(buffer, ret.offset) 126 ret = decoders.IPV4(buffer, ret.offset)
126 netplay.ip = ret.info.srcaddr 127 netplay.ip = ret.info.srcaddr
127 netplay.to = ret.info.dstaddr 128 netplay.to = ret.info.dstaddr
128 if (ret.info.protocol !== PROTOCOL.IP.TCP) { -  
129 logger.info(`not a tcp protocol`) 129 if (ret.info.protocol !== PROTOCOL.IP.TCP) {
130 return 130 return
Line 131... Line 131...
131 } 131 }