Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { PromiseSocket } from 'promise-socket'
  2. import net from 'net'
  3.  
  4. const DBUS_SOCKET = '/run/user/1000/bus'
  5.  
  6. async function doit() {
  7.   const socket = new PromiseSocket(net.createConnection({ path: DBUS_SOCKET }))
  8.  
  9.   // Setup AUTH (AUTH EXTERNAL 31303030)
  10.   const uid = process.getuid()
  11.   const newId = Buffer.from(uid.toString(), 'ascii').toString('hex')
  12.   const msg = Buffer.from(`AUTH EXTERNAL ${newId}\r\n`, 'ascii')
  13.   console.log(msg.toString('ascii'))
  14.   await socket.write(Buffer.from('00', 'hex'))
  15.   await socket.write(msg)
  16.  
  17.   // OK response (or gather response)
  18.   const okRes = await socket.readAll()
  19.   console.log(okRes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement