diamnettoml

package
v0.0.0-...-c9303cd Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const DiamNetTomlMaxSize = 100 * 1024

DiamNetTomlMaxSize is the maximum size of diamnet.toml file

View Source
const WellKnownPath = "/.well-known/diamnet.toml"

WellKnownPath represents the url path at which the diamnet.toml file should exist to conform to the federation protocol.

Variables

View Source
var DefaultClient = &Client{HTTP: http.DefaultClient}

DefaultClient is a default client using the default parameters

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTP is the http client used when resolving a DiamNet.toml file
	HTTP HTTP

	// UseHTTP forces the client to resolve against servers using plain HTTP.
	// Useful for debugging.
	UseHTTP bool
}

Client represents a client that is capable of resolving a DiamNet.toml file using the internet.

func (*Client) GetDiamNetToml

func (c *Client) GetDiamNetToml(domain string) (resp *Response, err error)

GetDiamNetToml returns diamnet.toml file for a given domain

Example

ExampleGetTOML gets the diamnet.toml file for coins.asia

_, err := DefaultClient.GetDiamNetToml("coins.asia")
if err != nil {
	log.Fatal(err)
}
Output:

func (*Client) GetDiamNetTomlByAddress

func (c *Client) GetDiamNetTomlByAddress(addy string) (*Response, error)

GetDiamNetTomlByAddress returns diamnet.toml file of a domain fetched from a given address

type ClientInterface

type ClientInterface interface {
	GetDiamNetToml(domain string) (*Response, error)
	GetDiamNetTomlByAddress(addy string) (*Response, error)
}

type HTTP

type HTTP interface {
	Get(url string) (*http.Response, error)
}

HTTP represents the http client that a stellertoml resolver uses to make http requests.

type MockClient

type MockClient struct {
	mock.Mock
}

MockClient is a mockable diamnettoml client.

func (*MockClient) GetDiamNetToml

func (m *MockClient) GetDiamNetToml(domain string) (*Response, error)

GetDiamNetToml is a mocking a method

func (*MockClient) GetDiamNetTomlByAddress

func (m *MockClient) GetDiamNetTomlByAddress(address string) (*Response, error)

GetDiamNetTomlByAddress is a mocking a method

type Response

type Response struct {
	AuthServer       string `toml:"AUTH_SERVER"`
	FederationServer string `toml:"FEDERATION_SERVER"`
	EncryptionKey    string `toml:"ENCRYPTION_KEY"`
	SigningKey       string `toml:"SIGNING_KEY"`
}

Response represents the results of successfully resolving a diamnet.toml file

func GetDiamNetToml

func GetDiamNetToml(domain string) (*Response, error)

GetDiamNetToml returns diamnet.toml file for a given domain

func GetDiamNetTomlByAddress

func GetDiamNetTomlByAddress(addy string) (*Response, error)

GetDiamNetTomlByAddress returns diamnet.toml file of a domain fetched from a given address

Jump to

Keyboard shortcuts

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