Merge branch '5-socketpaths'

This commit is contained in:
boyska 2019-05-29 00:12:03 +02:00
commit db33746f26
2 changed files with 8 additions and 8 deletions

View file

@ -54,8 +54,8 @@ func (b *BoolAuto) Set(s string) error {
}
func main() {
addr := flag.String("addr", "localhost:9080", "http service address")
querySocket := flag.String("socket", "", "Path to a unix domain socket for the HTTP server")
queryAddr := flag.String("addr", "", "http service address")
querySocket := flag.String("socket", "/tmp/circologd-query.sock", "Path to a unix domain socket for the HTTP server")
backlogLimit := flag.Int("n", -1, "Limit the backlog length, defaults to no limit (-1)")
var format formatter.Format
format = formatter.FormatSyslog
@ -75,7 +75,7 @@ func main() {
signal.Notify(interrupt, os.Interrupt)
var d *websocket.Dialer
u := url.URL{Scheme: "ws",
Host: *addr, // ignored in case of -socket; see the Dialer below
Host: *queryAddr, // ignored in case of -socket; see the Dialer below
Path: "/ws",
}
q := u.Query()
@ -84,7 +84,7 @@ func main() {
q.Set("l", strconv.Itoa(*backlogLimit))
}
u.RawQuery = q.Encode()
if *querySocket != "" {
if *queryAddr == "" {
d = &websocket.Dialer{
NetDial: func(network, addr string) (net.Conn, error) {
return net.Dial("unix", *querySocket)
@ -95,7 +95,7 @@ func main() {
log.Printf("connecting to %s", *querySocket)
} else {
d = websocket.DefaultDialer
log.Printf("connecting to %s", *addr)
log.Printf("connecting to %s", *queryAddr)
}
c, _, err := d.Dial(u.String(), nil)

View file

@ -38,8 +38,8 @@ func main() {
// dumpSocketPath := flag.String("dump-socket", "/run/buffer.sock", "The socket that user will connect to in order to receive logs")
bufsize := flag.Int("buffer-size", 1000, "Number of messages to keep")
syslogAddr := flag.String("syslog-addr", "127.0.0.1:9514", "Address:port where to listen for syslog messages")
queryAddr := flag.String("query-addr", "127.0.0.1:9080", "Address:port where to bind the query service")
querySocket := flag.String("query-socket", "", "Path to a unix domain socket for the HTTP server; recommended for security reasons!")
queryAddr := flag.String("query-addr", "", "Address:port where to bind the query service")
querySocket := flag.String("query-socket", "/tmp/circologd-query.sock", "Path to a unix domain socket for the HTTP server; recommended for security reasons!")
ctlSocket := flag.String("ctl-socket", "/tmp/circologd-ctl.sock", "Path to a unix domain socket for the control server; leave empty to disable")
flag.Var(&logFmt, "log-fmt", "Log messages format. If not set, defaults to automatic choice. Allowed values: rfc3164, rfc5424, auto.")
verbose := flag.Bool("verbose", false, "Print more output executing the daemon")
@ -89,7 +89,7 @@ func main() {
}
httpQueryServer := http.Server{Handler: setupHTTP(hub)}
if *querySocket != "" {
if *queryAddr == "" {
fmt.Printf("Binding address `%s` [http]\n", *querySocket)
unixListener, err := net.Listen("unix", *querySocket)
if err != nil {