Documentation ¶
Index ¶
- Constants
- func RegisterContactUnserializer(contactType string, ...)
- func RegisterServiceType(serviceType string)
- type AccessPolicy
- type AccessPolicyRuleSet
- type AccessRule
- type Contact
- type ContactDefinition
- type ContactDefinitionUnserializer
- type ContactList
- type LatestPrices
- type Location
- type NewProposalOpts
- type Price
- type PriceByServiceType
- type PriceByType
- type PriceHistory
- type ProposalID
- type Quality
- type ServiceProposal
- type UnsupportedContactType
Constants ¶
const ( // AccessPolicyTypeIdentity Explicitly allow just specific identities ("0xd1faed693fec75389c3d1e59b863e4835ac6f5d1") AccessPolicyTypeIdentity = "identity" // AccessPolicyTypeDNSHostname Explicitly allow just specific hostname ("ipinfo.io") AccessPolicyTypeDNSHostname = "dns_hostname" // AccessPolicyTypeDNSZone Explicitly allow just specific DNS zone ("example.com" matches "example.com" and all of its subdomains) AccessPolicyTypeDNSZone = "dns_zone" )
Variables ¶
This section is empty.
Functions ¶
func RegisterContactUnserializer ¶
func RegisterContactUnserializer(contactType string, unserializer func(*json.RawMessage) (ContactDefinition, error))
RegisterContactUnserializer registers unserializer for specified contact type.
func RegisterServiceType ¶
func RegisterServiceType(serviceType string)
RegisterServiceType registers a supported service type.
Types ¶
type AccessPolicy ¶
AccessPolicy represents the access controls for proposal
type AccessPolicyRuleSet ¶
type AccessPolicyRuleSet struct { ID string `json:"id"` Title string `json:"title"` Description string `json:"description"` Allow []AccessRule `json:"allow"` }
AccessPolicyRuleSet represents named list with rules specifying whether access is allowed
type AccessRule ¶
AccessRule represents rule specifying whether connection should be allowed
type Contact ¶
type Contact struct { Type string `json:"type"` Definition ContactDefinition `json:"definition"` }
Contact represents contact object with type and concrete definition according to type
type ContactDefinition ¶
type ContactDefinition interface { }
ContactDefinition is interface for contacts of all types
type ContactDefinitionUnserializer ¶
type ContactDefinitionUnserializer func(*json.RawMessage) (ContactDefinition, error)
ContactDefinitionUnserializer represents function which called for concrete contact type to unserialize
type ContactList ¶
type ContactList []Contact
ContactList is list of Contact structures, to have custom JSON marshaling
func (ContactList) MarshalJSON ¶
func (list ContactList) MarshalJSON() ([]byte, error)
MarshalJSON encodes in such manner that `null` situation avoided in JSON
type LatestPrices ¶
type LatestPrices struct { Defaults *PriceHistory `json:"defaults"` PerCountry map[string]*PriceHistory `json:"per_country"` CurrentValidUntil time.Time `json:"current_valid_until"` PreviousValidUntil time.Time `json:"previous_valid_until"` CurrentServerTime time.Time `json:"current_server_time,omitempty"` }
LatestPrices represents the latest pricing.
type Location ¶
type Location struct { Continent string `json:"continent,omitempty"` Country string `json:"country,omitempty"` Region string `json:"region,omitempty"` City string `json:"city,omitempty"` ASN int `json:"asn,omitempty"` ISP string `json:"isp,omitempty"` IPType string `json:"ip_type,omitempty"` }
Location struct represents geographic location of service provider
func NewLocation ¶
func NewLocation(loc locationstate.Location) *Location
NewLocation creates a new Location.
type NewProposalOpts ¶
type NewProposalOpts struct { Location *Location AccessPolicies []AccessPolicy Contacts []Contact Quality *Quality }
NewProposalOpts optional params for the new proposal creation.
type Price ¶
type Price struct { PricePerHour *big.Int `json:"price_per_hour"` PricePerGiB *big.Int `json:"price_per_gib"` }
Price represents the price.
type PriceByServiceType ¶
type PriceByServiceType struct { Wireguard *Price `json:"wireguard"` Scraping *Price `json:"scraping"` DataTransfer *Price `json:"data_transfer"` DVPN *Price `json:"dvpn"` }
PriceByServiceType is a slice of pricing by service type.
type PriceByType ¶
type PriceByType struct { Residential *PriceByServiceType `json:"residential"` Other *PriceByServiceType `json:"other"` }
PriceByType is a slice of pricing by type.
type PriceHistory ¶
type PriceHistory struct { Current *PriceByType `json:"current"` Previous *PriceByType `json:"previous"` }
PriceHistory represents the current and previous price.
type ProposalID ¶
type ProposalID struct { // Type of service type offered ServiceType string // Unique identifier of a provider ProviderID string // Per provider unique serial number of service description provided // TODO Not supported yet ID int }
ProposalID defines composite ID to identify unique proposal discovery of Mysterium Network
type Quality ¶
type Quality struct { Quality float64 `json:"quality"` Latency float64 `json:"latency"` Bandwidth float64 `json:"bandwidth"` Uptime float64 `json:"uptime"` PacketLoss float64 `json:"packetLoss"` }
Quality represents service quality.
type ServiceProposal ¶
type ServiceProposal struct { ID int64 `json:"id"` // A version number is included in the proposal to allow extensions to the proposal format Format string `json:"format"` Compatibility int `json:"compatibility"` // Unique identifier of a provider ProviderID string `json:"provider_id"` // Type of service type offered ServiceType string `json:"service_type"` // Service location Location Location `json:"location"` // Communication methods possible Contacts ContactList `json:"contacts"` // AccessPolicies represents the access controls for proposal AccessPolicies *[]AccessPolicy `json:"access_policies,omitempty"` // Quality represents the service quality. Quality Quality `json:"quality"` }
ServiceProposal is top level structure which is presented to marketplace by service provider, and looked up by service consumer service proposal can be marked as unsupported by deserializer, because of unknown service, payment method, or contact type
func NewProposal ¶
func NewProposal(providerID, serviceType string, opts NewProposalOpts) ServiceProposal
NewProposal creates a new proposal.
func (*ServiceProposal) IsSupported ¶
func (proposal *ServiceProposal) IsSupported() bool
IsSupported returns true if this service proposal can be used for connections by service consumer can be used as a filter to filter out all proposals which are unsupported for any reason
func (*ServiceProposal) UniqueID ¶
func (proposal *ServiceProposal) UniqueID() ProposalID
UniqueID returns unique proposal composite ID
func (*ServiceProposal) UnmarshalJSON ¶
func (proposal *ServiceProposal) UnmarshalJSON(data []byte) error
UnmarshalJSON is custom json unmarshaler to dynamically fill in ServiceProposal values
func (*ServiceProposal) Validate ¶
func (proposal *ServiceProposal) Validate() error
Validate validates the proposal.
type UnsupportedContactType ¶
type UnsupportedContactType struct { }
UnsupportedContactType is a contact which is returned by unserializer when encountering unregistered types of contact