(self, conn)
| 138 | } |
| 139 | |
| 140 | def connection_close_handler(self, conn): |
| 141 | # After data channel closes, store file content in control channel's |
| 142 | # 'filedata' field. |
| 143 | # Control channel will write it to disk after it determines the |
| 144 | # filename. |
| 145 | try: |
| 146 | info = self.conns[conn.addr] |
| 147 | except KeyError: |
| 148 | return |
| 149 | |
| 150 | if self.dump and info['mode'] == DATA_CONN: |
| 151 | # find the associated control channel |
| 152 | if info['ctrlchan'] == None: |
| 153 | if (conn.clientip, conn.clientport) in self.data_channel_map: |
| 154 | info['ctrlchan'] = self.data_channel_map[(conn.clientip, conn.clientport)] |
| 155 | if (conn.serverip, conn.serverport) in self.data_channel_map: |
| 156 | info['ctrlchan'] = self.data_channel_map[(conn.serverip, conn.serverport)] |
| 157 | try: |
| 158 | ctrlchan = self.conns[info['ctrlchan']] |
| 159 | except KeyError: |
| 160 | return |
| 161 | # add data to control channel dictionary |
| 162 | for blob in conn.blobs: |
| 163 | if ctrlchan['filedata']: |
| 164 | ctrlchan['filedata'] += blob.data |
| 165 | else: |
| 166 | ctrlchan['filedata'] = blob.data |
| 167 | # update port list and data channel knowledge |
| 168 | if (conn.serverip, conn.serverport) == ctrlchan['datachan']: |
| 169 | del self.data_channel_map[ctrlchan['datachan']] |
| 170 | ctrlchan['datachan'] = None |
| 171 | self.__update_bpf() |
| 172 | if (conn.clientip, conn.clientport) == ctrlchan['datachan']: |
| 173 | del self.data_channel_map[ctrlchan['datachan']] |
| 174 | ctrlchan['datachan'] = None |
| 175 | self.__update_bpf() |
| 176 | del self.conns[conn.addr] |
| 177 | |
| 178 | elif info['mode'] == CTRL_CONN: |
| 179 | # clear control channels if they've been alerted on |
| 180 | if info['file'] == None: |
| 181 | del self.conns[conn.addr] |
| 182 | |
| 183 | def postmodule(self): |
| 184 | for addr, info in self.conns.items(): |
nothing calls this directly
no test coverage detected