fcp

package
v0.0.0-...-840fb12 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version is the current version of GoHyphanet
	Version = "0.1.0"

	// SourceURL is the URL to the source code repository (AGPL requirement)
	SourceURL = "https://github.com/blubskye/gohyphanet"

	// LicenseName is the name of the license
	LicenseName = "GNU AGPLv3"

	// LicenseURL is the URL to the license text
	LicenseURL = "https://www.gnu.org/licenses/agpl-3.0.txt"
)

Variables

View Source
var DebugMode bool

Functions

func ConvertUSKToSSK

func ConvertUSKToSSK(uri string, edition int64) string

ConvertUSKToSSK converts a USK to the equivalent SSK for a specific edition

func GenerateCHK

func GenerateCHK(data []byte) (string, error)

GenerateCHK generates a CHK from data (deterministic hash)

func GetFullVersionString

func GetFullVersionString() string

GetFullVersionString returns a detailed version string with all info

func GetRequestURI

func GetRequestURI(insertURI string) string

GetRequestURI extracts the public (request) URI from an insert URI

func GetVersionString

func GetVersionString() string

GetVersionString returns a formatted version string

func IncrementUSK

func IncrementUSK(uskURI string) (string, error)

IncrementUSK increments a USK version number

func IsInsertURI

func IsInsertURI(uri string) bool

IsInsertURI checks if a URI is an insert (private) URI

func ParseKeyType

func ParseKeyType(uri string) string

ParseKeyType determines the key type from a URI

func PrintLicenseNotice

func PrintLicenseNotice() string

PrintLicenseNotice prints the AGPL notice

func UpdateUSKEdition

func UpdateUSKEdition(uri string, edition int64) string

UpdateUSKEdition updates the URI to use a specific edition

Types

type Client

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

Client represents a connection to a Freenet node

func Connect

func Connect(config *Config) (*Client, error)

Connect establishes a connection to the Freenet node

func (*Client) ClientGet

func (c *Client) ClientGet(uri string, identifier string) error

ClientGet retrieves data from Freenet

func (*Client) ClientPut

func (c *Client) ClientPut(uri string, identifier string, data []byte) error

ClientPut inserts data into Freenet

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the Freenet node

func (*Client) GenerateSSK

func (c *Client) GenerateSSK() (*KeyPair, error)

GenerateSSK generates a new SSK key pair using the Freenet node

func (*Client) GetNode

func (c *Client) GetNode(withPrivate, withVolatile bool) error

GetNode returns information about the node

func (*Client) Listen

func (c *Client) Listen() error

Listen starts listening for incoming messages and dispatches to handlers

func (*Client) ReceiveMessage

func (c *Client) ReceiveMessage() (*Message, error)

ReceiveMessage reads an FCP message from the node

func (*Client) RegisterHandler

func (c *Client) RegisterHandler(msgType string, handler MessageHandler)

RegisterHandler registers a handler for a specific message type

func (*Client) SendMessage

func (c *Client) SendMessage(msg *Message) error

SendMessage sends an FCP message to the node

func (*Client) SendRawData

func (c *Client) SendRawData(data []byte) error

SendRawData sends raw bytes to the node (used for ClientPutComplexDir file data)

type Config

type Config struct {
	Host    string
	Port    int
	Name    string
	Version string
}

Config holds configuration for connecting to Freenet node

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a config with sensible defaults

type KeyPair

type KeyPair struct {
	Name       string            `json:"name"`
	Type       string            `json:"type"` // SSK, USK
	PublicKey  string            `json:"public_key"`
	PrivateKey string            `json:"private_key,omitempty"`
	Created    time.Time         `json:"created"`
	Modified   time.Time         `json:"modified"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

KeyPair represents a Freenet key pair

type KeyStore

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

KeyStore manages key storage and retrieval (JSON backend)

func NewKeyStore

func NewKeyStore(path string) (*KeyStore, error)

NewKeyStore creates or loads a key store from the specified path

func (*KeyStore) Add

func (ks *KeyStore) Add(name string, keyPair *KeyPair) error

Add adds a new key pair to the store

func (*KeyStore) Delete

func (ks *KeyStore) Delete(name string) error

Delete removes a key pair from the store

func (*KeyStore) Get

func (ks *KeyStore) Get(name string) (*KeyPair, error)

Get retrieves a key pair by name

func (*KeyStore) List

func (ks *KeyStore) List() ([]string, error)

List returns all key names

func (*KeyStore) ListAll

func (ks *KeyStore) ListAll() ([]*KeyPair, error)

ListAll returns all key pairs

func (*KeyStore) Update

func (ks *KeyStore) Update(name string, keyPair *KeyPair) error

Update updates an existing key pair

type KeyStoreInterface

type KeyStoreInterface interface {
	Add(name string, keyPair *KeyPair) error
	Get(name string) (*KeyPair, error)
	Update(name string, keyPair *KeyPair) error
	Delete(name string) error
	List() ([]string, error)
	ListAll() ([]*KeyPair, error)
}

KeyStoreInterface defines the interface for key storage backends

type Message

type Message struct {
	Name   string
	Fields map[string]string
	Data   []byte
}

Message represents an FCP message with fields and optional payload

func (*Message) String

func (m *Message) String() string

String returns a string representation of a Message

type MessageHandler

type MessageHandler func(*Message) error

MessageHandler is a function that processes incoming messages

type OperationResult

type OperationResult struct {
	Success    bool
	Identifier string
	URI        string
	Data       []byte
	Error      string
	Metadata   map[string]string
}

OperationResult represents the result of an FCP operation

type Operations

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

Operations provides high-level operations on top of the FCP client

func NewOperations

func NewOperations(client *Client) *Operations

NewOperations creates a new Operations instance

func (*Operations) Get

func (o *Operations) Get(ctx context.Context, uri string) (*OperationResult, error)

Get retrieves data from Freenet with a timeout

func (*Operations) GetWithProgress

func (o *Operations) GetWithProgress(ctx context.Context, uri string, progressFn func(succeeded, total int)) (*OperationResult, error)

GetWithProgress retrieves data and provides progress updates

func (*Operations) Put

func (o *Operations) Put(ctx context.Context, uri string, data []byte) (*OperationResult, error)

Put inserts data into Freenet with a timeout

func (*Operations) PutWithProgress

func (o *Operations) PutWithProgress(ctx context.Context, uri string, data []byte, progressFn func(succeeded, total int)) (*OperationResult, error)

PutWithProgress inserts data and provides progress updates

type SQLiteKeyStore

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

SQLiteKeyStore implements KeyStore using SQLite database

func NewSQLiteKeyStore

func NewSQLiteKeyStore(path string) (*SQLiteKeyStore, error)

NewSQLiteKeyStore creates or opens an SQLite-backed key store

func (*SQLiteKeyStore) Add

func (ks *SQLiteKeyStore) Add(name string, keyPair *KeyPair) error

Add adds a new key pair or updates an existing one (upsert)

func (*SQLiteKeyStore) Close

func (ks *SQLiteKeyStore) Close() error

Close closes the database connection

func (*SQLiteKeyStore) Delete

func (ks *SQLiteKeyStore) Delete(name string) error

Delete removes a key pair from the store

func (*SQLiteKeyStore) Export

func (ks *SQLiteKeyStore) Export() ([]byte, error)

Export exports all keys to JSON

func (*SQLiteKeyStore) Get

func (ks *SQLiteKeyStore) Get(name string) (*KeyPair, error)

Get retrieves a key pair by name

func (*SQLiteKeyStore) GetStats

func (ks *SQLiteKeyStore) GetStats() (map[string]interface{}, error)

GetStats returns statistics about the keystore

func (*SQLiteKeyStore) Import

func (ks *SQLiteKeyStore) Import(data []byte) error

Import imports keys from JSON

func (*SQLiteKeyStore) List

func (ks *SQLiteKeyStore) List() ([]string, error)

List returns all key names

func (*SQLiteKeyStore) ListAll

func (ks *SQLiteKeyStore) ListAll() ([]*KeyPair, error)

ListAll returns all key pairs

func (*SQLiteKeyStore) Search

func (ks *SQLiteKeyStore) Search(keyType string, searchTerm string) ([]*KeyPair, error)

Search finds keys matching criteria

func (*SQLiteKeyStore) Update

func (ks *SQLiteKeyStore) Update(name string, keyPair *KeyPair) error

Update updates an existing key pair

type USKCallback

type USKCallback func(uri string, edition int64, newURI string)

USKCallback is called when a USK update is received

type USKManager

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

USKManager handles USK subscriptions

func NewUSKManager

func NewUSKManager(client *Client) *USKManager

NewUSKManager creates a new USK manager

func (*USKManager) GetAllSubscriptions

func (m *USKManager) GetAllSubscriptions() []*USKSubscription

GetAllSubscriptions returns all active subscriptions

func (*USKManager) GetSubscription

func (m *USKManager) GetSubscription(identifier string) *USKSubscription

GetSubscription returns a subscription by identifier

func (*USKManager) Subscribe

func (m *USKManager) Subscribe(uri string, callback USKCallback) (*USKSubscription, error)

Subscribe creates a new USK subscription

func (*USKManager) Unsubscribe

func (m *USKManager) Unsubscribe(identifier string) error

Unsubscribe removes a USK subscription

func (*USKManager) UnsubscribeByURI

func (m *USKManager) UnsubscribeByURI(uri string) error

UnsubscribeByURI removes a USK subscription by URI

type USKSubscription

type USKSubscription struct {
	ID         string
	URI        string
	Edition    int64
	Identifier string
	DontPoll   bool
	Callbacks  []USKCallback
	// contains filtered or unexported fields
}

USKSubscription represents an active USK subscription

type VersionInfo

type VersionInfo struct {
	Version   string
	GoVersion string
	OS        string
	Arch      string
	SourceURL string
	License   string
}

VersionInfo contains version and build information

func GetVersionInfo

func GetVersionInfo() VersionInfo

GetVersionInfo returns complete version information

Jump to

Keyboard shortcuts

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