Merge branch 'master' of github.com:huin/goupnp
This commit is contained in:
commit
679507af18
@ -412,7 +412,7 @@ func unmarshalXmlFile(file *zip.File, data interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
decoder := xml.NewDecoder(r)
|
decoder := xml.NewDecoder(r)
|
||||||
r.Close()
|
defer r.Close()
|
||||||
return decoder.Decode(data)
|
return decoder.Decode(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package httpu
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
@ -28,6 +29,20 @@ func NewHTTPUClient() (*HTTPUClient, error) {
|
|||||||
return &HTTPUClient{conn: conn}, nil
|
return &HTTPUClient{conn: conn}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewHTTPUClientAddr creates a new HTTPUClient which will broadcast packets
|
||||||
|
// from the specified address, opening up a new UDP socket for the purpose
|
||||||
|
func NewHTTPUClientAddr(addr string) (*HTTPUClient, error) {
|
||||||
|
ip := net.ParseIP(addr)
|
||||||
|
if ip == nil {
|
||||||
|
return nil, errors.New("Invalid listening address")
|
||||||
|
}
|
||||||
|
conn, err := net.ListenPacket("udp", ip.String()+":0")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &HTTPUClient{conn: conn}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Close shuts down the client. The client will no longer be useful following
|
// Close shuts down the client. The client will no longer be useful following
|
||||||
// this.
|
// this.
|
||||||
func (httpu *HTTPUClient) Close() error {
|
func (httpu *HTTPUClient) Close() error {
|
||||||
|
@ -18,7 +18,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
maxAgeRx = regexp.MustCompile("max-age=([0-9]+)")
|
maxAgeRx = regexp.MustCompile("max-age= *([0-9]+)")
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user