seed

package
v0.0.0-...-8abf890 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

* Copyright 2019-2021 Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2019-2021 Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2019-2021 Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

* Copyright 2019-2021 Yuji Ito <llamerada.jp@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.

Index

Constants

View Source
const (
	// version
	ProtocolVersion = "A2"

	// Node ID.
	NidStrNone    = ""
	NidStrThis    = "."
	NidStrSeed    = "seed"
	NidStrNext    = "next"
	NidTypeNone   = 0
	NidTypeNormal = 1
	NidTypeThis   = 2
	NidTypeSeed   = 3
	NidTypeNext   = 4

	// Packet mode.
	ModeNone      = 0x0000
	ModeResponse  = 0x0001
	ModeExplicit  = 0x0002
	ModeOneWay    = 0x0004
	ModeRelaySeed = 0x0008
	ModeNoRetry   = 0x0010

	ChannelNone         = 0
	ChannelMain         = 1
	ChannelSeedAccessor = 2
	ChannelNodeAccessor = 3

	// Commonly packet method.
	MethodError   = 0xffff
	MethodFailure = 0xfffe
	MethodSuccess = 0xfffd

	MethodSeedAuth          = 1
	MethodSeedHint          = 2
	MethodSeedPing          = 3
	MethodSeedRequireRandom = 4

	MethodWebrtcConnectOffer = 1

	// Offer type of WebRTC connect.
	OfferTypeFirst = 0

	// Hint
	HintOnlyOne       = uint32(0x01)
	HintRequireRandom = uint32(0x02)

	// Key of routineLocal
	GroupMutex = 1
	LinkMutex  = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	SessionTimeout int64       `json:"sessionTimeout"`
	PollingTimeout int64       `json:"pollingTimeout"`
	Node           *ConfigNode `json:"node,omitempty"`
}

type ConfigCoordSystem2D

type ConfigCoordSystem2D struct {
	Type *string `json:"type,omitempty"`
	// for sphere
	Radius *float64 `json:"radius,omitempty"`
	// for plane
	XMin *float64 `json:"xMin,omitempty"`
	XMax *float64 `json:"xMax,omitempty"`
	YMin *float64 `json:"yMin,omitempty"`
	YMax *float64 `json:"yMax,omitempty"`
}

type ConfigIceServer

type ConfigIceServer struct {
	Urls       []string `json:"urls,omitempty"`
	Username   *string  `json:"username,omitempty"`
	Credential *string  `json:"credential,omitempty"`
}

type ConfigKvs

type ConfigKvs struct {
	RetryMax         *uint32 `json:"retryMax,omitempty"`
	RetryIntervalMin *uint32 `json:"retryIntervalMin,omitempty"`
	RetryIntervalMax *uint32 `json:"retryIntervalMax,omitempty"`
}

type ConfigNode

type ConfigNode struct {
	Revision      float64              `json:"revision"`
	NodeAccessor  *ConfigNodeAccessor  `json:"nodeAccessor,omitempty"`
	CoordSystem2d *ConfigCoordSystem2D `json:"coordSystem2D,omitempty"`
	IceServers    []ConfigIceServer    `json:"iceServers,omitempty"`
	Routing       *ConfigRouting       `json:"routing,omitempty"`
	Kvs           *ConfigKvs           `json:"kvs,omitempty"`
	Spread        *ConfigSpread        `json:"spread,omitempty"`
}

type ConfigNodeAccessor

type ConfigNodeAccessor struct {
	BufferInterval *uint32 `json:"bufferInterval,omitempty"`
	HopCountMax    *uint32 `json:"hopCountMax,omitempty"`
	PacketSize     *uint32 `json:"packetSize,omitempty"`
}

type ConfigRouting

type ConfigRouting struct {
	ForceUpdateCount        *uint32  `json:"forceUpdateCount,omitempty"`
	SeedConnectInterval     *uint32  `json:"seedConnectInterval,omitempty"`
	SeedConnectRate         *uint32  `json:"seedConnectRate,omitempty"`
	SeedDisconnectThreshold *uint32  `json:"seedDisconnectThreshold,omitempty"`
	SeedInfoKeepThreshold   *uint32  `json:"seedInfoKeepThreshold,omitempty"`
	SeedInfoNidsCount       *uint32  `json:"seedInfoNidsCount,omitempty"`
	SeedNextPosition        *float64 `json:"seedNextPosition,omitempty"`
	UpdatePeriod            *uint32  `json:"updatePeriod,omitempty"`
}

type ConfigSpread

type ConfigSpread struct {
	CacheTime *uint32 `json:"cacheTime,omitempty"`
}

type ContextKeyType

type ContextKeyType string
const CONTEXT_REQUEST_KEY ContextKeyType = "requestID"

*

  • CONTEXT_REQUEST_KEY is used to describe the request id for logs.
  • caller module can set the request id for the value to `http.Request.ctx` using this key.

type Seed

type Seed struct {
	Handler http.Handler
	// contains filtered or unexported fields
}

func NewSeed

func NewSeed(config *Config, verifier TokenVerifier) (*Seed, error)

*

  • NewSeedHandler creates an http handler to provide colonio's seed.
  • It also starts a go routine for the seed features.

func (*Seed) Start

func (seed *Seed) Start(ctx context.Context)

type TokenVerifier

type TokenVerifier interface {
	Verify(token string) (bool, error)
}

*

  • TokenVerifier is an interface to implement the function of verifying the token received from the node.

Jump to

Keyboard shortcuts

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