Add CLI flags for listening address and hostname
This commit is contained in:
parent
3c3f218b2b
commit
603bd6bdef
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
@ -8,7 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
addr := ":6667"
|
var addr, hostname string
|
||||||
|
flag.StringVar(&addr, "addr", ":6667", "listening address")
|
||||||
|
flag.StringVar(&hostname, "hostname", "localhost", "server hostname")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
ln, err := net.Listen("tcp", addr)
|
ln, err := net.Listen("tcp", addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -17,7 +21,7 @@ func main() {
|
|||||||
|
|
||||||
srv := jounce.NewServer()
|
srv := jounce.NewServer()
|
||||||
// TODO: load from config/DB
|
// TODO: load from config/DB
|
||||||
srv.Hostname = "localhost"
|
srv.Hostname = hostname
|
||||||
srv.Upstreams = []jounce.Upstream{{
|
srv.Upstreams = []jounce.Upstream{{
|
||||||
Addr: "chat.freenode.net:6697",
|
Addr: "chat.freenode.net:6697",
|
||||||
Nick: "jounce",
|
Nick: "jounce",
|
||||||
@ -26,7 +30,7 @@ func main() {
|
|||||||
Channels: []string{"#jounce"},
|
Channels: []string{"#jounce"},
|
||||||
}}
|
}}
|
||||||
|
|
||||||
log.Printf("Server listening on %v", addr)
|
log.Printf("server listening on %v", addr)
|
||||||
go srv.Run()
|
go srv.Run()
|
||||||
log.Fatal(srv.Serve(ln))
|
log.Fatal(srv.Serve(ln))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user