CasaOS/pkg/upnp/upnp.go

26 lines
636 B
Go
Raw Normal View History

2021-09-26 02:35:02 +00:00
package upnp
import (
"fmt"
"github.com/prestonTao/upnp"
)
type Upnp struct {
LocalHost string `json:"local_host"`
2021-12-03 08:48:07 +00:00
GatewayName string `json:"gateway_name"` //网关名称
GatewayHost string `json:"gateway_host"` //网关ip和端口
2021-09-26 02:35:02 +00:00
DeviceDescUrl string `json:"device_desc_url"` //设备描述url
2021-12-03 08:48:07 +00:00
CtrlUrl string `json:"ctrl_url"` //控制请求url
2021-09-26 02:35:02 +00:00
}
func Testaaa() {
upnpMan := new(upnp.Upnp)
err := upnpMan.SearchGateway()
if err != nil {
fmt.Println(err.Error())
} else {
fmt.Println("local ip address: ", upnpMan.LocalHost)
fmt.Println("gateway ip address: ", upnpMan.Gateway.Host)
}
}