Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { PromiseSocket } from 'promise-socket'
- import net from 'net'
- const DBUS_SOCKET = '/run/user/1000/bus'
- async function doit() {
- const socket = new PromiseSocket(net.createConnection({ path: DBUS_SOCKET }))
- // Setup AUTH (AUTH EXTERNAL 31303030)
- const uid = process.getuid()
- const newId = Buffer.from(uid.toString(), 'ascii').toString('hex')
- const msg = Buffer.from(`AUTH EXTERNAL ${newId}\r\n`, 'ascii')
- console.log(msg.toString('ascii'))
- await socket.write(Buffer.from('00', 'hex'))
- await socket.write(msg)
- // OK response (or gather response)
- const okRes = await socket.readAll()
- console.log(okRes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement