Skip to content

Commit 331c402

Browse files
Add minor fine tunings to get full IPv6 support
1 parent 69f442d commit 331c402

File tree

6 files changed

+68
-3
lines changed

6 files changed

+68
-3
lines changed

doc/MANUAL-EN.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,26 @@ and just wait it :sleeping:. Take a look at **Figure 16** :sweat_smile:!
457457
> you the freedom to select the songs that your are wanting to listen to in the way you want.
458458
459459
[`Back`](#topics)
460+
461+
## Supported command line options
462+
463+
While a command line application, `Eutherpe` accepts some options. If you want to use `Eutherpe`
464+
just as a final user, you do not need to mind about them. However, if you want to adapt `Eutherpe`
465+
to your state of things, the following options can be useful to make some customizations.
466+
467+
An option is passed via command line prefixed with `--`, something like: `--blau`. If the option is
468+
a boolean flag (on/off stuff) it would be `--blau` (when passed it is on). If the option is about a
469+
content one, it follows the form `--blau=content`, the content depends on the option.
470+
471+
Take a look at **Table 1** to know more about.
472+
473+
| **Option** | **Utility** | **Usage sample** |
474+
|:----------:|:-----------:|:----------------:|
475+
| `--listen-port=<port>` | Changes the default listen port number (8080) to the passed one | `eutherpe --listen-port=4242` |
476+
| `--listen-addr=<ip>` | Specifies which ip address will be used as listen address, `Eutherpe` detects your system ip by design (giving preference to `IPv4`) | `eutherpe --listen-addr=2a2a::2a` |
477+
| `--version` | Shows the `Eutherpe` version and exits | `eutherpe --version` |
478+
| `--help` | Shows a quick help about these options and exits | `eutherpe --help` |
479+
480+
**Table 1**: All command line options currently supported.
481+
482+
[`Back`](#topics)

doc/MANUAL-PT.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ de projeto, como instalar e usar. Enfim, aqui você aprende pilotar o seu éter
2020
- [A tela Settings](#a-tela-settings)
2121
- [Uma preguiça simpática](#uma-preguiça-simpática)
2222
- [Sobre a escolha individual de músicas nas listas](#sobre-a-escolha-individual-de-músicas-nas-listas)
23+
- [Opções de linha de comando suportadas](#opções-de-linha-de-comand-suportadas)
2324

2425
## O que é?
2526

@@ -467,3 +468,27 @@ se assuste e apenas espere-a :sleeping:. Dê uma olhada na **Figura 16** :sweat_
467468
> na ordem que bem entender. Aqui utilidade realmente rima com liberdade!
468469
469470
[`Voltar`](#tópicos)
471+
472+
## Opções de linha de comando suportadas
473+
474+
`Eutherpe` enquanto um aplicativo de linha de comando aceita algumas opções. Se você quer
475+
utilizar `Eutherpe` como um usuário final, não precisa se preocupar com essas opções. Entretanto,
476+
se você quiser adaptar `Eutherpe` para o seu estado de coisas as seguintes opções podem ser
477+
úteis para customizações.
478+
479+
Uma opção é passada via linha de comando precedida por `--`, algo como: `--blau`. Se a
480+
opção for de liga e desliga é `--blau` (ela existindo está "ligada"). Se a opção for de
481+
conteúdo, ela segue a forma `--blau=conteúdo`, o conteúdo é vário, depende da opção.
482+
483+
Dê uma olhada na **Tabela 1** para saber mais.
484+
485+
| **Opção** | **Utilidade** | **Exemplo de uso** |
486+
|:---------:|:-------------:|:------------------:|
487+
| `--listen-port=<porta>` | Altera o número da porta de escuta default (8080) para uma de sua escolha | `eutherpe --listen-port=4242` |
488+
| `--listen-addr=<ip>` | Especifica qual endereço ip será usado para a escuta por conexões, por padrão `Eutherpe` detecta o seu ip, dando preferência para `IPv4` | `eutherpe --listen-addr=2a2a::2a` |
489+
| `--version` | Exibe a versão de `Eutherpe` em seu sistema e sai | `eutherpe --version` |
490+
| `--help` | Exibe uma ajuda rápida sobre essas opções aqui e sai | `eutherpe --help` |
491+
492+
**Tabela 1**: Opções de linha de comando suportadas por `Eutherpe` até o presente momento.
493+
494+
[`Voltar`](#tópicos)

src/eutherpe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func version() {
8787
}
8888

8989
func help() {
90-
fmt.Printf("use: %s [ --listen-port=<port-number|defaults to 8080> | --version | --help ]\n", os.Args[0])
90+
fmt.Printf("use: %s [ --listen-port=<port-number|defaults to 8080> | --listen-addr=<ip4|ip6> | --version | --help ]\n", os.Args[0])
9191
}
9292

9393
func tryToPairWithPreviousBluetoothDevice(eutherpeVars *vars.EutherpeVars,

src/internal/mdns/mdns.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ func doMDNSServerRunN(proto, listenAddr string,
387387
}
388388
if err != nil {
389389
fmt.Fprintf(os.Stderr, "error: %s\n", err.Error())
390+
continue
391+
}
392+
if conn != nil {
393+
conn.Close()
390394
}
391-
conn.Close()
392395
}
393396

394397
}

src/internal/mplayer/songinfo_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ func TestGetSongInfo(t *testing.T) {
203203
}
204204

205205
func TestScanSongs(t *testing.T) {
206+
if _, err := os.Stat("/tmp/cache.mp3"); err == nil {
207+
err := os.Remove("/tmp/cache.mp3")
208+
if err != nil {
209+
t.Errorf("/tmp/cache.mp3 found remove it yourself, please : '%s'", err.Error())
210+
}
211+
}
206212
songs, err := ScanSongs("/tmp")
207213
if err != nil {
208214
t.Errorf("ScanSongs() has returned an error while it should not.\n")

src/internal/vars/vars.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ func (e *EutherpeVars) connectToWLAN(wpaSupplicantConfFilePath string) (string,
430430
}
431431

432432
func (e *EutherpeVars) SetAddr() error {
433+
e.HTTPd.Addr = options.Get(EutherpeOptionListenAddr)
434+
if len(e.HTTPd.Addr) > 0 {
435+
return nil
436+
}
433437
ifaces, err := net.Interfaces()
434438
if err != nil {
435439
return err
@@ -586,9 +590,12 @@ func (e *EutherpeVars) TuneUp() {
586590
if strings.Index(e.HTTPd.Addr, ".") > - 1 {
587591
ipAddr = ipAddr[12:16]
588592
}
589-
e.MDNS.Hosts = append(e.MDNS.Hosts, mdns.MDNSHost { e.HostName, ipAddr, 300, })
593+
e.MDNS.Hosts = append(e.MDNS.Hosts, mdns.MDNSHost { e.HostName, ipAddr, 3600, })
590594
go mdns.MDNSServerStart(e.MDNS.Hosts, e.MDNS.GoinHome)
591595
}
596+
if strings.Index(e.HTTPd.Addr, ":") > -1 {
597+
e.HTTPd.Addr = "[" + e.HTTPd.Addr + "]"
598+
}
592599
e.HTTPd.Port = options.Get(EutherpeOptionListenPort, "8080")
593600
}
594601

@@ -749,5 +756,6 @@ const EutherpeMusicDevWLANDir = "wlan"
749756
const EutherpeMusicDevWLANPubApsFile = "pub-aps"
750757

751758
const EutherpeOptionListenPort = "listen-port"
759+
const EutherpeOptionListenAddr = "listen-addr"
752760

753761
const EutherpeCachedMP3FilePath = "/tmp/cache.mp3"

0 commit comments

Comments
 (0)