Next: , Previous: , Up: Hooks   [Contents][Index]


6.1.5 Netsync Transport Hooks

When a monotone client initiates a netsync connection, these hooks are called to attempt to parse the host argument provided on the command line. If the hooks fail or return nil, monotone will interpret the host argument as a network name (possibly with a port number) and open a TCP socket.

get_netsync_connect_command (uri, args)

Returns a table describing a command to run to connect to the specified host. The uri argument is a table containing between 0 and 7 components:

The args argument is a table containing between 0 and 3 components:

The default definition of this hook follows:

function get_netsync_connect_command(uri, args)

        local argv = nil

        if uri["scheme"] == "ssh"
                and uri["host"]
                and uri["path"] then

                argv = { "ssh" }
                if uri["user"] then
                        table.insert(argv, "-l")
                        table.insert(argv, uri["user"])
                end
                if uri["port"] then
                        table.insert(argv, "-p")
                        table.insert(argv, uri["port"])
                end

                table.insert(argv, uri["host"])
        end

        if uri["scheme"] == "file" and uri["path"] then
                argv = { }
        end

        if argv then

                table.insert(argv, get_mtn_command(uri["host"]))

                if args["debug"] then
                        table.insert(argv, "--debug")
                else
                        table.insert(argv, "--quiet")
                end

                table.insert(argv, "--db")
                table.insert(argv, uri["path"])
                table.insert(argv, "serve")
                table.insert(argv, "--stdio")
                table.insert(argv, "--no-transport-auth")

                if args["include"] then
                        table.insert(argv, args["include"])
                end

                if args["exclude"] then
                        table.insert(argv, "--exclude")
                        table.insert(argv, args["exclude"])
                end
        end
        return argv
end
use_transport_auth (uri)

Returns a boolean indicating whether monotone should use transport authentication mechanisms when communicating with uri. If this hook fails, the return value is assumed to be true. The form of the uri argument is a table, identical to the table provided as an argument to get_netsync_connect_command.

Note that the return value of this hook must "match" the semantics of the command returned by get_netsync_connect_command. In particular, if this hook returns false, the serve command line arguments passed to the remote end of the connection should include the --no-transport-auth option. A mismatch between this hook’s return value and the command line returned by get_netsync_connect_command will cause a communication failure, as the local and remote monotone processes will have mismatched authentication assumptions.

function use_transport_auth(uri)
        if uri["scheme"] == "ssh"
        or uri["scheme"] == "file" then
                return false
        else
                return true
        end
end
get_mtn_command(host)

Returns a string containing the monotone command to be executed on host when communicating over ssh. The host argument is a string containing the name of the host to which ssh is connecting, from the server URI. This is useful when there are multiple monotone binaries on the remote host, or the monotone binary is not in the default path.

function get_mtn_command(host)
    return "mtn"
end

Next: , Previous: , Up: Hooks   [Contents][Index]

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status