def _callFunc(session, funcName, password, args):
    """Call custom cjdns admin function"""

    txid = _randomString()
    sock = session.socket
    sock.send(bytearray('d1:q6:cookie4:txid10:%se' % txid, 'utf-8'))
    msg = _getMessage(session, txid)
    cookie = msg['cookie']
    txid = _randomString()
    tohash = (password + cookie).encode('utf-8')
    req = {
        'q': funcName,
        'hash': hashlib.sha256(tohash).hexdigest(),
        'cookie': cookie,
        'args': args,
        'txid': txid
    }

    if password:
        req['aq'] = req['q']
        req['q'] = 'auth'
        reqBenc = bencode(req).encode('utf-8')
        req['hash'] = hashlib.sha256(reqBenc).hexdigest()

    reqBenc = bencode(req)
    sock.send(bytearray(reqBenc, 'utf-8'))
    return _getMessage(session, txid)
Call custom cjdns admin function