http

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 26 Imported by: 3

Documentation

Index

Constants

View Source
const CapabilityRLDP2 int64 = 1

Variables

View Source
var Connector = func(ctx context.Context, addr string, peerKey ed25519.PublicKey, ourKey ed25519.PrivateKey) (ADNL, error) {
	return adnl.Connect(ctx, addr, peerKey, ourKey)
}
View Source
var ErrSiteUsesStorage = fmt.Errorf("requested site is static and uses ton storage, you can files using storage.Downloader")
View Source
var Logger = log.Println

Functions

func ParseADNLAddress

func ParseADNLAddress(addr string) ([]byte, error)

func SerializeADNLAddress

func SerializeADNLAddress(addr []byte) (string, error)

Types

type ADNL

type ADNL interface {
	GetID() []byte
	RemoteAddr() string
	Query(ctx context.Context, req, result tl.Serializable) error
	SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey))
	GetDisconnectHandler() func(addr string, key ed25519.PublicKey)
	SetCustomMessageHandler(handler func(msg *adnl.MessageCustom) error)
	SendCustomMessage(ctx context.Context, req tl.Serializable) error
	SetQueryHandler(handler func(msg *adnl.MessageQuery) error)
	GetQueryHandler() func(msg *adnl.MessageQuery) error
	Answer(ctx context.Context, queryID []byte, result tl.Serializable) error
	Close()
}

type ADNLGateway added in v1.6.0

type ADNLGateway interface {
	GetAddressList() address.List
	Close() error
	SetConnectionHandler(func(client adnl.Peer) error)
	SetExternalIP(ip net.IP)
	StartServer(listenAddr string) error
}

type Capabilities added in v1.7.0

type Capabilities struct {
	Value int64 `tl:"long"`
}

type DHT

type DHT interface {
	StoreAddress(ctx context.Context, addresses address.List, ttl time.Duration, ownerKey ed25519.PrivateKey, copies int) (int, []byte, error)
	FindAddresses(ctx context.Context, key []byte) (*address.List, ed25519.PublicKey, error)
	Close()
}

type GetCapabilities added in v1.7.0

type GetCapabilities struct {
	Capabilities int64 `tl:"long"`
}

type GetNextPayloadPart

type GetNextPayloadPart struct {
	ID           []byte `tl:"int256"`
	Seqno        int32  `tl:"int"`
	MaxChunkSize int32  `tl:"int"`
}
type Header struct {
	Name  string `tl:"string"`
	Value string `tl:"string"`
}

type PayloadPart

type PayloadPart struct {
	Data    []byte   `tl:"bytes"`
	Trailer []Header `tl:"vector struct"`
	IsLast  bool     `tl:"bool"`
}

type RLDP

type RLDP interface {
	Close()
	DoQuery(ctx context.Context, maxAnswerSize int64, query, result tl.Serializable) error
	SetOnQuery(handler func(transferId []byte, query *rldp.Query) error)
	SetOnDisconnect(handler func())
	SendAnswer(ctx context.Context, maxAnswerSize int64, queryId, transferId []byte, answer tl.Serializable) error
}

type Request

type Request struct {
	ID      []byte   `tl:"int256"`
	Method  string   `tl:"string"`
	URL     string   `tl:"string"`
	Version string   `tl:"string"`
	Headers []Header `tl:"vector struct"`
}

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, domain string) (*dns.Domain, error)
}

type Response

type Response struct {
	Version    string   `tl:"string"`
	StatusCode int32    `tl:"int"`
	Reason     string   `tl:"string"`
	Headers    []Header `tl:"vector struct"`
	NoPayload  bool     `tl:"bool"`
}

type Server

type Server struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func NewServer

func NewServer(key ed25519.PrivateKey, dht DHT, handler http.Handler) *Server

func (*Server) Address

func (s *Server) Address() []byte

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(listenAddr string) error

func (*Server) SetExternalIP

func (s *Server) SetExternalIP(ip net.IP)

func (*Server) Stop

func (s *Server) Stop() (err error)

type Transport

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

func NewTransport

func NewTransport(dht DHT, resolver Resolver, adnlKey ...ed25519.PrivateKey) *Transport

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(request *http.Request) (_ *http.Response, err error)

Jump to

Keyboard shortcuts

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