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 ForwardArgs ¶
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
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
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
type TunnelAddrs ¶
type TunnelInfo ¶
type TunnelInfo struct {
// contains filtered or unexported fields
}