Documentation ¶
Index ¶
- Constants
- func IsRFC1918(ip net.IP) bool
- type ActiveInterface
- type Gateway
- func (gw *Gateway) ActiveTCP() map[int]*streams.TcpProxy
- func (gw *Gateway) Close()
- func (gw *Gateway) Dial(tp *streams.TcpProxy, dest string, addr *net.TCPAddr) error
- func (gw *Gateway) DialContext(ctx context.Context, network, addr string) (conn net.Conn, e error)
- func (gw *Gateway) DialMesh(tp *streams.TcpProxy) error
- func (gw *Gateway) DialMeshLocal(tp *streams.TcpProxy, node *ugate.DMNode) bool
- func (gw *Gateway) DialProxy(ctx context.Context, addr net.Addr, directClientAddr net.Addr, ctype string, ...) (net.Conn, func(client net.Conn) error, error)
- func (gw *Gateway) FreeIdleSockets()
- func (gw *Gateway) GetNodeByID(dmFrom uint64) (*ugate.DMNode, bool)
- func (gw *Gateway) HandleTUN(conn net.Conn, target *net.TCPAddr) error
- func (gw *Gateway) HttpAllTCP(w http.ResponseWriter, r *http.Request)
- func (gw *Gateway) HttpGetNodes(w http.ResponseWriter, r *http.Request)
- func (gw *Gateway) HttpNodesFilter(w http.ResponseWriter, r *http.Request)
- func (gw *Gateway) HttpTCP(w http.ResponseWriter, r *http.Request)
- func (gw *Gateway) IsMeshAddr(host net.IP) bool
- func (gw *Gateway) IsMeshHost(hostport string) bool
- func (gw *Gateway) NewStream(acceptClientAddr net.IP, remotePort uint16, ctype string, initialData []byte, ...) interface{}
- func (gw *Gateway) NewTcpProxy(src net.Addr, ctype string, initialData []byte, clientIn io.ReadCloser, ...) *streams.TcpProxy
- func (gw *Gateway) Node(pub []byte) *ugate.DMNode
- func (gw *Gateway) OnProxyClose(tp *streams.TcpProxy)
- func (gw *Gateway) Status() (int, int, int, int)
- type MeshDevice
- type ScanResults
- type WifiRegistrationInfo
Constants ¶
const (
TopicConnectUP = "connectUP"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActiveInterface ¶
type ActiveInterface struct { // Interface name. Name containing 'p2p' results in specific behavior. Name string // IP6 link local address. May be nil if IPPub is set. // One or the other must be set. IP6LL net.IP // IP4 address - may be a routable address, nil or private address. // If public address - may be included in the register, but typically not // useful. IP4 net.IP // Public addresses. IP6 address may be used for direct connections (in some // cases) IPPub []net.IP // Port for the UDP unicast link-local listener. Port int // Port for the UDP unicast link-local listener. Port4 int // True if this interface is an Android AP AndroidAP bool // True if this interface is connected to an Android DM node. AndroidAPClient bool }
Track one interface.
type Gateway ¶
type Gateway struct { *ugates.UGate // Vpn is the currently active VPN server. Will be selected from the list of // known VPN servers (in future - for now hardcoded to the test server) Vpn string // User agent - hostname or android build id or custom. UA string ActiveTcp map[int]*streams.TcpProxy AllTcpCon map[string]*ugate.HostStats // DNS forward DNS requests, may resolve local addresses DNS ugate.IPResolver // SSHClientConn-based gateway SSHGate ugate.Transport // Client to VPN SSHClient ugate.MuxedConn JumpHosts map[string]ugate.MuxedConn // Client to mesh expansion - not trusted, set when mesh expansion is in use. // Used as a jump host to connect to the next destination. // TODO: allow multiple addresses. // TODO: this can also be used as 'egressGateway' SSHClientUp ugate.MuxedConn Auth *auth.Auth // contains filtered or unexported fields }
Gateway is the main capture API.
func (*Gateway) Dial ¶
dest can be: - hostname:port - [IP]:port - [MESHIP6]/dest
"addr" is used for TUN, Iptables, SOCKS(with IP), when only destination IP is known. Name may be available in dns cache.
addr and dest can be mesh IP6 or regular external IP.
Note that DialIP may already stream bytes from localIn if the call is successful - for HTTP proxy it uses a Request, and the body starts getting read and streammed after headers. The data from the remote will need to be proxied to localOut manually.
Init a connection to the destination. Will attempt to find a route, may call 'DialXXX' several times to find a path. Route discovery and other overhead expected.
In case of error, caller should close local in/out streams
func (*Gateway) DialContext ¶
Implements the http.Transport.DialContext function - used for dialing requests using custom net.Conn.
Also implements x.net.proxy.ContextDialer - socks also implements it.
func (*Gateway) DialMesh ¶
DialMesh creates a circuit to a mesh host: - if a local address is known, will be used directly - if an IP address is known, will be used directly - otherwise, will send up to the parent
The circuit is currently NOT encrypted E2E - each host on the path can see the content, similar with the ISP or a Wifi access point. After the circuit is created e2e encryption should be added - typically this is used for HTTPS connections. Tor-like obfuscation is not supported yet.
dest - the destionation, in [IP6]:port format addr - the address. host - in this case will be an IPv6 - all mesh hosts are in this form port - is the port to use on the mesh node. The real port used is the mesh port from registry
func (*Gateway) DialMeshLocal ¶
DialMeshLocal will connect to a node that is locally known - has a MUX connection, local IP or external IP.
func (*Gateway) DialProxy ¶
func (gw *Gateway) DialProxy(ctx context.Context, addr net.Addr, directClientAddr net.Addr, ctype string, meta ...string) (net.Conn, func(client net.Conn) error, error)
Glue for interface type. Called when a new captured TCP connection is accepted and src/dst meta decoded.
func (*Gateway) FreeIdleSockets ¶
func (gw *Gateway) FreeIdleSockets()
func (*Gateway) GetNodeByID ¶
Used by the mesh router to find the GW address based on IP
func (*Gateway) HttpAllTCP ¶
func (gw *Gateway) HttpAllTCP(w http.ResponseWriter, r *http.Request)
func (*Gateway) HttpGetNodes ¶
func (gw *Gateway) HttpGetNodes(w http.ResponseWriter, r *http.Request)
HttpGetNodes (/dmesh/ip6) returns the list of known nodes, both direct and indirect. This allows nodes to sync the mesh routing table.
func (*Gateway) HttpNodesFilter ¶
func (gw *Gateway) HttpNodesFilter(w http.ResponseWriter, r *http.Request)
HttpGetNodes (/dmesh/ip6) returns the list of known nodes, both direct and indirect. This allows nodes to sync the mesh routing table.
func (*Gateway) IsMeshHost ¶
func (*Gateway) NewStream ¶
func (gw *Gateway) NewStream(acceptClientAddr net.IP, remotePort uint16, ctype string, initialData []byte, clientIn io.ReadCloser, clientOut io.Writer) interface{}
Glue for interface type. Called when a new captured TCP connection is accepted and src/dst meta decoded.
func (*Gateway) NewTcpProxy ¶
func (gw *Gateway) NewTcpProxy(src net.Addr, ctype string, initialData []byte, clientIn io.ReadCloser, clientOut io.Writer) *streams.TcpProxy
Initiate and track the TcpProxy object. Requires an "Id" key to be set - based on the source only. ctype represents the type of the acceptor.
src is typically the 'previous hop' - i.e. the IP address and port accepting the connection. The original source may be different.
clientOut can be a http.ResponseWriter or net.Conn
func (*Gateway) OnProxyClose ¶
type MeshDevice ¶
type MeshDevice struct { SSID string `json:"s,omitempty"` PSK string `json:"p,omitempty"` // MAC is used with explicit P2P connect ( i.e. no hacks ) // User input required on the receiving end ( PBC ) MAC string `json:"d,omitempty"` Name string `json:"N,omitempty"` // Set only if the device is currently visible in scan Level int `json:"l,omitempty"` Freq int `json:"f,omitempty"` // Extracted from DIRECT DNSSD UserAgent string `json:"ua,omitempty"` Net string `json:"n,omitempty"` Cap string `json:"c,omitempty"` BSSID string `json:"b,omitempty"` LastSeen time.Time `json:"lastSeen,omitempty"` Self int `json:"self,omitempty"` // Only on supplicant,not on android ServiceUpdateInd int `json:"sui,omitempty"` }
Info about a device from the P2P info.
func (*MeshDevice) String ¶
func (md *MeshDevice) String() string
type ScanResults ¶
type ScanResults struct { // Visible devices at this moment Scan []*MeshDevice `json:"scan,omitempty"` Stats string `json:"stat,omitempty"` // Visible wifi networks (all kinds) Visible int `json:"visible,omitempty"` // My SSID and PSK SSID string `json:"s,omitempty"` PSK string `json:"p,omitempty"` ConnectedWifi string `json:"w,omitempty"` Freq int `json:"f,omitempty"` Level int `json:"l,omitempty"` }
type WifiRegistrationInfo ¶
type WifiRegistrationInfo struct { // Visible P2P devices in the mesh. This includes active APs as well as devices announcing via // BLE or NAN (or other means). Devices map[string]*MeshDevice `json:"devices,omitempty"` SSID string `json:"ssid,omitempty"` PSK string `json:"psk,omitempty"` // Network we are connected to. // TODO: In case of chained P2P networks, should be either the path, or a separate field should include the path // and the net should be the 'top level' network of the root. Net string `json:"net,omitempty"` // Number of visible wifi networks (all kinds) VisibleWifi int `json:"scanCnt,omitempty"` }
WifiRegistrationInfo contains information about the wifi node sent to the other nodes, to sync up visibility info.