client

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: Apache-2.0, MIT Imports: 13 Imported by: 0

Documentation

Overview

Package client contains high-level client-side interface to Assuan IPC protocol implementation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(fn string) (net.Conn, error)

Dial Asuan file socket on Windows - read contents of the target file and connect to a TCP port.

Types

type Session

type Session struct {
	Pipe common.Pipe
}

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

func InitCmd(cmd *exec.Cmd) (*Session, error)

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) Close

func (ses *Session) Close() error

Close sends BYE and closes underlying pipe.

func (*Session) Option

func (ses *Session) Option(name string, value string) error

Option sets options for connections.

func (*Session) Reset

func (ses *Session) Reset() error

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

func (ses *Session) SimpleCmd(cmd string, params string) (data []byte, err error)

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.

Jump to

Keyboard shortcuts

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