MASQNodeand User Interfaces
MASQNode.exefor Windows) binary is used for two different purposes. One is called the Daemon; the other is called the Node.
localhost-only port (5333 by default) for connections from user interfaces. UIs connect first to the Daemon on its well-known port. There are certain conversations that the Daemon can carry on with the UI (one of which tells the Daemon to start up the Node), but when it's time, the Daemon will tell the UI where the Node is so that the UI can connect directly to the Node.
localhostpseudo-NIC. This means that all the UIs for a particular Daemon or Node must run on the same computer as the Daemon or Node: they cannot call in over the network from another machine. This restriction is in place for security reasons.
MASQNode-UIv2. Any other protocol name will be rejected, and no connection will be made.
MASQNode-UIv2messages is reasonably simple. It looks like this:
opcodeis a short string that identifies the message type. If a message is a request (UI to Node) and the protocol dictates that a response (Node to UI) should result from it, both the request and the response will have the same opcode.
contextIdis a positive integer best thought of as a conversation number. Just as there can be many UIs connected to the same Node, each UI can be carrying on many simultaneous conversations with the Node. When a request is sent as part of a unique conversation, the Daemon and the Node guarantee that the next message received in that conversation will be the response to that request. It is the responsibility of each UI to manage
contextIds. When the UI wants to start a new conversation, it merely mentions a new
contextIdin the first message of that conversation; when it's done with a conversation, it just stops mentioning that conversation's
contextIdfor all the messages a UI sends in its lifetime, and this is perfectly legal as far as the Node and Daemon are concerned; but if the UI does this, it will have to determine for itself which conversation each incoming message is part of. For example, if there are three conversations going on at once, this might happen:
opcode, and their
contextIdshould be ignored. (In the real world, it's always zero, but depending on that might be dangerous.)
payloadis the body of the message, with its structure being signaled by the contents of the
opcodefield. See the Message Reference section below for specifics about the
payloadfield for each type of message. It will be present if and only if the
errorfield is not present.
errorfield, if present, tells about the error that was encountered in the process of trying to satisfy a request. It will be present if and only if the
payloadfield is not present. It will have this structure:
codefield is a 64-bit integer. Its numeric value is not particularly important, but it denotes a kind of error. The UI can tell whether a particular operation is producing the same kind of error repeatedly, or different kinds of errors, by comparing one
codeto the next.
messagefield is a string with a hopefully-friendly description of the error.
MASQNode-UIv2protocol for UIs to communicate with one another. A UI may be able to deduce, from broadcasts, the existence of other UIs, but it can never be assured that there aren't any other UIs connected to the Node or Daemon.
MASQNode-UIv2message depends on the
opcodeof that message. See the Message Reference section below.
localhost, using the
MASQNode-UIv2protocol), and resend the original message--which, in case the UI doesn't remember it anymore, is helpfully included in the Redirect payload. If it's a valid Node message, the Node should respond appropriately to it.
MASQNode-UIv2messages, the UI can check to see if a password is correct; it can change the database password (if it knows the old one); and it can be notified when some other UI changes the password (so that it knows the one it's aware of is no longer valid).
MASQNode-UIv2as well. A UI can request the configuration information, and if the information changes for some reason, all UIs will be notified so that--if desired--they can request the latest version.