Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bittorrent/go-btns

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bittorrent/go-btns

  • v0.2.0
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-btns

btns record definitions

This package contains all of the components necessary to create, understand, and validate BTNS records. It does not publish or resolve those records. go-btfs uses this package internally to manipulate records.

Usage

To create a new BTNS record:

import (
    "time"

    btns "github.com/bittorrent/go-btns"
    crypto "github.com/libp2p/go-libp2p-crypto"
)

// Generate a private key to sign the BTNS record with. Most of the time, 
// however, you'll want to retrieve an already-existing key from BTFS using the
// go-btfs/core/coreapi CoreAPI.KeyAPI() interface.
privateKey, publicKey, err := crypto.GenerateKeyPair(crypto.RSA, 2048)
if err != nil {
    panic(err)
}

// Create an BTNS record that expires in one hour and points to the BTFS address
// /btfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5
btnsRecord, err := btns.Create(privateKey, []byte("/btfs/Qme1knMqwt1hKZbc1BmQFmnm9f36nyQGwXxPGVpVJ9rMK5"), 0, time.Now().Add(1*time.Hour))
if err != nil {
    panic(err)
}

Once you have the record, you’ll need to use BTFS to publish it.

There are several other major operations you can do with go-btns. Check out the API docs or look at the tests in this repo for examples.

Documentation

https://pkg.go.dev/github.com/bittorrent/go-btns

Contribute

Feel free to join in. All welcome. Open an issue!

License

Copyright (c) Bittorrent.

FAQs

Package last updated on 31 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc