From 06feef75594fef491b8dbcbd530c7a42af4163d6 Mon Sep 17 00:00:00 2001 From: Craig Date: Sun, 26 Jan 2020 10:43:08 +0000 Subject: [PATCH] minor changes --- server/build | 2 +- server/cmd/root.go | 4 +- server/internal/webrtc/webrtc.go | 45 +++++++++++------------ server/neko.go | 63 ++++++++++++++++++-------------- 4 files changed, 60 insertions(+), 54 deletions(-) diff --git a/server/build b/server/build index a3835e7b..4812691c 100755 --- a/server/build +++ b/server/build @@ -5,4 +5,4 @@ GIT_COMMIT=`git rev-parse --short HEAD` GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD` GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "✗-"` -go build -o bin/neko -ldflags "-s -X version.buildTime=${BUILD_TIME} -X version.gitRevision=${GIT_DIRTY}${GIT_REVISION} -X version.gitBranch=${GIT_BRANCH}" -i cmd/neko/main.go \ No newline at end of file +go build -o bin/neko -ldflags "-s -X 'n.eko.moe/neko.buildDate=${BUILD_TIME}' -X 'n.eko.moe/neko.gitCommit=${GIT_DIRTY}${GIT_COMMIT}' -X 'n.eko.moe/neko.gitBranch=${GIT_BRANCH}'" -i cmd/neko/main.go diff --git a/server/cmd/root.go b/server/cmd/root.go index b64ab57a..68fcbae9 100644 --- a/server/cmd/root.go +++ b/server/cmd/root.go @@ -1,8 +1,6 @@ package cmd import ( - "fmt" - "github.com/rs/zerolog/log" "github.com/spf13/cobra" @@ -32,5 +30,5 @@ func init() { log.Panic().Err(err).Msg("unable to run root command") } - root.SetVersionTemplate(fmt.Sprintf("version: %s\n", neko.Service.Version)) + root.SetVersionTemplate(neko.Service.Version.Details()) } diff --git a/server/internal/webrtc/webrtc.go b/server/internal/webrtc/webrtc.go index 3643897a..db809c73 100644 --- a/server/internal/webrtc/webrtc.go +++ b/server/internal/webrtc/webrtc.go @@ -92,11 +92,11 @@ func (m *WebRTCManager) Start() { return case sample := <-videoPipeline.Sample: if err := m.sessions.WriteVideoSample(sample); err != nil { - m.logger.Warn().Err(err).Msg("video pipeline failed") + m.logger.Warn().Err(err).Msg("video pipeline failed to write") } case sample := <-audioPipeline.Sample: if err := m.sessions.WriteAudioSample(sample); err != nil { - m.logger.Warn().Err(err).Msg("audio pipeline failed") + m.logger.Warn().Err(err).Msg("audio pipeline failed to write") } case <-m.cleanup.C: hid.Check(time.Second * 10) @@ -182,28 +182,27 @@ func (m *WebRTCManager) CreatePeer(id string, sdp string) (string, types.Peer, e return "", nil, err } - // clear the Transceiver bufers - go func() { - defer func() { - m.logger.Warn().Msgf("ReadRTCP shutting down") - }() + /* + // clear the Transceiver bufers + go func() { + defer func() { + m.logger.Warn().Msgf("ReadRTCP shutting down") + }() + for { + packet, err := videoTransceiver.Sender.ReadRTCP() + if err != nil { + return + } + m.logger.Debug().Msgf("vReadRTCP %v", packet) - /* - for { - packet, err := videoTransceiver.Sender.ReadRTCP() - if err != nil { - return - } - m.logger.Debug().Msgf("vReadRTCP %v", packet) - - packet, err = audioTransceiver.Sender.ReadRTCP() - if err != nil { - return - } - m.logger.Debug().Msgf("aReadRTCP %v", packet) - } - */ - }() + packet, err = audioTransceiver.Sender.ReadRTCP() + if err != nil { + return + } + m.logger.Debug().Msgf("aReadRTCP %v", packet) + } + }() + */ // set remote description connection.SetRemoteDescription(description) diff --git a/server/neko.go b/server/neko.go index 134e44e7..5a7cf643 100644 --- a/server/neko.go +++ b/server/neko.go @@ -28,13 +28,12 @@ const Header = `&34 var ( // - buildDate = "" + buildDate = "dev" // - gitCommit = "" + gitCommit = "dev" // - gitVersion = "" - // - gitState = "" + gitBranch = "dev" + // Major version when you make incompatible API changes, major = "0" // Minor version when you add functionality in a backwards-compatible manner, and @@ -48,16 +47,15 @@ var Service *Neko func init() { Service = &Neko{ Version: &Version{ - Major: major, - Minor: minor, - Patch: patch, - GitVersion: gitVersion, - GitCommit: gitCommit, - GitTreeState: gitState, - BuildDate: buildDate, - GoVersion: runtime.Version(), - Compiler: runtime.Compiler, - Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), + Major: major, + Minor: minor, + Patch: patch, + GitCommit: gitCommit, + GitBranch: gitBranch, + BuildDate: buildDate, + GoVersion: runtime.Version(), + Compiler: runtime.Compiler, + Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), }, Root: &config.Root{}, Server: &config.Server{}, @@ -67,21 +65,32 @@ func init() { } type Version struct { - Major string - Minor string - Patch string - Version string - GitVersion string - GitCommit string - GitTreeState string - BuildDate string - GoVersion string - Compiler string - Platform string + Major string + Minor string + Patch string + GitCommit string + GitBranch string + BuildDate string + GoVersion string + Compiler string + Platform string } func (i *Version) String() string { - return fmt.Sprintf("%s.%s.%s", i.Major, i.Minor, i.Patch) + return fmt.Sprintf("%s.%s.%s %s", i.Major, i.Minor, i.Patch, i.GitCommit) +} + +func (i *Version) Details() string { + return fmt.Sprintf( + "%s\n%s\n%s\n%s\n%s\n%s\n%s\n", + fmt.Sprintf("Verison %s.%s.%s", i.Major, i.Minor, i.Patch), + fmt.Sprintf("GitCommit %s", i.GitCommit), + fmt.Sprintf("GitBranch %s", i.GitBranch), + fmt.Sprintf("BuildDate %s", i.BuildDate), + fmt.Sprintf("GoVersion %s", i.GoVersion), + fmt.Sprintf("Compiler %s", i.Compiler), + fmt.Sprintf("Platform %s", i.Platform), + ) } type Neko struct {