Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(x int16) int16
- func Listen()
- func Logf(f string, v ...interface{})
- func Logln(v ...interface{})
- func Loglnf(f string, v ...interface{})
- func OpenPort(port uint16, portName string)
- func RequestPeering(peer *Peer) error
- func SendJson(w http.ResponseWriter, data interface{}) error
- func SendPage(w http.ResponseWriter, pageName string) error
- func Start() error
- type Address
- type ApiDefinition
- type ApiPeerInfo
- type CKGame
- type CKMove
- type CKPosition
- type Content
- type Directory
- func (directory Directory) Deregister(service Service) error
- func (directory *Directory) Register(service Service) error
- func (directory Directory) Search(serviceSearched Service) (report ServiceReport, count int)
- func (directory Directory) SearchByDescription(description string) (services []*Service)
- func (directory Directory) SearchByID(id int64) (*Service, error)
- func (directory Directory) SearchByName(name string) (*Service, error)
- type Distance
- type Key
- type Mail
- type Mailbox
- type Move
- type MoveDesc
- type Peer
- func (peer *Peer) Address() Address
- func (peer *Peer) CheckList(peer2 *Peer) RerouteList
- func (peer Peer) Distance(peer2 Peer) Distance
- func (peer Peer) GetList() Peers
- func (peer Peer) Info() (info PeerInfo)
- func (peer *Peer) Ip() string
- func (peer Peer) MarshalPeerData(writer io.Writer, message peerMessage) error
- func (peer *Peer) Name() string
- func (peer *Peer) Port() int
- func (peer *Peer) PortString() string
- func (peer *Peer) SetAddress(address Address) *Peer
- func (peer *Peer) SetIp(ip string) *Peer
- func (peer *Peer) SetName(name string) *Peer
- func (peer *Peer) SetPort(port int) *Peer
- func (peer *Peer) SetState(state State) *Peer
- func (peer *Peer) SetStateInfo(info string) *Peer
- func (peer *Peer) State() State
- func (peer Peer) String() string
- type PeerInfo
- type PeerInfos
- type PeerInfosByZero
- type PeerList
- type Peers
- type PeersByAddress
- type PeersByDistance
- type PeersByName
- type RerouteList
- type Route
- type Service
- type ServiceHandlers
- type ServiceInfo
- type ServiceReport
- type ServiceStarter
- type State
- type Storage
- type StorageBlock
- type StoredData
Constants ¶
View Source
const ( AddressSize = 4 DistMax = 1<<15 - 1 )
View Source
const ( BLANK = iota BLACK WHITE )
View Source
const ( EMPTY = iota PAWN KING )
View Source
const ( ALL = iota REPORT_BY_NAME REPORT_BY_DESCRIPTION REPORT_BY_ID REPORT_CATEGORIES )
View Source
const ( VERSION = "0.0.1" MAX_MESSAGES_IN = 1000 MAX_MESSAGES_OUT = 1000 MAX_MESSAGE_HANDLERS = 100 MAX_MESSAGE_SENDERS = 100 MAX_PEERS = 50 MAX_ACTIVE_PEERS = 500 MGMT_PORT = 80 SERVICE_PORT = 33301 DEFAULT_PORT = 33400 MIN_HOPS = 7 MAX_TTL = 30 BASE_DIR = ".peer-z" )
View Source
const ( MAGIC_NUMBER = 0x0368 RELAY_IP = "delphi.local" RELAY_PORT = 33200 )
View Source
const ( STATE_OFF = iota // peer unreachable STATE_INITIALIZED // peer started STATE_READY // peer ready to receive STATE_CONNECTED // peer connected STATE_PR_SENT // peer request sent STATE_PR_REFUSED // peer request refused STATE_PR_WAIT // peer request accepted STATE_PL_SENT // peerlist sent STATE_PL_WAIT // peerlist replied STATE_RP_SENT // reroute protocol sent STATE_STANDBY // waiting for connection confirmation STATE_RR_PENDING )
Peer state
View Source
const ( M_PING = iota M_ROUTING M_REROUTING )
View Source
const ( MSG_ACK_REQUEST = uint32(1) << iota MSG_ACK MSG_READ_REQUEST MSG_ROUTING_REQUEST MSG_TTL_EXPIRED )
View Source
const ( CMD_PR = iota // peering request CMD_PR_ACK // peering request acknowledgement CMD_PR_NAK // peering requestrefusal CMD_PL // peer list information CMD_PL_ACK // peer listresponse CMD_RP // re-routing proposal CMD_RP_ACK // re-routing proposalacknowledgement CMD_RP_NAK // re-routing proposalrefusal CMD_SR // standby request CMD_SR_ACK // standby request acknowledgement CMD_PR_OK // confirm peering established CMD_RR // Re-routing request CMD_RR_ACK // Re-routing request acknowledgement CMD_RR_NAK // Re-routing request refusal CMD_DR // Disconnect request CMD_DR_ACK // Disconnect request acknowledgement )
View Source
const ( SERVICE_NEW = 1 << iota SERVICE_RENAMED SERVICE_UPDATED SERVICE_ABANDONED )
View Source
const (
MSG_FMT_VERSION = 0x100
)
View Source
const (
SVC_VERSION = 0x0100
)
View Source
const (
TTL_EXPIRED = "Message TTL expired"
)
Variables ¶
View Source
var ( AddressNone = Address{0} BroadcastAddress = Address{65535} )
View Source
var Games []CKGame
View Source
var STATES = map[State]string{ STATE_OFF: "OFF", STATE_INITIALIZED: "Initialized", STATE_READY: "Ready", STATE_CONNECTED: "Connected", STATE_PR_SENT: "PR Sent", STATE_PR_REFUSED: "PR Refused", STATE_PR_WAIT: "PR Wait", STATE_PL_SENT: "PL Sent", STATE_PL_WAIT: "PL Wait", STATE_RP_SENT: "RP Sent", STATE_STANDBY: "Standby", STATE_RR_PENDING: "RR Pending", }
Functions ¶
func RequestPeering ¶
RequestPeering Starts a peering request with peer
func SendJson ¶
func SendJson(w http.ResponseWriter, data interface{}) error
Types ¶
type Address ¶
type Address [AddressSize]uint16
type ApiDefinition ¶
type ApiDefinition struct {
// contains filtered or unexported fields
}
type ApiPeerInfo ¶
type CKMove ¶
type CKMove struct { gorm.Model Color int `json:"color"` Piece int `json:"piece"` Positions []CKPosition `gorm:"foreignKey:MoveID",json:"positions"` GameID int Game CKGame `json:"game"` }
func (CKMove) MarshalJSON ¶
type CKPosition ¶
type CKPosition struct { gorm.Model Row int `json:"row"` Column int `json:"column"` Index int `json:"play"` MoveID int Move CKMove `json:"move"` }
func (CKPosition) String ¶
func (position CKPosition) String() string
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
func (Directory) Deregister ¶
Abandon a service
func (Directory) Search ¶
func (directory Directory) Search(serviceSearched Service) (report ServiceReport, count int)
func (Directory) SearchByDescription ¶
type Mail ¶
type Mail struct { gorm.Model //From Address `gorm:"type:string;default:”"` //To Address `gorm:"type:string;default:”"` DateSent time.Time `json:"dateSent"` DateReceived time.Time `json:"dateReceived"` DateRead time.Time `json:"dateRead"` Subject string `json:"subject"` Body string `json:"body"` Flags uint64 `json:"flags"` Mailboxes []Mailbox `gorm:"many2many:mailbox_messages",json:"mailboxes"` }
type Peer ¶
var Me *Peer
func (*Peer) CheckList ¶
func (peer *Peer) CheckList(peer2 *Peer) RerouteList
func (Peer) MarshalPeerData ¶
func (*Peer) PortString ¶
Return string representation of peer port
type PeerInfo ¶
type PeerInfo struct { Name string `json:"name"` Address Address `json:"address"` IP string `json:"ip"` LocalIp string `json:"localIp"` Port int `json:"port"` Distance Distance `json:"distance"` PeerCount int `json:"peers"` }
func (PeerInfo) ApiInfo ¶
func (peerInfo PeerInfo) ApiInfo() ApiPeerInfo
type PeerInfos ¶
type PeerInfos []PeerInfo
func (PeerInfos) ApiPeerInfos ¶
func (infos PeerInfos) ApiPeerInfos() (apiPeerInfos []ApiPeerInfo)
type PeerInfosByZero ¶
type PeerInfosByZero PeerInfos
func (PeerInfosByZero) Len ¶
func (peerInfos PeerInfosByZero) Len() int
func (PeerInfosByZero) Less ¶
func (peerInfos PeerInfosByZero) Less(i, j int) bool
func (PeerInfosByZero) Swap ¶
func (peerInfos PeerInfosByZero) Swap(i, j int)
type PeersByAddress ¶
type PeersByAddress Peers
func (PeersByAddress) Len ¶
func (peers PeersByAddress) Len() int
func (PeersByAddress) Swap ¶
func (peers PeersByAddress) Swap(i, j int)
type PeersByDistance ¶
type PeersByDistance Peers
func (PeersByDistance) Len ¶
func (peers PeersByDistance) Len() int
func (PeersByDistance) Less ¶
func (peers PeersByDistance) Less(i, j int) bool
func (PeersByDistance) Swap ¶
func (peers PeersByDistance) Swap(i, j int)
type PeersByName ¶
type PeersByName Peers
func (PeersByName) Len ¶
func (peers PeersByName) Len() int
func (PeersByName) Less ¶
func (peers PeersByName) Less(i, j int) bool
func (PeersByName) Swap ¶
func (peers PeersByName) Swap(i, j int)
type RerouteList ¶
func (RerouteList) Bytes ¶
func (rerouteList RerouteList) Bytes() []byte
func (RerouteList) String ¶
func (rerouteList RerouteList) String() string
type Service ¶
type Service struct { Info ServiceInfo `json:"info"` // contains filtered or unexported fields }
func (Service) StartService ¶
func (service Service) StartService()
type ServiceHandlers ¶
type ServiceHandlers []ApiDefinition
func (*ServiceHandlers) AddHandler ¶
func (serviceHandlers *ServiceHandlers) AddHandler(definition ApiDefinition)
type ServiceInfo ¶
type ServiceReport ¶
type ServiceReport [REPORT_CATEGORIES][]*Service
type ServiceStarter ¶
type ServiceStarter interface {
StartService()
}
type StorageBlock ¶
type StorageBlock struct {
// contains filtered or unexported fields
}
type StoredData ¶
type StoredData struct {
// contains filtered or unexported fields
}
func (StoredData) AddBlock ¶
func (storageData StoredData) AddBlock(block StorageBlock)
func (StoredData) Search ¶
func (storageData StoredData) Search(name string) (*StorageBlock, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.