Documentation ¶
Index ¶
- func DialSocks(options DialOptions, config *config.EntryConfig) func(ctx context.Context, _, addr string) (net.Conn, error)
- type ContextKeyTargetPublicKey
- type DialOptions
- type NostrAddress
- type NostrConnOption
- type NostrConnection
- func (nc *NostrConnection) Close() error
- func (nc *NostrConnection) LocalAddr() net.Addr
- func (nc *NostrConnection) Read(b []byte) (int, error)
- func (nc *NostrConnection) RemoteAddr() net.Addr
- func (nc *NostrConnection) SetDeadline(_ time.Time) error
- func (nc *NostrConnection) SetReadDeadline(_ time.Time) error
- func (nc *NostrConnection) SetWriteDeadline(_ time.Time) error
- func (nc *NostrConnection) Write(b []byte) (int, error)
- func (nc *NostrConnection) WriteNostrEvent(event nostr.IncomingEvent)
- type NostrDNS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DialSocks ¶
func DialSocks( options DialOptions, config *config.EntryConfig, ) func(ctx context.Context, _, addr string) (net.Conn, error)
DialSocks connects to a destination using the provided SimplePool and returns a Dialer function. It creates a new Connection using the specified context, private key, destination address, It parses the destination address to get the public key and relays. It creates a signed event using the private key, public key, and destination address. It ensures that the relays are available in the pool and publishes the signed event to each relay. Finally, it returns the Connection and nil error. If there are any errors, nil connection and the error are returned.
Types ¶
type ContextKeyTargetPublicKey ¶
type ContextKeyTargetPublicKey string
const TargetPublicKey ContextKeyTargetPublicKey = "TargetPublicKey"
type DialOptions ¶
type NostrAddress ¶
type NostrAddress struct { Nprofile string // contains filtered or unexported fields }
NostrAddress represents a type that holds the profile and public key of a Nostr address.
func (NostrAddress) Network ¶
func (n NostrAddress) Network() string
Network returns the network type of the NostrAddress, which is "nostr".
func (NostrAddress) String ¶
func (n NostrAddress) String() string
type NostrConnOption ¶
type NostrConnOption func(*NostrConnection)
NostrConnOption is a functional option type for configuring NostrConnConfig.
func WithDefaultRelays ¶
func WithDefaultRelays(defaultRelays []string) NostrConnOption
WithPrivateKey sets the private key for the NostrConnConfig.
func WithDst ¶
func WithDst(dst string) NostrConnOption
WithDst is a NostrConnOption function that sets the destination address for the Nostr connection configuration. It takes a string parameter `dst` and updates the `config.dst` field accordingly.
func WithPrivateKey ¶
func WithPrivateKey(privateKey string) NostrConnOption
WithPrivateKey sets the private key for the NostrConnConfig.
func WithSub ¶
func WithSub(...bool) NostrConnOption
WithSub is a function that returns a NostrConnOption. When this option is applied to a NostrConnConfig, it sets the 'sub' field to true, indicating that the connection will handle subscriptions.
func WithTargetPublicKey ¶
func WithTargetPublicKey(pubKey string) NostrConnOption
WithTargetPublicKey sets the private key for the NostrConnConfig.
func WithUUID ¶
func WithUUID(uuid uuid.UUID) NostrConnOption
WithUUID sets the UUID option for creating a NostrConnConfig. It assigns the provided UUID to the config's uuid field.
type NostrConnection ¶
type NostrConnection struct {
// contains filtered or unexported fields
}
NostrConnection implements the net.Conn interface. It is used to establish a connection to Nostr relays. It provides methods for reading and writing data.
func NewConnection ¶
func NewConnection(ctx context.Context, opts ...NostrConnOption) *NostrConnection
NewConnection creates a new NostrConnection object with the provided context and options. It initializes the config with default values, processes the options to customize the config, and creates a new NostrConnection object using the config. If an uuid is provided in the options, it is assigned to the NostrConnection object. The NostrConnection object is then returned.
func (*NostrConnection) Close ¶
func (nc *NostrConnection) Close() error
func (*NostrConnection) LocalAddr ¶
func (nc *NostrConnection) LocalAddr() net.Addr
func (*NostrConnection) Read ¶
func (nc *NostrConnection) Read(b []byte) (int, error)
Read reads data from the connection. The data is decrypted and returned in the provided byte slice. If there is no data available, Read blocks until data arrives or the context is canceled. If the context is canceled before data is received, Read returns an error.
The number of bytes read is returned as n and any error encountered is returned as err. The content of the decrypted message is then copied to the provided byte slice b.
func (*NostrConnection) RemoteAddr ¶
func (nc *NostrConnection) RemoteAddr() net.Addr
func (*NostrConnection) SetDeadline ¶
func (nc *NostrConnection) SetDeadline(_ time.Time) error
func (*NostrConnection) SetReadDeadline ¶
func (nc *NostrConnection) SetReadDeadline(_ time.Time) error
func (*NostrConnection) SetWriteDeadline ¶
func (nc *NostrConnection) SetWriteDeadline(_ time.Time) error
func (*NostrConnection) Write ¶
func (nc *NostrConnection) Write(b []byte) (int, error)
Write writes data to the connection. It delegates the writing logic to handleNostrWrite method. The number of bytes written and error (if any) are returned.
func (*NostrConnection) WriteNostrEvent ¶
func (nc *NostrConnection) WriteNostrEvent(event nostr.IncomingEvent)
WriteNostrEvent writes the incoming event to the subscription channel of the NostrConnection. The subscription channel is used by the Read method to read events and handle them. Parameters: - event: The incoming event to be written to the subscription channel.
type NostrDNS ¶
type NostrDNS struct {
// contains filtered or unexported fields
}
NostrDNS does not resolve anything.