Don't export any fields of golangConnection

This commit is contained in:
M. Mert Yildiran 2022-06-02 06:23:12 +03:00
parent f26511df14
commit 97ce9d71c1
No known key found for this signature in database
GPG Key ID: D42ADB236521BF7A
2 changed files with 24 additions and 26 deletions

View File

@ -3,14 +3,12 @@ package tlstapper
import "github.com/up9inc/mizu/tap/api"
type golangConnection struct {
Pid uint32
ConnAddr uint32
AddressPair addressPair
Requests [][]byte
Responses [][]byte
Stream *tlsStream
ClientReader *golangReader
ServerReader *golangReader
pid uint32
connAddr uint32
addressPair addressPair
stream *tlsStream
clientReader *golangReader
serverReader *golangReader
}
func NewGolangConnection(pid uint32, connAddr uint32, extension *api.Extension, emitter api.Emitter) *golangConnection {
@ -21,11 +19,11 @@ func NewGolangConnection(pid uint32, connAddr uint32, extension *api.Extension,
serverReader := NewGolangReader(extension, false, emitter, counterPair, stream, reqResMatcher)
stream.reader = clientReader
return &golangConnection{
Pid: pid,
ConnAddr: connAddr,
Stream: stream,
ClientReader: clientReader,
ServerReader: serverReader,
pid: pid,
connAddr: connAddr,
stream: stream,
clientReader: clientReader,
serverReader: serverReader,
}
}
@ -34,6 +32,6 @@ func (c *golangConnection) setAddressBySockfd(procfs string, pid uint32, fd uint
if err != nil {
return err
}
c.AddressPair = addrPair
c.addressPair = addrPair
return nil
}

View File

@ -156,7 +156,7 @@ func (p *tlsPoller) pollGolangReadWrite(rd *ringbuf.Reader, emitter api.Emitter,
connection = NewGolangConnection(b.Pid, b.ConnAddr, p.extension, tlsEmitter)
p.golangReadWriteMap.Set(identifier, connection)
streamsMap.Store(streamsMap.NextId(), connection.Stream)
streamsMap.Store(streamsMap.NextId(), connection.stream)
} else {
connection = _connection.(*golangConnection)
}
@ -168,25 +168,25 @@ func (p *tlsPoller) pollGolangReadWrite(rd *ringbuf.Reader, emitter api.Emitter,
continue
}
tcpid := p.buildTcpId(&connection.AddressPair)
connection.ClientReader.tcpID = &tcpid
connection.ServerReader.tcpID = &api.TcpID{
SrcIP: connection.ClientReader.tcpID.DstIP,
DstIP: connection.ClientReader.tcpID.SrcIP,
SrcPort: connection.ClientReader.tcpID.DstPort,
DstPort: connection.ClientReader.tcpID.SrcPort,
tcpid := p.buildTcpId(&connection.addressPair)
connection.clientReader.tcpID = &tcpid
connection.serverReader.tcpID = &api.TcpID{
SrcIP: tcpid.DstIP,
DstIP: tcpid.SrcIP,
SrcPort: tcpid.DstPort,
DstPort: tcpid.SrcPort,
}
go dissect(p.extension, connection.ClientReader, options)
go dissect(p.extension, connection.ServerReader, options)
go dissect(p.extension, connection.clientReader, options)
go dissect(p.extension, connection.serverReader, options)
request := make([]byte, len(b.Data[:b.Len]))
copy(request, b.Data[:b.Len])
connection.ClientReader.send(request)
connection.clientReader.send(request)
} else {
response := make([]byte, len(b.Data[:b.Len]))
copy(response, b.Data[:b.Len])
connection.ServerReader.send(response)
connection.serverReader.send(response)
}
}
}