plugin

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 8 Imported by: 0

README

libdns-plugin

A Go-based plugin system for libdns DNS providers.

Overview

libdns-plugin enables DNS providers to be implemented as standalone plugins that can be loaded dynamically by applications using the libdns library. Built on HashiCorp's go-plugin library with GRPC communication, it provides a flexible architecture where DNS provider implementations can be distributed as separate binaries.

The system supports all standard libdns operations (get, set, append, delete records) and uses JSON for provider configuration.

Usage

Implementing a Plugin
package main

import (
    "github.com/libdns/libdns"
    "github.com/jsiebens/libdns-plugin"
)

type MyDNSProvider struct {
    // Your provider implementation
}

// Implement the necessary libdns interfaces
func (p *MyDNSProvider) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error) {
    // Implementation
}

// Other required methods...

func main() {
    provider := &MyDNSProvider{}
    plugin.Serve(provider)
}
Using a Plugin
package main

import (
	"context"
	"github.com/jsiebens/libdns-plugin"
)

func main() {
	client, provider, err := plugin.NewClient("path/to/plugin")
	if err != nil {
		// Handle error
	}
	defer client.Close()

	// Configure the provider
	err = provider.Configure(context.Background(), []byte(`{"api_token": "your-token"}`))
	if err != nil {
		// Handle error
	}

	// Use the provider
	records, err := provider.GetRecords(context.Background(), "example.com")
	// ...
}

Documentation

Index

Constants

View Source
const ProviderPluginName = "provider"

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "LIBDNS_PLUGIN",
	MagicCookieValue: "k29lqez4d5dzfh629t2it4fv8n804blr38nj9495uj3wqrgoyzalmg2l7jnqmz6e",
}

Handshake is a common handshake that is shared by plugin and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	ProviderPluginName: &ProviderPlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

Types

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

func (*GRPCClient) AppendRecords

func (g *GRPCClient) AppendRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)

func (*GRPCClient) Configure

func (g *GRPCClient) Configure(ctx context.Context, message json.RawMessage) error

func (*GRPCClient) DeleteRecords

func (g *GRPCClient) DeleteRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)

func (*GRPCClient) GetRecords

func (g *GRPCClient) GetRecords(ctx context.Context, zone string) ([]libdns.Record, error)

func (*GRPCClient) SetRecords

func (g *GRPCClient) SetRecords(ctx context.Context, zone string, recs []libdns.Record) ([]libdns.Record, error)

type GRPCServer

type GRPCServer struct {
	Impl Provider
	// contains filtered or unexported fields
}

func (*GRPCServer) AppendRecords

func (g *GRPCServer) AppendRecords(ctx context.Context, request *proto.RecordsRequest) (*proto.RecordsResponse, error)

func (*GRPCServer) Configure

func (g *GRPCServer) Configure(ctx context.Context, request *proto.ConfigureRequest) (*proto.ConfigureResponse, error)

func (*GRPCServer) DeleteRecords

func (g *GRPCServer) DeleteRecords(ctx context.Context, request *proto.RecordsRequest) (*proto.RecordsResponse, error)

func (*GRPCServer) GetRecords

func (g *GRPCServer) GetRecords(ctx context.Context, request *proto.GetRecordsRequest) (*proto.RecordsResponse, error)

func (*GRPCServer) SetRecords

func (g *GRPCServer) SetRecords(ctx context.Context, request *proto.RecordsRequest) (*proto.RecordsResponse, error)

type Provider

func NewClient

func NewClient(cmd *exec.Cmd) (*plugin.Client, Provider, error)

type ProviderPlugin

type ProviderPlugin struct {
	plugin.NetRPCUnsupportedPlugin
	Impl Provider
}

func (*ProviderPlugin) GRPCClient

func (p *ProviderPlugin) GRPCClient(_ context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*ProviderPlugin) GRPCServer

func (p *ProviderPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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