WIP: test (+ more todos)
This commit is contained in:
@@ -19,16 +19,17 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.suyono.dev/suyono/netbounce/cmd/slicewriter"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"golang.org/x/sys/unix"
|
||||
"net"
|
||||
"os/signal"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -43,6 +44,13 @@ func main() {
|
||||
openPorts(wg, ctx)
|
||||
|
||||
wg.Wait()
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Debug().Caller().Msg("received signal to quit")
|
||||
default:
|
||||
log.Debug().Caller().Msg("unexpected exit")
|
||||
}
|
||||
}
|
||||
|
||||
func parseFlags() {
|
||||
@@ -94,7 +102,7 @@ func bindUDP(ctx context.Context, wg *sync.WaitGroup, address string) {
|
||||
addr net.Addr
|
||||
)
|
||||
|
||||
log.Debug().Str("address", address).Msg("binding socket for UDP")
|
||||
log.Debug().Caller().Msgf("binding socket for UDP on %v", address)
|
||||
if conn, err = net.ListenPacket("udp", address); err != nil {
|
||||
panic(fmt.Errorf("failed to bind udp address: %v", err))
|
||||
}
|
||||
@@ -158,6 +166,7 @@ func listen(ctx context.Context, wg *sync.WaitGroup, address string) {
|
||||
conn net.Conn
|
||||
)
|
||||
|
||||
log.Debug().Caller().Msgf("listeng for TCP on %v", address)
|
||||
if listener, err = net.Listen("tcp", address); err != nil {
|
||||
log.Error().Err(err).Str("address", address).Msg("failed to listen")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user