MCPcopy
hub / github.com/dreadl0ck/netcap / Decode

Method Decode

decoder/stream/irc/irc_data.go:67–134  ·  view source on GitHub ↗

Decode extracts file from IRC DCC DATA channel

()

Source from the content-addressed store, hash-verified

65
66// Decode extracts file from IRC DCC DATA channel
67func (i *ircDCCDataReader) Decode() {
68 // Check if this connection matches a tracked DCC connection
69 keys := []string{
70 fmt.Sprintf("%s:%d", i.conversation.ServerIP, i.conversation.ServerPort),
71 fmt.Sprintf("%s:%d", i.conversation.ClientIP, i.conversation.ClientPort),
72 }
73
74 var connInfo *IRCDCCConnection
75 var found bool
76 var matchedKey string
77
78 for _, key := range keys {
79 connInfo, found = CheckDCCConnection(key)
80 if found {
81 matchedKey = key
82 break
83 }
84 }
85
86 if !found {
87 // Not a tracked DCC connection
88 return
89 }
90
91 ircLog.Info("Processing IRC DCC DATA channel",
92 zap.String("filename", connInfo.Filename),
93 zap.String("type", connInfo.Type),
94 zap.Int64("expectedSize", connInfo.Filesize),
95 zap.String("ident", i.conversation.Ident),
96 )
97
98 // DCC SEND: sender connects to receiver
99 // Data flows from sender (collect all data, typically from one direction)
100 var fileData []byte
101
102 // Extract all data from the connection
103 // DCC transfers are typically unidirectional
104 for _, fragment := range i.conversation.Data {
105 fileData = append(fileData, fragment.Raw()...)
106 }
107
108 if len(fileData) == 0 {
109 ircLog.Warn("No data in IRC DCC channel",
110 zap.String("ident", i.conversation.Ident),
111 )
112 RemoveDCCConnection(matchedKey)
113 return
114 }
115
116 ircLog.Info("Extracting IRC DCC file",
117 zap.String("filename", connInfo.Filename),
118 zap.Int("dataSize", len(fileData)),
119 zap.Int64("expectedSize", connInfo.Filesize),
120 zap.String("ident", i.conversation.Ident),
121 )
122
123 // Extract file
124 err := ExtractDCCDataChannel(i.conversation, fileData, connInfo)

Callers

nothing calls this directly

Calls 9

CheckDCCConnectionFunction · 0.85
RemoveDCCConnectionFunction · 0.85
ExtractDCCDataChannelFunction · 0.85
Int64Method · 0.80
IntMethod · 0.80
InfoMethod · 0.65
RawMethod · 0.65
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected