blob: 9027d2a68ba12839a355bd99e0c2e1f079ec9b5a [file] [log] [blame]
package core
import (
"flag"
"fmt"
"io"
"v.io/core/veyron/lib/modules"
"v.io/core/veyron/services/wsprd/wspr"
"v.io/v23"
)
var (
port *int = flag.CommandLine.Int("port", 0, "Port to listen on.")
identd *string = flag.CommandLine.String("identd", "", "identd server name. Must be set.")
)
func init() {
modules.RegisterChild(WSPRCommand, usage(flag.CommandLine), startWSPR)
}
func startWSPR(stdin io.Reader, stdout, stderr io.Writer, env map[string]string, args ...string) error {
ctx, shutdown := v23.Init()
defer shutdown()
l := v23.GetListenSpec(ctx)
proxy := wspr.NewWSPR(ctx, *port, &l, *identd, nil)
defer proxy.Shutdown()
addr := proxy.Listen()
go func() {
proxy.Serve()
}()
fmt.Fprintf(stdout, "WSPR_ADDR=%s\n", addr)
modules.WaitForEOF(stdin)
return nil
}