From d4f0c4679fa1e2e056a68857045d9ab12244d81f Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sun, 1 Dec 2013 09:06:37 +0000 Subject: [PATCH] rename the project to "autoradio" --- README.rst | 28 ++++++++-------- api.go | 4 +-- cmd/radioctl/radioctl.go | 12 +++---- cmd/radiod/radiod.go | 6 ++-- cmd/redirectord/redirectord.go | 12 +++---- debian/{radioai.default => autoradio.default} | 6 ++-- debian/changelog | 4 +-- debian/control | 6 ++-- debian/copyright | 2 +- debian/postinst | 2 +- debian/rules | 20 ++++++------ debian/services/lib.sh | 6 ++-- debian/services/radiod | 2 +- debian/services/redirectord | 2 +- debian/{radioai.xsl => status.xsl} | 0 etcd_client.go | 4 +-- fe/dns.go | 6 ++-- fe/http.go | 16 +++++----- fe/loadbalancing.go | 10 +++--- fe/templates/index.html | 4 +-- masterelection/masterelection.go | 2 +- node/icecast.go | 10 +++--- node/icecast_config.go | 14 ++++---- node/icecast_config_test.go | 4 +-- node/node.go | 32 +++++++++---------- 25 files changed, 107 insertions(+), 107 deletions(-) rename debian/{radioai.default => autoradio.default} (72%) rename debian/{radioai.xsl => status.xsl} (100%) diff --git a/README.rst b/README.rst index bf963a16..666188f3 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,9 @@ -======== -radio.ai -======== +========= +autoradio +========= -The RadioAI service aims to provide a reliable, fault-tolerant Icecast +The *autoradio* service aims to provide a reliable, fault-tolerant Icecast streaming network for audio and video. It provides all the necessary components to ensure that the traffic from the source to the clients is uninterrupted, even in face of high load or server crashes. All @@ -24,19 +24,19 @@ Installation The simplest installation method is probably to use the pre-built Debian packages (only available for amd64 at the moment), by placing -this line in ``/etc/apt/sources.list.d/radioai.list``:: +this line in ``/etc/apt/sources.list.d/autoradio.list``:: - deb http://www.incal.net/ale/debian radioai/ + deb http://www.incal.net/ale/debian autoradio/ And then running:: $ sudo apt-get update - $ sudo apt-get install etcd radioai + $ sudo apt-get install etcd autoradio This will install and start the necessary jobs (which will initially fail due to the missing configuration). -Edit ``/etc/default/radioai`` and set, at least, the ``DOMAIN`` +Edit ``/etc/default/autoradio`` and set, at least, the ``DOMAIN`` variable to what you've assigned to the cluster. The jobs will automatically start as soon as the configuration is saved. @@ -55,7 +55,7 @@ bootstrap a new streaming cluster: #. On every server, run the above-mentioned steps to set up the APT repository and install (do not configure) the ``etcd`` and - ``radioai`` packages. + ``autoradio`` packages. #. Pick one of your servers and add a delegation for *radio.example.com* to it. For instance, with ``bind``:: @@ -66,7 +66,7 @@ bootstrap a new streaming cluster: ``BOOTSTRAP=1``. Once you save the file, the ``etcd`` daemon will start with an empty database. -#. On *machine1*, edit ``/etc/default/radioai`` and set +#. On *machine1*, edit ``/etc/default/autoradio`` and set ``DOMAIN=radio.example.com``. This will start the ``radiod`` and ``redirectord`` daemons, and you will be able to serve DNS records for the *radio.example.com* zone. Check with:: @@ -77,7 +77,7 @@ bootstrap a new streaming cluster: #. Set up all other machines, setting ``ETCD_SERVER=etcd.radio.example.com`` in ``/etc/default/etcd`` and - ``DOMAIN=radio.example.com`` in ``/etc/default/radioai``. + ``DOMAIN=radio.example.com`` in ``/etc/default/autoradio``. @@ -93,9 +93,9 @@ an online CA (such as autoca_). This way, enrolling a new machine in the cluster only requires generating a new client certificate, and no other configuration. -Install the CA certificate in ``/etc/radioai/etcd_ca.pem``, the client -certificate in ``/etc/radioai/etcd_client.pem`` and its private key in -``/etc/radioai/etcd_client.key``, and the clients will connect to +Install the CA certificate in ``/etc/autoradio/etcd_ca.pem``, the client +certificate in ``/etc/autoradio/etcd_client.pem`` and its private key in +``/etc/autoradio/etcd_client.key``, and the clients will connect to *etcd* using SSL authentication. diff --git a/api.go b/api.go index 7b49833b..50ac90f4 100644 --- a/api.go +++ b/api.go @@ -1,4 +1,4 @@ -package radioai +package autoradio import ( "bytes" @@ -10,7 +10,7 @@ import ( "sync" "time" - "git.autistici.org/ale/radioai/third_party/github.com/coreos/go-etcd/etcd" + "git.autistici.org/ale/autoradio/third_party/github.com/coreos/go-etcd/etcd" ) var ( diff --git a/cmd/radioctl/radioctl.go b/cmd/radioctl/radioctl.go index 3b3f45e0..56df9470 100644 --- a/cmd/radioctl/radioctl.go +++ b/cmd/radioctl/radioctl.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" ) // Describes the syntax of a command. @@ -66,9 +66,9 @@ func Run(cl CommandList) { log.Fatalf("Unknown command '%s'", cmdArg) } -func getClient() *radioai.RadioAPI { - etc := radioai.NewEtcdClient() - return radioai.NewRadioAPI(etc) +func getClient() *autoradio.RadioAPI { + etc := autoradio.NewEtcdClient() + return autoradio.NewRadioAPI(etc) } func deleteMount(args []string) { @@ -118,8 +118,8 @@ func createMount(args []string) { // Create the new mount, randomly generate source authentication. username := generateUsername(path) - password := radioai.GeneratePassword() - m := &radioai.Mount{ + password := autoradio.GeneratePassword() + m := &autoradio.Mount{ Name: path, Username: username, Password: password, diff --git a/cmd/radiod/radiod.go b/cmd/radiod/radiod.go index 30dc0b2f..8e783a5a 100644 --- a/cmd/radiod/radiod.go +++ b/cmd/radiod/radiod.go @@ -7,8 +7,8 @@ import ( "os/signal" "syscall" - "git.autistici.org/ale/radioai" - "git.autistici.org/ale/radioai/node" + "git.autistici.org/ale/autoradio" + "git.autistici.org/ale/autoradio/node" ) var ( @@ -19,7 +19,7 @@ var ( func main() { flag.Parse() - client := radioai.NewEtcdClient() + client := autoradio.NewEtcdClient() n := node.NewRadioNode(*publicIp, client) // Set up a clean shutdown function on SIGTERM. diff --git a/cmd/redirectord/redirectord.go b/cmd/redirectord/redirectord.go index 5e862cea..7d07dc8c 100644 --- a/cmd/redirectord/redirectord.go +++ b/cmd/redirectord/redirectord.go @@ -5,8 +5,8 @@ import ( "fmt" "log" - "git.autistici.org/ale/radioai" - "git.autistici.org/ale/radioai/fe" + "git.autistici.org/ale/autoradio" + "git.autistici.org/ale/autoradio/fe" ) var ( @@ -15,8 +15,8 @@ var ( httpPort = flag.Int("http-port", 80, "HTTP port") publicIp = flag.String("ip", "127.0.0.1", "Public IP for this machine") - staticDir = flag.String("static-dir", "/usr/share/radioai/htdocs/static", "Static content directory") - templateDir = flag.String("template-dir", "/usr/share/radioai/htdocs/templates", "HTML templates directory") + staticDir = flag.String("static-dir", "/usr/share/autoradio/htdocs/static", "Static content directory") + templateDir = flag.String("template-dir", "/usr/share/autoradio/htdocs/templates", "HTML templates directory") lbPolicy = flag.String("lb-policy", "weighted", "Load balancing policy (weighted, leastloaded)") @@ -31,8 +31,8 @@ func main() { log.Fatal("Must specify --domain") } - client := radioai.NewEtcdClient() - api := radioai.NewRadioAPI(client) + client := autoradio.NewEtcdClient() + api := autoradio.NewRadioAPI(client) dnsRed := fe.NewDnsRedirector(api, *domain, *publicIp, dnsTtl) dnsRed.Run(fmt.Sprintf(":%d", *dnsPort)) diff --git a/debian/radioai.default b/debian/autoradio.default similarity index 72% rename from debian/radioai.default rename to debian/autoradio.default index de7baa6f..d82935bb 100644 --- a/debian/radioai.default +++ b/debian/autoradio.default @@ -1,6 +1,6 @@ -# Defaults for radioai initscript -# sourced by /etc/init.d/radioai -# installed at /etc/default/radioai by the maintainer scripts +# Defaults for autoradio initscript +# sourced by /etc/init.d/autoradio +# installed at /etc/default/autoradio by the maintainer scripts # # This is a POSIX shell fragment diff --git a/debian/changelog b/debian/changelog index e179ded0..9c118a35 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -radioai (0.2) unstable; urgency=low +autoradio (0.2) unstable; urgency=low * Update to the etcd 0.2 API. -- ale <ale@incal.net> Fri, 15 Nov 2013 20:40:06 +0000 -radioai (0.1) unstable; urgency=low +autoradio (0.1) unstable; urgency=low * Initial Release. diff --git a/debian/control b/debian/control index 7a2ee1e4..286acc9f 100644 --- a/debian/control +++ b/debian/control @@ -1,12 +1,12 @@ -Source: radioai +Source: autoradio Section: net Priority: extra Maintainer: ale <ale@incal.net> Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.4 -Homepage: https://git.autistici.org/ale/radioai +Homepage: https://git.autistici.org/ale/autoradio -Package: radioai +Package: autoradio Architecture: any Depends: icecast2, runit, libcap2-bin, ${shlibs:Depends}, ${misc:Depends} Description: Icecast clustering software. diff --git a/debian/copyright b/debian/copyright index ab450ff8..60db7c04 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,5 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: radioai +Upstream-Name: autoradio Source: <url://example.com> Files: * diff --git a/debian/postinst b/debian/postinst index 90ffe8ec..bc2b0a6b 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,5 +1,5 @@ #!/bin/sh -# postinst script for radioai +# postinst script for autoradio # # see: dh_installdeb(1) diff --git a/debian/rules b/debian/rules index 7b6a62ba..7c36673c 100755 --- a/debian/rules +++ b/debian/rules @@ -16,9 +16,9 @@ # This has to be exported to make some magic below work. export DH_OPTIONS -GOPKG = git.autistici.org/ale/radioai +GOPKG = git.autistici.org/ale/autoradio -DESTDIR = $(CURDIR)/debian/radioai +DESTDIR = $(CURDIR)/debian/autoradio SVCDIR = $(DESTDIR)/etc/svc %: @@ -39,20 +39,20 @@ override_dh_install: rm -fr $$tmpdir) # Install the static files and templates for the HTTP dashboard. - install -d -m 755 -o root -g root $(DESTDIR)/usr/share/radioai - install -d -m 755 -o root -g root $(DESTDIR)/usr/share/radioai/htdocs/static + install -d -m 755 -o root -g root $(DESTDIR)/usr/share/autoradio + install -d -m 755 -o root -g root $(DESTDIR)/usr/share/autoradio/htdocs/static (for f in $(CURDIR)/fe/static/* ; do \ - install -o root -g root -m 644 $$f $(DESTDIR)/usr/share/radioai/htdocs/static/ ; \ + install -o root -g root -m 644 $$f $(DESTDIR)/usr/share/autoradio/htdocs/static/ ; \ done) - install -d -m 755 -o root -g root $(DESTDIR)/usr/share/radioai/htdocs/templates + install -d -m 755 -o root -g root $(DESTDIR)/usr/share/autoradio/htdocs/templates (for f in $(CURDIR)/fe/templates/*.html ; do \ - install -o root -g root -m 644 $$f $(DESTDIR)/usr/share/radioai/htdocs/templates/ ; \ + install -o root -g root -m 644 $$f $(DESTDIR)/usr/share/autoradio/htdocs/templates/ ; \ done) # Install runit service runners. install -d -m 755 -o root -g root $(SVCDIR) install -m 644 -o root -g root $(CURDIR)/debian/services/lib.sh \ - $(DESTDIR)/usr/share/radioai/lib.sh + $(DESTDIR)/usr/share/autoradio/lib.sh (for f in radiod redirectord ; do \ install -d -o root -g root $(SVCDIR)/$$f ; \ install -d -o root -g root $(SVCDIR)/$$f/log ; \ @@ -65,5 +65,5 @@ override_dh_install: # Icecast2 status XSL template. install -d -m 755 -o root -g root $(DESTDIR)/usr/share/icecast2/web - install -m 644 -o root -g root $(CURDIR)/debian/radioai.xsl \ - $(DESTDIR)/usr/share/icecast2/web/status-radioai.xsl + install -m 644 -o root -g root $(CURDIR)/debian/status.xsl \ + $(DESTDIR)/usr/share/icecast2/web/status-autoradio.xsl diff --git a/debian/services/lib.sh b/debian/services/lib.sh index 32a93e08..7db958c7 100644 --- a/debian/services/lib.sh +++ b/debian/services/lib.sh @@ -1,12 +1,12 @@ -# Common functions for the 'radioai' startup scripts. +# Common functions for the 'autoradio' startup scripts. PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:$PATH export PATH -test -e /etc/default/radioai && . /etc/default/radioai +test -e /etc/default/autoradio && . /etc/default/autoradio if [ -z "${DOMAIN}" ]; then - echo "You must set DOMAIN in /etc/default/radioai!" 1>&2 + echo "You must set DOMAIN in /etc/default/autoradio!" 1>&2 exit 1 fi diff --git a/debian/services/radiod b/debian/services/radiod index 9c316e5a..bbf8b4a3 100755 --- a/debian/services/radiod +++ b/debian/services/radiod @@ -1,6 +1,6 @@ #!/bin/sh -. /usr/share/radioai/lib.sh +. /usr/share/autoradio/lib.sh set_public_ip set_etcd_params diff --git a/debian/services/redirectord b/debian/services/redirectord index 795a0b57..165504c0 100755 --- a/debian/services/redirectord +++ b/debian/services/redirectord @@ -1,6 +1,6 @@ #!/bin/sh -. /usr/share/radioai/lib.sh +. /usr/share/autoradio/lib.sh set_public_ip set_etcd_params diff --git a/debian/radioai.xsl b/debian/status.xsl similarity index 100% rename from debian/radioai.xsl rename to debian/status.xsl diff --git a/etcd_client.go b/etcd_client.go index 2bbc2179..788c3109 100644 --- a/etcd_client.go +++ b/etcd_client.go @@ -1,4 +1,4 @@ -package radioai +package autoradio import ( "flag" @@ -7,7 +7,7 @@ import ( "net" "strings" - "git.autistici.org/ale/radioai/third_party/github.com/coreos/go-etcd/etcd" + "git.autistici.org/ale/autoradio/third_party/github.com/coreos/go-etcd/etcd" ) var ( diff --git a/fe/dns.go b/fe/dns.go index b2a827e3..8682a076 100644 --- a/fe/dns.go +++ b/fe/dns.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" "github.com/miekg/dns" ) @@ -29,7 +29,7 @@ var ( // DNS server. type DnsRedirector struct { - client *radioai.RadioAPI + client *autoradio.RadioAPI queryStats *expvar.Map targetStats *expvar.Map origin string @@ -41,7 +41,7 @@ type DnsRedirector struct { // NewDnsRedirector returns a DNS server for the given origin and // publicIp. The A records served will have the specified ttl. -func NewDnsRedirector(client *radioai.RadioAPI, origin, publicIp string, ttl int) *DnsRedirector { +func NewDnsRedirector(client *autoradio.RadioAPI, origin, publicIp string, ttl int) *DnsRedirector { if !strings.HasSuffix(origin, ".") { origin += "." } diff --git a/fe/http.go b/fe/http.go index 863244c9..e20c8cdd 100644 --- a/fe/http.go +++ b/fe/http.go @@ -17,7 +17,7 @@ import ( _ "net/http/pprof" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" "github.com/PuerkitoBio/ghost/handlers" ) @@ -46,13 +46,13 @@ func statsHandler(h http.Handler, stats *expvar.Map) http.HandlerFunc { type HttpRedirector struct { domain string lb LoadBalancingPolicy - client *radioai.RadioAPI + client *autoradio.RadioAPI template *template.Template stats *expvar.Map targetStats *expvar.Map } -func NewHttpRedirector(client *radioai.RadioAPI, domain string, lbpolicy string) *HttpRedirector { +func NewHttpRedirector(client *autoradio.RadioAPI, domain string, lbpolicy string) *HttpRedirector { targetStats := new(expvar.Map).Init() stats := expvar.NewMap("http") stats.Set("targets", targetStats) @@ -74,7 +74,7 @@ func (h *HttpRedirector) pickActiveNode() string { } // Filter nodes where Icecast is reported to be up. - okNodes := make([]*radioai.NodeStatus, 0, len(nodes)) + okNodes := make([]*autoradio.NodeStatus, 0, len(nodes)) for _, n := range nodes { if n.IcecastUp { okNodes = append(okNodes, n) @@ -92,7 +92,7 @@ func (h *HttpRedirector) pickActiveNode() string { } // Parse the request and extract the mount path. -func (h *HttpRedirector) getMount(r *http.Request) (*radioai.Mount, error) { +func (h *HttpRedirector) getMount(r *http.Request) (*autoradio.Mount, error) { path := r.URL.Path if strings.HasSuffix(path, ".m3u") { path = path[:len(path)-4] @@ -101,7 +101,7 @@ func (h *HttpRedirector) getMount(r *http.Request) (*radioai.Mount, error) { } func makeIcecastUrl(server string) string { - return net.JoinHostPort(server, strconv.Itoa(radioai.IcecastPort)) + return net.JoinHostPort(server, strconv.Itoa(autoradio.IcecastPort)) } // Serve a response for a client connection to a relay. @@ -220,8 +220,8 @@ func (h *HttpRedirector) serveStatusPage(w http.ResponseWriter, r *http.Request) mounts, _ := h.client.ListMounts() ctx := struct { Domain string - Nodes []*radioai.NodeStatus - Mounts []*radioai.Mount + Nodes []*autoradio.NodeStatus + Mounts []*autoradio.Mount }{h.domain, nodes, mounts} var buf bytes.Buffer diff --git a/fe/loadbalancing.go b/fe/loadbalancing.go index 4a1afe5f..9ecca940 100644 --- a/fe/loadbalancing.go +++ b/fe/loadbalancing.go @@ -3,21 +3,21 @@ package fe import ( "log" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" "github.com/jmcvetta/randutil" ) // A load balancing policy selects a single node from the pool of // currently active ones. type LoadBalancingPolicy interface { - GetNode([]*radioai.NodeStatus) *radioai.NodeStatus + GetNode([]*autoradio.NodeStatus) *autoradio.NodeStatus } // Simple load balancing policy that always returns the nodes with the // least amount of listeners. type leastListenersPolicy struct{} -func (llp leastListenersPolicy) GetNode(nodes []*radioai.NodeStatus) *radioai.NodeStatus { +func (llp leastListenersPolicy) GetNode(nodes []*autoradio.NodeStatus) *autoradio.NodeStatus { minIdx := 0 min := 1000000 for i, n := range nodes { @@ -34,7 +34,7 @@ func (llp leastListenersPolicy) GetNode(nodes []*radioai.NodeStatus) *radioai.No // number of active listeners. type weightedListenersPolicy struct{} -func (wlp weightedListenersPolicy) GetNode(nodes []*radioai.NodeStatus) *radioai.NodeStatus { +func (wlp weightedListenersPolicy) GetNode(nodes []*autoradio.NodeStatus) *autoradio.NodeStatus { choices := make([]randutil.Choice, 0, len(nodes)) weightBase := 1000000 for _, n := range nodes { @@ -45,7 +45,7 @@ func (wlp weightedListenersPolicy) GetNode(nodes []*radioai.NodeStatus) *radioai if err != nil { return nil } - return result.Item.(*radioai.NodeStatus) + return result.Item.(*autoradio.NodeStatus) } func getNamedLoadBalancingPolicy(lbpolicy string) LoadBalancingPolicy { diff --git a/fe/templates/index.html b/fe/templates/index.html index 7b7ea7ab..50f747c7 100644 --- a/fe/templates/index.html +++ b/fe/templates/index.html @@ -44,8 +44,8 @@ <div class="footer"> powered by - <a href="https://git.autistici.org/public/ale/radioai"> - radioai 0.1 + <a href="https://git.autistici.org/ale/autoradio"> + autoradio 0.1 </a> </div> </div> diff --git a/masterelection/masterelection.go b/masterelection/masterelection.go index a37a9f7d..87316beb 100644 --- a/masterelection/masterelection.go +++ b/masterelection/masterelection.go @@ -4,7 +4,7 @@ import ( "log" "time" - "git.autistici.org/ale/radioai/third_party/github.com/coreos/go-etcd/etcd" + "git.autistici.org/ale/autoradio/third_party/github.com/coreos/go-etcd/etcd" ) const ( diff --git a/node/icecast.go b/node/icecast.go index 88aa0c85..c8cafdfd 100644 --- a/node/icecast.go +++ b/node/icecast.go @@ -11,11 +11,11 @@ import ( "strconv" "time" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" ) var ( - statusPageUrl = "http://localhost:8000/status-radioai.xsl" + statusPageUrl = "http://localhost:8000/status-autoradio.xsl" ) // Icecast returns empty fields in our status handler, which we'll @@ -40,7 +40,7 @@ type icecastStatusUnparsed struct { } type IcecastStatus struct { - Mounts []radioai.IcecastMountStatus + Mounts []autoradio.IcecastMountStatus Up bool } @@ -146,10 +146,10 @@ func (ic *IcecastController) parseStatusPage(input io.Reader) (*IcecastStatus, e status := IcecastStatus{ Up: true, - Mounts: make([]radioai.IcecastMountStatus, 0, len(ustatus.Mounts)), + Mounts: make([]autoradio.IcecastMountStatus, 0, len(ustatus.Mounts)), } for _, um := range ustatus.Mounts { - m := radioai.IcecastMountStatus{ + m := autoradio.IcecastMountStatus{ Name: um.Name, Listeners: toi(um.Listeners), BitRate: toi(um.BitRate), diff --git a/node/icecast_config.go b/node/icecast_config.go index ca195827..67b5bb42 100644 --- a/node/icecast_config.go +++ b/node/icecast_config.go @@ -6,7 +6,7 @@ import ( "io" "os" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" ) var ( @@ -113,8 +113,8 @@ type icecastConfig struct { func defaultDebianConfig(publicIp string) *icecastConfig { // Pick some random passwords on startup. We don't use them, // but icecast is happier if they're set. - sourcePw := radioai.GeneratePassword() - adminPw := radioai.GeneratePassword() + sourcePw := autoradio.GeneratePassword() + adminPw := autoradio.GeneratePassword() return &icecastConfig{ XMLName: xml.Name{"", "icecast"}, @@ -150,7 +150,7 @@ func defaultDebianConfig(publicIp string) *icecastConfig { }, Security: iceSecurityConfig{0}, Listen: []iceListenConfig{ - {"0.0.0.0", radioai.IcecastPort, 0}, + {"0.0.0.0", autoradio.IcecastPort, 0}, //{"0.0.0.0", shoutHttpPort, 1}, }, } @@ -191,7 +191,7 @@ func (c *icecastConfig) EncodeToFile(path string) error { return err } -func mountToConfig(m *radioai.Mount) iceMountConfig { +func mountToConfig(m *autoradio.Mount) iceMountConfig { mconfig := iceMountConfig{ Name: m.Name, Username: m.Username, @@ -207,12 +207,12 @@ func mountToConfig(m *radioai.Mount) iceMountConfig { return mconfig } -func mountToRelay(masterAddr string, m *radioai.Mount) iceRelayConfig { +func mountToRelay(masterAddr string, m *autoradio.Mount) iceRelayConfig { return iceRelayConfig{ Mount: m.Name, LocalMount: m.Name, Server: masterAddr, - Port: radioai.IcecastPort, + Port: autoradio.IcecastPort, Username: m.Username, Password: m.Password, OnDemand: 1, diff --git a/node/icecast_config_test.go b/node/icecast_config_test.go index 20407809..08099a72 100644 --- a/node/icecast_config_test.go +++ b/node/icecast_config_test.go @@ -4,11 +4,11 @@ import ( "strings" "testing" - "git.autistici.org/ale/radioai" + "git.autistici.org/ale/autoradio" ) func TestIcecastConfig(t *testing.T) { - mount := &radioai.Mount{ + mount := &autoradio.Mount{ Name: "/test.ogg", Username: "user", Password: "pass", diff --git a/node/node.go b/node/node.go index 5413dc42..1447b17d 100644 --- a/node/node.go +++ b/node/node.go @@ -8,9 +8,9 @@ import ( "sync" "time" - "git.autistici.org/ale/radioai" - "git.autistici.org/ale/radioai/masterelection" - "git.autistici.org/ale/radioai/third_party/github.com/coreos/go-etcd/etcd" + "git.autistici.org/ale/autoradio" + "git.autistici.org/ale/autoradio/masterelection" + "git.autistici.org/ale/autoradio/third_party/github.com/coreos/go-etcd/etcd" ) func trigger(c chan bool) { @@ -23,34 +23,34 @@ func trigger(c chan bool) { // Remove mountPrefix from the beginning of the path, but keep the // leading slash. func keyToMount(key string) string { - return key[len(radioai.MountPrefix)-1:] + return key[len(autoradio.MountPrefix)-1:] } // In-memory representation of the overall configuration (basically // just a list of the known mounts). type ClusterConfig struct { - mounts map[string]*radioai.Mount + mounts map[string]*autoradio.Mount lock sync.Mutex } func NewClusterConfig() *ClusterConfig { return &ClusterConfig{ - mounts: make(map[string]*radioai.Mount), + mounts: make(map[string]*autoradio.Mount), } } // TODO: remove? -func (c *ClusterConfig) GetMount(name string) *radioai.Mount { +func (c *ClusterConfig) GetMount(name string) *autoradio.Mount { c.lock.Lock() defer c.lock.Unlock() return c.mounts[name] } // TODO: remove? -func (c *ClusterConfig) ListMounts() []*radioai.Mount { +func (c *ClusterConfig) ListMounts() []*autoradio.Mount { c.lock.Lock() defer c.lock.Unlock() - result := make([]*radioai.Mount, 0, len(c.mounts)) + result := make([]*autoradio.Mount, 0, len(c.mounts)) for _, m := range c.mounts { result = append(result, m) } @@ -58,7 +58,7 @@ func (c *ClusterConfig) ListMounts() []*radioai.Mount { } // Update a mount (in-memory only). -func (c *ClusterConfig) setMount(m *radioai.Mount) { +func (c *ClusterConfig) setMount(m *autoradio.Mount) { c.lock.Lock() defer c.lock.Unlock() c.mounts[m.Name] = m @@ -127,7 +127,7 @@ func (w *ConfigSyncer) syncer() { func (w *ConfigSyncer) updateConfigWithResponse(key, value string) { mountName := keyToMount(key) log.Printf("updating mount %s: %s", mountName, value) - var m radioai.Mount + var m autoradio.Mount if err := json.NewDecoder(strings.NewReader(value)).Decode(&m); err != nil { log.Printf("corrupted data: %s: %s", value, err) } else { @@ -142,7 +142,7 @@ func (w *ConfigSyncer) Run() { // Run until the first successful Get(). log.Printf("attempting to retrieve initial config...") for { - response, err := w.client.Get(radioai.MountPrefix, false) + response, err := w.client.Get(autoradio.MountPrefix, false) if err == nil && response.Dir { // Directly update the configuration. for _, r := range response.Kvs { @@ -171,7 +171,7 @@ func (w *ConfigSyncer) Run() { for { curIndex := w.index + 1 log.Printf("starting watcher at index %d", curIndex) - _, err := w.client.WatchAll(radioai.MountPrefix, curIndex, w.rch, w.stop) + _, err := w.client.WatchAll(autoradio.MountPrefix, curIndex, w.rch, w.stop) if err == etcd.ErrWatchStoppedByUser { return } else if err != nil { @@ -221,7 +221,7 @@ func NewRadioNode(ip string, client *etcd.Client) *RadioNode { client: client, me: masterelection.NewMasterElection( client, - radioai.MasterElectionPath, + autoradio.MasterElectionPath, ip, 5, mech, @@ -244,7 +244,7 @@ func (rc *RadioNode) presence() { case <-ticker.C: // Build our NodeStatus. icecastSt := rc.icecast.GetStatus() - nodeSt := radioai.NodeStatus{ + nodeSt := autoradio.NodeStatus{ IP: rc.ip, IcecastUp: icecastSt.Up, Mounts: icecastSt.Mounts, @@ -253,7 +253,7 @@ func (rc *RadioNode) presence() { // Update our node entry in the database. var buf bytes.Buffer json.NewEncoder(&buf).Encode(&nodeSt) - if _, err := rc.client.Set(radioai.NodePrefix+rc.ip, buf.String(), rc.livenessTtl); err != nil { + if _, err := rc.client.Set(autoradio.NodePrefix+rc.ip, buf.String(), rc.livenessTtl); err != nil { log.Printf("presence: Set(): %s", err) } -- GitLab