Documentation ¶
Overview ¶
Package client contains high-level client-side interface to Assuan IPC protocol implementation.
Index ¶
- func Dial(fn string) (net.Conn, error)
- type Session
- func (ses *Session) Close() error
- func (ses *Session) Option(name string, value string) error
- func (ses *Session) Reset() error
- func (ses *Session) SimpleCmd(cmd string, params string) (data []byte, err error)
- func (ses *Session) Transact(cmd string, params string, data map[string]interface{}) (rdata []byte, err error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Session ¶
Session struct is a wrapper which represents an alive connection between client and server.
In Assuan protocol roles of peers after handshake is not same, for this reason there is no generic Session object that will work for both client and server. In particular, client.Session (the struct you are looking at) represents client side of connection.
Example ¶
package main import ( "fmt" "net" assuan "github.com/rupor-github/win-gpg-agent/assuan/client" ) func main() { // Connect to dirmngr. conn, _ := net.Dial("unix", ".gnupg/S.dirmngr") ses, _ := assuan.Init(conn) defer ses.Close() // Search for my key on default keyserver. data, _ := ses.SimpleCmd("KS_SEARCH", "foxcpp") fmt.Println(string(data)) // data []byte = "info:1:1%0Apub:2499BEB8B47B0235009A5F0AEE8384B0561A25AF:..." // More complex transaction: send key to keyserver. ses.Transact("KS_PUT", "", map[string]interface{}{ "KEYBLOCK": []byte{}, "KEYBLOCK_INFO": []byte{}, }) }
Output:
func Init ¶
func Init(stream io.ReadWriter) (*Session, error)
Init initiates session using passed Reader/Writer.
func InitCmd ¶
InitCmd initiates session using command's stdin and stdout as a I/O channel. cmd.Start() will be done by this function and should not be done before.
Warning: It's caller's responsibility to close pipes set in exec.Cmd object (cmd.Stdin, cmd.Stdout).
func (*Session) Reset ¶
Reset sends RESET command. According to Assuan documentation: Reset the connection but not any existing authentication. The server should release all resources associated with the connection.
func (*Session) SimpleCmd ¶
SimpleCmd sends command with specified parameters and reads data sent by server if any.
func (*Session) Transact ¶
func (ses *Session) Transact(cmd string, params string, data map[string]interface{}) (rdata []byte, err error)
Transact sends command with specified params and uses byte arrays in data argument to answer server's inquiries. Values in data can be either []byte or pointer to implementer of io.Reader or encoding.TextMarhshaller.