From 30530a2dbcde098daba0c5d361d665b49a550189 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 12 Apr 2019 00:02:07 +0100 Subject: [PATCH] Update Debian metadata and add a missing dependency --- debian/autoradio-server.radiod.service | 1 + ...e => autoradio-server.transcoderd.service} | 4 +- debian/autoradio.default | 13 +- debian/compat | 2 +- debian/rules | 5 +- node/http.go | 2 +- .../elazarl/go-bindata-assetfs/LICENSE | 23 +++ .../elazarl/go-bindata-assetfs/README.md | 46 +++++ .../elazarl/go-bindata-assetfs/assetfs.go | 167 ++++++++++++++++++ .../elazarl/go-bindata-assetfs/doc.go | 13 ++ vendor/vendor.json | 6 + 11 files changed, 270 insertions(+), 12 deletions(-) rename debian/{autoradio-server.redirectord.service => autoradio-server.transcoderd.service} (65%) create mode 100644 vendor/github.com/elazarl/go-bindata-assetfs/LICENSE create mode 100644 vendor/github.com/elazarl/go-bindata-assetfs/README.md create mode 100644 vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go create mode 100644 vendor/github.com/elazarl/go-bindata-assetfs/doc.go diff --git a/debian/autoradio-server.radiod.service b/debian/autoradio-server.radiod.service index 460c5822..8d0f732e 100644 --- a/debian/autoradio-server.radiod.service +++ b/debian/autoradio-server.radiod.service @@ -9,6 +9,7 @@ EnvironmentFile=-/etc/default/autoradio ExecStart=/usr/bin/radiod $ETCD_SERVER $PUBLIC_IP $INTERFACE $RADIOD_OPTIONS Restart=always RestartSec=1 +LimitNOFILE=65535 [Install] WantedBy=multi-user.target diff --git a/debian/autoradio-server.redirectord.service b/debian/autoradio-server.transcoderd.service similarity index 65% rename from debian/autoradio-server.redirectord.service rename to debian/autoradio-server.transcoderd.service index d512269d..f6e3dabd 100644 --- a/debian/autoradio-server.redirectord.service +++ b/debian/autoradio-server.transcoderd.service @@ -1,12 +1,12 @@ [Unit] -Description=autoradio front-end +Description=autoradio transcoder service After=etcd.service Wants=etcd.service [Service] User=nobody EnvironmentFile=-/etc/default/autoradio -ExecStart=/usr/sbin/redirectord $ETCD_SERVER $PUBLIC_IP $DOMAIN $REDIRECTORD_OPTIONS +ExecStart=/usr/bin/transcoderd $ETCD_SERVER $PUBLIC_IP $DOMAIN $TRANSCODERD_OPTIONS CapabilityBoundingSet=CAP_NET_BIND_SERVICE Restart=always RestartSec=1 diff --git a/debian/autoradio.default b/debian/autoradio.default index 10d29804..872e76a4 100644 --- a/debian/autoradio.default +++ b/debian/autoradio.default @@ -2,17 +2,16 @@ # Set your base domain name here. #DOMAIN="--domain=" -# Set your public IP if necessary. -#PUBLIC_IP="--ip=" +# Set your public IP if necessary (specify multiple times for v4/v6). +#PUBLIC_IP="--public-ip=" -# Name of the outbound network interface (if unset, radiod will try to -# figure it out automatically). -#INTERFACE="--interface=eth0" +# Set the IP address that is advertised to peers. +PEER_IP="--peer-ip=" # Set the etcd servers to connect to (default: localhost:2379). -#ETCD_SERVER="--etcd-servers=localhost:2379" +ETCD_SERVER="--etcd=http://localhost:2379" # Additional options that are passed to specific daemons. #RADIOD_OPTIONS="--bwlimit=1000" #RADIOD_OPTIONS="--interface=eth0" -REDIRECTORD_OPTIONS="" +RADIOD_OPTIONS="" diff --git a/debian/compat b/debian/compat index 45a4fb75..f599e28b 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -8 +10 diff --git a/debian/rules b/debian/rules index 7e93b48c..1f2bc568 100755 --- a/debian/rules +++ b/debian/rules @@ -3,12 +3,14 @@ export DH_GOPKG = git.autistici.org/ale/autoradio export DH_GOLANG_EXCLUDES = vendor +DESTDIR = debian/autoradio-server + %: dh $@ --with systemd --with golang --buildsystem golang override_dh_auto_install: dh_auto_install - $(RM) -rv debian/tmp/usr/share/gocode + $(RM) -rv $(DESTDIR)/usr/share/gocode # Icecast2 status XSL template. install -d -m 755 -o root -g root $(DESTDIR)/usr/share/icecast2/web @@ -26,3 +28,4 @@ override_dh_installinit: override_dh_systemd_enable: dh_systemd_enable --name=radiod + dh_systemd_enable --name=transcoderd diff --git a/node/http.go b/node/http.go index 07bdc169..9058a84b 100644 --- a/node/http.go +++ b/node/http.go @@ -7,6 +7,7 @@ import ( "context" "flag" "fmt" + "html/template" "io" "log" "net" @@ -18,7 +19,6 @@ import ( "git.autistici.org/ale/autoradio" pb "git.autistici.org/ale/autoradio/proto" - "github.com/alecthomas/template" assetfs "github.com/elazarl/go-bindata-assetfs" ) diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/LICENSE b/vendor/github.com/elazarl/go-bindata-assetfs/LICENSE new file mode 100644 index 00000000..5782c726 --- /dev/null +++ b/vendor/github.com/elazarl/go-bindata-assetfs/LICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2014, Elazar Leibovich +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/README.md b/vendor/github.com/elazarl/go-bindata-assetfs/README.md new file mode 100644 index 00000000..27ee48f0 --- /dev/null +++ b/vendor/github.com/elazarl/go-bindata-assetfs/README.md @@ -0,0 +1,46 @@ +# go-bindata-assetfs + +Serve embedded files from [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) with `net/http`. + +[GoDoc](http://godoc.org/github.com/elazarl/go-bindata-assetfs) + +### Installation + +Install with + + $ go get github.com/jteeuwen/go-bindata/... + $ go get github.com/elazarl/go-bindata-assetfs/... + +### Creating embedded data + +Usage is identical to [jteeuwen/go-bindata](https://github.com/jteeuwen/go-bindata) usage, +instead of running `go-bindata` run `go-bindata-assetfs`. + +The tool will create a `bindata_assetfs.go` file, which contains the embedded data. + +A typical use case is + + $ go-bindata-assetfs data/... + +### Using assetFS in your code + +The generated file provides an `assetFS()` function that returns a `http.Filesystem` +wrapping the embedded files. What you usually want to do is: + + http.Handle("/", http.FileServer(assetFS())) + +This would run an HTTP server serving the embedded files. + +## Without running binary tool + +You can always just run the `go-bindata` tool, and then + +use + + import "github.com/elazarl/go-bindata-assetfs" + ... + http.Handle("/", + http.FileServer( + &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "data"})) + +to serve files embedded from the `data` directory. diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go b/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go new file mode 100644 index 00000000..04f6d7a3 --- /dev/null +++ b/vendor/github.com/elazarl/go-bindata-assetfs/assetfs.go @@ -0,0 +1,167 @@ +package assetfs + +import ( + "bytes" + "errors" + "io" + "io/ioutil" + "net/http" + "os" + "path" + "path/filepath" + "strings" + "time" +) + +var ( + defaultFileTimestamp = time.Now() +) + +// FakeFile implements os.FileInfo interface for a given path and size +type FakeFile struct { + // Path is the path of this file + Path string + // Dir marks of the path is a directory + Dir bool + // Len is the length of the fake file, zero if it is a directory + Len int64 + // Timestamp is the ModTime of this file + Timestamp time.Time +} + +func (f *FakeFile) Name() string { + _, name := filepath.Split(f.Path) + return name +} + +func (f *FakeFile) Mode() os.FileMode { + mode := os.FileMode(0644) + if f.Dir { + return mode | os.ModeDir + } + return mode +} + +func (f *FakeFile) ModTime() time.Time { + return f.Timestamp +} + +func (f *FakeFile) Size() int64 { + return f.Len +} + +func (f *FakeFile) IsDir() bool { + return f.Mode().IsDir() +} + +func (f *FakeFile) Sys() interface{} { + return nil +} + +// AssetFile implements http.File interface for a no-directory file with content +type AssetFile struct { + *bytes.Reader + io.Closer + FakeFile +} + +func NewAssetFile(name string, content []byte, timestamp time.Time) *AssetFile { + if timestamp.IsZero() { + timestamp = defaultFileTimestamp + } + return &AssetFile{ + bytes.NewReader(content), + ioutil.NopCloser(nil), + FakeFile{name, false, int64(len(content)), timestamp}} +} + +func (f *AssetFile) Readdir(count int) ([]os.FileInfo, error) { + return nil, errors.New("not a directory") +} + +func (f *AssetFile) Size() int64 { + return f.FakeFile.Size() +} + +func (f *AssetFile) Stat() (os.FileInfo, error) { + return f, nil +} + +// AssetDirectory implements http.File interface for a directory +type AssetDirectory struct { + AssetFile + ChildrenRead int + Children []os.FileInfo +} + +func NewAssetDirectory(name string, children []string, fs *AssetFS) *AssetDirectory { + fileinfos := make([]os.FileInfo, 0, len(children)) + for _, child := range children { + _, err := fs.AssetDir(filepath.Join(name, child)) + fileinfos = append(fileinfos, &FakeFile{child, err == nil, 0, time.Time{}}) + } + return &AssetDirectory{ + AssetFile{ + bytes.NewReader(nil), + ioutil.NopCloser(nil), + FakeFile{name, true, 0, time.Time{}}, + }, + 0, + fileinfos} +} + +func (f *AssetDirectory) Readdir(count int) ([]os.FileInfo, error) { + if count <= 0 { + return f.Children, nil + } + if f.ChildrenRead+count > len(f.Children) { + count = len(f.Children) - f.ChildrenRead + } + rv := f.Children[f.ChildrenRead : f.ChildrenRead+count] + f.ChildrenRead += count + return rv, nil +} + +func (f *AssetDirectory) Stat() (os.FileInfo, error) { + return f, nil +} + +// AssetFS implements http.FileSystem, allowing +// embedded files to be served from net/http package. +type AssetFS struct { + // Asset should return content of file in path if exists + Asset func(path string) ([]byte, error) + // AssetDir should return list of files in the path + AssetDir func(path string) ([]string, error) + // AssetInfo should return the info of file in path if exists + AssetInfo func(path string) (os.FileInfo, error) + // Prefix would be prepended to http requests + Prefix string +} + +func (fs *AssetFS) Open(name string) (http.File, error) { + name = path.Join(fs.Prefix, name) + if len(name) > 0 && name[0] == '/' { + name = name[1:] + } + if b, err := fs.Asset(name); err == nil { + timestamp := defaultFileTimestamp + if fs.AssetInfo != nil { + if info, err := fs.AssetInfo(name); err == nil { + timestamp = info.ModTime() + } + } + return NewAssetFile(name, b, timestamp), nil + } + if children, err := fs.AssetDir(name); err == nil { + return NewAssetDirectory(name, children, fs), nil + } else { + // If the error is not found, return an error that will + // result in a 404 error. Otherwise the server returns + // a 500 error for files not found. + if strings.Contains(err.Error(), "not found") { + return nil, os.ErrNotExist + } + return nil, err + } +} diff --git a/vendor/github.com/elazarl/go-bindata-assetfs/doc.go b/vendor/github.com/elazarl/go-bindata-assetfs/doc.go new file mode 100644 index 00000000..a664249f --- /dev/null +++ b/vendor/github.com/elazarl/go-bindata-assetfs/doc.go @@ -0,0 +1,13 @@ +// assetfs allows packages to serve static content embedded +// with the go-bindata tool with the standard net/http package. +// +// See https://github.com/jteeuwen/go-bindata for more information +// about embedding binary data with go-bindata. +// +// Usage example, after running +// $ go-bindata data/... +// use: +// http.Handle("/", +// http.FileServer( +// &assetfs.AssetFS{Asset: Asset, AssetDir: AssetDir, Prefix: "data"})) +package assetfs diff --git a/vendor/vendor.json b/vendor/vendor.json index 4f0b6ab4..1fd35eab 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -44,6 +44,12 @@ "revision": "a621d807f061e1dd635033a8d6bc261461429e27", "revisionTime": "2019-04-01T20:57:24Z" }, + { + "checksumSHA1": "7DxViusFRJ7UPH0jZqYatwDrOkY=", + "path": "github.com/elazarl/go-bindata-assetfs", + "revision": "38087fe4dafb822e541b3f7955075cc1c30bd294", + "revisionTime": "2018-02-23T16:03:09Z" + }, { "checksumSHA1": "RGA4gzP1R6tMTLRfjsH7luN/y3c=", "origin": "go.etcd.io/etcd/vendor/github.com/ghodss/yaml", -- GitLab