func (r *Reader) Init(config jsonstruct.JSONStruct) error { port := config.IntWithDefault(Port, DefaultPort) remoteAddr := config.StringWithDefault(RemoteWriterAddr, DefaultRemoteWriterAddr) resp, err := http.DefaultClient.Get(fmt.Sprintf("http://%s:%d/", remoteAddr, port)) if err != nil { return err } r.sseReader = vitosse.NewReadCloser(resp.Body) return nil }
func (w *Writer) Init(config jsonstruct.JSONStruct) error { port := config.IntWithDefault(Port, DefaultPort) remoteAddr := config.StringWithDefault(RemoteReaderAddr, DefaultRemoteReaderAddr) raddr, err := net.ResolveUDPAddr("udp4", net.JoinHostPort(remoteAddr, strconv.Itoa(port))) if err != nil { return err } w.connection, err = net.DialUDP("udp4", nil, raddr) if err != nil { return err } return nil }