diff --git a/README.rst b/README.rst index bf963a166a11d93962ab719d4fd1146346ac0969..666188f36653c99a6035d26b19add958660e08e4 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 7b49833b3fd5651d38e62234d2333b98b139e0b2..50ac90f43deb5637cbe7971bcdc5f5421d451176 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 3b3f45e005f9d43c4fd92e7efc4ec23cb961d582..56df947013f2e141e60f140c0a80427370229743 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 30dc0b2fea24df3ea0372031fbff9279c7e63f48..8e783a5a0c97dc0510004e8df85af6890ca3d099 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 5e862cea2b106baad35d78cd67c78f41adce272a..7d07dc8c3440c7374cc606e1a75e05996de44f9c 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 de7baa6f90f5cd5f0478574f13181708d3073d04..d82935bbc23efdc83d3b33f36ea5c5889ca60f64 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 e179ded086cbc2129b6ca203c673ef4ccb62f0df..9c118a3569ee8d72d0dd3795cc1a4c374eea67c6 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 7a2ee1e4156a0059bae141409083bc2d2d373cc6..286acc9fbeae5308d5773c6f31a5b248cf586986 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 ab450ff8df052d288d21445bd08994740df92700..60db7c046d9ce3aa4a1f483a34a79b27c991921c 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 90ffe8ec336b6804b16f5fb75654b7328be37b42..bc2b0a6bbfc710e8521f3b75f795374cfbb8a8b1 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 7b6a62bad15daed13cca8c43cfb68c39489a1f54..7c36673cddcfea8ea465a3eb2f7b592df6e78718 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 32a93e0857846e5dad3c809bbdfb86849e03bac8..7db958c7ffd1818ef051aefc6a9d4756ee5fd9f9 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 9c316e5abbcdfd9c54831170b1d5806dd36c52f1..bbf8b4a344f6313eaa8abda1ae50a99368cf1055 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 795a0b5751a97111c14d09965dfd050e6e57b919..165504c03a2e26a31704aab5186bb13e5ff2896a 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 2bbc2179cd231b8539e1b363fe17b885f5a137bd..788c3109fca9777466ac42561ac3532c496114f5 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 b2a827e309b2b5611f8d6a38d97c6630012dde85..8682a07686042a3dadf5ea9dc202900d3f8f9a4f 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 863244c96aaee4d47280ab8ad732ff5e92665922..e20c8cdde6a45f1ddea93970b408a112df243525 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 4a1afe5f8bfd847c20e6d807d3f32d6fde7ebf12..9ecca94013df2a2f7f231b7e05c46310e14907f6 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 7b7ea7ab2976845dd7dbc7373f9ae0a1e71b306d..50f747c7d88e0a327070137652c2b3198dcd62e1 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 a37a9f7d53d72abbc4dca4d5a058f68d17ab4ccc..87316bebf20d326891a72823d25e7f909e61b49e 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 88aa0c85594fc324be51efbf70ef895f9ddee2f2..c8cafdfdd3e75ac44f05f3acbf32b1891fb95ef1 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 ca1958276121540819df5e229e1a4e02c4c1174c..67b5bb429612cc443d1970e83a0c7c3f031e3042 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 2040780958301e573cfdac9053a4d2db741f52d8..08099a7220aca7f75bfed01703f05ad105ce806f 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 5413dc42cc26753f38bf529e13b785cb0981b710..1447b17dd5d6f7d8ae508589bcc47988104f8c20 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) }