This file is indexed.

/usr/lib/python3/dist-packages/wormhole/xfer_util.py is in magic-wormhole 0.10.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import json
from twisted.internet.defer import inlineCallbacks, returnValue

from . import wormhole
from .tor_manager import get_tor

@inlineCallbacks
def receive(reactor, appid, relay_url, code,
            use_tor=False, launch_tor=False, tor_control_port=None,
            on_code=None):
    """
    This is a convenience API which returns a Deferred that callbacks
    with a single chunk of data from another wormhole (and then closes
    the wormhole). Under the hood, it's just using an instance
    returned from :func:`wormhole.wormhole`. This is similar to the
    `wormhole receive` command.

    :param unicode appid: our application ID

    :param unicode relay_url: the relay URL to use

    :param unicode code: a pre-existing code to use, or None

    :param bool use_tor: True if we should use Tor, False to not use it (None for default)

    :param on_code: if not None, this is called when we have a code (even if you passed in one explicitly)
    :type on_code: single-argument callable
    """
    tor = None
    if use_tor:
        tor = yield get_tor(reactor, launch_tor, tor_control_port)
        # For now, block everything until Tor has started. Soon: launch
        # tor in parallel with everything else, make sure the Tor object
        # can lazy-provide an endpoint, and overlap the startup process
        # with the user handing off the wormhole code

    wh = wormhole.create(appid, relay_url, reactor, tor=tor)
    if code is None:
        wh.allocate_code()
        code = yield wh.get_code()
    else:
        wh.set_code(code)
    # we'll call this no matter what, even if you passed in a code --
    # maybe it should be only in the 'if' block above?
    if on_code:
        on_code(code)
    data = yield wh.get_message()
    data = json.loads(data.decode("utf-8"))
    offer = data.get('offer', None)
    if not offer:
        raise Exception(
            "Do not understand response: {}".format(data)
        )
    msg = None
    if 'message' in offer:
        msg = offer['message']
        wh.send_message(json.dumps({"answer":
                                    {"message_ack": "ok"}}).encode("utf-8"))

    else:
        raise Exception(
            "Unknown offer type: {}".format(offer.keys())
        )

    yield wh.close()
    returnValue(msg)


@inlineCallbacks
def send(reactor, appid, relay_url, data, code,
         use_tor=False, launch_tor=False, tor_control_port=None,
         on_code=None):
    """
    This is a convenience API which returns a Deferred that callbacks
    after a single chunk of data has been sent to another
    wormhole. Under the hood, it's just using an instance returned
    from :func:`wormhole.wormhole`. This is similar to the `wormhole
    send` command.

    :param unicode appid: the application ID

    :param unicode relay_url: the relay URL to use

    :param unicode code: a pre-existing code to use, or None

    :param bool use_tor: True if we should use Tor, False to not use it (None for default)

    :param on_code: if not None, this is called when we have a code (even if you passed in one explicitly)
    :type on_code: single-argument callable
    """
    tor = None
    if use_tor:
        tor = yield get_tor(reactor, launch_tor, tor_control_port)
        # For now, block everything until Tor has started. Soon: launch
        # tor in parallel with everything else, make sure the Tor object
        # can lazy-provide an endpoint, and overlap the startup process
        # with the user handing off the wormhole code
    wh = wormhole.create(appid, relay_url, reactor, tor=tor)
    if code is None:
        wh.allocate_code()
        code = yield wh.get_code()
    else:
        wh.set_code(code)
    if on_code:
        on_code(code)

    wh.send_message(
        json.dumps({
            "offer": {
                "message": data
            }
        }).encode("utf-8")
    )
    data = yield wh.get_message()
    data = json.loads(data.decode("utf-8"))
    answer = data.get('answer', None)
    yield wh.close()
    if answer:
        returnValue(None)
    else:
        raise Exception(
            "Unknown answer: {}".format(data)
        )