From d7ddae7b46f34647b87223a0c33ecfb80f0455d5 Mon Sep 17 00:00:00 2001 From: traetox Date: Thu, 22 Sep 2016 14:02:28 -0600 Subject: [PATCH 1/3] httpu client bind to specific address function (#11) added additional function to allow for specifying which IP the PacketConn should listen on and broadcast on --- httpu/httpu.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/httpu/httpu.go b/httpu/httpu.go index 862c3de..f52dad6 100644 --- a/httpu/httpu.go +++ b/httpu/httpu.go @@ -3,6 +3,7 @@ package httpu import ( "bufio" "bytes" + "errors" "fmt" "log" "net" @@ -28,6 +29,20 @@ func NewHTTPUClient() (*HTTPUClient, error) { 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 // this. func (httpu *HTTPUClient) Close() error { From 97f671ee5eaaff14a7221356f352a66fed95514f Mon Sep 17 00:00:00 2001 From: inhies Date: Tue, 25 Oct 2016 10:18:49 -0600 Subject: [PATCH 2/3] Defer closing of xml file --- gotasks/specgen_task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gotasks/specgen_task.go b/gotasks/specgen_task.go index 921e8c8..438b694 100644 --- a/gotasks/specgen_task.go +++ b/gotasks/specgen_task.go @@ -412,7 +412,7 @@ func unmarshalXmlFile(file *zip.File, data interface{}) error { return err } decoder := xml.NewDecoder(r) - r.Close() + defer r.Close() return decoder.Decode(data) } From 949b8a77532ae1076171f4d112a5eb41354cb340 Mon Sep 17 00:00:00 2001 From: Julien LEICHER Date: Mon, 31 Oct 2016 19:15:47 +0100 Subject: [PATCH 3/3] Fix for max-age (#13) * Fix for max-age with space * Changed ? to * for multiple spaces --- ssdp/registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssdp/registry.go b/ssdp/registry.go index 2f84bea..d3bc114 100644 --- a/ssdp/registry.go +++ b/ssdp/registry.go @@ -18,7 +18,7 @@ const ( ) var ( - maxAgeRx = regexp.MustCompile("max-age=([0-9]+)") + maxAgeRx = regexp.MustCompile("max-age= *([0-9]+)") ) const (