rpc

package
v0.0.0-...-e3a9e5c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2021 License: BSD-3-Clause, LGPL-2.1, MIT, + 1 more Imports: 0 Imported by: 0

Documentation

Overview

Package rpc provides access to the Vyatta operational mode RPC implementation. This library allows access to the operational template tree, as well as executes programs on the user's behalf and allowing for the user to connect back to the spawned pty.

Access to the operational mode template tree is provided by to facilitate the implementaion of user interfaces in the Vyatta system. These RPC stub functions are described as part of their implementation. This library is currently synchronous, use of concurrent requests from the same client is unsupported, but concurrent requests from multiple clients is possible.

A server implemntation invokes the RPC service in the following way:

t, err := tree.BuildOpTree(OpTmplPath)
l, err := net.ListenUnix("unix", ua)
achan := make(chan rpc.Auth)

srv := rpc.NewServer(l, t, achan, debug)
err = srv.Serve()
if err != nil {
	log.Fatal(err)
}

A simple client implementation could work this way:

c, err := rpc.Connect("server.sock", debug)
result, err := c.Complete(argv)

Index

Constants

This section is empty.

Variables

View Source
var Env []string = []string{"vyatta_htmldir=/opt/vyatta/share/html",
	"vyatta_datadir=/opt/vyatta/share",
	"vyatta_op_templates=/opt/vyatta/share/vyatta-op/templates",
	"vyatta_sysconfdir=/opt/vyatta/etc",
	"vyatta_sharedstatedir=/opt/vyatta/com",
	"vyatta_sbindir=/opt/vyatta/sbin",
	"vyatta_cfg_templates=/opt/vyatta/share/vyatta-cfg/templates",
	"VYATTA_CFG_GROUP_NAME=vyattacfg",
	"vyatta_bindir=/opt/vyatta/bin",
	"VYATTA_USER_LEVEL_DIR=/opt/vyatta/etc/shell/level/admin",
	"vyatta_libdir=/opt/vyatta/lib",
	"vyatta_localstatedir=/opt/vyatta/var",
	"VYATTA_PAGER=less --buffers=64 --auto-buffers --no-lessopen --QUIT-AT-EOF --quit-if-one-screen --RAW-CONTROL-CHARS --squeeze-blank-lines --no-init",
	"vyatta_libexecdir=/opt/vyatta/libexec",
	"vyatta_prefix=/opt/vyatta",
	"vyatta_datarootdir=/opt/vyatta/share",
	"vyatta_configdir=/opt/vyatta/config",
	"vyatta_infodir=/opt/vyatta/share/info",
	"vyatta_localedir=/opt/vyatta/share/locale",
	"PERL5LIB=/opt/vyatta/share/perl5",
}

Env is the environment needed to run vyatta commands.

Functions

This section is empty.

Types

type Fn

type Fn uint

Fn is an enumeration used to identify RPC call handlers

const (
	FnRun Fn = iota
	FnComplete
	FnHelp
	FnExpand
	FnTmpl
	FnChildren
	FnAllowed
	FnGetPerms
)

type Request

type Request struct {
	//Op is the method that was called via json rpc
	Op Fn `json:"method"`
	//Args is a list of arguments to that method
	Args []string `json:"args"`
	//Id is the unique request identifier
	Id uint `json:"id"`
}

Request represents an RPC request

type Response

type Response struct {
	//Result is any value returned by the handler
	//The client library uses reflection to ensure it received the appropriate type.
	Result interface{} `json:"result"`
	//Error contains a message describing a problem
	Error string `json:"error"`
	//Id is the unique request identifier
	Id uint `json:"id"`
}

Response represents an RPC response

func NewResponse

func NewResponse(result interface{}, err error, id uint) *Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL