Documentation
¶
Index ¶
- Constants
- func GetLocalIp() string
- func LogGO(level C.int, logString *C.char)
- func OneConnectGO(id C.uint64, connType C.int, localIp *C.char, localPort C.uint16, ...) C.int
- func ReceivePacketsGO(id C.uint64, remoteIp *C.char, remotePort C.uint16, connType C.int, ...) C.int
- func RunDriver(localTcpProxyAddr, localUdpProxyAddr, dnsServer string, ...) bool
- func RunTun(address, dnsServer, routeTxt string, proxy Proxy) bool
- func SendToAdapter(id uint64, isFromRemoteBind int, remoteIp string, remotePort uint16, ...) int
- func TunClose(id uint64) int
- func TunConnectionStatusGO(id C.uint64) C.int
- func TunPrintMemInfo()
- type AdapterConnMgr
- func (cm *AdapterConnMgr) AcceptConnection(id uint64, connType int, localAddr string, remoteAddr string) bool
- func (cm *AdapterConnMgr) CloseConnection(id uint64) int
- func (cm *AdapterConnMgr) ConnectionStatus(id uint64) int
- func (cm *AdapterConnMgr) ReceivePackets(id uint64, packet []byte, dstAddr string) int
- type LwipConn
- func (c *LwipConn) Close() error
- func (c *LwipConn) LocalAddr() net.Addr
- func (c *LwipConn) PushPacket(packet []byte, dstAddr string) int
- func (c *LwipConn) Read(b []byte) (n int, err error)
- func (c *LwipConn) ReadFromBind(b []byte) (n int, addr net.Addr, err error)
- func (c *LwipConn) RemoteAddr() net.Addr
- func (c *LwipConn) SetDeadline(t time.Time) error
- func (c *LwipConn) SetReadDeadline(t time.Time) error
- func (c *LwipConn) SetWriteDeadline(t time.Time) error
- func (c *LwipConn) Status() int
- func (c *LwipConn) Write(b []byte) (n int, err error)
- func (c *LwipConn) WriteToFromBind(b []byte, from net.Addr) (n int, err error)
- type Packet
- type Proxy
- type TunReactor
Constants ¶
View Source
const ( ConnTypeIp = 0 // ip packet ConnTypeIcmp // icmp packet ConnTypeTcp // tcp packet ConnTypeUdp // udp packet )
View Source
const ( ACT_IP_RECEIVE = 0 // 收到ip包 ACT_TCP_CONNECT // 新的TCP连接 ACT_TCP_SEND // tcp发送 ACT_TCP_RECEIVE // 收到tcp包 ACT_TCP_CLOSE // 关闭 ACT_UDP_SEND // udp发送 ACT_UDP_RECEIVE // 收到udp包 ACT_UDP_CLOSE // 关闭 )
View Source
const ( PacketNodeSize = 1500 // 每个数据包大小 PacketNodeCount = 16 // 数据包个数 PacketBufChanCount = PacketNodeCount * 100 // 接近 2.5MB 缓存 )
Variables ¶
This section is empty.
Functions ¶
func GetLocalIp ¶
func GetLocalIp() string
func OneConnectGO ¶
func ReceivePacketsGO ¶
func SendToAdapter ¶
func SendToAdapter(id uint64, isFromRemoteBind int, remoteIp string, remotePort uint16, connType int, packet []byte) int
*
SendToAdapter 发送数据到底层. *
@param id 唯一ID用于区分连接,如果packetType=ConnTypeIp,则忽略
@param isFromRemoteBind 是否来自服务端bind模式
@param remoteIp 远端IP
@param remotePort 远端Port
@param connType 数据包类型 ip、icmp、tcp、udp: ConnTypeIp, // ip packet ConnTypeIcmp, // icmp packet ConnTypeTcp, // tcp packet ConnTypeUdp // udp packet
@param packet Pointer to receive data. *
返回值 成功>=0 , 失败<0
*
Types ¶
type AdapterConnMgr ¶
type AdapterConnMgr struct {
// contains filtered or unexported fields
}
func AdapterConnMgrInstance ¶
func AdapterConnMgrInstance() *AdapterConnMgr
func (*AdapterConnMgr) AcceptConnection ¶
func (*AdapterConnMgr) CloseConnection ¶
func (cm *AdapterConnMgr) CloseConnection(id uint64) int
关闭连接
func (*AdapterConnMgr) ConnectionStatus ¶
func (cm *AdapterConnMgr) ConnectionStatus(id uint64) int
func (*AdapterConnMgr) ReceivePackets ¶
func (cm *AdapterConnMgr) ReceivePackets(id uint64, packet []byte, dstAddr string) int
数据包
type LwipConn ¶
type LwipConn struct {
// contains filtered or unexported fields
}
func (*LwipConn) ReadFromBind ¶
目前只能是udp FIXME 目前受限于虚拟网卡无法实现来自本地网卡同一个本地地址的udp,不一样的目标地址的数据包 能够关联上,所有目前只适用nat打洞
func (*LwipConn) RemoteAddr ¶
Click to show internal directories.
Click to hide internal directories.