-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy.go
49 lines (39 loc) · 1.16 KB
/
proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"context"
"os"
"os/signal"
"sync"
"time"
"github.com/sirupsen/logrus"
"github.com/hsmade/comfoconnectbridge/pkg/comfoconnect"
"github.com/hsmade/comfoconnectbridge/pkg/instrumentation"
"github.com/hsmade/comfoconnectbridge/pkg/proxy"
)
func main() {
logrus.SetLevel(logrus.DebugLevel)
customFormatter := new(logrus.TextFormatter)
customFormatter.TimestampFormat = time.StampMilli
logrus.SetFormatter(customFormatter)
customFormatter.FullTimestamp = true
ctx, cancel := context.WithCancel(context.Background())
wg := &sync.WaitGroup{}
closer := instrumentation.EnableTracing("proxy", "tower:5775")
defer closer.Close()
instrumentation.EnableMetrics()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
l := comfoconnect.NewBroadcastListener("192.168.178.52", []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10, 0x10, 0x80, 0x01, 0xb8, 0x27, 0xeb, 0xf9, 0xf9, 0x12})
go l.Run()
defer l.Stop()
p := proxy.NewProxy("192.168.0.19", []byte{0xb8, 0x27, 0xeb, 0xf9, 0xf9, 0x12})
go p.Run(ctx, wg)
logrus.Info("waiting for ctrl-c")
for _ = range c {
logrus.Info("closing down")
l.Stop()
cancel()
wg.Wait()
os.Exit(0)
}
}