Documentation ¶
Index ¶
- Constants
- Variables
- func ClassifyFeatureCount(features []*NatFeature) (int, int, int)
- func DecodeMessageInto(data, key []byte, m msg.Message) error
- func Discover(stunServers []string, localAddr string) ([]string, net.Addr, error)
- func EncodeMessage(m msg.Message, key []byte) ([]byte, error)
- func ExchangeInfo(ctx context.Context, transporter transport.MessageTransporter, laneKey string, ...) (*msg.NatHoleResp, error)
- func ListAllLocalIPs() ([]net.IP, error)
- func ListLocalIPsForNatHole(max int) ([]string, error)
- func MakeHole(ctx context.Context, listenConn *net.UDPConn, m *msg.NatHoleResp, key []byte) (*net.UDPConn, *net.UDPAddr, error)
- func NewTransactionID() string
- func PreCheck(ctx context.Context, transporter transport.MessageTransporter, ...) error
- type Analyzer
- type BehaviorScore
- type ChangedAddress
- type ClientCfg
- type Controller
- func (c *Controller) CleanWorker(ctx context.Context)
- func (c *Controller) CloseClient(name string)
- func (c *Controller) GenNatHoleResponse(transactionID string, session *Session, errInfo string) *msg.NatHoleResp
- func (c *Controller) GenSid() string
- func (c *Controller) HandleClient(m *msg.NatHoleClient, transporter transport.MessageTransporter)
- func (c *Controller) HandleReport(m *msg.NatHoleReport)
- func (c *Controller) HandleVisitor(m *msg.NatHoleVisitor, transporter transport.MessageTransporter, ...)
- func (c *Controller) ListenClient(name string, sk string, allowUsers []string) (chan string, error)
- type MakeHoleRecords
- type Message
- type NatFeature
- type PrepareResult
- type RecommandBehavior
- type Session
Constants ¶
View Source
const ( EasyNAT = "EasyNAT" HardNAT = "HardNAT" BehaviorNoChange = "BehaviorNoChange" BehaviorIPChanged = "BehaviorIPChanged" BehaviorPortChanged = "BehaviorPortChanged" BehaviorBothChanged = "BehaviorBothChanged" )
Variables ¶
View Source
var ( // mode 0: simple detect mode, usually for both EasyNAT or HardNAT & EasyNAT(Public Network) // a. receiver sends detect message with low TTL // b. sender sends normal detect message to receiver // c. receiver receives detect message and sends back a message to sender // // mode 1: For HardNAT & EasyNAT, send detect messages to multiple guessed ports. // Usually applicable to scenarios where port changes are regular. // Most of the steps are the same as mode 0, but EasyNAT is fixed as the receiver and will send detect messages // with low TTL to multiple guessed ports of the sender. // // mode 2: For HardNAT & EasyNAT, ports changes are not regular. // a. HardNAT machine will listen on multiple ports and send detect messages with low TTL to EasyNAT machine // b. EasyNAT machine will send detect messages to random ports of HardNAT machine. // // mode 3: For HardNAT & HardNAT, both changes in the ports are regular. // Most of the steps are the same as mode 1, but the sender also needs to send detect messages to multiple guessed // ports of the receiver. // // mode 4: For HardNAT & HardNAT, one of the changes in the ports is regular. // Regular port changes are usually on the sender side. // a. Receiver listens on multiple ports and sends detect messages with low TTL to the sender's guessed range ports. // b. Sender sends detect messages to random ports of the receiver. SupportedModes = []int{DetectMode0, DetectMode1, DetectMode2, DetectMode3, DetectMode4} SupportedRoles = []string{DetectRoleSender, DetectRoleReceiver} DetectMode0 = 0 DetectMode1 = 1 DetectMode2 = 2 DetectMode3 = 3 DetectMode4 = 4 DetectRoleSender = "sender" DetectRoleReceiver = "receiver" )
View Source
var NatHoleTimeout int64 = 10
NatHoleTimeout seconds.
Functions ¶
func ClassifyFeatureCount ¶
func ClassifyFeatureCount(features []*NatFeature) (int, int, int)
func ExchangeInfo ¶
func ExchangeInfo( ctx context.Context, transporter transport.MessageTransporter, laneKey string, m msg.Message, timeout time.Duration, ) (*msg.NatHoleResp, error)
ExchangeInfo is used to exchange information between client and visitor. 1. Send input message to server by msgTransporter. 2. Server will gather information from client and visitor and analyze it. Then send back a NatHoleResp message to them to tell them how to do next. 3. Receive NatHoleResp message from server.
func ListAllLocalIPs ¶
func ListLocalIPsForNatHole ¶
func MakeHole ¶
func MakeHole(ctx context.Context, listenConn *net.UDPConn, m *msg.NatHoleResp, key []byte) (*net.UDPConn, *net.UDPAddr, error)
MakeHole is used to make a NAT hole between client and visitor.
func NewTransactionID ¶
func NewTransactionID() string
Types ¶
type Analyzer ¶
type Analyzer struct {
// contains filtered or unexported fields
}
func NewAnalyzer ¶
func (*Analyzer) GetRecommandBehaviors ¶
func (a *Analyzer) GetRecommandBehaviors(key string, c, v *NatFeature) (mode, index int, _ RecommandBehavior, _ RecommandBehavior)
func (*Analyzer) ReportSuccess ¶
type BehaviorScore ¶
type ChangedAddress ¶
func (*ChangedAddress) GetFrom ¶
func (s *ChangedAddress) GetFrom(m *stun.Message) error
func (*ChangedAddress) String ¶
func (s *ChangedAddress) String() string
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(analysisDataReserveDuration time.Duration) (*Controller, error)
func (*Controller) CleanWorker ¶
func (c *Controller) CleanWorker(ctx context.Context)
func (*Controller) CloseClient ¶
func (c *Controller) CloseClient(name string)
func (*Controller) GenNatHoleResponse ¶
func (c *Controller) GenNatHoleResponse(transactionID string, session *Session, errInfo string) *msg.NatHoleResp
func (*Controller) GenSid ¶
func (c *Controller) GenSid() string
func (*Controller) HandleClient ¶
func (c *Controller) HandleClient(m *msg.NatHoleClient, transporter transport.MessageTransporter)
func (*Controller) HandleReport ¶
func (c *Controller) HandleReport(m *msg.NatHoleReport)
func (*Controller) HandleVisitor ¶
func (c *Controller) HandleVisitor(m *msg.NatHoleVisitor, transporter transport.MessageTransporter, visitorUser string)
func (*Controller) ListenClient ¶
type MakeHoleRecords ¶
func NewMakeHoleRecords ¶
func NewMakeHoleRecords(c, v *NatFeature) *MakeHoleRecords
func (*MakeHoleRecords) Recommand ¶
func (mhr *MakeHoleRecords) Recommand() (mode, index int)
func (*MakeHoleRecords) ReportSuccess ¶
func (mhr *MakeHoleRecords) ReportSuccess(mode int, index int)
type NatFeature ¶
type NatFeature struct { NatType string Behavior string PortsDifference int RegularPortsChange bool PublicNetwork bool }
func ClassifyNATFeature ¶
func ClassifyNATFeature(addresses []string, localIPs []string) (*NatFeature, error)
type PrepareResult ¶
type PrepareResult struct { Addrs []string AssistedAddrs []string ListenConn *net.UDPConn NatType string Behavior string }
func Prepare ¶
func Prepare(stunServers []string) (*PrepareResult, error)
Prepare is used to do some preparation work before penetration.
type RecommandBehavior ¶
Click to show internal directories.
Click to hide internal directories.