p2p

package module
v0.0.0-...-d1f170c Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: Apache-2.0 Imports: 11 Imported by: 2

README

tp-p2p

A teleport-based p2p application framework that penetrates the intranet through TCP tunnel.

developing...

Documentation

Overview

Package p2p is a teleport-based p2p application framework that penetrates the intranet through TCP tunnel.

Copyright 2018 HenryLee. All Rights Reserved.

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

This section is empty.

Variables

This section is empty.

Functions

func Proxy

func Proxy(cfg ProxyConfig)

Types

type ApplyArgs

type ApplyArgs struct {
	FromPeerId string
	ToPeerId   string
}

type ForwardArgs

type ForwardArgs struct {
	TunnelId   string
	FromPeerId string
}

type OnlineArgs

type OnlineArgs struct {
	PeerId string
}

type Peer

type Peer interface {
	tp.EarlyPeer
	Tunnel(peerId string) (tp.Session, *tp.Rerror)
	// Dial connects with the peer of the destination address.
	Dial(addr string, protoFunc ...socket.ProtoFunc) (tp.Session, *tp.Rerror)
	// DialContext connects with the peer of the destination address, using the provided context.
	DialContext(ctx context.Context, addr string, protoFunc ...socket.ProtoFunc) (tp.Session, *tp.Rerror)
	// ServeConn serves the connection and returns a session.
	ServeConn(conn net.Conn, protoFunc ...socket.ProtoFunc) (tp.Session, error)
}

Peer the communication peer which is server or client role

func NewPeer

func NewPeer(cfg PeerConfig, plugin ...tp.Plugin) Peer

type PeerConfig

type PeerConfig struct {
	PeerId             string        `yaml:"peer_id" ini:"peer_id" comment:"p2p tunel config"`
	Proxy              string        `yaml:"proxy"   ini:"proxy"   comment:"p2p tunel config"`
	DefaultDialTimeout time.Duration `` /* 135-byte string literal not displayed */
	DefaultBodyCodec   string        `yaml:"default_body_codec"   ini:"default_body_codec"   comment:"Default body codec type id"`
	DefaultSessionAge  time.Duration `` /* 148-byte string literal not displayed */
	DefaultContextAge  time.Duration `` /* 161-byte string literal not displayed */
	SlowCometDuration  time.Duration `yaml:"slow_comet_duration"  ini:"slow_comet_duration"  comment:"Slow operation alarm threshold; ns,µs,ms,s ..."`
	PrintDetail        bool          `yaml:"print_detail"         ini:"print_detail"         comment:"Is print body and metadata or not"`
	CountTime          bool          `yaml:"count_time"           ini:"count_time"           comment:"Is count cost time or not"`
}

PeerConfig p2p tunel config

func (*PeerConfig) Reload

func (p *PeerConfig) Reload(bind cfgo.BindFunc) error

Reload Bi-directionally synchronizes config between YAML file and memory.

type ProxyConfig

type ProxyConfig struct {
	ListenAddress     string        `yaml:"listen_address"      ini:"listen_address"      comment:"Listen address; for server role"`
	SlowCometDuration time.Duration `yaml:"slow_comet_duration" ini:"slow_comet_duration" comment:"Slow operation alarm threshold; ns,µs,ms,s ..."`
	CountTime         bool          `yaml:"count_time"          ini:"count_time"          comment:"Is count cost time or not"`
}

ProxyConfig proxy peer config Note:

yaml tag is used for github.com/henrylee2cn/cfgo
ini tag is used for github.com/henrylee2cn/ini

func (*ProxyConfig) Reload

func (p *ProxyConfig) Reload(bind cfgo.BindFunc) error

Reload Bi-directionally synchronizes config between YAML file and memory.

type ReplyArgs

type ReplyArgs struct {
	TunnelId string
}

type TunnelAddrs

type TunnelAddrs struct {
	TunnelId   string
	LocalAddr  string
	RemoteAddr string
}

type TunnelInfo

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

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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