upnp: github.com/prestonTao/upnp Index | Files | Directories

package upnp

import "github.com/prestonTao/upnp"

Index

Package Files

AddPortMapping.go DelPortMapping.go DeviceDesc.go DeviceStatusInfo.go ExternalIPAddress.go SearchGatewayMsg.go common.go message.go upnp.go

func GetLocalIPs Uses

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 Uses

func GetLocalIntenetIp() string

获取本机能联网的ip地址

type AddPortMapping Uses

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

func (*AddPortMapping) Send Uses

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

type DelPortMapping Uses

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

func (*DelPortMapping) Send Uses

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

type DeviceDesc Uses

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

func (*DeviceDesc) BuildRequest Uses

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

func (*DeviceDesc) Send Uses

func (this *DeviceDesc) Send() bool

type ExternalIPAddress Uses

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

func (*ExternalIPAddress) BuildRequest Uses

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

func (*ExternalIPAddress) Send Uses

func (this *ExternalIPAddress) Send() bool

type Gateway Uses

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 Uses

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

对所有的端口进行管理

func (*MappingPortStruct) GetAllMapping Uses

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

type Node Uses

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

func (*Node) AddChild Uses

func (n *Node) AddChild(node Node)

func (*Node) BuildXML Uses

func (n *Node) BuildXML() string

type SearchGateway Uses

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

func (*SearchGateway) Send Uses

func (this *SearchGateway) Send() bool

type SearchGatewayReq Uses

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

func (SearchGatewayReq) BuildRequest Uses

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

func (SearchGatewayReq) Send Uses

func (this SearchGatewayReq) Send()

type Upnp Uses

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 Uses

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

添加一个端口映射

func (*Upnp) DelPortMapping Uses

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

func (*Upnp) ExternalIPAddr Uses

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

查看公网ip地址

func (*Upnp) GetAllMapping Uses

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

func (*Upnp) Reclaim Uses

func (this *Upnp) Reclaim()

回收端口

func (*Upnp) SearchGateway Uses

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

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

Directories

PathSynopsis
example

Package upnp imports 11 packages (graph) and is imported by 6 packages. Updated 2016-07-20. Refresh now. Tools for package owners.