upnp

package
v0.0.0-...-58a2b35 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIPs

func GetLocalIPs() ([]*net.IP, error)

This returns the list of local ip addresses which other hosts can connect to (NOTE: Loopback ip is ignored).

func GetLocalIntenetIp

func GetLocalIntenetIp() string

获取本机能联网的ip地址

Types

type AddPortMapping

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

func (*AddPortMapping) Send

func (this *AddPortMapping) Send(localPort, remotePort int, protocol string) bool

type DelPortMapping

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

func (*DelPortMapping) Send

func (this *DelPortMapping) Send(remotePort int, protocol string) bool

type DeviceDesc

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

func (*DeviceDesc) BuildRequest

func (this *DeviceDesc) BuildRequest() *http.Request

func (*DeviceDesc) Send

func (this *DeviceDesc) Send() bool

type ExternalIPAddress

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

func (*ExternalIPAddress) BuildRequest

func (this *ExternalIPAddress) BuildRequest() *http.Request

func (*ExternalIPAddress) Send

func (this *ExternalIPAddress) Send() bool

type Gateway

type Gateway struct {
	GatewayName   string //网关名称
	Host          string //网关ip和端口
	DeviceDescUrl string //网关设备描述路径
	Cache         string //cache
	ST            string
	USN           string

	ControlURL  string //设备端口映射请求路径
	ServiceType string //提供upnp服务的服务类型
	// contains filtered or unexported fields
}

type MappingPortStruct

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

对所有的端口进行管理

func (*MappingPortStruct) GetAllMapping

func (this *MappingPortStruct) GetAllMapping() map[string][][]int

type Node

type Node struct {
	Name    string
	Content string
	Attr    map[string]string
	Child   []Node
}

func (*Node) AddChild

func (n *Node) AddChild(node Node)

func (*Node) BuildXML

func (n *Node) BuildXML() string

type SearchGateway

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

func (*SearchGateway) Send

func (this *SearchGateway) Send() bool

type SearchGatewayReq

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

func (SearchGatewayReq) BuildRequest

func (this SearchGatewayReq) BuildRequest() *http.Request

func (SearchGatewayReq) Send

func (this SearchGatewayReq) Send()

type Upnp

type Upnp struct {
	Active             bool              //这个upnp协议是否可用
	LocalHost          string            //本机ip地址
	GatewayInsideIP    string            //局域网网关ip
	GatewayOutsideIP   string            //网关公网ip
	OutsideMappingPort map[string]int    //映射外部端口
	InsideMappingPort  map[string]int    //映射本机端口
	Gateway            *Gateway          //网关信息
	CtrlUrl            string            //控制请求url
	MappingPort        MappingPortStruct //已经添加了的映射 {"TCP":[1990],"UDP":[1991]}
}

func (*Upnp) AddPortMapping

func (this *Upnp) AddPortMapping(localPort, remotePort int, protocol string) (err error)

添加一个端口映射

func (*Upnp) DelPortMapping

func (this *Upnp) DelPortMapping(remotePort int, protocol string) bool

func (*Upnp) ExternalIPAddr

func (this *Upnp) ExternalIPAddr() (err error)

查看公网ip地址

func (*Upnp) GetAllMapping

func (this *Upnp) GetAllMapping() map[string][][]int

func (*Upnp) Reclaim

func (this *Upnp) Reclaim()

回收端口

func (*Upnp) SearchGateway

func (this *Upnp) SearchGateway() (err error)

得到本地联网的ip地址 得到局域网网关ip

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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