Skip to content

Commit

Permalink
fix: detect oid from auth packet
Browse files Browse the repository at this point in the history
  • Loading branch information
kuznetsovin committed Aug 8, 2022
1 parent 4938777 commit 92d6f00
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cli/receiver/integration_test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestIntegration(t *testing.T) {
response := []byte{0x1, 0x0, 0x0, 0xb, 0x0, 0x10, 0x0, 0xe9, 0x4, 0x0, 0xa1, 0xe8, 0x4, 0x0, 0x6, 0x0, 0x1, 0x0, 0x20, 0x2, 0x2, 0x0, 0x3,
0x0, 0xa1, 0xa, 0x0, 0x5e, 0xb6}

conn, err := net.Dial("tcp", conf.Host+":"+conf.Port)
conn, err := net.Dial("tcp", conf.GetListenAddress())
if assert.NoError(t, err) {
_ = conn.SetWriteDeadline(time.Now().Add(2 * time.Second))
_, _ = conn.Write(message)
Expand Down
6 changes: 4 additions & 2 deletions cli/receiver/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (s *Server) handleConn(conn net.Conn) {
serviceType uint8
srResponsesRecord egts.RecordDataSet
recvPacket []byte
client uint32
)

if s.store == nil {
Expand Down Expand Up @@ -156,7 +157,7 @@ func (s *Server) handleConn(conn net.Conn) {

// если в секции с данными есть oid то обновляем его
if rec.ObjectIDFieldExists == "1" {
exportPacket.Client = rec.ObjectIdentifier
client = rec.ObjectIdentifier
}

for _, subRec := range rec.RecordDataSet {
Expand All @@ -165,7 +166,7 @@ func (s *Server) handleConn(conn net.Conn) {
log.Debug("Разбор подзаписи EGTS_SR_TERM_IDENTITY")

// на случай если секция с данными не содержит oid
exportPacket.Client = subRecData.TerminalIdentifier
client = subRecData.TerminalIdentifier

if srResultCodePkg, err = createSrResultCode(pkg.PacketIdentifier, egtsPcOk); err != nil {
log.Errorf("Ошибка сборки EGTS_SR_RESULT_CODE: %v", err)
Expand Down Expand Up @@ -267,6 +268,7 @@ func (s *Server) handleConn(conn net.Conn) {
}
}

exportPacket.Client = client
if isPkgSave {
if err := s.store.Save(&exportPacket); err != nil {
log.WithField("err", err).Error("Ошибка сохранения телеметрии")
Expand Down
2 changes: 1 addition & 1 deletion configs/config.test.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
host: "127.0.0.1"
port: "6000"
port: "7000"
con_live_sec: 10
log_level: "DEBUG"

Expand Down

0 comments on commit 92d6f00

Please sign in to comment.