Documentation
¶
Overview ¶
this package contains ipfs helper functions
this package contains ipfs helper functions
this package contains ipfs helper functions
Index ¶
- func AddBytes(node iface.CoreAPI, msg []byte) (cid.Cid, error)
- func AddFsFile(node iface.CoreAPI, pth string) (path.ImmutablePath, error)
- func AddProtobufFile(node iface.CoreAPI, msg proto.Message) (cid.Cid, error)
- func DecryptSecret(secret *pb.Volume_SecretConfig, contents []byte) ([]byte, error)
- func DownloadSecret(ctx context.Context, ipfs iface.CoreAPI, secret *pb.Volume_SecretConfig) ([]byte, error)
- func EncryptSecret(data []byte) (key *pb.Key, contents []byte, err error)
- func GetBytes(node iface.CoreAPI, cid cid.Cid) ([]byte, error)
- func GetFsFile(node iface.CoreAPI, file files.Node, path path.Path, savePath string) error
- func GetIpfsClient(ipfsApi string) (api *rpc.HttpApi, apiMultiaddr multiaddr.Multiaddr, err error)
- func GetProtobufFile(node iface.CoreAPI, cid cid.Cid, msg proto.Message) error
- func ReadSecret(basepath string, secret *pb.Volume_SecretConfig) ([]byte, error)
- func RemoveSecret(ctx context.Context, ipfs iface.CoreAPI, cidBytes []byte) error
- func TransformSecrets(pod *pb.Pod, transformations ...SecretTransformation) error
- func UploadSecret(ctx context.Context, ipfs iface.CoreAPI, contents []byte) (cid []byte, err error)
- type ExistingOption
- type ExposedEndpoint
- type ForwardedConnection
- type IpfsAddr
- type IpfsListener
- type P2PListenerInfoOutput
- type P2PLsOutput
- type P2pApi
- func (api *P2pApi) Connect(protocol string, target multiaddr.Multiaddr) (*IpfsAddr, error)
- func (api *P2pApi) ConnectTo(protocol string, target peer.ID) (*IpfsAddr, error)
- func (api *P2pApi) ExposeEndpoint(protocol string, endpoint multiaddr.Multiaddr, existing ExistingOption) (*ExposedEndpoint, error)
- func (api *P2pApi) ForwardConnection(protocol string, endpoint multiaddr.Multiaddr, target multiaddr.Multiaddr) (*ForwardedConnection, error)
- func (api *P2pApi) Listen(protocol string) (*IpfsListener, error)
- type SecretTransformation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddProtobufFile ¶
Adds a file from a protobuf slice to IPFS
func DecryptSecret ¶
func DecryptSecret(secret *pb.Volume_SecretConfig, contents []byte) ([]byte, error)
func DownloadSecret ¶
func GetFsFile ¶
Saves an IPFS file or directory represented by the given files.Node to the specified local file system path.
func GetIpfsClient ¶
func GetProtobufFile ¶
func ReadSecret ¶
func ReadSecret(basepath string, secret *pb.Volume_SecretConfig) ([]byte, error)
func RemoveSecret ¶
func TransformSecrets ¶
func TransformSecrets(pod *pb.Pod, transformations ...SecretTransformation) error
Types ¶
type ExistingOption ¶
type ExistingOption int
Configures how [ExposeEndpoint] should behave when there is an endpoint for the same protocol already registered by another ExposeEndpoint call.
const ( ConflictExistingEndpoint ExistingOption = 0 // Throw an error (default) ReturnExistingEndpoint ExistingOption = 1 // Return the previously existing endpoint, at which point you can close it or compare it with the desired endpoint. )
type ExposedEndpoint ¶
type ExposedEndpoint struct { P2PListenerInfoOutput // contains filtered or unexported fields }
Represents the low-level counterpart of a IpfsListener; a local endpoint that the kubo node is exposing to the world on a given libp2p protocol.
func (*ExposedEndpoint) Close ¶
func (i *ExposedEndpoint) Close() error
Stop listening on the exposed endpoint, removing it from the node, and making the desired protocol available for future ExposeEndpoint calls. Note that this is not automatically garbage-collected in cases of process crash; if a lingering p2p connection remains, `ipfs p2p close -a` would close all forwarded and exposed connections, while `ipfs p2p close -l /p2p/<own node id> -p <protocol>` would close the specific exposed endpoint.
type ForwardedConnection ¶
type ForwardedConnection struct { P2PListenerInfoOutput // contains filtered or unexported fields }
Represents the low-level counterpart of a IpfsAddr; a local address that the kubo node is listening on and forwarding requests to over a given libp2p protocol.
func (*ForwardedConnection) Close ¶
func (f *ForwardedConnection) Close() error
Stop forwarding connections from the specified address, making the endpoint accessible for futere ForwardConnection calls. Note that this is not automatically garbage-collected in cases of process crash; if a lingering p2p connection remains, `ipfs p2p close -a` would close all forwarded and exposed connections, while `ipfs p2p close -t /p2p/<target node id> -p <protocol>` would close the specific exposed endpoint.
type IpfsAddr ¶
type IpfsAddr struct { net.Addr *ForwardedConnection }
A net.Addr which has been enhanced with a Close() method that can be used to stop forwarding requests for the given connection. You may convert the address to a String() representing the TCP host and port; however, note that this address is only accessible locally and may not be resolvable on other hosts.
type IpfsListener ¶
type IpfsListener struct { net.Listener *ExposedEndpoint }
A net.Listener which has been enhanced with a Close() method that can be used to stop listening for the given connection.
func (*IpfsListener) Close ¶
func (l *IpfsListener) Close() error
Close the local listener as well as the endpoint on the kubo node.
type P2PLsOutput ¶
type P2PLsOutput struct {
Listeners []P2PListenerInfoOutput
}
type P2pApi ¶
type P2pApi struct {
// contains filtered or unexported fields
}
A wrapper around the experimental P2P api of kubo.
func NewP2pApi ¶
Create a new P2pApi given an HttpApi and the IP address where the kubo node resides. The node address is passed as a multiaddr.Multiaddr and is expected to be either a multiaddr that will be accepted by manet.ToNetAddr or the same plus a TCP component at the end which will be stripped off.
func (*P2pApi) Connect ¶
Connect to a given peer (as a /p2p/... multiaddr) over the specified libp2p protocol through the kubo node. Make sure to close the resulting address once you are done using it, for garbage-collection
func (*P2pApi) ConnectTo ¶
Connect to a given peer over the specified libp2p protocol through the kubo node. Make sure to close the resulting address once you are done using it, for garbage-collection.
func (*P2pApi) ExposeEndpoint ¶
func (api *P2pApi) ExposeEndpoint(protocol string, endpoint multiaddr.Multiaddr, existing ExistingOption) (*ExposedEndpoint, error)
Expose an endpoint accessible by the kubo node to the rest of the network over a libp2p protocol. (any peer -> us) The endpoint passed in should be accessible _from_ the kubo node; this methods makes no attempts to fix the network address given. (i.e. this means that passing localhost:XXX for the endpoint will result in the kubo node exposing its own localhost and not the localhost of the machine making the request.)
func (*P2pApi) ForwardConnection ¶
func (api *P2pApi) ForwardConnection(protocol string, endpoint multiaddr.Multiaddr, target multiaddr.Multiaddr) (*ForwardedConnection, error)
Listen on an address on the kubo node and forward connections to a particular peer over a libp2p protocol. (us -> specific peer) The endpoint passed in should be on the kubo node itself; this methods makes no attempts to fix the network address given. (i.e. this means that passing localhost:XXX for the endpoint will result in the kubo node listening on its own localhost -- which is typically precisely the desired effect) The target peer should be a /p2p/... multiaddr.
func (*P2pApi) Listen ¶
func (api *P2pApi) Listen(protocol string) (*IpfsListener, error)
Start listening for a certain libp2p protocol on the kubo node, and forward connections to the returned listener. Make sure to close the resulting listener once you are done using it, for garbage-collection. If another Listen request has been made to the kubo node for the same protocol, this method will produce an error.
type SecretTransformation ¶
type SecretTransformation func(secret *pb.Volume_SecretConfig) error